yumeng 2 éve
szülő
commit
9d3b5260a0

+ 7 - 0
ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java

@@ -345,6 +345,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return orderCreateTimeStart;
     }
 
+
+    public static Integer getIntegerTime(String date) {
+        String replace = date.replace("-", "");
+        return Integer.valueOf(replace);
+    }
+
+
     public static Long getEndLongTime(String orderEndDate) {
         String date = orderEndDate + " 23:59:59";
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

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

@@ -1229,4 +1229,147 @@ public class SupplyChainController extends BaseController {
         }
     }
 
+
+    @GetMapping("/bdReportList")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdReportList(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("用户ID") @RequestParam(value = "userId", 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.bdReportList(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/bdDetailList")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdDetailList(
+            @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.bdDetailList(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/bdTotal")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo bdTotal(
+            @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.bdTotal(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @PostMapping("/exportBdDetail")
+    @ApiOperation(value = "认领商品列表")
+    @ResponseBody
+    public void exportBdDetail(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.exportBdDetail(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();
+    }
+
+
+
 }

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

@@ -86,4 +86,12 @@ public interface SupplyChainMapper {
     List<JSONObject> getMonthOrderAmountByItems(Map<String, Object> map);
 
     JSONObject getMonthOrderAmountTotalByItems(Map<String, Object> map);
+
+    List<JSONObject> bdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdDetailList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdTotal(Map<String, Object> requestMap);
+
+    List<JSONObject> exportBdDetail(Map<String, Object> requestMap);
 }

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

@@ -109,4 +109,12 @@ public interface ISupplyChainService {
     List<JSONObject> getMonthOrderAmountByItems(Map<String, Object> map);
 
     JSONObject getMonthOrderAmountTotalByItems(Map<String, Object> map);
+
+    List<JSONObject> bdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdDetailList(Map<String, Object> requestMap);
+
+    List<JSONObject> bdTotal(Map<String, Object> requestMap);
+
+    List<JSONObject> exportBdDetail(Map<String, Object> requestMap);
 }

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

@@ -215,4 +215,24 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     public JSONObject getMonthOrderAmountTotalByItems(Map<String, Object> map) {
         return supplyChainMapper.getMonthOrderAmountTotalByItems(map);
     }
+
+    @Override
+    public List<JSONObject> bdReportList(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdReportList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> bdDetailList(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdDetailList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> bdTotal(Map<String, Object> requestMap) {
+        return supplyChainMapper.bdTotal(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> exportBdDetail(Map<String, Object> requestMap) {
+        return supplyChainMapper.exportBdDetail(requestMap);
+    }
 }

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

@@ -1255,4 +1255,188 @@
         AND order_create_time &lt;= #{endLong}
         )t2 ON 1=1
     </select>
+
+
+    <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t1.collectSampleId,
+        t1.collectSampleName,
+        t2.promoterCount,
+        t3.sampleCount,
+        round(t3.sampleCount / promoterCount * 100, 3) as 'sampleRate',
+        t2.promoterCount - t3.sampleCount as 'notSampleCount',
+        t1.orderNum,
+        t1.validOrderNum,
+        t1.validOrderRate,
+        t1.orderAmount,
+        t1.regimentalPromotionAmount,
+        t1.totalRegimentalSettleAmount
+        from (
+        select collect_sample_id as 'collectSampleId',
+        collect_sample_name as 'collectSampleName',
+        sum(order_num) as 'orderNum',
+        sum(valid_order_num) as 'validOrderNum',
+        round(sum(valid_order_num) / sum(order_num) * 100, 3) as 'validOrderRate',
+        sum(order_amount) as 'orderAmount',
+        sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
+        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
+        from ruixuan.canal_management
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and collect_sample_id = #{collectSampleId}
+        </if>
+        group by collect_sample_id) t1
+        left join (
+        select user_id as 'userId',
+        count(distinct promoter_id) as 'promoterCount'
+        from kuaishou_promoter
+        group by user_id) t2
+        on t1.collectSampleId = t2.userId
+        left join (
+        select collect_sample_id as 'collectSampleId',
+        count(distinct promoter_id) as 'sampleCount'
+        from kuaishou_item_collect_samples
+        where collect_sample_status > 2
+        group by collect_sample_id) t3
+        on t2.userId = t3.collectSampleId
+        order by t1.orderNum desc
+    </select>
+    <select id="bdDetailList" 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 promoter_id as 'promoterId',
+        promoter_name as 'promoterName',
+        promoter_url as 'promoterUrl',
+        sum(order_num) as 'orderNum',
+        sum(valid_order_num) as 'validOrderNum',
+        round(sum(valid_order_num) / sum(order_num) * 100, 3) as 'validOrderRate',
+        sum(order_amount) as 'orderAmount',
+        sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
+        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
+        from ruixuan.canal_management
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and collect_sample_id = #{collectSampleId}
+        </if>
+        group by promoter_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}
+    </select>
+    <select id="bdTotal" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t2.sampleCount,
+        t1.orderNum,
+        t1.validOrderNum,
+        t1.validOrderRate,
+        t1.orderAmount,
+        t1.regimentalPromotionAmount,
+        t1.totalRegimentalSettleAmount
+        from (
+        select
+        sum(order_num) as 'orderNum',
+        sum(valid_order_num) as 'validOrderNum',
+        round(sum(valid_order_num) / sum(order_num) * 100, 3) as 'validOrderRate',
+        sum(order_amount) as 'orderAmount',
+        sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
+        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
+        from ruixuan.canal_management
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and collect_sample_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
+
+    </select>
+    <select id="exportBdDetail" 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 promoter_id as 'promoterId',
+        promoter_name as 'promoterName',
+        promoter_url as 'promoterUrl',
+        sum(order_num) as 'orderNum',
+        sum(valid_order_num) as 'validOrderNum',
+        round(sum(valid_order_num) / sum(order_num) * 100, 3) as 'validOrderRate',
+        sum(order_amount) as 'orderAmount',
+        sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
+        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
+        from ruixuan.canal_management
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="collectSampleId != null and collectSampleId != ''">
+            and collect_sample_id = #{collectSampleId}
+        </if>
+        group by promoter_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  t1.orderNum desc
+    </select>
 </mapper>