Browse Source

工作台数据查询,渠道维度 (初版)

zhaoxian 2 years ago
parent
commit
77ef5b8906

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

@@ -346,7 +346,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     }
 
     public static Long getEndLongTime(String orderEndDate) {
-        String date = orderEndDate + " 23:60:00";
+        String date = orderEndDate + " 23:59:59";
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Long orderCreateTimeEnd = null;
         try {
@@ -380,7 +380,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     }
 
     public static Long getNowEndHourTemp(String dateStr, Integer hour) {
-        String date = dateStr + " " + hour + ":60:00";
+        String date = dateStr + " " + hour + ":59:59";
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Long orderCreateTimeEnd = null;
         try {

+ 26 - 9
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -6,13 +6,20 @@ import com.ruixuan.common.core.page.TableDataInfo;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.data.utils.ExportExcelUtils;
+import com.ruixuan.isc.service.IKuaishouPromoterService;
 import com.ruixuan.isc.service.ISupplyChainService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.SneakyThrows;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -20,7 +27,10 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/isv/supply_chain")
@@ -29,6 +39,9 @@ public class SupplyChainController extends BaseController {
     @Autowired
     private ISupplyChainService supplyChainService;
 
+    @Autowired
+    private IKuaishouPromoterService promoterService;
+
     /**
      * 达人订单
      *
@@ -516,9 +529,9 @@ public class SupplyChainController extends BaseController {
     @GetMapping("/indexOrderRank")
     @ApiOperation(value = "首页-商品排行")
     public TableDataInfo indexOrderRank(
-            @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
-            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
-            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
+            @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate) {
 
         Map<String, Object> requestMap = new HashMap<>();
         if (dateType == 0) {
@@ -563,12 +576,16 @@ public class SupplyChainController extends BaseController {
     @GetMapping("/indexPromoterRank")
     @ApiOperation(value = "首页-达人排行")
     public TableDataInfo indexPromoterRank(
-            @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType,
-            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
-            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
+            @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType,
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate,
+            @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId) {
 
         Map<String, Object> requestMap = new HashMap<>();
         if (dateType == 0) {
+            if (Check.isNotNull(userId)) {
+                requestMap.put("promoterIds", promoterService.selectPromoterIdList(userId));
+            }
             if (!Check.isNull(orderStartDate)) {
                 Long start = DateUtils.getStartLongTime(orderStartDate); //当天开始时间
                 requestMap.put("start", start);
@@ -1051,7 +1068,7 @@ public class SupplyChainController extends BaseController {
                 exportList.add(export);
             }
         }
-        String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "结算服务费收入","商品封面"};
+        String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "结算服务费收入", "商品封面"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();

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

@@ -426,6 +426,13 @@
         round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
         from kuaishou_supply_chain
         where 1= 1
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND promoter_id IN
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
             and order_create_time &gt;= #{nowStartHourTemp}
         </if>
@@ -439,6 +446,13 @@
         count(oid) as 'orderNum'
         from kuaishou_supply_chain
         where 1=1
+        <if test='promoterIds != null and promoterIds.size() > 0'>
+            AND promoter_id IN
+            <foreach collection="promoterIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
             and order_create_time &gt;= #{yesterdayStartHourTemp}
         </if>