Procházet zdrojové kódy

渠道号。。。修改bug

zhaoxian před 3 roky
rodič
revize
e860f545e5

+ 12 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -394,13 +394,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 if (unitCode != 0) {
                     log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                    if (!Check.isNull(channel)) {
+                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null,0);
+                    }
                     continue;
                 }
                 Long unitId = (Long) unitCreateResult.get("unitId");
                 unitLevelOperationRecord.setUnitId(unitId);
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                 videoCnt--;
-                channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId);
+                if (!Check.isNull(channel)) {
+                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId,1);
+                }
                 JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, channel);//TODO 添加素材
                 createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
                 if (videoCnt <= 0) {
@@ -727,12 +732,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 if (unitCode != 0) {
                     log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                    if (!Check.isNull(channel)) {
+                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null,0);
+                    }
                     return;
                 }
                 Long unitId = (Long) unitCreateResult.get("unitId");
                 unitLevelOperationRecord.setUnitId(unitId);
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId);
+                if (!Check.isNull(channel)) {
+                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId,1);
+                }
                 JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, channel);
                 createProgramCreative(token, creativeParams, strategy);
             }

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannel.java

@@ -82,6 +82,10 @@ public class KuaishouChannel {
      * 使用范围,1账户,2项目
      */
     private Integer usageRange;
+    /**
+     * 渠道号锁 0 不可用,1可用
+     */
+    private Integer channelLock;
 
     /**
      * 创建人

+ 0 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/entity/KuaishouChannelItems.java

@@ -51,12 +51,6 @@ public class KuaishouChannelItems {
 
     private Integer state;
     /**
-     * 渠道号
-     */
-    @Excel(name = "渠道号", width = 15)
-    @ApiModelProperty(value = "渠道号")
-    private String channelCode;
-    /**
      * 单品名称
      */
     @Excel(name = "单品名称", width = 15)

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelItemsMapper.java

@@ -24,5 +24,4 @@ public interface KuaishouChannelItemsMapper extends BaseMapper<KuaishouChannelIt
 
     KuaishouChannelItems queryByProjectIdAndName(@Param("projectId") Long projectId, @Param("itemName") String itemName);
 
-    List<KuaishouChannelItems> queryItemsByChannelCode(@Param("projectId") Long projectId,@Param("channelCode") String channelCode);
 }

+ 0 - 7
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelItemsMapper.xml

@@ -77,12 +77,5 @@
           AND item_name = #{itemName} limit 1
     </select>
 
-    <select id="queryItemsByChannelCode" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems">
-        SELECT item_name, project_id, project_name, state, keyword
-        FROM ctop_kuaishou_channel_items
-        WHERE project_id = #{projectId}
-          AND channel_code = #{channelCode}
-    </select>
-
 
 </mapper>

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

@@ -201,6 +201,7 @@
         WHERE account_id = #{accountId}
           and usage_level = #{usageLevel}
           AND state = 1
+          and channel_lock = 1
     </select>
 
     <select id="queryChannelByHaveCycleTimes" resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel">
@@ -224,6 +225,7 @@
         AND have_cycle_times = #{haveCycleTimes}
         AND state = 1
         and usage_level = #{usageLevel}
+        and channel_lock = 1
         ORDER BY usage_times
     </select>
 

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelItemsService.java

@@ -29,5 +29,4 @@ public interface IKuaishouChannelItemsService extends IService<KuaishouChannelIt
 
     Result<Object> importItemExcel(MultipartFile file) throws Exception;
 
-    List<KuaishouChannelItems> queryItemsByChannelCode(Long projectId, String channelCode);
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -34,5 +34,5 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> queryChannelLevel(JSONObject request);
 
-    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId);
+    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId,Integer state);
 }

+ 0 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelItemsServiceImpl.java

@@ -170,10 +170,4 @@ public class KuaishouChannelItemsServiceImpl extends ServiceImpl<KuaishouChannel
         return Result.ok("添加成功");
     }
 
-    @Override
-    public List<KuaishouChannelItems> queryItemsByChannelCode(Long projectId, String channelCode) {
-        return channelItemsMapper.queryItemsByChannelCode(projectId, channelCode);
-    }
-
-
 }

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

@@ -205,6 +205,11 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             boolean save = channelCreateStrategyService.save(strategy);
             //下载链接
             String url = strategy.getUrl();
+
+            String appIconUrl = strategy.getAppIconUrl();
+            if (!Check.isNull(appIconUrl) && !appIconUrl.contains("http")) {
+                strategy.setAppIconUrl("https:" + appIconUrl);
+            }
             /**==========================范围是 项目==========================*/
             if (usageRange == 2) {
                 String usageLevel = strategy.getUsageLevel();
@@ -658,6 +663,9 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         return Result.error("解析数据失败,文档中第" + (i + 1) + "行,账户ID列缺失数据");
                     } else {
                         CtopOauthToken token = tokenService.getTokenByAccountId(Long.valueOf(accountId));
+                        if (!imageUrl.contains("http")) {
+                            imageUrl = "https:" + imageUrl;
+                        }
                         JSONObject tokenJson = appInfoService.uploadAppIconImage(imageUrl, token.getAccountId(), token.getAccessToken());
                         if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
                             log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
@@ -810,8 +818,11 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             }
             try {
                 strategy.setStateDate(DateUtils.getDate(DateUtils.WEB_FORMAT));
+                String appIconUrl = strategy.getAppIconUrl();
+                if (!Check.isNull(appIconUrl) && !appIconUrl.contains("http")) {
+                    strategy.setAppIconUrl("https:" + appIconUrl);
+                }
                 channelCreateStrategyService.save(strategy);
-
                 /**==========================范围是 项目==========================*/
                 if (usageRange == 2) {
                     List<Long> accountList = userAllocationService.getAccountListByProjectId(strategy.getProjectId());
@@ -970,32 +981,39 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     }
 
     @Override
-    public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long groupId) {
+    public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long groupId, Integer state) {
         try {
             QueryWrapper<KuaishouChannel> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account_id", accountId);
             queryWrapper.eq("channel_code", channelCode).last("limit 1");
             KuaishouChannel one = this.getOne(queryWrapper);
             if (!Check.isNull(one)) {
-                QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
-                relqueryWrapper.eq("account_id", accountId);
-                relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
-                KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
-                if (!Check.isNull(rel)) {
-                    if (!Check.isNull(rel.getCampaignId())) {
-                        rel.setId(null);
-                    }
-                    rel.setCampaignId(planId);
-                    rel.setUnitId(groupId);
-                    channelRelService.save(rel);
-                    if ("plan".equals(level)) {
-                        Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
-                        one.setUsageTimes(usageTimes);
-                        this.saveOrUpdate(one);
-                    } else if ("group".equals(level)) {
-                        Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
-                        one.setUsageTimes(usageTimes);
-                        this.saveOrUpdate(one);
+                if (0 == state) {
+                    one.setChannelLock(1);
+                    this.saveOrUpdate(one);
+                } else {
+                    QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
+                    relqueryWrapper.eq("account_id", accountId);
+                    relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
+                    KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
+                    if (!Check.isNull(rel)) {
+                        if (!Check.isNull(rel.getCampaignId())) {
+                            rel.setId(null);
+                        }
+                        rel.setCampaignId(planId);
+                        rel.setUnitId(groupId);
+                        channelRelService.save(rel);
+                        if ("plan".equals(level)) {
+                            Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
+                            one.setUsageTimes(usageTimes);
+                            one.setChannelLock(1);
+                            this.saveOrUpdate(one);
+                        } else if ("group".equals(level)) {
+                            Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
+                            one.setUsageTimes(usageTimes);
+                            one.setChannelLock(1);
+                            this.saveOrUpdate(one);
+                        }
                     }
                 }
             }
@@ -1062,9 +1080,13 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         } else {
                             channelRel.setAppId(channel.getAppId());
                             channelRelService.saveOrUpdate(channelRel);
+                            channel.setChannelLock(0);
+                            this.saveOrUpdate(channel);
                             return Result.ok(channel);
                         }
                     } else {
+                        channel.setChannelLock(0);
+                        this.saveOrUpdate(channel);
                         channel.setAppId(channelRel.getAppId());
                         return Result.ok(channel);
                     }
@@ -1115,9 +1137,13 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         } else {
                             channelRel.setAppId(channel.getAppId());
                             channelRelService.saveOrUpdate(channelRel);
+                            channel.setChannelLock(0);
+                            this.saveOrUpdate(channel);
                             return Result.ok(channel);
                         }
                     } else {
+                        channel.setChannelLock(0);
+                        this.saveOrUpdate(channel);
                         channel.setAppId(channelRel.getAppId());
                         return Result.ok(channel);
                     }
@@ -1148,6 +1174,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             return;
         }
         KuaishouChannelAppInfo one = channelAppInfoService.getById(channel.getChannelAppInfoId());
+        String appIconUrl = one.getAppIconUrl();
+        if (!Check.isNull(appIconUrl) && !appIconUrl.contains("http")) {
+            one.setAppIconUrl("https:" + appIconUrl);
+        }
         JSONObject tokenJson = appInfoService.uploadAppIconImage(one.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
         if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
             log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));