yumeng 1 년 전
부모
커밋
01eaadd9be

+ 109 - 70
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -191,20 +191,36 @@ public class SupplyChainController extends BaseController {
             @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
             @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("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
             @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort,
-            @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId
-
-    ) {
+            @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId) {
         Map<String, Object> requestMap = new HashMap<>();
-        if (!Check.isNull(orderStartDate)) {
-            Long start = DateUtils.getStartLongTime(orderStartDate);
-            requestMap.put("start", start);
+        if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
+            if (!Check.isNull(orderStartDate)) {
+                Long start = DateUtils.getStartLongTime(orderStartDate);
+                requestMap.put("start", start);
+            }
+            if (!Check.isNull(orderEndDate)) {
+                Long end = DateUtils.getEndLongTime(orderEndDate);
+                requestMap.put("end", end);
+            }
         }
-        if (!Check.isNull(orderEndDate)) {
-            Long end = DateUtils.getEndLongTime(orderEndDate);
-            requestMap.put("end", end);
+
+        if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
+            if (!Check.isNull(bindStartDate)) {
+                Long start = DateUtils.getStartLongTime(bindStartDate);
+                requestMap.put("start", start);
+                requestMap.put("bindStartDate", bindStartDate);
+            }
+            if (!Check.isNull(bindEndDate)) {
+                Long end = DateUtils.getEndLongTime(bindEndDate);
+                requestMap.put("end", end);
+                requestMap.put("bindEndDate", bindEndDate);
+            }
         }
+
         if (!Check.isNull(itemId)) {
             requestMap.put("itemId", itemId);
         }
@@ -225,11 +241,94 @@ public class SupplyChainController extends BaseController {
             return dataInfo;
         }
         startPage();
-        List<JSONObject> list = supplyChainService.itemList(requestMap);
+        List<JSONObject> list = new ArrayList<>();
+        if (!Check.isNull(orderStartDate) && !Check.isNull(orderEndDate)) {
+            list = supplyChainService.itemList(requestMap);
+        } else if (!Check.isNull(bindStartDate) && !Check.isNull(bindEndDate)) {
+            list = supplyChainService.itemBindList(requestMap);
+        }
+
         return getDataTable(list);
     }
 
 
+    @RequestMapping(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"))) {
+            Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
+            Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(requestJson.getString("bindStartDate"))) {
+            Long start = DateUtils.getStartLongTime(requestJson.getString("bindStartDate"));
+            requestMap.put("start", start);
+            requestMap.put("bindStartDate", requestJson.getString("bindStartDate"));
+        }
+        if (!Check.isNull(requestJson.getString("bindEndDate"))) {
+            Long end = DateUtils.getEndLongTime(requestJson.getString("bindEndDate"));
+            requestMap.put("end", end);
+            requestMap.put("bindEndDate", requestJson.getString("bindEndDate"));
+        }
+
+
+        if (!Check.isNull(requestJson.getString("promoterNickName"))) {
+            requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
+        }
+        if (!Check.isNull(requestJson.getLong("promoterId"))) {
+            requestMap.put("promoterId", requestJson.getLong("promoterId"));
+        }
+        if (!Check.isNull(requestJson.getLong("itemId"))) {
+            requestMap.put("itemId", requestJson.getLong("itemId"));
+        }
+        if (!Check.isNull(requestJson.getString("itemTitle"))) {
+            requestMap.put("itemTitle", requestJson.getString("itemTitle"));
+        }
+        if (!Check.isNull(requestJson.getLong("userId"))) {
+            requestMap.put("userId", requestJson.getLong("userId"));
+        }
+        List<JSONObject> list = new ArrayList<>();
+        if(!Check.isNull(requestJson.getString("orderStartDate")) && !Check.isNull(requestJson.getString("orderEndDate"))){
+            list = supplyChainService.exportOrder(requestMap);
+        }else if(!Check.isNull(requestJson.getString("bindStartDate")) && !Check.isNull(requestJson.getString("bindEndDate"))){
+            list = supplyChainService.exportBindOrder(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("userName"));
+                export.add(date.getLong("itemId"));
+                export.add(date.getString("itemTitle"));
+                export.add(date.getString("imageUrl"));
+                export.add(date.getString("itemCommissionRate"));
+                export.add(date.getInteger("orderNum"));
+                export.add(date.getInteger("validOrderNUm"));
+                export.add(date.getString("validRadio"));
+                export.add(date.getString("deliveryNum"));
+                export.add(date.getString("deliveryRadio"));
+                export.add(date.getString("notDeliveryNum"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"所属人", "商品ID", "商品名称", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
+        this.setResponseHeader(response, "订单信息.xls");
+        workbook.write(os);
+        os.flush();
+        os.close();
+    }
+
+
     /**
      * 根据商品id获取top达人
      *
@@ -822,66 +921,6 @@ public class SupplyChainController extends BaseController {
     }
 
 
-    @RequestMapping(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"))) {
-            Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
-            requestMap.put("start", start);
-        }
-        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
-            Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
-            requestMap.put("end", end);
-        }
-        if (!Check.isNull(requestJson.getString("promoterNickName"))) {
-            requestMap.put("promoterNickName", requestJson.getString("promoterNickName"));
-        }
-        if (!Check.isNull(requestJson.getLong("promoterId"))) {
-            requestMap.put("promoterId", requestJson.getLong("promoterId"));
-        }
-        if (!Check.isNull(requestJson.getLong("itemId"))) {
-            requestMap.put("itemId", requestJson.getLong("itemId"));
-        }
-        if (!Check.isNull(requestJson.getString("itemTitle"))) {
-            requestMap.put("itemTitle", requestJson.getString("itemTitle"));
-        }
-        if (!Check.isNull(requestJson.getLong("userId"))) {
-            requestMap.put("userId", requestJson.getLong("userId"));
-        }
-
-        List<JSONObject> list = supplyChainService.exportOrder(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("userName"));
-                export.add(date.getLong("itemId"));
-                export.add(date.getString("itemTitle"));
-                export.add(date.getString("imageUrl"));
-                export.add(date.getString("itemCommissionRate"));
-                export.add(date.getInteger("orderNum"));
-                export.add(date.getInteger("validOrderNUm"));
-                export.add(date.getString("validRadio"));
-                export.add(date.getString("deliveryNum"));
-                export.add(date.getString("deliveryRadio"));
-                export.add(date.getString("notDeliveryNum"));
-                exportList.add(export);
-            }
-        }
-        String[] headers = {"所属人", "商品ID", "商品名称", "商品封面", "佣金率", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数"};
-        OutputStream os = response.getOutputStream();
-        ExportExcelUtils eeu = new ExportExcelUtils();
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
-        this.setResponseHeader(response, "订单信息.xls");
-        workbook.write(os);
-        os.flush();
-        os.close();
-    }
-
-
     /**
      * 获取供应链人员列表
      *

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

@@ -17,6 +17,8 @@ public interface SupplyChainMapper {
 
     List<JSONObject> itemList(Map<String, Object> requestMap);
 
+    List<JSONObject> itemBindList(Map<String, Object> requestMap);
+
     List<JSONObject> getTopAnchors(Map<String, Object> requestMap);
 
     List<JSONObject> itemDetail(Map<String, Object> requestMap);
@@ -138,4 +140,6 @@ public interface SupplyChainMapper {
     List<JSONObject> getPromoterRatioListBytedance(Map<String, Object> requestMap);
 
     List<JSONObject> bdReportListV2ByBind(Map<String, Object> requestMap);
+
+    List<JSONObject> exportBindOrder(Map<String, Object> requestMap);
 }

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

@@ -17,6 +17,7 @@ public interface ISupplyChainService {
 
     //商品列表
     List<JSONObject> itemList(Map<String, Object> requestMap);
+    List<JSONObject> itemBindList(Map<String, Object> requestMap);
 
     //商品详情
     List<JSONObject> itemDetail(Map<String, Object> requestMap);
@@ -160,4 +161,7 @@ public interface ISupplyChainService {
     JSONObject selectOrderInfoBytedance(List<String> promoterIds, Long startDate, Long endDate);
 
     List<JSONObject> bdReportListV2ByBind(Map<String, Object> requestMap);
+
+
+    List<JSONObject> exportBindOrder(Map<String, Object> requestMap);
 }

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

@@ -76,6 +76,11 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     }
 
     @Override
+    public List<JSONObject> itemBindList(Map<String, Object> requestMap) {
+        return supplyChainMapper.itemBindList(requestMap);
+    }
+
+    @Override
     public List<JSONObject> itemDetail(Map<String, Object> requestMap) {
         return supplyChainMapper.itemDetail(requestMap);
     }
@@ -276,6 +281,11 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     }
 
     @Override
+    public List<JSONObject> exportBindOrder(Map<String, Object> requestMap) {
+        return supplyChainMapper.exportBindOrder(requestMap);
+    }
+
+    @Override
     public JSONObject getMonthOrderAmountTotal(Map<String, Object> map) {
         return supplyChainMapper.getMonthOrderAmountTotal(map);
     }

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

@@ -178,6 +178,54 @@
         order by ${fieId} ${sort}
     </select>
 
+
+    <select id="itemBindList" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
+        from kuaishou_item_list
+        where
+        create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
+        %H:%i:%s')
+        and
+        create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
+        %H:%i:%s')
+        ) t1
+        left join
+        (select item_id as 'itemId',
+        reserve_price as 'reservePrice',
+        item_title as 'itemTitle',
+        image_url as 'imageUrl',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),
+        4) as 'validRadio',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
+        when
+        order_status != 80
+        then 1
+        else 0 end),
+        4) as 'deliveryRadio',
+        item_commission_rate as 'itemCommissionRate'
+        from kuaishou_supply_chain t1
+        where order_create_time &gt;= #{start}
+        group by item_id) t2 on t1.itemId = t2.itemId
+        where 1 = 1
+        <if test="itemId != null and itemId != ''">
+            and t1.item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and t1.item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        <if test="userId != null and userId != ''">
+            and t1.userId = #{userId}
+        </if>
+        order by ${fieId} ${sort}
+
+    </select>
+
+
     <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
         select
         *
@@ -626,7 +674,7 @@
         sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
         round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
         from bytedance_order_list
-        where  author_short_id is not null
+        where author_short_id is not null
         <if test="start != null and start != ''">
             and pay_success_time &gt;= #{start}
         </if>
@@ -2302,4 +2350,41 @@
 
 
     </select>
+    <select id="exportBindOrder" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
+        from kuaishou_item_list
+        where
+        create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
+        %H:%i:%s')
+        and
+        create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
+        %H:%i:%s')
+        ) t1
+        left join
+        (select item_id as 'itemId',
+        image_url as 'imageUrl',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100, 2) as 'validRadio',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status
+        != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
+        round(item_commission_rate / 10,2) as 'itemCommissionRate'
+        from kuaishou_supply_chain
+        where order_create_time &gt;= #{start}
+        group by item_id) t2 on t1.itemId = t2.itemId
+        where 1 = 1
+        <if test="itemId != null and itemId != ''">
+            and t1.item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and t1.item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        <if test="userId != null and userId != ''">
+            and t1.userId = #{userId}
+        </if>
+         order by t2.orderNum desc
+    </select>
 </mapper>