浏览代码

达人业绩v2

yumeng 2 年之前
父节点
当前提交
a36e7fdfed

+ 201 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -1537,4 +1537,205 @@ public class SupplyChainController extends BaseController {
     }
 
 
+
+
+
+    @GetMapping("/bdReportListV2")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdReportListV2(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Integer start = DateUtils.getIntegerTime(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Integer end = DateUtils.getIntegerTime(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(collectSampleId)) {
+            requestMap.put("collectSampleId", collectSampleId);
+        }
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(500);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.bdReportListV2(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @PostMapping("/exportBdReportListV2")
+    @ApiOperation(value = "供应链管理员统计列表")
+    @ResponseBody
+    public void exportBdReportListV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
+            Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
+            Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
+            requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
+        }
+
+        List<JSONObject> list = supplyChainService.bdReportListV2(requestMap);
+        List<List<Object>> exportList = new ArrayList<>();
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject date = list.get(i);
+                List<Object> export = new ArrayList();
+                export.add(date.getString("collectSampleId"));
+                export.add(date.getString("collectSampleName"));
+                export.add(date.getString("promoterCount"));
+                export.add(date.getString("sampleCount"));
+                export.add(date.getString("sampleRate"));
+                export.add(date.getString("notSampleCount"));
+                export.add(date.getString("sendTotalCount"));
+                export.add(date.getString("sendPromoterCount"));
+                export.add(date.getString("sendItemCount"));
+                export.add(date.getString("orderNum"));
+                export.add(date.getString("validOrderNum"));
+                export.add(date.getString("validOrderRate"));
+                export.add(date.getString("orderAmount"));
+                export.add(date.getString("regimentalPromotionAmount"));
+                export.add(date.getString("totalRegimentalSettleAmount"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数",  "有效订单数",  "有效订单率", "订单金额",  "预估服务费", "结算服务费"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "bd业绩汇总V2", headers, exportList);
+        this.setResponseHeader(response, "bd业绩汇总V2.xls");
+        workbook.write(os);
+        os.flush();
+        os.close();
+
+
+    }
+
+
+
+    @GetMapping("/bdTotalV2")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdTotalV2(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Integer start = DateUtils.getIntegerTime(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Integer end = DateUtils.getIntegerTime(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(collectSampleId)) {
+            requestMap.put("collectSampleId", collectSampleId);
+        }
+
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(500);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.bdTotalV2(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/bdDetailListV2")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdDetailListV2(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
+            @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
+            @ApiParam("排序放肆") @RequestParam(value = "sort", required = false) String sort) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Integer start = DateUtils.getIntegerTime(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Integer end = DateUtils.getIntegerTime(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(collectSampleId)) {
+            requestMap.put("collectSampleId", collectSampleId);
+        }
+        requestMap.put("fieId", fieId);
+        requestMap.put("sort", sort);
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(500);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
+        return getDataTable(list);
+    }
+
+    @PostMapping("/exportBdDetailV2")
+    @ApiOperation(value = "认领商品列表")
+    @ResponseBody
+    public void exportBdDetailV2(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
+            Integer start = DateUtils.getIntegerTime(requestJson.getString("orderStartDate"));
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
+            Integer end = DateUtils.getIntegerTime(requestJson.getString("orderEndDate"));
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(requestJson.getLong("collectSampleId"))) {
+            requestMap.put("collectSampleId", requestJson.getLong("collectSampleId"));
+        }
+        requestMap.put("fieId","orderNum");
+        requestMap.put("sort","desc");
+        List<JSONObject> list = supplyChainService.bdDetailListV2(requestMap);
+        List<List<Object>> exportList = new ArrayList<>();
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject date = list.get(i);
+                List<Object> export = new ArrayList();
+                export.add(date.getString("promoterId"));
+                export.add(date.getString("promoterName"));
+                export.add(date.getString("sampleCount"));
+                export.add(date.getString("orderNum"));
+                export.add(date.getString("validOrderNum"));
+                export.add(date.getString("validOrderRate"));
+                export.add(date.getString("regimentalPromotionAmount"));
+                export.add(date.getString("totalRegimentalSettleAmount"));
+                export.add(date.getString("promoterUrl"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"达人ID", "达人名称", "领样数", "订单数", "有效订单数", "有效率", "预估服务费收入", "结算服务费收入", "达人头像"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "bd业绩", headers, exportList);
+        this.setResponseHeader(response, "bd业绩.xls");
+        workbook.write(os);
+        os.flush();
+        os.close();
+    }
+
+
 }

+ 6 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -108,4 +108,10 @@ public interface SupplyChainMapper {
     List<JSONObject> adminReportListByBind(Map<String, Object> requestMap);
 
     List<JSONObject> exportAdminReportListByBind(Map<String, Object> requestMap);
+
+    List<JSONObject> bdReportListV2(Map<String, Object> requestMap);
+
+    List<JSONObject> bdTotalV2(Map<String, Object> requestMap);
+
+    List<JSONObject> bdDetailListV2(Map<String, Object> requestMap);
 }

+ 6 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -130,4 +130,10 @@ public interface ISupplyChainService {
     List<JSONObject> adminReportListByBind(Map<String, Object> requestMap);
     // 招商管理 绑定时间下载
     List<JSONObject> exportAdminReportListByBind(Map<String, Object> requestMap);
+
+    List<JSONObject> bdReportListV2(Map<String, Object> requestMap);
+
+    List<JSONObject> bdTotalV2(Map<String, Object> requestMap);
+
+    List<JSONObject> bdDetailListV2(Map<String, Object> requestMap);
 }

+ 15 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -289,4 +289,19 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     public List<JSONObject> exportAdminReportListByBind(Map<String, Object> requestMap) {
         return supplyChainMapper.exportAdminReportListByBind(requestMap);
     }
+
+    @Override
+    public List<JSONObject> bdReportListV2(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdReportListV2(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> bdTotalV2(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdTotalV2(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> bdDetailListV2(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdDetailListV2(requestMap);
+    }
 }

+ 1 - 1
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -520,7 +520,7 @@
         (
         #{userId},
         #{promotersCount},
-        #{mediaId},
+        #{mediaId}
         )
     </insert>
     <insert id="addRule">

+ 130 - 1
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -1702,7 +1702,7 @@
         <if test="userId != null and userId != ''">
             and t1.userId = #{userId}
         </if>
-        group by t1.user_id )  t left join (
+        group by t1.user_id ) t left join (
         select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
         kuaishou_item_collect_samples t2
         on t1.item_id = t2.item_id
@@ -1761,4 +1761,133 @@
         ) t2 on t.userId = t2.user_id order by t.orderNum desc;
 
     </select>
+    <select id="bdReportListV2" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        tt.promoterCount,
+        ttt.sampleCount,
+        tttt.sendTotalCount,
+        tttt.sendPromoterCount,
+        tttt.sendItemCount,
+        IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
+        round(ttt.sampleCount / tt.promoterCount * 100, 2) as 'sampleRate',
+        tt.promoterCount - ttt.sampleCount as 'notSampleCount'
+        from (
+        select t1.user_id as 'collectSampleId',
+        t1.user_name as 'collectSampleName',
+        sum(t2.order_num) as 'orderNum',
+        sum(t2.valid_order_num) as 'validOrderNum',
+        concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join canal_management t2
+        on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and t1.stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t1.stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and t1.user_id = #{collectSampleId}
+        </if>
+        group by t1.user_id) t
+        left join (select user_id,
+        count(distinct promoter_id) as 'promoterCount'
+        from kuaishou_promoter
+        group by user_id) tt on t.collectSampleId = tt.user_id
+        left join (select collect_sample_id as 'user_id',
+        count(distinct promoter_id) as 'sampleCount'
+        from kuaishou_item_collect_samples
+        where collect_sample_status > 2
+        group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
+        left join (select collect_sample_id as 'user_id',
+        count(1) as 'sendTotalCount',
+        count(distinct promoter_id) as 'sendPromoterCount',
+        count(distinct item_id) as 'sendItemCount'
+        from kuaishou_item_collect_samples
+        where collect_sample_status > 2
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and collect_sample_id = #{collectSampleId}
+        </if>
+        <if test="start != null and start != ''">
+            and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
+            %H:%i:%s')
+        </if>
+        <if test="end != null and end != ''">
+            and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
+        </if>
+        group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
+        left join (select user_id, promoters_count
+        from user_promoters_count
+        where media_id = 2) ttttt
+        on t.collectSampleId = ttttt.user_id
+        order by t.orderNum desc
+    </select>
+    <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,tt.sampleCount
+        from (select t1.user_id as 'collectSampleId',
+        t1.user_name as 'collectSampleName',
+        sum(t2.order_num) as 'orderNum',
+        sum(t2.valid_order_num) as 'validOrderNum',
+        concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join canal_management t2
+        on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
+        where 1 = 1
+        <if test="start != null and start != '' ">
+            and t1.stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t1.stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and t1.user_id = #{collectSampleId}
+        </if>
+        group by t1.user_id) t
+        join (select count(distinct item_id) as 'sampleCount'
+        from kuaishou_item_collect_samples
+        where collect_sample_status > 2
+        and collect_sample_id = #{collectSampleId} ) tt
+
+    </select>
+    <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*, tt.sampleCount
+        from (select t1.promoter_id as 'promoterId',
+        t1.promoter_name as 'promoterName',
+        t1.promoter_url as 'promoterUrl',
+        sum(t2.order_num) as 'orderNum',
+        sum(t2.valid_order_num) as 'validOrderNum',
+        concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join canal_management t2
+        on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
+        where 1 = 1
+        <if test="start != null and start != '' ">
+            and t1.stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t1.stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and t1.user_id = #{collectSampleId}
+        </if>
+        group by t1.promoter_id) t
+        left join (select promoter_id,
+        count(distinct item_id) as 'sampleCount'
+        from kuaishou_item_collect_samples
+        where collect_sample_status > 2
+        and collect_sample_id = #{collectSampleId}
+        group by promoter_id) tt on t.promoterId = tt.promoter_id
+        where t.orderNum > 0
+        order by ${fieId} ${sort}
+    </select>
 </mapper>