Explorar o código

导出添加订单roi

zhaoxian hai 9 meses
pai
achega
40253f355e

+ 83 - 25
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -105,7 +105,7 @@ public class SupplyChainController extends BaseController {
             //下个周期的结束时间
             String lastTimeEnd = map.get("lastTimeEnd");
             //当前小时
-            Integer hour = DateUtils.getNowHour() - 1;
+            Integer hour = DateUtils.getNowHour();
             //当天 yyyy-MM-dd
             String today = DateUtils.getNowDateStr();
             if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
@@ -255,7 +255,7 @@ public class SupplyChainController extends BaseController {
             //下个周期的结束时间
             String lastTimeEnd = map.get("lastTimeEnd");
             //当前小时
-            Integer hour = DateUtils.getNowHour() - 1;
+            Integer hour = DateUtils.getNowHour();
             //当天 yyyy-MM-dd
             String today = DateUtils.getNowDateStr();
             if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
@@ -304,16 +304,34 @@ public class SupplyChainController extends BaseController {
     }
 
 
-    @RequestMapping(value = "/exportOrder")
+    @PostMapping("/exportOrder")
+    @ApiOperation(value = "exportOrder")
     @ResponseBody
     public void exportOrder(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
         Map<String, Object> requestMap = new HashMap<>();
-        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
+        if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
             requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
-        }
-        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
             requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
+
+            //根据本阶段日期 获取上阶段 开始 和 截至 日期
+            Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate"));
+            //下个周期的开始时间
+            String lastTimeStart = map.get("lastTimeStart");
+            //下个周期的结束时间
+            String lastTimeEnd = map.get("lastTimeEnd");
+            //当前小时
+            Integer hour = DateUtils.getNowHour();
+            //当天 yyyy-MM-dd
+            String today = DateUtils.getNowDateStr();
+            if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) {
+                hour = 23;
+            }
+            requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
+            requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
+            requestMap.put("hour", hour);
         }
+
+
         if (!Check.isNull(requestJson.getString("bindStartDate"))) {
             requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("bindStartDate")));
             requestMap.put("bindStartDate", requestJson.getString("bindStartDate"));
@@ -338,11 +356,14 @@ public class SupplyChainController extends BaseController {
         if (!Check.isNull(requestJson.getLong("userId"))) {
             requestMap.put("userId", requestJson.getLong("userId"));
         }
+        String[] headers = null;
         List<JSONObject> list = new ArrayList<>();
         if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
             list = supplyChainService.exportOrder(requestMap);
+            headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "订单数环比", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
         } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
             list = supplyChainService.exportBindOrder(requestMap);
+            headers = new String[]{"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
         }
 
         List<List<Object>> exportList = new ArrayList<>();
@@ -357,6 +378,9 @@ public class SupplyChainController extends BaseController {
                 export.add(date.getString("imageUrl"));
                 export.add(date.getString("itemCommissionRate"));
                 export.add(date.getInteger("orderNum"));
+                if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
+                    export.add(date.getString("orderNumRoi"));
+                }
                 export.add(date.getInteger("validOrderNUm"));
                 export.add(date.getString("validRadio"));
                 export.add(date.getString("deliveryNum"));
@@ -371,7 +395,6 @@ public class SupplyChainController extends BaseController {
                 exportList.add(export);
             }
         }
-        String[] headers = {"所属人", "商品ID", "商品名称", "是否预售", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数", "ccr", "小店星级", "店铺物流分", "店铺评分", "店铺服务分", "店铺质量分"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();
@@ -593,7 +616,7 @@ public class SupplyChainController extends BaseController {
             }
             JSONObject orderTotal = supplyChainService.getOrderTotal(requestMap);
             returnJson.put("orderTotal", orderTotal);
-            Integer hour = DateUtils.getNowHour() - 1; // 当前小时
+            Integer hour = DateUtils.getNowHour(); // 当前小时
             if (hour >= 0) {
                 JSONObject ratioJson = new JSONObject();
                 Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳
@@ -655,7 +678,7 @@ public class SupplyChainController extends BaseController {
             }
             JSONObject amountTotal = supplyChainService.getAmountTotal(requestMap);
             returnJson.put("amountTotal", amountTotal);
-            Integer hour = DateUtils.getNowHour() - 1; // 当前小时
+            Integer hour = DateUtils.getNowHour(); // 当前小时
             if (hour >= 0) {
                 JSONObject amountRatioJson = new JSONObject();
                 Long nowStartHourTemp = DateUtils.strDateToInt(orderStartDate); // 当天开始时间
@@ -892,16 +915,32 @@ public class SupplyChainController extends BaseController {
         }
     }
 
-    @RequestMapping(value = "/exportPromoterTotal")
+    @PostMapping("/exportPromoterTotal")
+    @ApiOperation(value = "exportPromoterTotal")
     @ResponseBody
     public void exportPromoterTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
 
         Map<String, Object> requestMap = new HashMap<>();
-        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
+        if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
             requestMap.put("start", DateUtils.strDateToInt(requestJson.getString("orderStartDate")));
-        }
-        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
             requestMap.put("end", DateUtils.strDateToInt(requestJson.getString("orderEndDate")));
+
+            //根据本阶段日期 获取上阶段 开始 和 截至 日期
+            Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderEndDate"));
+            //下个周期的开始时间
+            String lastTimeStart = map.get("lastTimeStart");
+            //下个周期的结束时间
+            String lastTimeEnd = map.get("lastTimeEnd");
+            //当前小时
+            Integer hour = DateUtils.getNowHour();
+            //当天 yyyy-MM-dd
+            String today = DateUtils.getNowDateStr();
+            if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderEndDate")) && requestJson.getString("orderStartDate").equals(today))) {
+                hour = 23;
+            }
+            requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
+            requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
+            requestMap.put("hour", hour);
         }
         if (!Check.isNull(requestJson.getString("promoterNickName"))) {
             requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
@@ -935,6 +974,7 @@ public class SupplyChainController extends BaseController {
                 }
 
                 export.add(date.getInteger("orderNum"));
+                export.add(date.getString("orderNumRoi"));
                 export.add(date.getInteger("validOrderNUm"));
                 export.add(date.getString("validRadio"));
                 export.add(date.getString("payAmount"));
@@ -994,9 +1034,9 @@ public class SupplyChainController extends BaseController {
         }
         String[] headers = {};
         if (ownershipId.equals("miaogousi") || ownershipId.equals("yufu")) {
-            headers = new String[]{"达人ID", "达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
+            headers = new String[]{"达人ID", "达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
         } else {
-            headers = new String[]{"达人名称", "订单数", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
+            headers = new String[]{"达人名称", "订单数", "订单数环比", "有效订单数", "有效订单率", "GVM", "有效GMV", "发货数", "发货率", "未发货数", "绑定人"};
         }
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
@@ -1238,7 +1278,7 @@ public class SupplyChainController extends BaseController {
             //下个周期的结束时间
             String lastTimeEnd = map.get("lastTimeEnd");
             //当前小时
-            Integer hour = DateUtils.getNowHour() - 1;
+            Integer hour = DateUtils.getNowHour();
             //当天 yyyy-MM-dd
             String today = DateUtils.getNowDateStr();
             if (!(orderStartDate.equals(orderEndDate) && orderStartDate.equals(today))) {
@@ -1282,16 +1322,27 @@ public class SupplyChainController extends BaseController {
             @RequestBody JSONObject requestJson
     ) throws IOException {
         Map<String, Object> requestMap = new HashMap<>();
-        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
-            Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
-            requestMap.put("start", start);
+        if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
             requestMap.put("startDate", requestJson.getString("orderStartDate"));
-
-        }
-        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
-            Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
-            requestMap.put("end", end);
             requestMap.put("endDate", requestJson.getString("orderEndDate") + " 23:59:59");
+
+
+            //根据本阶段日期 获取上阶段 开始 和 截至 日期
+            Map<String, String> map = DateUtils.getStartEndTime(requestJson.getString("orderStartDate"), requestJson.getString("orderStartDate"));
+            //下个周期的开始时间
+            String lastTimeStart = map.get("lastTimeStart");
+            //下个周期的结束时间
+            String lastTimeEnd = map.get("lastTimeEnd");
+            //当前小时
+            Integer hour = DateUtils.getNowHour();
+            //当天 yyyy-MM-dd
+            String today = DateUtils.getNowDateStr();
+            if (!(requestJson.getString("orderStartDate").equals(requestJson.getString("orderStartDate")) && requestJson.getString("orderStartDate").equals(today))) {
+                hour = 23;
+            }
+            requestMap.put("lastTimeStart", DateUtils.strDateToInt(lastTimeStart));
+            requestMap.put("lastTimeEnd", DateUtils.strDateToInt(lastTimeEnd));
+            requestMap.put("hour", hour);
         }
 
         if (!Check.isNull(requestJson.getString("bindStartDate"))) {
@@ -1310,11 +1361,16 @@ public class SupplyChainController extends BaseController {
         if (!Check.isNull(requestJson.getString("userId"))) {
             requestMap.put("userId", requestJson.getString("userId"));
         }
+        String[] headers = null;
         List<JSONObject> list = new ArrayList<>();
         if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
             list = supplyChainService.exportAdminReportList(requestMap);
+            headers = new String[]{"招商", "商品数", "发样数", "订单数", "订单数环比", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
+
         } else if (!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))) {
             list = supplyChainService.exportAdminReportListByBind(requestMap);
+            headers = new String[]{"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
+
         }
 
         List<List<Object>> exportList = new ArrayList<>();
@@ -1326,6 +1382,9 @@ public class SupplyChainController extends BaseController {
                 export.add(date.getString("itemCount"));
                 export.add(date.getString("sendSampleCount"));
                 export.add(date.getString("orderNum"));
+                if (!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))) {
+                    export.add(date.getString("orderNumRoi"));
+                }
                 export.add(date.getString("validOrderNUm"));
                 export.add(date.getString("validRadio"));
                 export.add(date.getString("deliveryNum"));
@@ -1338,7 +1397,6 @@ public class SupplyChainController extends BaseController {
                 exportList.add(export);
             }
         }
-        String[] headers = {"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入", "平均服务费率"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();

+ 4 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -463,7 +463,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         JSONObject order = new JSONObject();
 
         //当前小时
-        Integer hour2 = DateUtils.getNowHour() - 1;
+        Integer hour2 = DateUtils.getNowHour();
         //当天 yyyy-MM-dd
         String today = DateUtils.getNowDateStr();
 
@@ -508,7 +508,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
         Date date = new Date();
         //当前小时
-        Integer hour = DateUtils.getNowHour() - 1;
+        Integer hour = DateUtils.getNowHour();
         //昨天
         String yesterday = DateUtils.getSubtractTime(date, 1);
         //上周的同一天(上个近七天的结束日期)
@@ -608,7 +608,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         if (Check.isNotNull(itemIds)) {
             JSONObject order = null;
             //当前小时
-            Integer hour2 = DateUtils.getNowHour() - 1;
+            Integer hour2 = DateUtils.getNowHour();
             //当天
             String today = DateUtils.getNowDateStr();
             //根据本阶段日期 获取上阶段 开始 和 截至 日期
@@ -652,7 +652,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
 
             Date date = new Date();
             //当前小时
-            Integer hour = DateUtils.getNowHour() - 1;
+            Integer hour = DateUtils.getNowHour();
 
             //昨天
             String yesterday = DateUtils.getSubtractTime(date, 1);

+ 73 - 10
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -37,7 +37,7 @@
 
     <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
         select t.*,t2.userName,
-        ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2) as 'orderNumRoi'
+        IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
         from (
         select promoter_id as 'promoterId',
         promoter_nick_name as 'promoterNickName',
@@ -200,7 +200,7 @@
         t1.item_title as 'itemTitle',
         t1.image_url as 'imageUrl',
         count(t1.oid) as 'orderNum',
-        ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2) as 'orderNumRoi',
+        IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
         sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
         round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
         sum(case when t1.send_status = 1 then 1 else 0 end) as 'deliveryNum',
@@ -844,7 +844,8 @@
     </select>
 
     <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
-        select *
+        select t.*,
+        IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
         from (
         select
         promoter_id as 'promoterId',
@@ -861,7 +862,7 @@
         round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as
         'regimentalPromotionAmount'
         from kuaishou_supply_chain
-        where 1= 1
+        where stat_hour &lt;= #{hour}
         <if test="start != null and start != ''">
             and stat_date &gt;= #{start}
         </if>
@@ -881,6 +882,31 @@
             and item_title like concat(concat('%',#{itemTitle}),'%')
         </if>
         group by promoter_id) t
+        left join (
+        select promoter_id as 'promoterId',
+        count(oid) as 'orderNum'
+        from kuaishou_supply_chain
+        where stat_hour &lt;= #{hour}
+        <if test="lastTimeStart != null and lastTimeStart != ''">
+            and stat_date &gt;= #{lastTimeStart}
+        </if>
+        <if test="lastTimeEnd != null and lastTimeEnd != ''">
+            and stat_date &lt;= #{lastTimeEnd}
+        </if>
+        <if test="promoterId != null and promoterId != ''">
+            and promoter_id = #{promoterId}
+        </if>
+        <if test="promoterNickName != null and promoterNickName != ''">
+            and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        group by promoter_id
+        ) t3 on t.promoterId = t3.promoterId
         order by t.orderNum desc
 
     </select>
@@ -934,6 +960,7 @@
         t1.item_title as 'itemTitle',
         t1.image_url as 'imageUrl',
         count(t1.oid) as 'orderNum',
+        IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
         sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
         round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
         sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
@@ -964,7 +991,26 @@
         on t1.item_id = t4.item_id
         left join kuaishou_item_list t5
         on t1.item_id = t5.item_id
-        where 1 = 1
+        left join (
+        select
+        item_id as 'itemId',
+        count(oid) as 'orderNum'
+        from kuaishou_supply_chain
+        where stat_hour &lt;= #{hour}
+        <if test="lastTimeStart != null and lastTimeStart != ''">
+            and stat_date &gt;= #{lastTimeStart}
+        </if>
+        <if test="lastTimeEnd != null and lastTimeEnd != ''">
+            and stat_date &lt;= #{lastTimeEnd}
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        group by item_id) t6 on t1.item_id = t6.itemId
+        where t1.stat_hour &lt;= #{hour}
         <if test="start != null and start != ''">
             and t1.stat_date &gt;= #{start}
         </if>
@@ -1049,7 +1095,7 @@
     <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
         select t.*,
                t1.sendSampleCount,
-               ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2) as 'orderNumRoi'
+        IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
         from (select t1.user_id as 'userId',
         t1.user_name as 'userName',
         count(distinct t2.item_id) as 'itemCount',
@@ -2396,7 +2442,9 @@
 
     </select>
     <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
-        select *
+        select t.*,
+        t1.sendSampleCount,
+        IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
         from (select t1.user_id as 'userId',
         t1.user_name as 'userName',
         count(distinct t2.item_id) as 'itemCount',
@@ -2423,11 +2471,11 @@
         from kuaishou_item_bind_user t1
         left join kuaishou_supply_chain t2
         on t1.item_id = t2.item_id
-        where 1= 1
-        <if test="start != null and start != ''">
+        where t2.stat_hour &lt;= #{hour}
+        <if test="startDate != null and startDate != ''">
             and t2.stat_date &gt;= DATE_FORMAT(#{startDate},'%Y%m%d')
         </if>
-        <if test="end != null and end != ''">
+        <if test="endDate != null and endDate != ''">
             and t2.stat_date &lt;= DATE_FORMAT(#{endDate},'%Y%m%d')
         </if>
         group by t1.user_id) t left join (
@@ -2437,6 +2485,21 @@
         group by item_create_id
 
         ) t1 on t.userId = t1.item_create_id
+        left join (
+        select t1.user_id as 'userId',
+        count(t2.oid) as 'orderNum'
+        from kuaishou_item_bind_user t1
+        left join kuaishou_supply_chain t2
+        on t1.item_id = t2.item_id
+        where  t2.stat_hour &lt;= #{hour}
+        <if test="lastTimeStart != null and lastTimeStart != ''">
+            and t2.stat_date &gt;= #{lastTimeStart}
+        </if>
+        <if test="lastTimeEnd != null and lastTimeEnd != ''">
+            and t2.stat_date &lt;= #{lastTimeEnd}
+        </if>
+        group by t1.user_id
+        ) t3 on t.userId = t3.userId
         where 1 =1
         <if test="userId != null and userId != ''">
             and t.userId = #{userId}