Przeglądaj źródła

自动投放-多应用多出价

yumeng 4 lat temu
rodzic
commit
d2dd524f5c

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

@@ -3,13 +3,16 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -43,6 +46,8 @@ public class AiKuaishouAdvertiserStrategyController {
     private IUserAllocationService allocationService;
     @Autowired
     private ISysRoleService sysRoleService;
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
     /**
      * 分页列表查询
@@ -254,6 +259,8 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @return
      */
+
+
     @GetMapping(value = "/queryById")
     public Result<AiKuaishouAdvertiserStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -261,6 +268,14 @@ public class AiKuaishouAdvertiserStrategyController {
         if (aiKuaishouAdvertiserStrategy == null) {
             result.error500("未找到对应实体");
         } else {
+            if (aiKuaishouAdvertiserStrategy.getMultipleBids() == 1) {
+                List<JSONObject> appInfoList = kuaiShouAppMultipleBidsService.getAppInfiList(aiKuaishouAdvertiserStrategy.getAccountId(), aiKuaishouAdvertiserStrategy.getAppIdArray());
+                if (!Check.isNull(appInfoList)) {
+                    aiKuaishouAdvertiserStrategy.setAppInfoList(appInfoList);
+
+                }
+            }
+
             result.setResult(aiKuaishouAdvertiserStrategy);
             result.setSuccess(true);
         }

+ 257 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouAppMultipleBidsController.java

@@ -0,0 +1,257 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-18
+ */
+@Slf4j
+@Api(tags = "多应用分别出价")
+@RestController
+@RequestMapping("/adsp/kuaiShouAppMultipleBids")
+public class KuaiShouAppMultipleBidsController {
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouAppMultipleBids
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-分页列表查询", notes = "多应用分别出价-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouAppMultipleBids>> queryPageList(KuaiShouAppMultipleBids kuaiShouAppMultipleBids,
+                                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                HttpServletRequest req) {
+        Result<IPage<KuaiShouAppMultipleBids>> result = new Result<>();
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppMultipleBids, req.getParameterMap());
+        Page<KuaiShouAppMultipleBids> page = new Page<KuaiShouAppMultipleBids>(pageNo, pageSize);
+        IPage<KuaiShouAppMultipleBids> pageList = kuaiShouAppMultipleBidsService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouAppMultipleBids
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-添加", notes = "多应用分别出价-添加")
+    @PostMapping(value = "/saveOrUpdate")
+    public Result<KuaiShouAppMultipleBids> add(@RequestBody KuaiShouAppMultipleBids kuaiShouAppMultipleBids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        try {
+            Long accountId = kuaiShouAppMultipleBids.getAccountId();
+            Long appId = kuaiShouAppMultipleBids.getAppId();
+            QueryWrapper<KuaiShouAppMultipleBids> appMultipleBidsQueryWrapper = new QueryWrapper<>();
+            appMultipleBidsQueryWrapper.eq("account_id", accountId);
+            appMultipleBidsQueryWrapper.eq("app_id", appId);
+            appMultipleBidsQueryWrapper.orderByDesc("create_time");
+            appMultipleBidsQueryWrapper.last("limit 1");
+            KuaiShouAppMultipleBids one = kuaiShouAppMultipleBidsService.getOne(appMultipleBidsQueryWrapper);
+            if (Check.isNull(one)) {
+                kuaiShouAppMultipleBidsService.save(kuaiShouAppMultipleBids);
+            } else {
+                kuaiShouAppMultipleBids.setId(one.getId());
+                kuaiShouAppMultipleBidsService.updateById(kuaiShouAppMultipleBids);
+            }
+
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouAppMultipleBids
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-编辑", notes = "多应用分别出价-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouAppMultipleBids> edit(@RequestBody KuaiShouAppMultipleBids kuaiShouAppMultipleBids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<KuaiShouAppMultipleBids>();
+        KuaiShouAppMultipleBids kuaiShouAppMultipleBidsEntity = kuaiShouAppMultipleBidsService.getById(kuaiShouAppMultipleBids.getId());
+        if (kuaiShouAppMultipleBidsEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouAppMultipleBidsService.updateById(kuaiShouAppMultipleBids);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-通过id删除", notes = "多应用分别出价-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            kuaiShouAppMultipleBidsService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-批量删除", notes = "多应用分别出价-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaiShouAppMultipleBids> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouAppMultipleBidsService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "多应用分别出价-通过id查询", notes = "多应用分别出价-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaiShouAppMultipleBids> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouAppMultipleBids> result = new Result<>();
+        KuaiShouAppMultipleBids kuaiShouAppMultipleBids = kuaiShouAppMultipleBidsService.getById(id);
+        if (kuaiShouAppMultipleBids == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouAppMultipleBids);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouAppMultipleBids kuaiShouAppMultipleBids = JSON.parseObject(deString, KuaiShouAppMultipleBids.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppMultipleBids, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouAppMultipleBids> pageList = kuaiShouAppMultipleBidsService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "多应用分别出价列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouAppMultipleBids.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("多应用分别出价列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaiShouAppMultipleBids> listKuaiShouAppMultipleBidss = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouAppMultipleBids.class, params);
+                kuaiShouAppMultipleBidsService.saveBatch(listKuaiShouAppMultipleBidss);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouAppMultipleBidss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 7 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -8,6 +9,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 快手账户策略设置信息表
@@ -71,7 +73,7 @@ public class AiKuaishouAdvertiserStrategy {
     /**
      * 深度出价
      */
-    private Long cpaBid;
+    private String cpaBid;
     private Long deepConversionBid;
     /**
      * 优先低成本出价
@@ -376,7 +378,11 @@ public class AiKuaishouAdvertiserStrategy {
     private Long programUnitCnt;
     private String materialKeyword;
     private Integer historyTop;
+    private Integer multipleBids;
 
     @TableField(exist = false)
     private String authName;
+
+    @TableField(exist = false)
+    private List<JSONObject> appInfoList;
 }

+ 295 - 148
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouUnitLevelOperationRecord.java

@@ -9,159 +9,306 @@ import java.util.Date;
 
 /**
  * 组创建记录
+ *
  * @author jeecg-boot
- * @date   2021-04-12
  * @version V1.0
+ * @date 2021-04-12
  */
 @Data
 @TableName("ctop_ai_kuaishou_unit_level_operation_record")
 public class AiKuaishouUnitLevelOperationRecord {
 
-	/**组操作表uuid*/
-	@TableId(type = IdType.ASSIGN_UUID)
-	private String groupUuid;
-	/**AI策略ID*/
-	private String aiStrategyUuid;
-	/**账户ID*/
-	private Long accountId;
-	/**广告计划ID*/
-	private Long campaignId;
-	/**广告组ID*/
-	private Long unitId;
-	/**广告组名称*/
-	private String groupName;
-	/**定向模板id*/
-	private Integer templateId;
-	/**优化目标出价类型*/
-	private Integer bidType;
-	/**优先从系统应用商店下载*/
-	private Integer useAppMarket;
-	/**应用商店列表*/
-	private String appStore;
-	/**出价*/
-	private Integer bid;
-	/**出价*/
-	private Integer cpaBid;
-	/**优先低成本出价*/
-	private Integer smartBid;
-	/**优化目标*/
-	private Integer ocpxActionType;
-	/**深度转化目标*/
-	private Integer deepConversionType;
-	/**付费ROI系数*/
-	private Float roiRatio;
-	/**资源位置*/
-	private String sceneId;
-	/** 创意制作方式*/
-	private Integer unitType;
-	/**投放开始时间*/
-	private String beginTime;
-	/**投放结束时间*/
-	private String endTime;
-	/**投放时间段*/
-	private String scheduleTime;
-	/**单日预算*/
-	private Integer dayBudget;
-	/**分日预算*/
-	private String dayBudgetSchedule;
-	/**转化目标ID*/
-	private Integer convertId;
-	/**url类型*/
-	private Integer urlType;
-	/**url类型*/
-	private Integer webUriType;
-	/**投放链接*/
-	private String url;
-	/**调起链接*/
-	private String schemaUri;
-	/**应用ID*/
-	private Integer appId;
-	/**创意展现方式*/
-	private Integer showMode;
-	/**投放方式*/
-	private Integer speed;
-	/**预约广告*/
-	private Integer siteType;
-	/**游戏礼包码*/
-	private String giftData;
-	/**是否使用落地页前置功能*/
-	private Integer videoLandingPage;
-	/**智能定向*/
-	private Integer autoTarget;
-	/**是否开启自动生成视频*/
-	private Integer autoCreatePhoto;
-	/**地域*/
-	private String region;
-	/**商圈定向*/
-	private String districtIds;
-	/**用户类型*/
-	private Integer userType;
-	/**最大年龄*/
-	private Integer ageMin;
-	/**最小年龄*/
-	private Integer ageMax;
-	/**固定年龄段*/
-	private String agesRange;
-	/**性别*/
-	private Integer gender;
-	/**操作系统*/
-	private Integer platformOs;
-	/**Android版本*/
-	private Integer androidOsv;
-	/**iOS版本*/
-	private Integer iosOsv;
-	/**网络环境*/
-	private Integer network;
-	/**设备品牌*/
-	private String deviceBrand;
-	/**设备价格*/
-	private String devicePrice;
-	/**商业兴趣类型*/
-	private Integer businessInterestType;
-	/**商业兴趣*/
-	private String businessInterest;
-	/**网红粉丝*/
-	private String fansStar;
-	/**兴趣视频用户*/
-	private String interestVideo;
-	/**APP行为-按分类*/
-	private String appInterest;
-	/**APP行为-按APP名称*/
-	private String appIds;
-	/**过滤已转化人群纬度*/
-	private Integer filterConvertedLevel;
-	/**人群包定向*/
-	private String population;
-	/**人群包排除*/
-	private String excludePopulation;
-	/**付费人群包id*/
-	private String paidAudience;
-	/**开启智能扩量*/
-	private Integer isOpen;
-	/**不可突破年龄*/
-	private Integer noAgeBreak;
-	/**不可突破性别*/
-	private Integer noGenderBreak;
-	/**不可突破地域*/
-	private Integer noAreaBreak;
-	/**行为兴趣定向*/
-	private String behaviorInterest;
-	/**操作类型 1-新增 2-修改*/
-	private Integer operationType;
-	/**组创建时间*/
-	private Date groupCreateTime;
-	/**组更新时间*/
-	private Date groupUpdateTime;
-	/**创建时间*/
-	private Date createTime;
-	/**状态*/
-	private Integer status;
-	/**状态详情*/
-	private String message;
-	/**程序化创意2.0-是否开启智能抽帧*/
-	private Integer smartCover;
-	/**程序化创意2.0-是否开启素材挖掘*/
-	private Integer assetMining;
-	/**深度转化目标出价*/
-	private Integer deepConversionBid;
+    /**
+     * 组操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String groupUuid;
+    /**
+     * AI策略ID
+     */
+    private String aiStrategyUuid;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    private Long campaignId;
+    /**
+     * 广告组ID
+     */
+    private Long unitId;
+    /**
+     * 广告组名称
+     */
+    private String groupName;
+    /**
+     * 定向模板id
+     */
+    private Integer templateId;
+    /**
+     * 优化目标出价类型
+     */
+    private Integer bidType;
+    /**
+     * 优先从系统应用商店下载
+     */
+    private Integer useAppMarket;
+    /**
+     * 应用商店列表
+     */
+    private String appStore;
+    /**
+     * 出价
+     */
+    private Integer bid;
+    /**
+     * 出价
+     */
+    private Integer cpaBid;
+    /**
+     * 优先低成本出价
+     */
+    private Integer smartBid;
+    /**
+     * 优化目标
+     */
+    private Integer ocpxActionType;
+    /**
+     * 深度转化目标
+     */
+    private Integer deepConversionType;
+    /**
+     * 付费ROI系数
+     */
+    private Float roiRatio;
+    /**
+     * 资源位置
+     */
+    private String sceneId;
+    /**
+     * 创意制作方式
+     */
+    private Integer unitType;
+    /**
+     * 投放开始时间
+     */
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    private String endTime;
+    /**
+     * 投放时间段
+     */
+    private String scheduleTime;
+    /**
+     * 单日预算
+     */
+    private Integer dayBudget;
+    /**
+     * 分日预算
+     */
+    private String dayBudgetSchedule;
+    /**
+     * 转化目标ID
+     */
+    private Integer convertId;
+    /**
+     * url类型
+     */
+    private Integer urlType;
+    /**
+     * url类型
+     */
+    private Integer webUriType;
+    /**
+     * 投放链接
+     */
+    private String url;
+    /**
+     * 调起链接
+     */
+    private String schemaUri;
+    /**
+     * 应用ID
+     */
+    private Integer appId;
+    /**
+     * 创意展现方式
+     */
+    private Integer showMode;
+    /**
+     * 投放方式
+     */
+    private Integer speed;
+    /**
+     * 预约广告
+     */
+    private Integer siteType;
+    /**
+     * 游戏礼包码
+     */
+    private String giftData;
+    /**
+     * 是否使用落地页前置功能
+     */
+    private Integer videoLandingPage;
+    /**
+     * 智能定向
+     */
+    private Integer autoTarget;
+    /**
+     * 是否开启自动生成视频
+     */
+    private Integer autoCreatePhoto;
+    /**
+     * 地域
+     */
+    private String region;
+    /**
+     * 商圈定向
+     */
+    private String districtIds;
+    /**
+     * 用户类型
+     */
+    private Integer userType;
+    /**
+     * 最大年龄
+     */
+    private Integer ageMin;
+    /**
+     * 最小年龄
+     */
+    private Integer ageMax;
+    /**
+     * 固定年龄段
+     */
+    private String agesRange;
+    /**
+     * 性别
+     */
+    private Integer gender;
+    /**
+     * 操作系统
+     */
+    private Integer platformOs;
+    /**
+     * Android版本
+     */
+    private Integer androidOsv;
+    /**
+     * iOS版本
+     */
+    private Integer iosOsv;
+    /**
+     * 网络环境
+     */
+    private Integer network;
+    /**
+     * 设备品牌
+     */
+    private String deviceBrand;
+    /**
+     * 设备价格
+     */
+    private String devicePrice;
+    /**
+     * 商业兴趣类型
+     */
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    private String businessInterest;
+    /**
+     * 网红粉丝
+     */
+    private String fansStar;
+    /**
+     * 兴趣视频用户
+     */
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    private String appIds;
+    /**
+     * 过滤已转化人群纬度
+     */
+    private Integer filterConvertedLevel;
+    /**
+     * 人群包定向
+     */
+    private String population;
+    /**
+     * 人群包排除
+     */
+    private String excludePopulation;
+    /**
+     * 付费人群包id
+     */
+    private String paidAudience;
+    /**
+     * 开启智能扩量
+     */
+    private Integer isOpen;
+    /**
+     * 不可突破年龄
+     */
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别
+     */
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域
+     */
+    private Integer noAreaBreak;
+    /**
+     * 行为兴趣定向
+     */
+    private String behaviorInterest;
+    /**
+     * 操作类型 1-新增 2-修改
+     */
+    private Integer operationType;
+    /**
+     * 组创建时间
+     */
+    private Date groupCreateTime;
+    /**
+     * 组更新时间
+     */
+    private Date groupUpdateTime;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 状态
+     */
+    private Integer status;
+    /**
+     * 状态详情
+     */
+    private String message;
+    /**
+     * 程序化创意2.0-是否开启智能抽帧
+     */
+    private Integer smartCover;
+    /**
+     * 程序化创意2.0-是否开启素材挖掘
+     */
+    private Integer assetMining;
+    /**
+     * 深度转化目标出价
+     */
+    private Integer deepConversionBid;
 }

+ 77 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaiShouAppMultipleBids.java

@@ -0,0 +1,77 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-05-18
+ */
+@Data
+@TableName("ctop_ai_kuaishou_app_multiple_bids")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_ai_kuaishou_app_multiple_bids对象", description = "多应用分别出价")
+public class KuaiShouAppMultipleBids {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户id
+     */
+    @Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+    private Long accountId;
+    /**
+     * app_id
+     */
+    @Excel(name = "app_id", width = 15)
+    @ApiModelProperty(value = "app_id")
+    private Long appId;
+    /**
+     * 出价
+     */
+    @Excel(name = "出价", width = 15)
+    @ApiModelProperty(value = "出价")
+    private Long cpaBid;
+    /**
+     * 监测链接
+     */
+    @Excel(name = "监测链接", width = 15)
+    @ApiModelProperty(value = "监测链接")
+    private String trackUrl;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaiShouAppMultipleBidsMapper.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+public interface KuaiShouAppMultipleBidsMapper extends BaseMapper<KuaiShouAppMultipleBids> {
+
+    List<JSONObject> getAppInfoList(@Param("accountId") Long accountId, @Param("appIds") JSONArray jsonArray);
+}

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaiShouAppMultipleBidsMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaiShouAppMultipleBidsMapper">
+
+    <select id="getAppInfoList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.*, t2.app_name,t2.app_version,t2.platform
+        FROM
+        (
+        SELECT
+        *
+        FROM
+        ctop_ai_kuaishou_app_multiple_bids
+        WHERE
+        account_id = #{accountId}
+        <if test="appIds != null and appIds != '' ">
+            and app_id in
+            <foreach collection="appIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t1
+        LEFT JOIN (
+        SELECT
+        app_id,
+        app_name,
+        app_version,
+        platform
+        FROM
+        ctop_kuaishou_app_list
+        WHERE
+        account_id =#{accountId}
+        ) t2 ON t1.app_id = t2.app_id
+    </select>
+</mapper>

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouAppMultipleBidsService.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+public interface IKuaiShouAppMultipleBidsService extends IService<KuaiShouAppMultipleBids> {
+
+    List<JSONObject> getAppInfiList(Long accountId, String appIdArray);
+
+    KuaiShouAppMultipleBids getInfoByAccountAndAppId(Long accountId, Long appId);
+}

+ 283 - 113
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.ai.entity.*;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
@@ -26,6 +27,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.*;
 
@@ -58,6 +60,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
     @Autowired
     private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
+    @Autowired
+    private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
 
     /**
@@ -89,30 +93,92 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Integer singleAppid = strategy.getSingleAppid();
         if (null != singleAppid && singleAppid == 0) {
             //多应用
-            String appidString = strategy.getAppIdArray();
-            JSONArray appIdArray = JSONArray.parseArray(appidString);
-            if (null != appIdArray && !appIdArray.isEmpty()) {
+            JSONArray appIdArray = JSONArray.parseArray(strategy.getAppIdArray());
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+            if (strategy.getMultipleBids() == 0) { // 非多应用多出价
+                if (null != appIdArray && !appIdArray.isEmpty()) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
+                        AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
+                        if (null == appInfo) {
+                            log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                            continue;
+                        }
+                        if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
+                            strategy.setClickTrackUrl(appInfo.getTrackUrl());
+                            strategy.setImpressionUrl(appInfo.getTrackUrl());
+                        }
+                        replaceString = appInfo.getAppVersion() + "-" + replaceString;
+                        //1:查询素材
+                        List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
+                        if (null == allVideos || allVideos.isEmpty()) {
+                            log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
+                            continue;
+                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+                        for (KuaiShouVideoGet videoItem : allVideos) {
+                            KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
+                            if (null != overrunInfo) {
+                                log.info("该账户创意创建已超限=>accountId:{}", accountId);
+                                return 0L;
+                            }
+                            // 获取视频封面数据
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            if ((null == cutFrameList || cutFrameList.isEmpty())) {
+                                log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
+                                continue;
+                            }
+                            //开始创建组+创意
+                            String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appInfo.getAppId());
+                            JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                            BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                            unitLevelOperationRecord.setGroupName(unitName);
+                            unitLevelOperationRecord.setCreateTime(new Date());
+                            unitLevelOperationRecord.setStatus(unitCode);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                            unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
+                            unitLevelOperationRecord.setMessage(unitMessage);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                            if (unitCode != 0) {
+                                log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+                            unitLevelOperationRecord.setUnitId(unitId);
+                            unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                            videoCnt--;
+                            JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
+                            createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, appInfo.getAppVersion());
+                            if (videoCnt <= 0) {
+                                return videoCnt;
+                            }
+                        }
+                    }
+                }
+            } else if (strategy.getMultipleBids() == 1) { //  多应用多出价
+                List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (Check.isNull(allVideos)) {
+                    return videoCnt;
+                }
                 for (int i = 0; i < appIdArray.size(); i++) {
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-                    AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
-                    if (null == appInfo) {
-                        log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                    Long appId = appIdArray.getLong(i);
+                    if (Check.isNull(appId)) {
                         continue;
                     }
-
-                    if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
-                        strategy.setClickTrackUrl(appInfo.getTrackUrl());
-                        strategy.setImpressionUrl(appInfo.getTrackUrl());
-                    }
-                    replaceString = appInfo.getAppVersion() + "-" + replaceString;
-                    //1:查询素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
-                    if (null == allVideos || allVideos.isEmpty()) {
-                        log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
+                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                    if (Check.isNull(multipleBids)) {
                         continue;
                     }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
-                    int unitCnt = 0;
+                    if (!Check.isNull(multipleBids.getTrackUrl())) {
+                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
+                    }
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                     for (KuaiShouVideoGet videoItem : allVideos) {
                         KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                         if (null != overrunInfo) {
@@ -125,15 +191,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                             continue;
                         }
-                        unitCnt++;
                         //开始创建组+创意
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, videoItem.getPhotoName(), "unit", newCampaignId);
-                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
+                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
+                        unitParams.remove("cpa_bid");
+                        unitParams.put("cpa_bid", multipleBids.getCpaBid());
+                        strategy.setCpaBid(multipleBids.getCpaBid() + "");
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                         BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                        unitLevelOperationRecord.setCampaignId(newCampaignId);
+                        unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                        unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
                         unitLevelOperationRecord.setGroupName(unitName);
                         unitLevelOperationRecord.setCreateTime(new Date());
                         unitLevelOperationRecord.setStatus(unitCode);
@@ -150,13 +221,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         videoCnt--;
                         JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, appInfo.getAppVersion());
+                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
                         if (videoCnt <= 0) {
                             return videoCnt;
                         }
                     }
                 }
+
             }
+
         } else {
             //单一应用
             String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
@@ -165,13 +238,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                 return videoCnt;
             }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
+            Long appId = null;
+            if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
+                if (Check.isNull(appId)) {
+                    return videoCnt;
+                }
+            }
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
             if (null == newCampaignId) {
                 return videoCnt;
             }
-
             //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
-            int unitCnt = 0;
             for (KuaiShouVideoGet videoItem : newVideos) {
                 KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
                 if (null != overrunInfo) {
@@ -183,14 +261,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                     continue;
                 }
-                unitCnt++;
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, videoItem.getPhotoName(), "unit", newCampaignId);
-
-                Long appId = null;
-                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
-                    appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
-                }
-
+                String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -198,12 +269,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                 BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 unitLevelOperationRecord.setGroupName(unitName);
-                if (!Check.isNull(strategy.getCpaBid())) {
-                    unitLevelOperationRecord.setCpaBid(Integer.valueOf(strategy.getCpaBid() + ""));
-                }
-                if (!Check.isNull(strategy.getBid())) {
-                    unitLevelOperationRecord.setBid(Integer.valueOf(strategy.getBid() + ""));
-                }
+                unitLevelOperationRecord.setCampaignId(newCampaignId);
+                unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
+                unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setStatus(unitCode);
                 unitLevelOperationRecord.setMessage(unitMessage);
@@ -249,59 +317,114 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         //2:判定账户是否单一应用
         Long timeStart = null;
         Long timeEnd = null;
-
         Integer singleAppid = strategy.getSingleAppid();
         if (null != singleAppid && singleAppid == 0) {
             timeStart = -7 * 60 * 24L;
             timeEnd = -5L;
         } else {
-            timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-            timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
-        }
+            if (strategy.getMultipleBids() == 0) {
+                timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+                timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+            } else if (strategy.getMultipleBids() == 1) {
+                timeStart = -1 * 60 * 24L;
+                timeEnd = -5L;
+            }
 
+        }
         Long now = System.currentTimeMillis();
         String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
         String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
-
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String key = token.getAccountId() + "_ProgramCreative" + "_" + nowDate;
-
-
+        JSONArray appIdArray = JSON.parseArray(strategy.getAppIdArray());
         if (null != singleAppid && singleAppid == 0) {
-            //多应用
-            String appidString = strategy.getAppIdArray();
-            JSONArray appIdArray = JSON.parseArray(appidString);
-            if (null != appIdArray && !appIdArray.isEmpty()) {
+            String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
+            if (strategy.getMultipleBids() == 0) { //  非多应用多出价
+                //多应用
+                if (null != appIdArray && !appIdArray.isEmpty()) {
+                    for (int i = 0; i < appIdArray.size(); i++) {
+                        AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
+                        if (null == appInfo) {
+                            log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                            continue;
+                        }
+                        //判定是否通用监测链接
+                        if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
+                            strategy.setClickTrackUrl(appInfo.getTrackUrl());
+                            strategy.setImpressionUrl(appInfo.getTrackUrl());
+                        }
+                        replaceString = appInfo.getAppVersion() + "-" + replaceString;
+                        //1:查询可用素材
+                        List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
+                        if (null == allVideos || allVideos.isEmpty()) {
+                            return;
+                        }
+                        //判定创意创建是否超限
+                        KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
+                        if (null != overrunInfo) {
+                            log.info("该账户创意创建已超限=>accountId:{}", accountId);
+                            return;
+                        }
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+
+                        //创建组+创意
+                        List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
+                        for (int j = 1; j < splitVideos.size() + 1; j++) {
+                            Object redisObj = redisUtil.get(key);
+                            if (!Check.isNull(redisObj)) {
+                                Integer value = (Integer) redisObj;
+                                if (value == 1) {
+                                    log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                                    return;
+                                }
+                            }
+                            //创建组
+                            String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appInfo.getAppId());
+                            JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                            BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                            unitLevelOperationRecord.setGroupName(unitName);
+                            unitLevelOperationRecord.setCreateTime(new Date());
+                            unitLevelOperationRecord.setStatus(unitCode);
+                            unitLevelOperationRecord.setMessage(unitMessage);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                            if (unitCode != 0) {
+                                log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+                            unitLevelOperationRecord.setUnitId(unitId);
+                            unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                            JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, appInfo.getAppVersion());
+                            createProgramCreative(token, creativeParams, strategy);
+                        }
+                    }
+                }
+            } else if (strategy.getMultipleBids() == 1) { // 多应用多出价
+                List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
+                if (Check.isNull(allVideos)) {
+                    return;
+                }
                 for (int i = 0; i < appIdArray.size(); i++) {
-                    AiKuaiShouAppInfo appInfo = appInfoService.getByParams(strategy.getAccountId(), appIdArray.getLong(i));
-                    if (null == appInfo) {
-                        log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
+                    Long appId = appIdArray.getLong(i);
+                    if (Check.isNull(appId)) {
                         continue;
                     }
-                    //判定是否通用监测链接
-                    if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
-                        strategy.setClickTrackUrl(appInfo.getTrackUrl());
-                        strategy.setImpressionUrl(appInfo.getTrackUrl());
-                    }
-                    String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-                    replaceString = appInfo.getAppVersion() + "-" + replaceString;
-                    //1:查询可用素材
-                    List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, appInfo, createType, videoCnt);
-                    if (null == allVideos || allVideos.isEmpty()) {
-                        return;
+                    KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                    if (Check.isNull(multipleBids)) {
+                        continue;
                     }
-                    //判定创意创建是否超限
-                    KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
-                    if (null != overrunInfo) {
-                        log.info("该账户创意创建已超限=>accountId:{}", accountId);
-                        return;
+                    if (!Check.isNull(multipleBids.getTrackUrl())) {
+                        strategy.setClickTrackUrl(multipleBids.getTrackUrl());
                     }
-                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo, strategyUuid);
-
-                    //创建组+创意
+                    Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
                     List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
                     for (int j = 1; j < splitVideos.size() + 1; j++) {
-
                         Object redisObj = redisUtil.get(key);
                         if (!Check.isNull(redisObj)) {
                             Integer value = (Integer) redisObj;
@@ -310,10 +433,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                                 return;
                             }
                         }
-
                         //创建组
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, null, "unit", newCampaignId);
-                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
+                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
+                        unitParams.put("cpa_bid", multipleBids.getCpaBid());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
                         String unitMessage = (String) unitCreateResult.get("message");
@@ -333,7 +456,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         Long unitId = (Long) unitCreateResult.get("unitId");
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, appInfo.getAppVersion());
+                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
                         createProgramCreative(token, creativeParams, strategy);
                     }
                 }
@@ -346,7 +469,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 return;
             }
 
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, null, strategyUuid);
+            Long appId = null;
+            String appIdString = strategy.getAppIdArray();
+            if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
+                    appId = JSON.parseArray(appIdString).getLong(0);
+                    if (Check.isNull(appId)) {
+                        return;
+                    }
+                }
+            }
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
             if (null == newCampaignId) {
                 return;
             }
@@ -362,14 +495,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     }
                 }
                 //创建组
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, null, "unit", newCampaignId);
-                String appIdString = strategy.getAppIdArray();
-                Long appId = null;
-                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
-                    if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
-                        appId = JSON.parseArray(appIdString).getLong(0);
-                    }
-                }
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -548,8 +674,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getActionbarClickUrl())) {
             programJson.put("actionbar_click_url", strategy.getActionbarClickUrl());
         }
-        JSONArray captions = new JSONArray();
-        captions.add(strategy.getDescription());
+
+        JSONArray captions = getCaptions(strategy.getDescription());
         programJson.put("captions", captions);
         if (!Check.isNull(strategy.getCreativeCategory())) {
             programJson.put("creative_category", strategy.getCreativeCategory());
@@ -558,6 +684,22 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return programJson;
     }
 
+    private JSONArray getCaptions(String description) {
+        JSONArray jsonArray = JSONArray.parseArray(description);
+        if (jsonArray.size() <= 3) {
+            return jsonArray;
+        }
+        Collections.shuffle(jsonArray);
+        JSONArray captions = new JSONArray();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            captions.add(jsonArray.getString(i));
+            if (captions.size() == 3) {
+                break;
+            }
+        }
+        return captions;
+    }
+
     private List<KuaiShouVideoGet> getNewVideoListByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo) {
         if (null == appInfo) {
             if (Check.isNull(strategy.getMaterialKeyword())) { // 素材名称为空 不需要标注特殊素材
@@ -652,7 +794,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
 
-    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
+    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, Long appId, String uuid) {
         Long campaignId = null;
         if ("ALL_CAMPAIGN".equals(checkType)) {
             campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
@@ -667,7 +809,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
-        String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, null, "plan", null);
+        String campaignName = getName(strategy.getCampaignName(), strategy, createType, null, "plan", null, appId);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("type", strategy.getCampaignType());
         if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
@@ -716,8 +858,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (null != strategy.getBid() && strategy.getBid() != 0) {
             unitParams.put("bid", strategy.getBid());
         }
-        if (null != strategy.getCpaBid() && strategy.getCpaBid() != 0) {
-            unitParams.put("cpa_bid", strategy.getCpaBid());
+        if (!Check.isNull(strategy.getCpaBid()) && !"0".equals((strategy.getCpaBid()))) {
+            Long cpdBid = getBidByString(strategy.getCpaBid());
+            unitParams.put("cpa_bid", cpdBid);
         }
         //优先低成本
         if (null != strategy.getSmartBid() && strategy.getSmartBid() != 0) {
@@ -897,7 +1040,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
             }
         }
-
         JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
         if (!Check.isNull(appInterest)) {
             targetJsonObject.put("app_interest", appInterest);
@@ -945,6 +1087,30 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return unitParams;
     }
 
+    private Long getBidByString(String cpaBid) {
+        if (Check.isNull(cpaBid)) {
+            return null;
+        }
+        String bidString = null;
+        if (cpaBid.contains("/")) { // 阶梯出价
+            String[] split = cpaBid.split("/");
+            int random = new Random().nextInt(split.length);
+            bidString = split[random];
+
+        } else if (cpaBid.contains("-")) { // 随机出价
+            String[] split = cpaBid.split("-");
+            Double min = Double.valueOf(split[0]) / 1000;
+            Double max = Double.valueOf(split[1]) / 1000;
+            Double randomNumber = new BigDecimal(min + Math.random() * (max - min)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
+            bidString = String.valueOf(new Double(randomNumber * 1000).longValue());
+
+        } else {
+            bidString = cpaBid;
+        }
+
+        return Long.valueOf(bidString);
+    }
+
     private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
         JSONArray result = new JSONArray();
         if (null == scenceArray || scenceArray.isEmpty()) {
@@ -1141,7 +1307,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         creativeParams.put("photo_id", videoItem.getPhotoId());
         creativeParams.put("creative_material_type", videoItem.getMaterialType());
         creativeParams.put("action_bar_text", strategy.getActionBarText());
-        creativeParams.put("description", strategy.getDescription());
+
+        JSONArray descArr = JSONArray.parseArray(strategy.getDescription());
+        int index = new Random().nextInt(descArr.size());
+        String description = descArr.getString(index);
+        creativeParams.put("description", description);
         // 封面广告语标题
         if (!Check.isNull(strategy.getStickerTitle())) {
             creativeParams.put("sticker_title", strategy.getStickerTitle());
@@ -1229,15 +1399,24 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      */
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private IKuaiShouAppListService appListService;
 
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String materialName, String type, Long campaignId) {
-        if (wildcard.contains("{{应用包名}}")) {
-            String appName = "";
-            if (null != appInfo) {
-                appName = appInfo.getAppName();
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, String materialName, String type, Long campaignId, Long appId) {
+
+
+        if (wildcard.contains("{{应用名称}}") || wildcard.contains("{{应用标记}}")) {
+            KuaiShouAppList getAppInfo = appListService.getAppInfo(strategy.getAccountId(), appId);
+            if (!Check.isNull(getAppInfo)) {
+                wildcard = wildcard.replace("{{应用名称}}", getAppInfo.getAppName());
+                wildcard = wildcard.replace("{{应用标记}}", getAppInfo.getAppVersion());
+            } else {
+                wildcard = wildcard.replace("{{应用名称}}", "");
+                wildcard = wildcard.replace("{{应用标记}}", "");
             }
-            wildcard = wildcard.replace("{{应用包名}}", appName);
         }
+
+
         if (wildcard.contains("{{创意制作方式}}")) {
             if (strategy.getUnitType() == 4) {
                 wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
@@ -1272,15 +1451,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             wildcard = wildcard.replace("{{日期}}", nowDate);
         }
 
+
         String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
-        if (null != appInfo) {
-            targetName = appInfo.getAppVersion() + "-" + targetName;
-        }
         wildcard = wildcard.replace("{{自定义}}", targetName);
 
+
         if (!Check.isNull(campaignId)) {
             Integer count = null;
-            if (null != strategy.getSingleAppid() && strategy.getSingleAppid() == 0) {
+            if (null != strategy.getSingleAppid() && strategy.getSingleAppid() == 0 && strategy.getMultipleBids() == 0) {
                 String redisKey = strategy.getAccountId() + "_" + campaignId;
                 Object redisValue = redisUtil.get(redisKey);
                 if (Check.isNull(redisValue)) {
@@ -1329,12 +1507,4 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
 
-    public static void main(String[] args) {
-        Date date = new Date();
-        String s = DateUtils.formatDate(date, "yy-MMdd");
-        String timestamp = DateUtils.formatDate(new Date(), "HHmmss");
-        System.err.println(timestamp);
-    }
-
-
 }

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouAppMultipleBidsServiceImpl.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaiShouAppMultipleBidsMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 多应用分别出价
+ *
+ * @author jeecg-boot
+ * 2021-05-18
+ * @version V1.0
+ */
+@Service
+public class KuaiShouAppMultipleBidsServiceImpl extends ServiceImpl<KuaiShouAppMultipleBidsMapper, KuaiShouAppMultipleBids> implements IKuaiShouAppMultipleBidsService {
+    @Autowired
+    private KuaiShouAppMultipleBidsMapper appMultipleBidsMapper;
+
+    @Override
+    public List<JSONObject> getAppInfiList(Long accountId, String appIdArray) {
+        if (!Check.isNull(appIdArray)) {
+            JSONArray jsonArray = JSONArray.parseArray(appIdArray);
+            List<JSONObject> appInfoList = appMultipleBidsMapper.getAppInfoList(accountId, jsonArray);
+            return appInfoList;
+
+        }
+        return null;
+    }
+
+    @Override
+    public KuaiShouAppMultipleBids getInfoByAccountAndAppId(Long accountId, Long appId) {
+        QueryWrapper<KuaiShouAppMultipleBids> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("app_id", appId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouAppListService extends IService<KuaiShouAppList> {
 
+    KuaiShouAppList getAppInfo(Long accountId, Long appId);
 }

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

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
@@ -15,4 +16,13 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaiShouAppListServiceImpl extends ServiceImpl<KuaiShouAppListMapper, KuaiShouAppList> implements IKuaiShouAppListService {
 
+    @Override
+    public KuaiShouAppList getAppInfo(Long accountId, Long appId) {
+        QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("app_id", appId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
 }