Browse Source

Merge remote-tracking branch 'origin/test' into test2

xuzuoyun 5 years ago
parent
commit
a7fcb2a7ce

+ 6 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -119,7 +119,12 @@ public class KuaishouInterfaceConstant {
     /**
     /**
      * 快手-广告主信息
      * 快手-广告主信息
      */
      */
-    public static final String ADVERTISER_INFO = "//rest/openapi/v1/advertiser/info";
+    public static final String ADVERTISER_INFO = "/rest/openapi/v1/advertiser/info";
+
+    /**
+     * 修改广告创意
+     */
+    public static final String UPDATE_CREATIVE = "/rest/openapi/v2/creative/update";
 
 
 
 
     /**
     /**

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

@@ -0,0 +1,101 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/MaterialRefuse")
+public class MaterialRefuseController {
+    @Autowired
+    private IMaterialRefuseService materialRefuseService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private KuaiShouCreativeMapper creativeMapper;
+
+
+    @PostMapping(value = "/getRefuseCreative")
+    public Map<String, Object> getRefuseCreative(@RequestBody JSONObject jsonObject) {
+        Map<String, Object> map = new HashMap<>();
+        try {
+            List<JSONObject> list = materialRefuseService.getRefuseCreative(jsonObject.getLong("accountId"));
+            map.put("code", 0);
+            map.put("data", list);
+        } catch (Exception e) {
+            map.put("code", -1);
+            e.printStackTrace();
+        }
+
+        return map;
+    }
+
+    @PostMapping(value = "/updateCreative")
+    public Map<String, Object> updateCreative(@RequestBody JSONObject jsonObject) {
+        Map<String, Object> map = new HashMap<>();
+        if (Check.isNull(jsonObject)) {
+            map.put("code", -1);
+            map.put("message", "入参为空");
+            return map;
+        }
+
+        Long accountId = jsonObject.getLong("accountId");
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("media_id", 2);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(queryWrapper);
+        if (Check.isNull(ctopOauthToken)) {
+            map.put("code", -1);
+            map.put("message", "未获取授权信息");
+            return map;
+        }
+
+        Map<String, Object> creativeMap = updateService.updateCreative(ctopOauthToken.getAccessToken(), accountId, jsonObject);
+        if (Check.isNullMap(creativeMap)) {
+            map.put("code", -1);
+            map.put("message", "修改失败,返回为空");
+            return map;
+
+        }
+
+        if ((Integer) creativeMap.get("code") != 0) {
+            map.put("code", -1);
+            map.put("message", creativeMap.get("message"));
+            return map;
+        }
+
+        QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+        creativeQueryWrapper.eq("account_id", accountId);
+        creativeQueryWrapper.eq("creative_id", jsonObject.getString("creativeId"));
+        creativeQueryWrapper.eq("unit_id", jsonObject.getString("unitId"));
+        creativeQueryWrapper.eq("campaign_id", jsonObject.getString("campaignId"));
+        int i = creativeMapper.delete(creativeQueryWrapper);
+        if (i > 0) {
+            map.put("code", 0);
+            map.put("message", "重审成功");
+            return map;
+        }
+
+        return null;
+    }
+
+}

+ 10 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/MaterialRefuseMapper.java

@@ -0,0 +1,10 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface MaterialRefuseMapper {
+    List<JSONObject> selectRefuseCreativeByAccountId(Long accountId);
+
+}

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

@@ -0,0 +1,26 @@
+<?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.batch.mapper.MaterialRefuseMapper">
+
+    <select id="selectRefuseCreativeByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select
+         t1.account_id accountId,
+         t1.campaign_id campaignId,
+         t1.unit_id unitId,
+         t1.creative_id creativeId,
+         t1.creative_name creativeName,
+         t2.url videoUrl,
+         t1.cover_url coverUrl,
+         t1.review_detail reviewDetail,
+         t1.description description
+    from
+        ctop_kuaishou_creative t1
+       left join ctop_kuaishou_video_get t2
+       on t1.account_id = t2.account_id
+       and t1.photo_id = t2.photo_id
+       where  t1.account_id = #{accountId}
+       and status = 42
+       order by t1.creative_id desc
+    </select>
+
+</mapper>

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

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 
+import com.alibaba.fastjson.JSONObject;
+
 import java.util.Map;
 import java.util.Map;
 
 
 public interface IKuaiShouUpdateService {
 public interface IKuaiShouUpdateService {
@@ -73,4 +75,15 @@ public interface IKuaiShouUpdateService {
      */
      */
     Map<String, Object> updateCreativeStatus(String token, Long advertiserId, Long creativeId, int putStatus, String loginId);
     Map<String, Object> updateCreativeStatus(String token, Long advertiserId, Long creativeId, int putStatus, String loginId);
 
 
+
+    /**
+     * 修改创意
+     *
+     * @param token
+     * @param advertiserId
+     * @param requestJson
+     * @return
+     */
+    Map<String, Object> updateCreative(String token, Long advertiserId, JSONObject requestJson);
+
 }
 }

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface IMaterialRefuseService {
+    List<JSONObject> getRefuseCreative(@Param("accountId") Long accountId);
+
+}

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

@@ -421,4 +421,66 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
 
         return returnMap;
         return returnMap;
     }
     }
+
+
+    /**
+     * 修改创意
+     *
+     * @param token
+     * @param advertiserId
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public Map<String, Object> updateCreative(String token, Long advertiserId, JSONObject requestJson) {
+        Map<String, Object> returnMap = new HashMap<>();
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CREATIVE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token);
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+
+
+            String creativeId = requestJson.getString("creativeId");
+            String creativeName = requestJson.getString("creativeName");
+            String description = requestJson.getString("description");
+
+
+            params.put("advertiser_id", advertiserId);
+            params.put("creative_id", creativeId);
+            params.put("creative_name", creativeName);
+            params.put("description", description);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println("返回结果: " + resultJson);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    returnMap.put("code", 0);
+                    returnMap.put("success", true);
+                    returnMap.put("message", "修改成功");
+                } else {
+                    log.error("修改广告创意状态失败,advertiserId:{},creativeId:{},返回信息:{}", advertiserId, creativeId, resultJson);
+                    returnMap.put("code", -1);
+                    returnMap.put("success", false);
+                    returnMap.put("message", resultJson.getString("message"));
+                }
+            } else {
+                log.error("修改广告创意返回结果为空,advertiserId:{},creativeId:{}", advertiserId, creativeId);
+                returnMap.put("code", -1);
+                returnMap.put("success", false);
+                returnMap.put("message", "修改广告组预算返回结果为空");
+            }
+
+        } catch (Exception e) {
+            log.error("修改广告创意异常,advertiserId:{}", advertiserId);
+            e.printStackTrace();
+            returnMap.put("code", -1);
+            returnMap.put("success", false);
+            returnMap.put("message", "修改广告创意异常");
+        }
+
+        return returnMap;
+    }
 }
 }

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

@@ -0,0 +1,25 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.mapper.MaterialRefuseMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j
+@Service
+public class MaterialRefuseServiceImpl implements IMaterialRefuseService {
+    @Autowired
+    private MaterialRefuseMapper materialRefuseMapper;
+
+
+    @Override
+    public List<JSONObject> getRefuseCreative(Long accountId) {
+        List<JSONObject> refuseCreativeList = materialRefuseMapper.selectRefuseCreativeByAccountId(accountId);
+        return refuseCreativeList;
+    }
+
+}

+ 22 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java

@@ -2,6 +2,8 @@ package cn.com.ctop.bytedance.controller;
 
 
 
 
 import cn.com.ctop.bytedance.service.IMaterialReportService;
 import cn.com.ctop.bytedance.service.IMaterialReportService;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,4 +36,24 @@ public class MaterialReportController {
 
 
     }
     }
 
 
+
+    @PostMapping(value = "/getMaterialAccount")
+    public List<UserAllocation> getKuaiShouChainRatio(@RequestBody String userId) {
+        if (Check.isNull(userId)) {
+            return null;
+        }
+        List<UserAllocation> accountIdList = materialReportService.selectAccountIds(userId);
+        return accountIdList;
+
+    }
+
+
+    @PostMapping(value = "/getMaterialReportByAccount")
+    public List<JSONObject> getMaterialReportByAccount(@RequestBody JSONObject json) {
+
+        List<JSONObject> reportList = materialReportService.selectReportByAccountIds(json);
+        return reportList;
+
+    }
+
 }
 }

+ 4 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/MaterialReportMapper.java

@@ -18,4 +18,8 @@ public interface MaterialReportMapper {
     List<JSONObject> selectDailyByMap(Map<String, Object> paramsMap);
     List<JSONObject> selectDailyByMap(Map<String, Object> paramsMap);
 
 
     JSONObject selectDailyChainRatioByMap(Map<String, Object> paramsMap);
     JSONObject selectDailyChainRatioByMap(Map<String, Object> paramsMap);
+
+    List<JSONObject> selectHourMaterialList(Map<String, Object> paramsMap);
+
+    List<JSONObject> selectDayMaterialList(Map<String, Object> paramsMap);
 }
 }

+ 186 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml

@@ -195,6 +195,10 @@
             <if test="signature != null">
             <if test="signature != null">
                 and signature = #{signature}
                 and signature = #{signature}
             </if>
             </if>
+            <if test="accountId != null">
+                and account_id = #{accountId}
+            </if>
+
         </where>
         </where>
         group by signature
         group by signature
 
 
@@ -364,9 +368,191 @@
             <if test="endDate != null">
             <if test="endDate != null">
                 and stat_date &lt;= #{endDate}
                 and stat_date &lt;= #{endDate}
             </if>
             </if>
+
+            <if test="accountId != null">
+                and account_id = #{accountId}
+            </if>
         </where>
         </where>
         group by signature
         group by signature
     </select>
     </select>
 
 
 
 
+    <select id="selectHourMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        sum(t2.charge) cost, -- 花费
+        sum(t2.photo_show) photoShow, -- 封面曝光数
+        sum(t2.photo_click) photoClick, -- 封面点击数
+        sum(t2.aclick) aclick, -- 素材曝光数
+        sum(t2.bclick) bclick, -- 行为数
+        (case
+        when sum(photo_show) != 0
+        then (sum(t2.photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(aclick) != 0
+        then (sum(t2.bclick) / sum(aclick))
+        else 0
+        end
+        ) actionRatio, -- 行为率
+
+        (case
+        when sum(t2.photo_show) != 0
+        then ((sum(t2.charge) / sum(t2.photo_show)) * 1000)
+        else 0
+        end
+        ) impression1kCost, -- 均千次封面曝光花费
+
+        (case
+        when sum(t2.photo_click) != 0
+        then (sum(t2.charge) / sum(t2.photo_click))
+        else 0
+        end
+        ) photoClickCost, -- 平均封面点击单价
+
+        (CASE
+        WHEN sum(t2.photo_click) != 0
+        THEN (sum(t2.charge) / sum(t2.photo_click))
+        ELSE 0
+        end
+        ) actionCost, -- 平均行为单价
+
+        (case
+        WHEN sum(t2.form_count) != 0
+        THEN sum(t2.form_count)
+        WHEN sum(t2.activation) != 0
+        THEN sum(t2.activation)
+        ELSE 0
+        END
+        ) conversions, -- 转化数
+
+        (
+        CASE
+        WHEN sum(t2.form_count) != 0
+        THEN (sum(t2.charge) / sum(t2.form_count))
+        WHEN sum(t2.activation) != 0
+        THEN (sum(t2.charge) / sum(t2.activation))
+        ELSE 0
+        END
+        ) conversionPrice, -- 转化单价
+
+        t2.url url, -- 视频url
+        t2.signature signature, -- 视频md5
+        t2.account_id accountId
+        from
+        ctop_oauth_token t1
+        left join
+        ctop_kuaishou_report_hourly_creative_statistic t2
+        on t1.id = t2.account_id
+        where t1.id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and t1.media_id = '2'
+        <if test="statHour != null">
+            and t2.stat_hour &lt;= #{statHour}
+        </if>
+        <if test="statDate != null">
+            and t2.stat_date = #{statDate}
+        </if>
+        and t2.signature != ''
+        GROUP BY t2.signature
+        order by sum(t2.charge) desc
+        limit 100
+    </select>
+
+
+    <select id="selectDayMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        sum(t2.charge) cost, -- 花费
+        sum(t2.photo_show) photoShow, -- 封面曝光数
+        sum(t2.photo_click) photoClick, -- 封面点击数
+        sum(t2.aclick) aclick, -- 素材曝光数
+        sum(t2.bclick) bclick, -- 行为数
+        (case
+        when sum(photo_show) != 0
+        then (sum(t2.photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(aclick) != 0
+        then (sum(t2.bclick) / sum(aclick))
+        else 0
+        end
+        ) actionRatio, -- 行为率
+
+        (case
+        when sum(t2.photo_show) != 0
+        then ((sum(t2.charge) / sum(t2.photo_show)) * 1000)
+        else 0
+        end
+        ) impression1kCost, -- 均千次封面曝光花费
+
+        (case
+        when sum(t2.photo_click) != 0
+        then (sum(t2.charge) / sum(t2.photo_click))
+        else 0
+        end
+        ) photoClickCost, -- 平均封面点击单价
+
+        (CASE
+        WHEN sum(t2.photo_click) != 0
+        THEN (sum(t2.charge) / sum(t2.photo_click))
+        ELSE 0
+        end
+        ) actionCost, -- 平均行为单价
+
+        (case
+        WHEN sum(t2.form_count) != 0
+        THEN sum(t2.form_count)
+        WHEN sum(t2.activation) != 0
+        THEN sum(t2.activation)
+        ELSE 0
+        END
+        ) conversions, -- 转化数
+
+        (
+        CASE
+        WHEN sum(t2.form_count) != 0
+        THEN (sum(t2.charge) / sum(t2.form_count))
+        WHEN sum(t2.activation) != 0
+        THEN (sum(t2.charge) / sum(t2.activation))
+        ELSE 0
+        END
+        ) conversionPrice, -- 转化单价
+
+        t2.url url, -- 视频url
+        t2.signature signature, -- 视频md5
+        t2.account_id accountId
+        from
+        ctop_oauth_token t1
+        left join
+        ctop_kuaishou_report_daily_creative_statistic t2
+        on t1.id = t2.account_id
+        where t1.id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and t1.media_id = '2'
+
+        <if test="startDate != null">
+            and t2.stat_date &gt;= #{startDate}
+        </if>
+
+        <if test="endDate != null">
+            and t2.stat_date &lt;= #{endDate}
+        </if>
+        and t2.signature != ''
+        GROUP BY t2.signature
+        order by sum(t2.charge) desc
+        limit 100
+    </select>
+
+
 </mapper>
 </mapper>

+ 17 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IMaterialReportService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.bytedance.service;
 package cn.com.ctop.bytedance.service;
 
 
+import cn.com.ctop.common.module.entity.UserAllocation;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
 import java.util.List;
 import java.util.List;
@@ -23,4 +24,20 @@ public interface IMaterialReportService {
      * @return
      * @return
      */
      */
     JSONObject getKuaiShouChainRatio(JSONObject json);
     JSONObject getKuaiShouChainRatio(JSONObject json);
+
+    /**
+     * 查询账号accountId
+     *
+     * @param userId
+     * @return
+     */
+    List<UserAllocation> selectAccountIds(String userId);
+
+    /**
+     * 根据账号 查新素材报表
+     *
+     * @param json
+     * @return
+     */
+    List<JSONObject> selectReportByAccountIds(JSONObject json);
 }
 }

+ 126 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java

@@ -2,8 +2,12 @@ package cn.com.ctop.bytedance.service.impl;
 
 
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.bytedance.service.IMaterialReportService;
 import cn.com.ctop.bytedance.service.IMaterialReportService;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +25,9 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
     @Autowired
     @Autowired
     private MaterialReportMapper materialReportMapper;
     private MaterialReportMapper materialReportMapper;
 
 
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+
     @Override
     @Override
     public String getRoleCodeByUserId(String userId) {
     public String getRoleCodeByUserId(String userId) {
         return materialReportMapper.getRoleCodeByUserId(userId);
         return materialReportMapper.getRoleCodeByUserId(userId);
@@ -142,10 +149,14 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
                 return null;
                 return null;
             }
             }
             Integer type = json.getInteger("type");
             Integer type = json.getInteger("type");
+            String accountId = json.getString("accountId");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             Map<String, Object> paramsMap = new HashMap<>();
             Map<String, Object> paramsMap = new HashMap<>();
             paramsMap.put("signature", signature);
             paramsMap.put("signature", signature);
+            if (!Check.isNull(accountId)) {
+                paramsMap.put("accountId", accountId);
+            }
             String beContrastDate = "";
             String beContrastDate = "";
             String contrastStartDate = "";
             String contrastStartDate = "";
             String beContrastStartDate = "";
             String beContrastStartDate = "";
@@ -430,4 +441,119 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
     }
     }
 
 
 
 
+    /**
+     * 查询 所有绑定账号
+     *
+     * @param userId
+     * @return
+     */
+
+
+    @Override
+    public List<UserAllocation> selectAccountIds(String userId) {
+        String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_id", 2);
+        if ("operator".equals(roleCode)) {
+            queryWrapper.eq("userId", userId);
+        }
+        queryWrapper.isNotNull("account_id");
+        queryWrapper.groupBy("account_id");
+        queryWrapper.orderByAsc("advertiser_name");
+
+        List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
+        return userAllocations;
+    }
+
+    /**
+     * 根据账号 查询素材报表
+     *
+     * @param json
+     * @return
+     */
+    @Override
+    public List<JSONObject> selectReportByAccountIds(JSONObject json) {
+
+
+        long startTime = System.currentTimeMillis();
+
+        List<JSONObject> marketJsonList = new ArrayList<>();
+        try {
+            if (Check.isNull(json)) {
+                return marketJsonList;
+            }
+
+            JSONArray accountIds = json.getJSONArray("accountIds");
+            if (Check.isNull(accountIds)) {
+                return marketJsonList;
+            }
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            Integer type = json.getInteger("type");
+
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("accountIds", accountIds);
+            if (type == 1) { // 今天分时数据
+                Integer maxHour = materialReportMapper.selectMaxHourByDate(nowDate);
+                if (Check.isNull(maxHour) || maxHour == 0) {
+                    return marketJsonList;
+                }
+                Integer statHour = maxHour - 1;
+                paramsMap.put("statHour", statHour);
+                paramsMap.put("statDate", nowDate);
+                marketJsonList = materialReportMapper.selectHourMaterialList(paramsMap);
+
+            } else if (type == 2) {
+                paramsMap.put("startDate", anotherDay);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 3) {
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 4) {
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 5) {// 近一个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 6) {// 近三个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 7) {// 近六个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 9) {  // 自定义查询日期
+                String startDate = json.getString("startDate");
+                String endDate = json.getString("endDate");
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", endDate);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        log.info("账户维度素材数据请求所用时长------------->: {} ms", System.currentTimeMillis() - startTime);
+        return marketJsonList;
+    }
+
+
 }
 }