Explorar o código

Merge remote-tracking branch 'origin/master'

yumeng %!s(int64=4) %!d(string=hai) anos
pai
achega
f1a05d5539

+ 32 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -9,7 +9,12 @@ import cn.com.ctop.common.module.service.IBindAccountAuthService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ISysDepartService;
 import cn.com.ctop.common.module.service.ISysUserService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.BytedanceInterfaceConstant;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
@@ -36,7 +41,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @RestController
@@ -59,6 +67,8 @@ public class CallbackController {
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
     private IReportService reportService;
+    @Autowired
+    private IKuaishouAppPackageService kuaishouAppPackageService;
 
     @GetMapping("/qywexin")
     public void qywexin(HttpServletRequest request,
@@ -197,6 +207,8 @@ public class CallbackController {
                     userAllocation.setWarningAmount(warningAmount);
                     userAllocation.setCreateTime(new Date());
                     userAllocation.setUpdateTime(new Date());
+                    //同步物料,0关闭,1开启
+                    userAllocation.setAutoDelivery(json.getInteger("autoDelivery"));
                     allocationMapper.deleteById(userAllocation.getId());
                     Map<String, Object> deleteUserMap = new HashMap<>();
                     deleteUserMap.put("advertiser_id", advertiserId);
@@ -206,6 +218,8 @@ public class CallbackController {
                     if (i > 0) {
                         log.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
                     }
+                    //物料类型,0-不同步,1应用包,(2人群包,3定向包)
+                    Integer materialType = json.getInteger("materialType");
                     //账号绑定
                     bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId);
                     Thread t = new Thread() {
@@ -213,6 +227,9 @@ public class CallbackController {
                         public void run() {
                             try {
                                 kuaishouInterfaceService.loadKuaishouDataSingle(topOauthToken);
+                                if (!Check.isNull(materialType) && materialType != 0) {
+                                    synchronMaterials(materialType, accountId, projectId);
+                                }
                             } catch (ParseException e) {
                                 e.printStackTrace();
                             }
@@ -228,9 +245,19 @@ public class CallbackController {
         return "授权绑定失败!";
     }
 
-
-    public static void main(String[] args) {
-        System.err.println(UUID.randomUUID().toString().replace("-", ""));
+    private void synchronMaterials(Integer materialType, Long accountId, Long projectId) {
+        if (materialType == 1) {
+            JSONArray accountIds = new JSONArray();
+            accountIds.add(accountId);
+            //1 有效项目模板
+            List<Long> ids = kuaishouAppPackageService.queryByAppVersion(projectId, null, 1);
+            log.info("同步账户应用,应用模板={}", ids);
+            if (!Check.isNull(ids)) {
+                for (Long id : ids) {
+                    kuaishouAppPackageService.pushAppPackage(id, accountIds);
+                }
+            }
+        }
     }
 
     @RequestMapping("/bytedance")

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java

@@ -138,6 +138,10 @@ public class UserAllocation implements Serializable {
      * 1 禁用
      */
     private Integer deleteComment;
+    /**
+     * 同步物料,0关闭,1开启
+     */
+    private Integer autoDelivery;
 
     /**
      * 修改时间

+ 33 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -461,6 +461,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
@@ -503,6 +506,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
@@ -531,6 +537,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
         WHERE t2.parent_id = 60155
@@ -560,6 +569,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id,t1.`code`
@@ -590,6 +602,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
         WHERE t2.parent_id = 60156
@@ -619,6 +634,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE  t2.parent_id = 60156
         GROUP BY t1.user_id,t1.`code`
@@ -670,6 +688,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id in(60155,60156)
         GROUP BY t1.user_id
@@ -699,6 +720,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
         WHERE t2.parent_id = 60155
@@ -728,6 +752,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60155
         GROUP BY t1.user_id,t1.`code`
@@ -758,6 +785,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         LEFT JOIN ctop_kuaishou_report_daily_material t5 ON  t1.`code` = t5.signature
         WHERE t2.parent_id = 60156
@@ -787,6 +817,9 @@
         <if test="roleCode!=null">
             AND tt3.role_code = #{roleCode}
         </if>
+        <if test="roleCode==null">
+            AND tt3.role_code in ('clip','shot','plan')
+        </if>
         ) t3 ON t3.id = t1.user_id
         WHERE t2.parent_id = 60156
         GROUP BY t1.user_id,t1.`code`