yumeng 1 năm trước cách đây
mục cha
commit
0c94f94117

+ 45 - 9
ruixuan-live/src/main/java/com/ruixuan/bytedance/controller/BytedancePromoterOrderListController.java

@@ -286,7 +286,11 @@ public class BytedancePromoterOrderListController extends BaseController {
     public TableDataInfo bytedanceBDReportList(
             @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("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId,
+            String bindStartDate,
+            String bindEndDate
+
+    ) {
         Map<String, Object> requestMap = new HashMap<>();
         if (!Check.isNull(orderStartDate)) {
             Integer start = DateUtils.getIntegerTime(orderStartDate);
@@ -299,6 +303,16 @@ public class BytedancePromoterOrderListController extends BaseController {
         if (!Check.isNull(collectSampleId)) {
             requestMap.put("collectSampleId", collectSampleId);
         }
+
+        if (!Check.isNull(bindStartDate)) {
+            Integer start = DateUtils.getIntegerTime(bindStartDate);
+            requestMap.put("bindStartDate", start);
+        }
+        if (!Check.isNull(bindEndDate)) {
+            Integer end = DateUtils.getIntegerTime(bindEndDate);
+            requestMap.put("bindEndDate", end);
+        }
+
         TableDataInfo dataInfo = new TableDataInfo();
         if (Check.isNullMap(requestMap)) {
             dataInfo.setCode(500);
@@ -306,7 +320,12 @@ public class BytedancePromoterOrderListController extends BaseController {
             return dataInfo;
         }
         startPage();
-        List<JSONObject> list = bytedancePromoterOrderListService.bytedanceBDReportList(requestMap);
+        List<JSONObject> list = new ArrayList<>();
+        if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
+            list = bytedancePromoterOrderListService.bdReportList(requestMap);
+        } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
+            list = bytedancePromoterOrderListService.bdReportListByBind(requestMap);
+        }
         return getDataTable(list);
     }
 
@@ -320,6 +339,8 @@ public class BytedancePromoterOrderListController extends BaseController {
     public void exportBdReportList(HttpServletRequest request, HttpServletResponse response,
                                    @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
                                    @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+                                   @ApiParam("结束时间") @RequestParam(value = "bindStartDate", required = false) String bindStartDate,
+                                   @ApiParam("结束时间") @RequestParam(value = "bindEndDate", required = false) String bindEndDate,
                                    @ApiParam("用户ID") @RequestParam(value = "collectSampleId", required = false) Long collectSampleId) throws IOException {
         Map<String, Object> requestMap = new HashMap<>();
         if (!Check.isNull(orderStartDate)) {
@@ -330,11 +351,31 @@ public class BytedancePromoterOrderListController extends BaseController {
             Integer end = DateUtils.getIntegerTime(orderEndDate);
             requestMap.put("end", end);
         }
+
+        if (!Check.isNull(bindStartDate)) {
+            Integer start = DateUtils.getIntegerTime(bindStartDate);
+            requestMap.put("bindStartDate", start);
+        }
+        if (!Check.isNull(bindEndDate)) {
+            Integer end = DateUtils.getIntegerTime(bindEndDate);
+            requestMap.put("bindEndDate", end);
+        }
+
+        if (!Check.isNull(collectSampleId)) {
+            requestMap.put("collectSampleId", collectSampleId);
+        }
+
+
         if (!Check.isNull(collectSampleId)) {
             requestMap.put("collectSampleId", collectSampleId);
         }
+        List<JSONObject> list = new ArrayList<>();
+        if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
+            list = bytedancePromoterOrderListService.bdReportList(requestMap);
+        }else {
+            list = bytedancePromoterOrderListService.bdReportListByBind(requestMap);
+        }
 
-        List<JSONObject> list = bytedancePromoterOrderListService.bytedanceBDReportList(requestMap);
         List<List<Object>> exportList = new ArrayList<>();
         if (!Check.isNull(list)) {
             for (int i = 0; i < list.size(); i++) {
@@ -350,20 +391,15 @@ public class BytedancePromoterOrderListController extends BaseController {
                 export.add(date.getString("sendPromoterCount"));
                 export.add(date.getString("sendItemCount"));
                 export.add(date.getString("orderNum"));
-                export.add(date.getString("voucherOrderNum"));
                 export.add(date.getString("validOrderNum"));
-                export.add(date.getString("voucherValidOrderNum"));
                 export.add(date.getString("validOrderRate"));
                 export.add(date.getString("orderAmount"));
-                export.add(date.getString("voucherOrderAmount"));
                 export.add(date.getString("regimentalPromotionAmount"));
-                export.add(date.getString("voucherRegimentalPromotionAmount"));
                 export.add(date.getString("totalRegimentalSettleAmount"));
-                export.add(date.getString("voucherTotalRegimentalSettleAmount"));
                 exportList.add(export);
             }
         }
-        String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "(凭)订单数", "有效订单数", "(凭)有效订单数", "有效订单率", "订单金额", "凭(订单金额)", "预估服务费", "(凭)预估服务费", "结算服务费", "(凭)结算服务费"};
+        String[] headers = {"渠道ID", "渠道姓名", "(总)达人数", "(总)领样达人数", "(总)领样率", "(总)未领样数", "发样数", "发样达人数", "发样商品数", "订单数", "有效订单数", "有效订单率", "订单金额", "预估服务费", "结算服务费"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();

+ 3 - 0
ruixuan-live/src/main/java/com/ruixuan/bytedance/mapper/BytedancePromoterOrderListMapper.java

@@ -60,4 +60,7 @@ public interface BytedancePromoterOrderListMapper
 
     List<JSONObject> exportBytedancePromoter(Map<String, Object> requestMap);
 
+    List<JSONObject> bdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdReportListByBind(Map<String, Object> requestMap);
 }

+ 3 - 0
ruixuan-live/src/main/java/com/ruixuan/bytedance/service/IBytedancePromoterOrderListService.java

@@ -58,4 +58,7 @@ public interface IBytedancePromoterOrderListService {
 
     List<JSONObject> exportBytedancePromoter(Map<String, Object> requestMap);
 
+    List<JSONObject> bdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdReportListByBind(Map<String, Object> requestMap);
 }

+ 10 - 0
ruixuan-live/src/main/java/com/ruixuan/bytedance/service/impl/BytedancePromoterOrderListServiceImpl.java

@@ -122,4 +122,14 @@ public class BytedancePromoterOrderListServiceImpl implements IBytedancePromoter
     public List<JSONObject> exportBytedancePromoter(Map<String, Object> requestMap) {
         return bytedancePromoterOrderListMapper.exportBytedancePromoter(requestMap);
     }
+
+    @Override
+    public List<JSONObject> bdReportList(Map<String, Object> requestMap) {
+        return bytedancePromoterOrderListMapper.bdReportList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> bdReportListByBind(Map<String, Object> requestMap) {
+        return bytedancePromoterOrderListMapper.bdReportListByBind(requestMap);
+    }
 }

+ 202 - 107
ruixuan-live/src/main/resources/mapper/bytedance/BytedancePromoterOrderListMapper.xml

@@ -587,124 +587,70 @@
     </select>
 
     <select id="bytedanceBDTotal" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        t2.sampleCount,
-        t1.orderNum,
-        t1.validOrderNum,
-        t1.validOrderRate,
-        t1.orderAmount,
-        t1.regimentalPromotionAmount,
-        t1.totalRegimentalSettleAmount
-        FROM (
-        SELECT
-        count(order_id) AS 'orderNum',
-        t0.validOrderNUm,
-        CONCAT(round(t0.validOrderNUm / count(order_id) * 100, 2),'%') AS 'validOrderRate',
-        sum(total_pay_amount)/100 AS 'orderAmount',
-        sum(colonel_estimated_commission)/100 AS 'regimentalPromotionAmount',
-        sum(colonel_real_commission)/100 AS 'totalRegimentalSettleAmount'
-        FROM ruixuan.bytedance_promoter_order_list t
-        LEFT JOIN (
-        SELECT author_bind_user_id AS 'collectSampleId',
-        sum(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END) AS 'validOrderNUm'
-        FROM ruixuan.bytedance_promoter_order_list
-        WHERE author_bind_user_id is not null
-        <if test="start != null and start != ''">
-            and pay_success_time &gt;= #{start}
-        </if>
-        <if test="end != null and end != ''">
-            and pay_success_time &lt;= #{end}
-        </if>
-        <if test="collectSampleId != null and collectSampleId != ''">
-            and author_bind_user_id = #{collectSampleId}
-        </if>
-        GROUP BY author_bind_user_id
-        ) t0 ON t.author_bind_user_id= t0.collectSampleId
-        WHERE 1 = 1
-        <if test="start != null and start != ''">
-            and pay_success_time &gt;= #{start}
+        select t.*, tt.sampleCount
+        from (select
+        count(t2.order_id) as 'orderNum',
+        sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNum',
+        concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end)  /  count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.pay_goods_amount) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.settled_goods_amount) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join bytedance_promoter_order_list t2
+        on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
+        where 1 = 1
+        <if test="start != null and start != '' ">
+            and t1.stat_date &gt;= #{start}
         </if>
         <if test="end != null and end != ''">
-            and pay_success_time &lt;= #{end}
+            and t1.stat_date &lt;= #{end}
         </if>
         <if test="collectSampleId != null and collectSampleId != ''">
-            and author_bind_user_id = #{collectSampleId}
-        </if>
-        ) t1
-        join (
-        SELECT
-        count(distinct item_id) AS 'sampleCount'
-        FROM kuaishou_item_collect_samples
-        WHERE collect_sample_status > 2
-        <if test="collectSampleId != null and collectSampleId != ''">
-            and collect_sample_id = #{collectSampleId}
-        </if>
-        ) t2
+            and t1.user_id = #{collectSampleId}
+        </if>) t
+        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}
+        ) tt
+
+
     </select>
 
     <select id="bytedanceBDDetailList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        t1.promoterId,
-        t1.promoterName,
-        t1.promoterUrl,
-        t2.sampleCount,
-        t1.orderNum,
-        t1.validOrderNum,
-        t1.validOrderRate,
-        t1.orderAmount,
-        t1.regimentalPromotionAmount,
-        t1.totalRegimentalSettleAmount
-        FROM (
-        SELECT
-        author_short_id AS 'promoterId',
-        author_short_name AS 'promoterName',
-        author_short_url AS 'promoterUrl',
-        count(order_id) AS 'orderNum',
-        t0.validOrderNUm,
-        CONCAT(round(t0.validOrderNUm / count(order_id) * 100, 2),'%') AS 'validOrderRate',
-        sum(total_pay_amount)/100 AS 'orderAmount',
-        sum(colonel_estimated_commission)/100 AS 'regimentalPromotionAmount',
-        sum(colonel_real_commission)/100 AS 'totalRegimentalSettleAmount'
-        FROM ruixuan.bytedance_promoter_order_list t
-        LEFT JOIN (
-        SELECT author_bind_user_id AS 'collectSampleId',
-        sum(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END) AS 'validOrderNUm'
-        FROM ruixuan.bytedance_promoter_order_list
-        WHERE author_short_id is not null
-        <if test="start != null and start != ''">
-            and pay_success_time &gt;= #{start}
+        select t.*, tt.sampleCount
+        from (select t1.promoter_id as 'promoterId',
+        t1.promoter_name as 'promoterName',
+        t1.promoter_url as 'promoterUrl',
+        count(t2.order_id) as 'orderNum',
+        sum(case when t2.flow_point != 'REFUND' then 1 else 0 end)  AS 'validOrderNum',
+        concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end)  /  count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.pay_goods_amount) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.settled_goods_amount) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join bytedance_promoter_order_list t2
+        on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
+        where 1 = 1
+        <if test="start != null and start != '' ">
+            and t1.stat_date &gt;= #{start}
         </if>
         <if test="end != null and end != ''">
-            and pay_success_time &lt;= #{end}
+            and t1.stat_date &lt;= #{end}
         </if>
         <if test="collectSampleId != null and collectSampleId != ''">
-            and author_bind_user_id = #{collectSampleId}
-        </if>
-        GROUP BY author_bind_user_id
-        ) t0 ON t.author_bind_user_id= t0.collectSampleId
-        WHERE 1 = 1
-        <if test="start != null and start != ''">
-            and pay_success_time &gt;= #{start}
-        </if>
-        <if test="end != null and end != ''">
-            and pay_success_time &lt;= #{end}
-        </if>
-        <if test="collectSampleId != null and collectSampleId != ''">
-            and author_bind_user_id = #{collectSampleId}
-        </if>
-        GROUP BY author_short_id) t1
-        LEFT JOIN (
-        SELECT
-        promoter_id AS 'promoterId',
-        count(distinct item_id) AS 'sampleCount'
-        FROM kuaishou_item_collect_samples
-        WHERE collect_sample_status > 2
-        <if test="collectSampleId != null and collectSampleId != ''">
-            and collect_sample_id = #{collectSampleId}
-        </if>
-        GROUP BY promoter_id) t2
-        on t1.promoterId = t2.promoterId
-        ORDER BY ${fieId} ${sort}
+            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>
 
     <select id="bytedanceUserItemTotal" resultType="com.alibaba.fastjson.JSONObject">
@@ -813,4 +759,153 @@
         ORDER BY t.promoterId,t.itemId desc
     </select>
 
+
+
+
+    <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        tt.promoterCount,
+        ttt.sampleCount,
+        tttt.sendTotalCount,
+        tttt.sendPromoterCount,
+        tttt.sendItemCount,
+        IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
+        concat(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',
+        count(t2.order_id) as 'orderNum',
+        sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNum',
+        concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
+        round(sum(t2.colonel_estimated_commission) / 100, 2) as 'regimentalPromotionAmount',
+        round(sum(t2.colonel_real_commission) / 100, 2) as 'totalRegimentalSettleAmount'
+        from promoter_bind_channel_date t1
+        left join bytedance_promoter_order_list t2
+        on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
+        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 = 1) ttttt
+        on t.collectSampleId = ttttt.user_id
+        where t.orderNum > 0
+        order by t.orderNum desc
+    </select>
+    <select id="bdReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        tt.promoterCount,
+        ttt.sampleCount,
+        tttt.sendTotalCount,
+        tttt.sendPromoterCount,
+        tttt.sendItemCount,
+        IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
+        from (select t1.user_id                                                               as 'collectSampleId',
+        t1.user_name                                                             as 'collectSampleName',
+        count(t2.order_id)                                                        as 'orderNum',
+        sum(case when t2.flow_point != 'REFUND' then 1 else 0 end)                                     as 'validOrderNum',
+        concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id)   * 100, 2), '%') as 'validOrderRate',
+        round(sum(t2.total_pay_amount) / 100, 2)                                     as 'orderAmount',
+        round(sum(t2.colonel_estimated_commission) / 100, 2)                      as 'regimentalPromotionAmount',
+        round(sum(t2.colonel_real_commission) / 100, 2)                   as 'totalRegimentalSettleAmount'
+        from kuaishou_promoter t1
+        left join(select *
+        from bytedance_promoter_order_list
+        where pay_success_time &gt;= #{bindStartDate}) t2
+        on t1.promoter_id = t2.author_short_id
+        where 1 = 1
+        <if test="bindStartDate != null and bindStartDate != '' ">
+            and t1.create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
+            '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="bindEndDate != null and bindEndDate != '' ">
+            and t1.create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
+            %H:%i:%s')
+        </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
+        where 1 = 1
+        <if test="collectSampleId != null and collectSampleId != '' ">
+            and user_id = #{collectSampleId}
+        </if>
+        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
+        <if test="collectSampleId != null and collectSampleId != '' ">
+            and collect_sample_id = #{collectSampleId}
+        </if>
+        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="bindStartDate != null and bindStartDate != '' ">
+            and create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
+            '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="bindEndDate != null and bindEndDate != '' ">
+            and create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%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
+        <if test="collectSampleId != null and collectSampleId != '' ">
+            and user_id = #{collectSampleId}
+        </if>
+        ) ttttt
+        on t.collectSampleId = ttttt.user_id
+        where t.orderNum > 0
+        order by t.orderNum desc
+    </select>
+
 </mapper>

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

@@ -2205,6 +2205,7 @@
         from user_promoters_count
         where media_id = 2) ttttt
         on t.collectSampleId = ttttt.user_id
+        where  t.orderNum > 0
         order by t.orderNum desc
     </select>
     <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">