Parcourir la source

跨账户调整

yumeng il y a 4 ans
Parent
commit
1cccc274ae

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProjectMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 项目
@@ -12,4 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ProjectMapper extends BaseMapper<Project> {
 
+    String getNameByAccountId(@Param("accountId") Long accountId);
 }

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -2,4 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.ProjectMapper">
 
+    <select id="getNameByAccountId" resultType="java.lang.String">
+     select project_name  from ctop_project
+     where id = (
+     select project_id from ctop_user_allocation
+     where account_id = #{accountId}
+     )
+    </select>
+
 </mapper>

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IProjectService.java

@@ -14,5 +14,7 @@ import java.util.List;
  */
 public interface IProjectService extends IService<Project> {
 
-    List<Project> listByMediaType(int projectType,int checkLink);
+    List<Project> listByMediaType(int projectType, int checkLink);
+
+    String getNameByAccountId(Long accountId);
 }

+ 12 - 4
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProjectServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.service.IProjectService;
 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;
@@ -18,13 +19,20 @@ import java.util.List;
  */
 @Service
 public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
+    @Autowired
+    private ProjectMapper projectMapper;
 
     @Override
-    public List<Project> listByMediaType(int projectType,int checkLink) {
-        QueryWrapper<Project>queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id",projectType);
-        queryWrapper.eq("check_link",checkLink);
+    public List<Project> listByMediaType(int projectType, int checkLink) {
+        QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_id", projectType);
+        queryWrapper.eq("check_link", checkLink);
         queryWrapper.orderByDesc("id");
         return this.list(queryWrapper);
     }
+
+    @Override
+    public String getNameByAccountId(Long accountId) {
+        return projectMapper.getNameByAccountId(accountId);
+    }
 }

+ 54 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/Enums/CampaignTypeEnum.java

@@ -0,0 +1,54 @@
+package cn.com.ctop.kuaishou.modules.batch.Enums;
+
+public enum CampaignTypeEnum {
+
+    TYPE2(2, "提升应用安装"),
+    TYPE3(3, "获取电商下单"),
+    TYPE4(4, "推广品牌活动"),
+    TYPE5(5, "收集销售线索"),
+    TYPE7(7, "提高应用活跃");
+
+
+    private Integer type;
+    private String value;
+
+    CampaignTypeEnum(Integer type, String value) {
+        this.type = type;
+        this.value = value;
+    }
+
+    public static String getNameByType(Integer type) {
+        for (CampaignTypeEnum campaignType : CampaignTypeEnum.values()) {
+
+            if (campaignType.getType() == type) {
+                return campaignType.getValue();
+            }
+        }
+        return "";
+    }
+
+
+    public Integer getType() {
+        return type;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public String toString() {
+        return "CampaignTypeEnum{" +
+                "type=" + type +
+                ", value='" + value + '\'' +
+                '}';
+    }
+}

+ 276 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java

@@ -0,0 +1,276 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.Enums.CampaignTypeEnum;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Slf4j
+@Api(tags = "快手-批量工具")
+@RestController
+@RequestMapping("/kuaishou/crossAccount")
+public class CrossAccountBatchController {
+    @Autowired
+    private IProjectService projectService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+
+
+    /**
+     * 批量创建广告计划
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchCampaignCreate")
+    public Result<JSONArray> campaignCreate(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            System.err.println(requestJson);
+            JSONArray accountArr = requestJson.getJSONArray("accountArr");
+            if (Check.isNull(accountArr)) {
+                throw new Exception("请选择需要创建的账户");
+            }
+            JSONArray returnArr = new JSONArray();
+
+            for (int i = 0; i < accountArr.size(); i++) {
+                Long accountId = accountArr.getLong(i);
+                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+                if (Check.isNull(oauthToken)) {
+                    throw new Exception("未获取到账户信息");
+                }
+
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("accountId", accountId);
+                JSONObject campaignJson = new JSONObject();
+                campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
+                Integer nameType = requestJson.getInteger("nameType");
+                Integer type = requestJson.getInteger("type");
+                campaignJson.put("type", type);
+                if (!Check.isNull(requestJson.getLong("dayBudget"))) {
+                    campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
+                }
+
+                if (!Check.isNull(requestJson.getJSONArray("dayBudgetSchedule"))) {
+                    campaignJson.put("day_budget_schedule", requestJson.getJSONArray("dayBudgetSchedule"));
+                }
+
+                JSONArray campaignNames = new JSONArray();
+                if (nameType == 0) { // 0 为统一命名  1 为分别命名
+                    //    Integer startNum = requestJson.getInteger("startNum");
+                    Integer createTotal = requestJson.getInteger("createTotal");
+                    String campaignName = requestJson.getString("campaignName");
+                    for (int j = 0; j < createTotal; j++) {
+                        if (campaignName.contains("{{数值}}")) {
+                            String name = getName(campaignName, accountId, j, type);
+                            campaignNames.add(name);
+                        } else {
+                            String name = null;
+                            if (createTotal == 1) {
+                                name = getName(campaignName, accountId, null, type);
+                            } else {
+                                name = getName(campaignName + "_" + j, accountId, null, type);
+                            }
+                            campaignNames.add(name);
+                        }
+                    }
+                } else if (nameType == 1) { // "分别命名"
+                    JSONArray nameArr = requestJson.getJSONArray("nameArr");
+                    for (int j = 0; j < nameArr.size(); j++) {
+                        JSONObject nameJson = nameArr.getJSONObject(j);
+                        if (nameJson.getLong("accountId").equals(accountId)) {
+                            campaignNames = nameJson.getJSONArray("campaignNames");
+                        }
+                    }
+                }
+                if (!Check.isNull(campaignNames)) {
+                    JSONArray returnCampaigns = new JSONArray();
+                    for (int j = 0; j < campaignNames.size(); j++) {
+                        JSONObject returnCampaignJson = new JSONObject();
+                        String campaignName = (String) campaignNames.get(j);
+                        campaignJson.put("campaign_name", campaignName);
+                        Map<String, Object> campaignMap = kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
+                        if ((Integer) campaignMap.get("code") == 0) {
+                            returnCampaignJson.put("code", 0);
+                            returnCampaignJson.put("campaignId", campaignMap.get("campaignId"));
+                            returnCampaignJson.put("campaignName", campaignName);
+                            returnCampaignJson.put("type", type);
+                            returnCampaignJson.put("message", campaignMap.get("message"));
+                        } else {
+                            returnCampaignJson.put("code", -1);
+                            returnCampaignJson.put("campaignName", campaignName);
+                            returnCampaignJson.put("message", campaignMap.get("message"));
+                        }
+                        returnCampaigns.add(returnCampaignJson);
+
+                    }
+                    returnJson.put("createDetail", returnCampaigns);
+
+                }
+                returnArr.add(returnJson);
+            }
+            result.setSuccess(true);
+            System.err.println(returnArr);
+            result.setResult(returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+
+        }
+        return result;
+
+    }
+
+
+    /**
+     * 获取账户授权名称
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/getAuthName")
+    public Result<JSONArray> getAuthName(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            JSONArray accountArr = requestJson.getJSONArray("accountArr");
+            if (Check.isNull(accountArr)) {
+                throw new Exception("请传入账户id");
+            }
+            JSONArray returnArr = new JSONArray();
+            for (int i = 0; i < accountArr.size(); i++) {
+                Long accountId = accountArr.getLong(i);
+                UserAllocation userAllocation = userAllocationService.getByAccountId(accountId);
+                if (!Check.isNull(userAllocation)) {
+                    JSONObject returnJson = new JSONObject();
+                    returnJson.put("accountId", accountId);
+                    returnJson.put("authName", userAllocation.getAuthName());
+                    returnArr.add(returnJson);
+                }
+            }
+            result.setSuccess(true);
+            result.setResult(returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+
+        }
+        return result;
+
+    }
+
+
+    /**
+     * @param content   计划名称
+     * @param accountId 账户id
+     * @param num       数值数
+     * @param type      计划类型
+     * @return
+     */
+    private String getName(String content, Long accountId, Integer num, Integer type) {
+        String reg = "\\{\\{(.+?)\\}\\}";
+        List<String> params = getParams(reg, content);
+        if (Check.isNull(params)) {
+            return content;
+        }
+
+
+        Map<String, String> data = new HashMap<>();
+        for (int i = 0; i < params.size(); i++) {
+            String regName = params.get(i);
+            if ("项目名称".equals(regName)) {
+                String projectName = projectService.getNameByAccountId(accountId);
+                data.put(regName, projectName);
+            }
+
+            if ("日期".equals(regName)) {
+                data.put(regName, DateUtils.getNowDate("yyyy-MM-dd"));
+            }
+
+            if ("计划类型".equals(regName)) {
+                data.put(regName, CampaignTypeEnum.getNameByType(type));
+            }
+
+            if ("数值".equals(regName)) {
+                data.put(regName, String.valueOf(num));
+            }
+
+        }
+        String text = parse(reg, content, data);
+        return text;
+    }
+
+
+    public static String parse(String pattern, String content, Map<String, String> data) {
+        Pattern p = Pattern.compile(pattern);
+        Matcher m = p.matcher(content);
+
+        StringBuffer sb = new StringBuffer();
+        while (m.find()) {
+            String key = m.group(1);
+            String value = data.get(key);
+            m.appendReplacement(sb, value == null ? "" : value);
+        }
+        m.appendTail(sb);
+        return sb.toString();
+    }
+
+    /**
+     * 根据正则表达式获取文本中的变量名列表
+     *
+     * @param pattern
+     * @param content
+     * @return
+     */
+    public static List<String> getParams(String pattern, String content) {
+        Pattern p = Pattern.compile(pattern);
+        Matcher m = p.matcher(content);
+
+        List<String> result = new ArrayList<String>();
+        while (m.find()) {
+            result.add(m.group(1));
+        }
+        return result;
+    }
+
+    /**
+     * 根据正则表达式将文本中的变量使用实际的数据替换成无变量的文本
+     *
+     * @param pattern
+     * @param content
+     * @param data
+     * @return
+     */
+
+
+}

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

@@ -86,6 +86,7 @@ public class KuaiShouCampaign {
     @Excel(name = "每日预算", width = 15)
     @ApiModelProperty(value = "每日预算")
     private Long dayBudget;
+    private String dayBudgetSchedule;
 
 
     @Excel(name = "广告投放时间", width = 15)

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

@@ -277,12 +277,12 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
 
         historyTypeList = new ArrayList<>();
         historyTypeList.add(1);
-        historyTypeList.add(2);
+       /* historyTypeList.add(2);
         historyTypeList.add(3);
         historyTypeList.add(4);
         historyTypeList.add(5);
         historyTypeList.add(7);
-        historyTypeList.add(10);
+        historyTypeList.add(10);*/
 
 
     }

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

@@ -972,7 +972,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     returnMap.put("campaignId", campaignId);
                     returnMap.put("success", true);
                     // 创建成功 拉取广告组信息
-                    Thread.sleep(1 * 1000L);
+                    Thread.sleep(500);
                     getCampaign(accessToken, advertiserId, campaignId);
                 } else {
                     log.error("创建广告计划失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
@@ -1174,8 +1174,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 campaign.setCampaignId(detail.getLong("campaign_id"));
                 campaign.setCampaignName(detail.getString("campaign_name"));
                 campaign.setDayBudget(detail.getLong("day_budget"));
+                if (!Check.isNull(detail.getJSONArray("day_budget_schedule"))) {
+                    campaign.setDayBudgetSchedule(detail.getJSONArray("day_budget_schedule").toJSONString());
+                }
                 campaign.setStatus(detail.getInteger("status"));
-
                 campaign.setPutStatus(detail.getInteger("put_status"));
                 campaign.setCampaignType(detail.getInteger("campaign_type"));
                 campaign.setCreateChannel(detail.getInteger("create_channel"));

+ 1 - 6
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

@@ -355,7 +355,7 @@
 
     <select id="getBytedanceProjectInfo"
             resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
-        select * from (
+
         select
         concat(#{startDate},'~',#{endDate}) as statDate,
         a.advertiser_id as 'accountId',
@@ -397,11 +397,6 @@
             #{item}
         </foreach>
         group by b.project_id
-        )m
-        <if test="yn = 1">
-            where
-            m.cost != 0
-        </if>
     </select>
 
     <select id="getRoleCodeByUserId" resultType="string">

+ 42 - 47
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
 import cn.com.ctop.common.module.vo.SheetInfoVo;
@@ -38,7 +39,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     @Autowired
     BytedanceAccountReportMapper bytedanceAccountReportMapper;
 
-    private static final BigDecimal zero=BigDecimal.ZERO;
+    private static final BigDecimal zero = BigDecimal.ZERO;
 
     @Override
     public Map<String, Object> getSumDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) {
@@ -51,12 +52,12 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
                 return result;
             }
             before = bytedanceAccountReportMapper.queryTodaySumByHour(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), after.getInteger("maxHour"), accounts);
-            if(before==null){
+            if (before == null) {
                 before = after;
             }
         } else {
             after = bytedanceAccountReportMapper.querySumByStartEndDate(endDate, startDate, accounts);
-            if(after==null){
+            if (after == null) {
                 return result;
             }
             before = after;
@@ -67,16 +68,16 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
 
     @Override
     public List<JSONObject> getChartDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) throws ParseException {
-        List<JSONObject> result=new ArrayList<>();
+        List<JSONObject> result = new ArrayList<>();
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapBy);
         if (startDate.equals(endDate)) {
             List<JSONObject> after = bytedanceAccountReportMapper.queryTodayDetailReportBy(filedAll, startDate, accounts);
             List<JSONObject> before = bytedanceAccountReportMapper.queryTodayDetailReportBy(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
-            if(after.size()==0){
+            if (after.size() == 0) {
                 return result;
             }
-            if(before.size()==0){
-                before=nullDataHandle();
+            if (before.size() == 0) {
+                before = nullDataHandle();
             }
             List<JSONObject> afterDis = this.countDiscountCost(mediaId, discount, after);
             List<JSONObject> beforeDis = this.countDiscountCost(mediaId, discount, before);
@@ -84,13 +85,12 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         } else {
             List<JSONObject> after;
             //判断是不是日期间隔大于半年
-            if(DateUtils.isMoreSixMonth(startDate,endDate)){
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
                 after = bytedanceAccountReportMapper.queryDetailGroupMonthByDate(endDate, startDate, accounts);
-            }
-            else {
+            } else {
                 after = bytedanceAccountReportMapper.queryDetailByStartEndDate(endDate, startDate, accounts);
             }
-            if(after==null){
+            if (after == null) {
                 return result;
             }
             result = this.countDiscountCost(mediaId, discount, after);
@@ -110,9 +110,9 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             result.add(beforeSum);
             result.add(countTotal(afterSum, beforeSum));
         } else {
-            if(accounts.size()>1){
+            if (accounts.size() > 1) {
                 result = bytedanceAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
-            }else{
+            } else {
                 result = bytedanceAccountReportMapper.querySumByDateGroupAccountAndDate(filedAll, endDate, startDate, accounts, target, order);
             }
             result.add(bytedanceAccountReportMapper.queryAllSumByStartEndDate(filedAll, endDate, startDate, accounts));
@@ -187,45 +187,40 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         JSONObject jsonObject = new JSONObject();
         after.forEach((k, v) -> {
             //去除没法计算的字段
-            if (k.equals("accountId") || k.equals("authName") || v.toString().contains("%")||before.getString(k).contains("%")) {
+            if (k.equals("accountId") || k.equals("authName") || v.toString().contains("%") || before.getString(k).contains("%")) {
                 jsonObject.put(k, "-");
             } else {
-                jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k)==null?zero:after.getBigDecimal(k), before.getBigDecimal(k)==null?zero:before.getBigDecimal(k)));
+                jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k) == null ? zero : after.getBigDecimal(k), before.getBigDecimal(k) == null ? zero : before.getBigDecimal(k)));
             }
         });
         return jsonObject;
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn){
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn) {
 
-        if(projectList==null || projectList.size()==0){
+        if (Check.isNull(projectList)) {
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             String userId = sysUser.getId();
-            //String userId = "388e787edd294ecfb9243fe176a3ae56";
             String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
-
             List<Long> mediaIds = new ArrayList<>();
             mediaIds.add(1L);
             mediaIds.add(3L);
-
-            if("admin".equals(roleCode)){
+            if ("admin".equals(roleCode)) {
                 projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
-            }else{
-                projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+            } else {
+                projectList = bytedanceAccountReportMapper.getSaleProjects(userId, mediaIds);
             }
         }
-
-        PageHelper.startPage(pageNum,pageSize);
+        PageHelper.startPage(pageNum, pageSize);
         List<ByteDanceReportAccountDailyDTO> p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, projectList, yn);
-
         return new PageInfo<>(p);
     }
 
     @Override
     public SheetInfoVo getBytedanceSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn) {
         SheetInfoVo vo = new SheetInfoVo<ByteDanceReportAccountDailyDTOEntity>();
-        if(projectList==null || projectList.size()==0){
+        if (Check.isNull(projectList)) {
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             String userId = sysUser.getId();
             String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
@@ -234,14 +229,14 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             mediaIds.add(1L);
             mediaIds.add(3L);
 
-            if("admin".equals(roleCode)){
+            if ("admin".equals(roleCode)) {
                 projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
-            }else{
-                projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+            } else {
+                projectList = bytedanceAccountReportMapper.getSaleProjects(userId, mediaIds);
             }
         }
 
-        PageHelper.startPage(pageNum,pageSize);
+        PageHelper.startPage(pageNum, pageSize);
         List<ByteDanceReportAccountDailyDTOEntity> dtos = bytedanceAccountReportMapper.getBytedanceProjectInfoEntity(startDate, endDate, projectList, yn);
         vo.setSheetName("头条销售报表");
         vo.setDetails(dtos);
@@ -249,7 +244,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn){
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn) {
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
@@ -257,33 +252,33 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(projectId == null){
-            if("admin".equals(roleCode)){
+        if (projectId == null) {
+            if ("admin".equals(roleCode)) {
                 accountIds = bytedanceAccountReportMapper.getUserProjectAccountIdsByAdmin();
-            }else {
+            } else {
                 accountIds = bytedanceAccountReportMapper.getSaleProjectAccountIds(userId);
             }
         }
 
-        if(StringUtils.isBlank(sort)){
+        if (StringUtils.isBlank(sort)) {
             sort = "cost-";
         }
         sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
         sort = sort.substring(0, sort.length() - 1);
-        PageHelper.startPage(pageNo,pageSize,sort);
-        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds,yn));
+        PageHelper.startPage(pageNo, pageSize, sort);
+        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
     }
 
-    private List<JSONObject> nullDataHandle(){
-        List<JSONObject> objectList= new ArrayList<>();
+    private List<JSONObject> nullDataHandle() {
+        List<JSONObject> objectList = new ArrayList<>();
         JSONObject jsonObject;
-        for(int i=0;i<24;i++){
-            jsonObject=new JSONObject();
-            jsonObject.put("cost",0);
-            jsonObject.put("showNum",0);
-            jsonObject.put("click",0);
-            jsonObject.put("convertNum",0);
-            jsonObject.put("statHour",i);
+        for (int i = 0; i < 24; i++) {
+            jsonObject = new JSONObject();
+            jsonObject.put("cost", 0);
+            jsonObject.put("showNum", 0);
+            jsonObject.put("click", 0);
+            jsonObject.put("convertNum", 0);
+            jsonObject.put("statHour", i);
             objectList.add(jsonObject);
         }
         return objectList;