Parcourir la source

渠道号。。。修改bug

zhaoxian il y a 3 ans
Parent
commit
56c0b64820

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java

@@ -32,7 +32,7 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
     List<KuaishouChannel> queryFollowOrder(@Param("accountId") Long accountId, @Param("usedId") Long usedId, @Param("usageRange") Integer usageRange);
 
-    KuaishouChannel queryByAccountId(@Param("accountId") Long accountId);
+    KuaishouChannel queryByAccountId(@Param("accountId") Long accountId, @Param("isHaveItem") Integer isHaveItem);
 
     List<KuaishouChannel> queryMaxChannelNumber(@Param("strategyId") Long strategyId);
 
@@ -46,5 +46,5 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
     List<JSONObject> queryItemsListByAccountId(@Param("accountId") Long accountId, @Param("appName") String appName);
 
-    KuaishouChannel queryUsedChannel(@Param("accountId") Long accountId,@Param("campaignId") Long campaignId,@Param("level") String level);
+    KuaishouChannel queryUsedChannel(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId, @Param("level") String level);
 }

+ 39 - 46
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -17,7 +17,7 @@
         LEFT JOIN sys_user t2 ON t1.user_id = t2.id
         where account_id is not null
         <if test="userId != null">
-        and t1.user_id = #{userId}
+            and t1.user_id = #{userId}
         </if>
         <if test="projectId != null">
             and project_id = #{projectId}
@@ -116,25 +116,18 @@
     </select>
 
     <select id="channelNumberUsageDetailsList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            CASE
-                t1.usage_range
-                WHEN 1 THEN
-                    '账户'
-                WHEN 2 THEN
-                    '项目' ELSE ''
-                END AS 'usageRange',
-            IFNULL( t3.channel_code, '' ) AS 'channelCode',
-            IFNULL( t1.project_name, '' ) AS 'projectName',
-            IFNULL( t2.auth_name, '' ) AS 'authName',
-            IFNULL( t3.account_id, '' ) AS 'accountId',
-            IFNULL( t3.campaign_id, '' ) AS 'campaignId',
-            IFNULL( t3.unit_id, '' ) AS 'unitId'
-        FROM
-            ctop_kuaishou_channel_rel t3
-                INNER JOIN ctop_kuaishou_channel t1 ON t1.account_id = t3.account_id
-                AND t1.channel_code = t3.channel_code
-                LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        SELECT CASE
+                   t1.usage_range
+                   WHEN 1 THEN
+                       '账户'
+                   WHEN 2 THEN
+                       '项目'
+                   ELSE ''
+                   END AS 'usageRange', IFNULL(t3.channel_code, '') AS 'channelCode', IFNULL(t1.project_name, '') AS 'projectName', IFNULL(t2.auth_name, '') AS 'authName', IFNULL(t3.account_id, '') AS 'accountId', IFNULL(t3.campaign_id, '') AS 'campaignId', IFNULL(t3.unit_id, '') AS 'unitId'
+        FROM ctop_kuaishou_channel_rel t3
+                 INNER JOIN ctop_kuaishou_channel t1 ON t1.account_id = t3.account_id
+            AND t1.channel_code = t3.channel_code
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         WHERE t3.account_id = #{accountId}
           AND t3.channel_code = #{channelCode}
           AND t3.unit_id is not null
@@ -174,12 +167,16 @@
 
     <select id="queryByAccountId" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
         SELECT id,
-               channel_code,
-               usage_level,
-               usage_range,
-               is_have_item
+        channel_code,
+        usage_level,
+        usage_range,
+        is_have_item
         FROM `ctop_kuaishou_channel`
         WHERE account_id = #{accountId}
+        AND state = 1
+        <if test="isHaveItem != null">
+            and is_have_item = #{isHaveItem}
+        </if>
         ORDER BY usage_range limit 1
     </select>
 
@@ -254,36 +251,32 @@
     </select>
 
     <select id="queryItemsListByAccountId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            tt2.keyword as 'keyword',
-            tt1.channel_code as 'channelCode',
-            tt3.app_name as 'appName'
-        FROM
-            ctop_kuaishou_channel_rel tt1
-                INNER JOIN (
-                SELECT t3.keyword, t1.channel_code FROM ctop_kuaishou_channel t1
-                INNER JOIN ctop_kuaishou_channel_items_rel t2 ON t1.id = t2.channel_id
-                LEFT JOIN ctop_kuaishou_channel_items t3 ON t2.item_id = t3.id
-                WHERE t1.is_have_item = 1
-                  AND t3.state = 1
-            ) tt2 ON tt2.channel_code = tt1.channel_code
-                INNER JOIN ctop_kuaishou_channel_app_info tt3 ON tt1.app_id = tt3.app_id
-        WHERE
-            tt1.account_id = #{accountId}
+        SELECT tt2.keyword as 'keyword', tt1.channel_code as 'channelCode', tt3.app_name as 'appName'
+        FROM ctop_kuaishou_channel_rel tt1
+                 INNER JOIN (
+            SELECT t3.keyword, t1.channel_code
+            FROM ctop_kuaishou_channel t1
+                     INNER JOIN ctop_kuaishou_channel_items_rel t2 ON t1.id = t2.channel_id
+                     LEFT JOIN ctop_kuaishou_channel_items t3 ON t2.item_id = t3.id
+            WHERE t1.is_have_item = 1
+              AND t3.state = 1
+        ) tt2 ON tt2.channel_code = tt1.channel_code
+                 INNER JOIN ctop_kuaishou_channel_app_info tt3 ON tt1.app_id = tt3.app_id
+        WHERE tt1.account_id = #{accountId}
           AND tt3.app_name = #{appName}
-        GROUP BY
-            tt2.keyword
+        GROUP BY tt2.keyword
     </select>
 
 
     <select id="queryUsedChannel" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
-        SELECT t2.* FROM ctop_kuaishou_channel_rel t1
-        INNER JOIN ctop_kuaishou_channel t2 ON t1.account_id = t2.account_id AND t1.channel_code = t2.channel_code
+        SELECT t2.*
+        FROM ctop_kuaishou_channel_rel t1
+                 INNER JOIN ctop_kuaishou_channel t2
+                            ON t1.account_id = t2.account_id AND t1.channel_code = t2.channel_code
         WHERE t2.account_id = #{accountId}
           AND t2.usage_level = #{level}
           AND t2.state = 1
-          AND t1.campaign_id =#{campaignId}
-          LIMIT 1
+          AND t1.campaign_id = #{campaignId} LIMIT 1
     </select>
 
 </mapper>

+ 8 - 7
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -1012,14 +1012,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
         Long accountId = data.getLong("accountId");
         JSONArray appNameArray = data.getJSONArray("appNameArray");
         String appName = appNameArray.getString(0);
-        KuaishouChannel channel = channelMapper.queryByAccountId(accountId);
-        if (Check.isNull(channel)) {
-            return Result.ok("没有渠道号");
-        }
+        KuaishouChannel channel = channelMapper.queryByAccountId(accountId, 1);
         JSONObject request = new JSONObject();
-        if (channel.getIsHaveItem() == 1) {
-            List<JSONObject> list = channelMapper.queryItemsListByAccountId(accountId, appName);
-            request.put("list", list);
+        if (!Check.isNull(channel)) {
+            request.put("list", channelMapper.queryItemsListByAccountId(accountId, appName));
+        } else {
+            channel = channelMapper.queryByAccountId(accountId, null);
+            if (Check.isNull(channel)) {
+                return Result.error("该账户没有配置渠道号");
+            }
         }
         request.put("channel", channel);
         return Result.ok(request);