Forráskód Böngészése

Merge branch 'V1.1.5'

yumeng 4 éve
szülő
commit
996e014d6c

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

@@ -8,11 +8,11 @@ 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.batch.service.IKuaishouVideoRelateCreativesService;
 import com.alibaba.fastjson.JSONArray;
 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.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
@@ -36,9 +36,14 @@ import java.util.*;
 @RequestMapping("/ctop/aiKuaishouAdvertiserStrategy")
 public class AiKuaishouAdvertiserStrategyController {
     @Autowired
+    private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
+    @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
     @Autowired
+    private IUserAllocationService allocationService;
+    @Autowired
     private ISysRoleService sysRoleService;
+
     /**
      * 分页列表查询
      *
@@ -48,7 +53,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param req
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-分页列表查询", notes = "快手账户策略设置信息表-分页列表查询")
     @GetMapping(value = "/list")
     public Result<IPage<AiKuaishouAdvertiserStrategy>> queryPageList(AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@@ -82,16 +86,12 @@ public class AiKuaishouAdvertiserStrategyController {
         return result;
     }
 
-    @Autowired
-    private IUserAllocationService allocationService;
-
     /**
      * 添加
      *
      * @param aiKuaishouAdvertiserStrategy
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-添加", notes = "快手账户策略设置信息表-添加")
     @PostMapping(value = "/add")
     public Result<AiKuaishouAdvertiserStrategy> add(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -112,6 +112,13 @@ public class AiKuaishouAdvertiserStrategyController {
                 aiKuaishouAdvertiserStrategy.setAppId(appId);
             }
             aiKuaishouAdvertiserStrategyService.save(aiKuaishouAdvertiserStrategy);
+            Thread thread = new Thread(){
+                @Override
+                public void run() {
+                    kuaishouVideoRelateCreativesService.videoRelateCreatives(aiKuaishouAdvertiserStrategy.getAccountId());
+                }
+            };
+            thread.start();
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -119,7 +126,6 @@ public class AiKuaishouAdvertiserStrategyController {
         }
         return result;
     }
-
     /**
      * 编辑
      *
@@ -205,7 +211,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-通过id删除", notes = "快手账户策略设置信息表-通过id删除")
     @DeleteMapping(value = "/delete")
     public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
         try {
@@ -223,7 +228,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param ids
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-批量删除", notes = "快手账户策略设置信息表-批量删除")
     @DeleteMapping(value = "/deleteBatch")
     public Result<AiKuaishouAdvertiserStrategy> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -242,7 +246,6 @@ public class AiKuaishouAdvertiserStrategyController {
      * @param id
      * @return
      */
-    @ApiOperation(value = "快手账户策略设置信息表-通过id查询", notes = "快手账户策略设置信息表-通过id查询")
     @GetMapping(value = "/queryById")
     public Result<AiKuaishouAdvertiserStrategy> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
@@ -255,4 +258,9 @@ public class AiKuaishouAdvertiserStrategyController {
         }
         return result;
     }
+
+    @GetMapping(value = "testCreate")
+    public Map<String,Object> testCreate(Long accountId){
+        return aiKuaishouAdvertiserStrategyService.testCreate(accountId);
+    }
 }

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

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.ai.service;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 /**
  * @Description: 快手账户策略设置信息表
  * @Author: jeecg-boot
@@ -13,4 +15,5 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
 
     AiKuaishouAdvertiserStrategy getByAccountId(Long accountId);
 
+    Map<String, Object> testCreate(Long accountId);
 }

+ 49 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java

@@ -1,12 +1,22 @@
 package cn.com.ctop.kuaishou.modules.ai.service.impl;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.HttpUtils;
+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.mapper.AiKuaishouAdvertiserStrategyMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+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.HashMap;
+import java.util.Map;
+
 /**
  * 快手账户策略设置信息表
  * @author jeecg-boot
@@ -15,7 +25,10 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuaishouAdvertiserStrategyMapper, AiKuaishouAdvertiserStrategy> implements IAiKuaishouAdvertiserStrategyService {
-
+    public static final String TEST_CREATIVE_URL= "http://139.186.27.96:31012/ai_historical_missing_material";
+    public static final String TEST_PROGRAM_CREATIVE_URL= "http://139.186.27.96:31012/ai_programme_new_material";
+    @Autowired
+    private IUserAllocationService userAllocationService;
     @Override
     public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
         QueryWrapper<AiKuaishouAdvertiserStrategy>queryWrapper =new QueryWrapper<>();
@@ -24,4 +37,39 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         queryWrapper.last("limit 1");
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public Map<String, Object> testCreate(Long accountId) {
+        Map<String,Object>result = new HashMap<>();
+        if(null == accountId||accountId == 0){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy = this.getByAccountId(accountId);
+        if(null == aiKuaishouAdvertiserStrategy||null == aiKuaishouAdvertiserStrategy.getStatus()||aiKuaishouAdvertiserStrategy.getStatus()!=1){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        UserAllocation allocation = userAllocationService.getByAccountId(accountId);
+        if(null == allocation){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        JSONObject params = new JSONObject();
+        params.put("account_id",accountId);
+        params.put("test_video_cnt",1);
+        String request = null;
+        //程序化
+        if(aiKuaishouAdvertiserStrategy.getOpenProgramCreate() == 1){
+            request = HttpUtils.httpPostRequest(TEST_PROGRAM_CREATIVE_URL,params,new HashMap<>());
+        }else{
+            request = HttpUtils.httpPostRequest(TEST_CREATIVE_URL, params, new HashMap<>());
+        }
+        JSONObject requestObject = JSONObject.parseObject(request);
+        String message = requestObject.getString("message");
+        Integer code = requestObject.getInteger("code");
+        result.put("code",code);
+        result.put("message",message);
+        return result;
+    }
 }

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

@@ -68,15 +68,12 @@ public class KuaishouAccountSpeedExploreLogServiceImpl extends ServiceImpl<Kuais
 // TODO       kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,startDate,endDate);
         //3:根据转化目标查询相应的符合条件的广告组数据
         //优化目标 2 行为数 180 激活数 53 表单数 190 付费 191 首日ROI
-        Integer convertType = kuaishouAccountSpeedExploreLog.getConvertType();
         //查询相关符合条件的广告组数据
         List<SpeedExploreGroupVO> speedExploreGroupVos = this.getSpeedExploreGroupVOSByParams(DateUtils.formatDate(endDate),kuaishouAccountSpeedExploreLog.getAccountId(),kuaishouAccountSpeedExploreLog.getConvertType(),kuaishouAccountSpeedExploreLog.getConvertCount(),kuaishouAccountSpeedExploreLog.getGroupCount());
         if(null==speedExploreGroupVos||speedExploreGroupVos.isEmpty()){
             speedExploreGroupVos.forEach(speedExploreGroupVO -> {
                 //触发加速探索逻辑
                 kuaishouGroupExploreService.unitOpenSpeedExplore(speedExploreGroupVO.getAccountId(),speedExploreGroupVO.getUnitId(),kuaishouAccountSpeedExploreLog.getGroupAccount(),kuaishouAccountSpeedExploreLog.getId());
-                //缺广告组加速探索记录数据表
-
             });
         }
 

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

@@ -29,4 +29,6 @@ public interface IKuaishouVideoRelateCreativesService extends IService<KuaishouV
     List<JSONObject> getVideoZeroListByMap(Map<String, Object> requestMap);
 
     List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap);
+
+    void videoRelateCreatives(Long accountId);
 }

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

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouVideoRelateCreatives;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouVideoRelateCreativesMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -21,11 +22,9 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.*;
 
 /**
  * 频库-视频关联创意数查询
@@ -175,4 +174,33 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
     public List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap) {
         return kuaishouVideoRelateCreativesMapper.getHistoryTopVideoList(requestMap);
     }
+
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
+    @Override
+    public void videoRelateCreatives(Long accountId) {
+        List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(accountId);
+        if (!Check.isNull(KuaiShouVideoGets)) {
+            JSONArray dateList = new JSONArray();
+            JSONArray photoIds = new JSONArray();
+            Map<String, KuaiShouVideoGet> statdateMap = new HashMap<>();
+            int count = 0;
+            for (KuaiShouVideoGet video : KuaiShouVideoGets) {
+                count++;
+                if (count < 20) {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(), video);
+                } else {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(),video);
+                    dateList.add(photoIds);
+                    photoIds = new JSONArray();
+                    count = 0;
+                }
+            }
+            dateList.add(photoIds);
+            this.videoRelateCreatives(accountId, dateList, statdateMap);
+        }
+    }
 }

+ 6 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouAudienceAccountDailyMapper.java

@@ -20,9 +20,13 @@ public interface EtlKuaishouAudienceAccountDailyMapper extends BaseMapper<EtlKua
 
     List<JSONObject> queryAudienceTypeInfo(@Param("value") String value, @Param("type") String type, @Param("accountId") Long accountId, @Param("audienceType") String audienceType, @Param("parType") String parType);
 
-    List<JSONObject> queryEveryDayInfo(@Param("value") String value, @Param("type") String type, @Param("accountId") Long accountId, @Param("audienceType") String audienceType, @Param("parType") String parType);
+    List<JSONObject> queryEveryDayInfo(@Param("value") String value, @Param("type") String type, @Param("accountId") Long accountId, @Param("audienceType") String audienceType, @Param("parType") String parType,@Param("day") String day);
 
     List<JSONObject> getSceneInfo(@Param("value") String value, @Param("accountId") Long accountId, @Param("parType") String parType);
 
-    List<JSONObject> getSceneEveryDayInfo(@Param("value") String value, @Param("accountId") Long accountId, @Param("parType") String parType);
+    List<JSONObject> getSceneEveryDayInfo(@Param("value") String value, @Param("accountId") Long accountId, @Param("parType") String parType,@Param("day") String day);
+
+    List<String> getTypeList(@Param("type") String type,@Param("audienceType") String audienceType);
+
+    List<String> getSceneTypeList();
 }

+ 22 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAudienceAccountDailyMapper.xml

@@ -92,12 +92,11 @@
         </if>
         ${type} as 'type'
         FROM ctop_etl_kuaishou_audience_account_daily
-        where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
-        AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
+        where stat_date = #{day}
         AND audience_type = #{audienceType}
         AND account_id = #{accountId}
         group by stat_date,${type}
-        order by stat_date
+        order by stat_date,${type}
     </select>
 
     <select id="getSceneEveryDayInfo" resultType="com.alibaba.fastjson.JSONObject">
@@ -121,16 +120,27 @@
                 IFNULL(ROUND(charge/ event_next_day_stay,2),0) as 'value',
             </if>
         </if>
-        CASE
-        WHEN ad_scene is null then '全部'
-        WHEN ad_scene = '' THEN '全部'
-        ELSE ad_scene END as 'type'
+        IFNULL(ad_scene,'全部') as 'type'
         FROM ctop_kuaishou_report_daily_account
-        where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
-        AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
+        where stat_date = #{day}
         AND account_id = #{accountId}
         group by stat_date,ad_scene
-        order by stat_date
+        order by stat_date,ad_scene
+    </select>
+
+    <select id="getSceneTypeList" resultType="java.lang.String">
+        SELECT DISTINCT IFNULL(ad_scene, '全部')
+        FROM ctop_kuaishou_report_daily_account
+        WHERE LENGTH(trim(ad_scene))>0
+        ORDER BY ad_scene
+    </select>
+
+    <select id="getTypeList" resultType="java.lang.String">
+        SELECT ${type} as 'type'
+        FROM ctop_etl_kuaishou_audience_account_daily
+        where audience_type = #{audienceType}
+        group by ${type}
+        order by ${type}
     </select>
 
     <select id="getSceneInfo" resultType="com.alibaba.fastjson.JSONObject">
@@ -153,14 +163,12 @@
                 IFNULL(ROUND(SUM(charge)/SUM(event_next_day_stay),2),0) as 'value',
             </if>
         </if>
-        CASE
-        WHEN ad_scene is null then '全部'
-        WHEN ad_scene = '' THEN '全部'
-        ELSE ad_scene END as 'type'
+        IFNULL(ad_scene,'全部')as 'type'
         FROM ctop_kuaishou_report_daily_account
         where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
         AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
         AND account_id = #{accountId}
         group by ad_scene
+        order by ad_scene
     </select>
 </mapper>

+ 87 - 12
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAudienceAccountDailyServiceImpl.java

@@ -9,9 +9,14 @@ import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAudienceAccountDa
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -52,13 +57,24 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
         String audienceType = "gender";
         String type = "gender";
         List<JSONObject> list = null;
+        List<String> typeList = accountDailyMapper.getTypeList(type, audienceType);
         if ("pie".equals(dataType)) {
             list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
+            if (Check.isNull(list)) {
+                return Result.ok("未查询到数据");
+            }
+            completeData(list, typeList);
         } else if ("line".equals(dataType)) {
-            list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
-        }
-        if (Check.isNull(list)) {
-            return Result.ok("未查询到数据");
+            String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
+            String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
+            List<String> dayList = DateUtils.getDays(startTime, endTime);
+            JSONObject data = new JSONObject();
+            for (String day : dayList) {
+                list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType, day);
+                completeData(list, typeList);
+                data.put(day, list);
+            }
+            return Result.ok(data);
         }
         return Result.ok(list);
     }
@@ -79,13 +95,24 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
         String audienceType = "ageSegment";
         String type = "age_segment";
         List<JSONObject> list = null;
+        List<String> typeList = accountDailyMapper.getTypeList(type, audienceType);
         if ("pie".equals(dataType)) {
             list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
+            if (Check.isNull(list)) {
+                return Result.ok("未查询到数据");
+            }
+            completeData(list, typeList);
         } else if ("line".equals(dataType)) {
-            list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
-        }
-        if (Check.isNull(list)) {
-            return Result.ok("未查询到数据");
+            String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
+            String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
+            List<String> dayList = DateUtils.getDays(startTime, endTime);
+            JSONObject data = new JSONObject();
+            for (String day : dayList) {
+                list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType, day);
+                completeData(list, typeList);
+                data.put(day, list);
+            }
+            return Result.ok(data);
         }
         return Result.ok(list);
     }
@@ -104,15 +131,63 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
             parType = "alone";
         }
         List<JSONObject> list = null;
+        List<String> typeList = accountDailyMapper.getSceneTypeList();
+        typeList.remove("全部");
         if ("pie".equals(dataType)) {
             list = accountDailyMapper.getSceneInfo(value, accountId, parType);
+            if (Check.isNull(list)) {
+                return Result.ok("未查询到数据");
+            }
+            completeData(list, typeList);
         } else if ("line".equals(dataType)) {
-            list = accountDailyMapper.getSceneEveryDayInfo(value, accountId, parType);
-        }
-        if (Check.isNull(list)) {
-            return Result.ok("未查询到数据");
+            String startTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 8);
+            String endTime = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 2);
+            List<String> dayList = DateUtils.getDays(startTime, endTime);
+            JSONObject data = new JSONObject();
+            for (String day : dayList) {
+                list = accountDailyMapper.getSceneEveryDayInfo(value, accountId, parType, day);
+                completeData(list, typeList);
+                data.put(day, list);
+            }
+            return Result.ok(data);
         }
         return Result.ok(list);
     }
 
+    /**
+     * 补全数据
+     */
+    private void completeData(List<JSONObject> list, List<String> typeList) {
+        List<String> newDayList = new ArrayList<>();
+        for (JSONObject data : list) {
+            if (!newDayList.contains(data.getString("type"))) {
+                newDayList.add(data.getString("type"));
+            }
+        }
+        for (String type : typeList) {
+            if (!newDayList.contains(type)) {
+                JSONObject obj = new JSONObject();
+                obj.put("type", type);
+                obj.put("value", 0);
+                list.add(obj);
+            }
+        }
+        userRechargeListSort(list);
+    }
+
+    private static void userRechargeListSort(List<JSONObject> list) {
+        Collections.sort(list, new Comparator<JSONObject>() {
+            @Override
+            public int compare(JSONObject o1, JSONObject o2) {
+                try {
+                    String st1 = o1.getString("type");
+                    String st2 = o2.getString("type");
+                    return st1.compareTo(st2);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                return 0;
+            }
+        });
+    }
 }