瀏覽代碼

Merge remote-tracking branch 'origin/master' into master_new

syh 5 年之前
父節點
當前提交
4e560abdb3

+ 10 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -99,18 +99,21 @@ public class TestController {
         return "Success";
     }
 
-
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
     @GetMapping(value = "/getVideoAndImage")
     public String getVideoAndImage() {
         QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
         tokenQueryWrapper.eq("media_id", 2);
         List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
         for (CtopOauthToken token : ctopOauthTokens) {
-
-            kuaishouInterfaceService.getVideoList2(token, null, null, 1);
-            kuaishouInterfaceService.getImageList2(token, null, null, 1);
-            kuaishouInterfaceService.getCreativeList2(token, null, null, 1);
-
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    kuaishouInterfaceService.getVideoList2(token, null, null, 1);
+                    kuaishouInterfaceService.getImageList2(token, null, null, 1);
+                 //   kuaishouInterfaceService.getCreativeList2(token, null, null, 1);
+                }
+            });
 
         }
         return "Success";
@@ -118,7 +121,7 @@ public class TestController {
 
     @Autowired
     private CtopOauthTokenMapper oauthTokenMapper;
-    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
 
     @GetMapping(value = "/gerCreative")
     public void gerCreative() {

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -172,7 +172,7 @@ public class UserAllocationController {
             if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
-
+            queryWrapper.orderByDesc("create_time");
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
             result.setResult(userAllocations);

+ 42 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DeleteCreativeStaticJob.java

@@ -0,0 +1,42 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeStatisticService;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+
+/**
+ * 出价预警
+ */
+public class DeleteCreativeStaticJob implements Job {
+    @Autowired
+    private IKuaishouReportHourlyCreativeStatisticService reportHourlyCreativeStatisticService;
+
+    /**
+     * 定时删除数据
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                    String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
+                    reportHourlyCreativeStatisticService.deleteHourlyReportByStatDate(anotherDay);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+        thread.start();
+    }
+
+}

+ 0 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -142,7 +142,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                             jsonObject.remove("materialName");
                             url = "https:" + url;
                             String localPath = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
-                            //  String localPath = LoadFileUtil.downLoadFromUrl(url, "D:\\tets1\\image");
                             String md5 = LoadFileUtil.getMD5(localPath);
                             jsonObject.put("code", md5);
                             LoadFileUtil.delFile(localPath);
@@ -153,7 +152,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                                 fileNameStr = split[0];
                             }
                             jsonObject.put("materialName", AesEncryptUtil.getUrlDecoderString(fileNameStr));
-
                             insertMaterialInfo(url, type, jsonObject);
                         }
 

+ 137 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/BigDecimalUtil.java

@@ -0,0 +1,137 @@
+package cn.com.ctop.common.module.utils;
+
+import java.math.BigDecimal;
+
+public class BigDecimalUtil {
+
+    /**
+     * 想加
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static BigDecimal addBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal add_result = v1.add(v2);
+        return add_result;
+    }
+
+
+    /**
+     * 相减
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static BigDecimal subtractBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal subtract_result = v1.subtract(v2);
+        return subtract_result;
+    }
+
+
+    /**
+     * 相乘
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static BigDecimal multiplyBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal multiply_result = v1.multiply(v2);
+        return multiply_result;
+    }
+
+
+    /**
+     * 相除
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static BigDecimal divideBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal divide_result = v1.divide(v2);
+        return divide_result;
+    }
+
+
+    /**
+     * 余数
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static BigDecimal remainderDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal remainder_result = v1.remainder(v2);
+        return remainder_result;
+    }
+
+    /**
+     * 最大数
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+
+    public static BigDecimal maxBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal max_result = v1.max(v2);
+        return max_result;
+    }
+
+    /**
+     * 最小数
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+
+    public static BigDecimal minBigDecimal(BigDecimal v1, BigDecimal v2) {
+        BigDecimal min_result = v1.min(v2);
+        return min_result;
+    }
+
+    /**
+     * 绝对值
+     *
+     * @param v
+     * @return
+     */
+    public static BigDecimal absBigDecimal(BigDecimal v) {
+        BigDecimal abs_result = v.abs();
+        return abs_result;
+
+
+    }
+
+
+    /**
+     * 相反数
+     *
+     * @param v
+     * @return
+     */
+    public static BigDecimal negateBigDecimal(BigDecimal v) {
+        BigDecimal negate_result = v.negate();
+        return negate_result;
+
+    }
+
+
+    /**
+     * 比较大小
+     *
+     * @param v1
+     * @param v2
+     * @return
+     */
+    public static int compareToDecimal(BigDecimal v1, BigDecimal v2) {
+        int i = v1.compareTo(v2);
+        return i;
+
+    }
+
+}

+ 4 - 3
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -202,8 +202,9 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                                 //   kuaishouInterfaceService.imageGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("image_token"));
                                                 if (!Check.isNull(dataJson)) {
                                                     String signature = dataJson.getString("signature");
+                                                    String image_token = dataJson.getString("image_token");
                                                     KuaiShouImageGet imageGet = new KuaiShouImageGet();
-                                                    imageGet.setId(accountId + signature);
+                                                    imageGet.setId(accountId + image_token);
                                                     imageGet.setAccountId(accountId);
                                                     imageGet.setUrl(dataJson.getString("url"));
                                                     imageGet.setWidth(dataJson.getInteger("width"));
@@ -215,7 +216,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                                         imageGet.setMaterialType(type);
                                                     }
                                                     imageGet.setSignature(signature);
-                                                    imageGet.setImageToken(dataJson.getString("image_token"));
+                                                    imageGet.setImageToken(image_token);
                                                     iKuaiShouImageGetService.saveOrUpdate(imageGet);
                                                 }
 
@@ -225,7 +226,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                                 String signature = dataJson.getString("signature");
                                                 KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
                                                 videoGet.setAccountId(accountId);
-                                                videoGet.setId(accountId + signature);
+                                                videoGet.setId(accountId + photoId);
                                                 videoGet.setUrl(materialInfo.getUrl());
                                                 QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
                                                 parameterQueryWrapper.eq("material_id", materialId);

+ 324 - 80
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
@@ -69,6 +70,12 @@ public class BatchController {
     private IKuaiShouAppInfoService appInfoService;
     @Autowired
     private IKuaiShouGroupTargetService targetService;
+    @Autowired
+    private IKuaiShouRegionListParentService regionListParentService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
 
 
     /**
@@ -143,8 +150,6 @@ public class BatchController {
     @PostMapping(value = "/batchUpdateStatus")
     public Result<JSONObject> batchUpdateStatus(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
-
-
         try {
             Long accountId = requestJson.getLong("accountId");
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
@@ -250,6 +255,76 @@ public class BatchController {
 
 
     /**
+     * 根据比例批量修改广告计划预算
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateDayBudgetByProportion")
+    public Result<JSONObject> batchUpdateDayBudgetByProportion(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            BigDecimal proportion = requestJson.getBigDecimal("proportion");
+            if (proportion.compareTo(new BigDecimal(0)) == 0) {
+                throw new Exception("比例不能为0");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(campaignIds)) {
+                for (int i = 0; i < campaignIds.size(); i++) {
+                    Long campaignId = campaignIds.getLong(i);
+                    if (!Check.isNull(campaignId)) {
+                        KuaiShouCampaign campaign = batchService.getCampaignInfo(accountId, campaignId);
+                        if (!Check.isNull(campaign)) {
+                            Long dayBudget = campaign.getDayBudget();
+                            if (Check.isNull(dayBudget)) {
+                                continue;
+                            }
+                            BigDecimal totalFee = new BigDecimal(dayBudget);
+                            Long multiply = 0L;
+                            if (proportion.compareTo(new BigDecimal(0)) == -1) {
+                                BigDecimal absBigDecimal = BigDecimalUtil.absBigDecimal(proportion);
+                                BigDecimal decimal = BigDecimalUtil.multiplyBigDecimal(totalFee, absBigDecimal);
+                                multiply = (BigDecimalUtil.subtractBigDecimal(totalFee, decimal)).longValue();
+                            } else if (proportion.compareTo(new BigDecimal(0)) == 1) {
+                                multiply = (totalFee.multiply(proportion)).longValue();
+                            }
+                            Map<String, Object> updateMap = updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, multiply, userId);
+                            if (!Check.isNull(updateMap)) {
+                                Integer code = (Integer) updateMap.get("code");
+                                if (code != 0) {
+                                    JSONObject failJson = new JSONObject();
+                                    failJson.put("message", updateMap.get("message"));
+                                    failJson.put("campaignName", campaign.getCampaignName());
+                                    failArr.add(failJson);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", campaignIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
      * 查询广告组列表
      *
      * @param kuaiShouGroup
@@ -286,50 +361,9 @@ public class BatchController {
     @GetMapping(value = "/getRegion")
     public Result<List<KuaiShouRegionListParent>> getRegion(KuaiShouRegionListParent kuaiShouRegionListParent, HttpServletRequest req) {
         Result<List<KuaiShouRegionListParent>> result = new Result<>();
-
-
         try {
-            /*JSONArray regionArr = new JSONArray();
-            QueryWrapper<KuaiShouRegionListParent> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("level", 1);
-            List<KuaiShouRegionListParent> regionListParents = regionListParentMapper.selectList(queryWrapper);
-            if (!Check.isNull(regionListParents)) {
-
-                for (KuaiShouRegionListParent regionListParent : regionListParents) {
-                    if (Check.isNull(regionListParent)) {
-                        continue;
-                    }
-                    JSONObject parentJson = new JSONObject();
-                    Long regionId = regionListParent.getRegionId();
-                    parentJson.put("regionId", regionId);
-                    parentJson.put("name", regionListParent.getName());
-                    QueryWrapper<KuaiShouRegionListParent> childrenQueryWrapper = new QueryWrapper<>();
-                    childrenQueryWrapper.eq("parent", regionId);
-                    List<KuaiShouRegionListParent> childrenRegions = regionListParentMapper.selectList(childrenQueryWrapper);
-
-                    JSONArray childrenArr = new JSONArray();
-                    if (!Check.isNull(childrenRegions)) {
-                        for (KuaiShouRegionListParent childrenRegion : childrenRegions) {
-                            if (!Check.isNull(childrenRegion)) {
-                                JSONObject childrenJson = new JSONObject();
-                                childrenJson.put("regionId", childrenRegion.getRegionId());
-                                childrenJson.put("name", childrenRegion.getName());
-                                childrenArr.add(childrenJson);
-                            }
-                        }
-                        parentJson.put("children", childrenArr);
-
-                    }
-
-                    regionArr.add(parentJson);
-                }
-            }*/
-
-
             QueryWrapper<KuaiShouRegionListParent> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouRegionListParent, req.getParameterMap());
-
             List<KuaiShouRegionListParent> pageList = kuaiShouRegionListParentService.list(queryWrapper);
-
             result.setSuccess(true);
             result.setResult(pageList);
         } catch (Exception e) {
@@ -388,7 +422,6 @@ public class BatchController {
         try {
             QueryWrapper<KuaiShouAppList> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppList, req.getParameterMap());
             queryWrapper.orderByDesc("return_time");
-
             List<KuaiShouAppList> appList = kuaiShouAppListService.list(queryWrapper);
             result.setSuccess(true);
             result.setResult(appList);
@@ -471,7 +504,6 @@ public class BatchController {
             if (Check.isNull(deepConversionJson)) {
                 throw new Exception("深度类型数据返回为空");
             }
-
             result.setSuccess(true);
             result.setResult(deepConversionJson);
         } catch (Exception e) {
@@ -510,7 +542,6 @@ public class BatchController {
         }
 
         return result;
-
     }
 
     /**
@@ -615,7 +646,6 @@ public class BatchController {
     public Result<IPage<KuaiShouCreative>> getCreativeList(KuaiShouCreative kuaiShouCreative, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
         Result<IPage<KuaiShouCreative>> result = new Result<>();
-
         QueryWrapper<KuaiShouCreative> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCreative, req.getParameterMap());
         queryWrapper.orderByDesc("creative_id");
         Page<KuaiShouCreative> page = new Page<>(pageNo, pageSize);
@@ -635,8 +665,6 @@ public class BatchController {
     @PostMapping(value = "/batchUpdateUnitBudget")
     public Result<JSONObject> batchUpdateUnitBudget(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
-
-
         try {
             Long accountId = requestJson.getLong("accountId");
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
@@ -686,6 +714,80 @@ public class BatchController {
 
 
     /**
+     * 根据比例批量修改广告组预算
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnitBudgetByProportion")
+    public Result<JSONObject> batchUpdateUnitBudgetByProportion(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            BigDecimal proportion = requestJson.getBigDecimal("proportion");
+            if (proportion.compareTo(new BigDecimal(0)) == 0) {
+                throw new Exception("比例不能为0");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(unitIds)) {
+                for (int i = 0; i < unitIds.size(); i++) {
+                    Long unitId = unitIds.getLong(i);
+                    if (!Check.isNull(unitId)) {
+                        KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
+                        if (!Check.isNull(group)) {
+                            Long dayBudget = group.getDayBudget();
+                            if (Check.isNull(dayBudget)) {
+                                continue;
+                            }
+                            BigDecimal totalFee = new BigDecimal(dayBudget);
+
+                            Long multiply = 0L;
+                            if (proportion.compareTo(new BigDecimal(0)) == -1) {
+                                BigDecimal absBigDecimal = BigDecimalUtil.absBigDecimal(proportion);
+                                BigDecimal decimal = BigDecimalUtil.multiplyBigDecimal(totalFee, absBigDecimal);
+                                multiply = (BigDecimalUtil.subtractBigDecimal(totalFee, decimal)).longValue();
+                            } else if (proportion.compareTo(new BigDecimal(0)) == 1) {
+                                multiply = (totalFee.multiply(proportion)).longValue();
+                            }
+
+                            Map<String, Object> updateMap = updateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, multiply, userId);
+                            if (!Check.isNull(updateMap)) {
+                                Integer code = (Integer) updateMap.get("code");
+                                if (code != 0) {
+                                    JSONObject failJson = new JSONObject();
+                                    failJson.put("message", updateMap.get("message"));
+                                    if (!Check.isNull(group)) {
+                                        failJson.put("unitName", group.getUnitName());
+                                    }
+                                    failArr.add(failJson);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", unitIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
      * 批量修改广告组状态
      *
      * @param requestJson
@@ -694,8 +796,6 @@ public class BatchController {
     @PostMapping(value = "/batchUpdateUnitStatus")
     public Result<JSONObject> batchUpdateUnitStatus(@RequestBody JSONObject requestJson) {
         Result<JSONObject> result = new Result<>();
-
-
         try {
             Long accountId = requestJson.getLong("accountId");
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
@@ -745,6 +845,83 @@ public class BatchController {
 
 
     /**
+     * 根据比列批量修改广告组出价
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnitBidByProportion")
+    public Result<JSONObject> batchUpdateUnitBidByProportion(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("账号信息为空");
+            }
+            BigDecimal proportion = requestJson.getBigDecimal("proportion");
+            if (proportion.compareTo(new BigDecimal(0)) == 0) {
+                throw new Exception("比例不能为0");
+            }
+            String userId = requestJson.getString("userId");
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            JSONArray failArr = new JSONArray();
+            if (!Check.isNull(unitIds)) {
+                for (int i = 0; i < unitIds.size(); i++) {
+                    Long unitId = unitIds.getLong(i);
+                    if (!Check.isNull(unitId)) {
+                        KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
+                        if (Check.isNull(group)) {
+                            continue;
+                        }
+                        Long groupBid;
+                        Long bid = group.getBid();
+                        Long cpaBid = group.getCpaBid();
+                        if (!Check.isNull(cpaBid)) {
+                            groupBid = cpaBid;
+                        } else {
+                            groupBid = bid;
+                        }
+                        BigDecimal totalFee = new BigDecimal(groupBid);
+                        Long multiply = 0L;
+                        if (proportion.compareTo(new BigDecimal(0)) == -1) {
+                            BigDecimal absBigDecimal = BigDecimalUtil.absBigDecimal(proportion);
+                            BigDecimal decimal = BigDecimalUtil.multiplyBigDecimal(totalFee, absBigDecimal);
+                            multiply = (BigDecimalUtil.subtractBigDecimal(totalFee, decimal)).longValue();
+                        } else if (proportion.compareTo(new BigDecimal(0)) == 1) {
+                            multiply = (totalFee.multiply(proportion)).longValue();
+                        }
+                        Map<String, Object> updateMap = updateService.updateUnitBid(token.getAccessToken(), accountId, unitId, multiply, userId);
+                        if (!Check.isNull(updateMap)) {
+                            Integer code = (Integer) updateMap.get("code");
+                            if (code != 0) {
+                                JSONObject failJson = new JSONObject();
+                                failJson.put("message", updateMap.get("message"));
+                                if (!Check.isNull(group)) {
+                                    failJson.put("unitName", group.getUnitName());
+                                }
+                                failArr.add(failJson);
+                            }
+                        }
+                    }
+                }
+            }
+            JSONObject json = new JSONObject();
+            json.put("totalCount", unitIds.size());
+            json.put("failCount", failArr.size());
+            json.put("failInfo", failArr);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
      * 批量修改广告组状态
      *
      * @param requestJson
@@ -778,7 +955,7 @@ public class BatchController {
                                 failJson.put("message", updateMap.get("message"));
                                 KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
                                 if (!Check.isNull(group)) {
-                                    failJson.put("campaignName", group.getUnitName());
+                                    failJson.put("unitName", group.getUnitName());
                                 }
                                 failArr.add(failJson);
                             }
@@ -822,12 +999,8 @@ public class BatchController {
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
-
         }
-
         return result;
-
-
     }
 
     /**
@@ -842,7 +1015,6 @@ public class BatchController {
                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
         Result<IPage<KuaiShouVideoGet>> result = new Result<IPage<KuaiShouVideoGet>>();
         try {
-
             QueryWrapper<KuaiShouVideoGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouVideoGet, req.getParameterMap());
             queryWrapper.orderByDesc("create_time");
             Page<KuaiShouVideoGet> page = new Page<KuaiShouVideoGet>(pageNo, pageSize);
@@ -869,7 +1041,6 @@ public class BatchController {
     public Result<MaterialInfo> getVideoList(String code) {
         Result<MaterialInfo> result = new Result<>();
         try {
-
             QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
             materialInfoQueryWrapper.eq("code", code);
             materialInfoQueryWrapper.last("limit 1");
@@ -931,8 +1102,6 @@ public class BatchController {
             e.printStackTrace();
             result.setSuccess(false);
         }
-
-
         return result;
     }
 
@@ -1010,7 +1179,6 @@ public class BatchController {
                                                                             HttpServletRequest req) {
         Result<List<KuaiShouDirectionalTemplate>> result = new Result<>();
         QueryWrapper<KuaiShouDirectionalTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDirectionalTemplate, req.getParameterMap());
-
         List<KuaiShouDirectionalTemplate> templates = kuaiShouDirectionalTemplateService.list(queryWrapper);
         result.setSuccess(true);
         result.setResult(templates);
@@ -1022,7 +1190,6 @@ public class BatchController {
      *
      * @return
      */
-
     @PostMapping(value = "/addDirectionalTemplate")
     public Result<KuaiShouDirectionalTemplate> add(@RequestBody KuaiShouDirectionalTemplate kuaiShouDirectionalTemplate) {
         Result<KuaiShouDirectionalTemplate> result = new Result<KuaiShouDirectionalTemplate>();
@@ -1065,9 +1232,8 @@ public class BatchController {
      * @param id
      * @return
      */
-
-    @DeleteMapping(value = "/deleteeditDirectionalTemplate")
-    public Result<?> deleteeditDirectionalTemplate(@RequestParam(name = "id", required = true) String id) {
+    @DeleteMapping(value = "/deleteDirectionalTemplate")
+    public Result<?> deleteDirectionalTemplate(@RequestParam(name = "id", required = true) String id) {
         try {
             kuaiShouDirectionalTemplateService.removeById(id);
         } catch (Exception e) {
@@ -1085,8 +1251,6 @@ public class BatchController {
      * @param unitId
      * @return
      */
-
-
     @GetMapping(value = "/getUnitDetail")
     public Result<JSONObject> getUnitDetail(Long accountId, Long unitId) {
         Result<JSONObject> result = new Result<>();
@@ -1143,7 +1307,6 @@ public class BatchController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
-
             JSONObject campaignJson = batchService.updateCampaign(requestJson);
             result.setSuccess(true);
             result.setResult(campaignJson);
@@ -1167,13 +1330,11 @@ public class BatchController {
      */
     @PostMapping(value = "/updateUnit")
     public Result<JSONObject> updateUnit(@RequestBody JSONObject requestJson) {
-
         Result<JSONObject> result = new Result<>();
         try {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
-
             JSONObject unitJson = batchService.updateUnit(requestJson);
             result.setSuccess(true);
             result.setResult(unitJson);
@@ -1187,6 +1348,57 @@ public class BatchController {
 
 
     /**
+     * 批量修改广告组定向
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateUnit")
+    public Result<JSONObject> batchUpdateUnit(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参为空");
+            }
+
+            JSONArray unitIds = requestJson.getJSONArray("unitIds");
+            if (Check.isNull(unitIds)) {
+                throw new Exception("请选择需要修改的广告组");
+            }
+            JSONObject returnJson = new JSONObject();
+            JSONArray failArr = new JSONArray();
+            for (int i = 0; i < unitIds.size(); i++) {
+                Long unitId = unitIds.getLong(i);
+                requestJson.put("unitId", unitId);
+                JSONObject unitJson = batchService.updateUnit(requestJson);
+                if (!Check.isNull(unitJson)) {
+                    Integer code = unitJson.getInteger("code");
+                    if (code != 0) {
+                        JSONObject failJson = new JSONObject();
+                        failJson.put("message", unitJson.get("message"));
+                        KuaiShouGroup group = batchService.getUnitInfo(requestJson.getLong("accountId"), unitId);
+                        if (!Check.isNull(group)) {
+                            failJson.put("unitName", group.getUnitName());
+                        }
+                        failArr.add(failJson);
+                    }
+                }
+            }
+            returnJson.put("totalCount", unitIds.size());
+            returnJson.put("failCount", failArr.size());
+            returnJson.put("failInfo", failArr);
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
      * 修改广告创意
      *
      * @param requestJson
@@ -1194,13 +1406,11 @@ public class BatchController {
      */
     @PostMapping(value = "/updateCreative")
     public Result<JSONObject> updateCreative(@RequestBody JSONObject requestJson) {
-
         Result<JSONObject> result = new Result<>();
         try {
             if (Check.isNull(requestJson)) {
                 throw new Exception("入参为空");
             }
-
             JSONObject creativeJson = batchService.updateCreative(requestJson);
             result.setSuccess(true);
             result.setResult(creativeJson);
@@ -1213,9 +1423,6 @@ public class BatchController {
     }
 
 
-    @Autowired
-    private IKuaiShouVideoGetService videoGetService;
-
     /**
      * 获取视频信息
      *
@@ -1240,15 +1447,11 @@ public class BatchController {
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
-
         }
         return result;
     }
 
 
-    @Autowired
-    private IKuaiShouImageGetService imageGetService;
-
     /**
      * 获取图片信息
      *
@@ -1273,10 +1476,51 @@ public class BatchController {
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
-
         }
         return result;
     }
 
 
+    /**
+     * 获取地域信息
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/getRegionDetail")
+    public Result<JSONArray> getRegionDetail(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("参数错误");
+            }
+            JSONArray returnArr = new JSONArray();
+            JSONArray regionArr = requestJson.getJSONArray("regionArr");
+            if (!Check.isNull(regionArr)) {
+                for (int i = 0; i < regionArr.size(); i++) {
+                    Long regionId = regionArr.getLong(i);
+                    if (!Check.isNull(regionId)) {
+                        QueryWrapper<KuaiShouRegionListParent> regionListParentQueryWrapper = new QueryWrapper<>();
+                        regionListParentQueryWrapper.eq("region_id", regionId);
+                        regionListParentQueryWrapper.last("limit 1");
+                        KuaiShouRegionListParent region = regionListParentService.getOne(regionListParentQueryWrapper);
+                        if (!Check.isNull(region)) {
+                            JSONObject returnJson = new JSONObject();
+                            returnJson.put("value", region.getRegionId());
+                            returnJson.put("label", region.getName());
+                            returnArr.add(returnJson);
+                        }
+                    }
+                }
+            }
+            result.setSuccess(true);
+            result.setResult(returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
+        }
+        return result;
+    }
+
 }

+ 0 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -487,8 +487,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             String creativeId = requestJson.getString("creativeId");
             String creativeName = requestJson.getString("creativeName");
             String description = requestJson.getString("description");
-
-
             params.put("advertiser_id", advertiserId);
             params.put("creative_id", creativeId);
             params.put("creative_name", creativeName);

+ 13 - 12
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -242,12 +242,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
             for (int i = 0; i < details.size(); i++) {
                 var detailJson = details.getJSONObject(i);
-                if (Check.isNull(detailJson.getString("signature"))) {
+               /* if (Check.isNull(detailJson.getString("signature"))) {
                     continue;
-                }
+                }*/
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
-                kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getSignature());
+                kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
                 kuaiShouVideoGet.setCreateTime(new Date());
                 kuaiShouVideoGet.setUpdateTime(new Date());
                 Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
@@ -302,11 +302,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             List<KuaiShouVideoGet> videoGets = new ArrayList<>();
             for (int i = 0; i < details.size(); i++) {
                 var detailJson = details.getJSONObject(i);
-                if (Check.isNull(detailJson.getString("signature"))) {
+               /* if (Check.isNull(detailJson.getString("signature"))) {
                     continue;
-                }
+                }*/
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
-                kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getSignature());
+                kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
 
             //    kuaiShouVideoGet.setCreateTime(new Date());
@@ -1516,6 +1516,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         try {
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
@@ -3215,16 +3216,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             for (int i = 0; i < details.size(); i++) {
                 var detailJson = details.getJSONObject(i);
 
-                if (Check.isNull(detailJson.getString("signature"))) {
+                /*if (Check.isNull(detailJson.getString("signature"))) {
                     continue;
-                }
+                }*/
 
                 var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
 
                 if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
                     continue;
                 }
-                kuaiShouImageGet.setId(token.getAccountId() + kuaiShouImageGet.getSignature());
+                kuaiShouImageGet.setId(token.getAccountId() + kuaiShouImageGet.getImageToken());
                 kuaiShouImageGet.setAccountId(token.getAccountId());
 
                 Integer type = MaterialEnum.getTypeBySize(kuaiShouImageGet.getWidth(), kuaiShouImageGet.getHeight());
@@ -3279,16 +3280,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             for (int i = 0; i < details.size(); i++) {
                 var detailJson = details.getJSONObject(i);
 
-                if (Check.isNull(detailJson.getString("signature"))) {
+               /* if (Check.isNull(detailJson.getString("signature"))) {
                     continue;
-                }
+                }*/
 
                 var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
 
                 if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
                     continue;
                 }
-                kuaiShouImageGet.setId(token.getAccountId() + kuaiShouImageGet.getSignature());
+                kuaiShouImageGet.setId(token.getAccountId() + kuaiShouImageGet.getImageToken());
                 kuaiShouImageGet.setAccountId(token.getAccountId());
 
                 Integer type = MaterialEnum.getTypeBySize(kuaiShouImageGet.getWidth(), kuaiShouImageGet.getHeight());

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyCreativeStatisticMapper.xml

@@ -13,6 +13,7 @@
 	`creative_id`,
 	`creative_name`,
 	`stat_date`,
+	`stat_date`,
 	`stat_hour`,
 	`charge`,
 	`photo_click`,

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportHourlyCreativeStatisticService.java

@@ -18,4 +18,5 @@ public interface IKuaishouReportHourlyCreativeStatisticService extends IService<
     void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate);
 
     void deleteHourlyReport(Date deleteDate);
+    void deleteHourlyReportByStatDate(String deleteDate);
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyCreativeStatisticServiceImpl.java

@@ -36,4 +36,9 @@ public class KuaishouReportHourlyCreativeStatisticServiceImpl extends ServiceImp
         String dateString = format.format(deleteDate);
         statisticMapper.deleteHourlyReport(dateString);
     }
+
+    @Override
+    public void deleteHourlyReportByStatDate(String deleteDate) {
+        statisticMapper.deleteHourlyReport(deleteDate);
+    }
 }