Jelajahi Sumber

产品销售统计 添加 发货时间

xgb 4 minggu lalu
induk
melakukan
e77cd0b001

+ 24 - 11
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreStatisticsScrmController.java

@@ -219,22 +219,35 @@ public class FsStoreStatisticsScrmController extends BaseController
             List<Long> userIds = users.stream().map(element -> element.getUserId()).collect(Collectors.toList());
             param.setUsers(userIds.toArray(new Long[userIds.size()]));
         }
+
+        TimeUtils.TimeEntity timeEntity=TimeUtils.parseTimeTwo(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
+        // 判断 员工是否为空
+//        timeEntity.setCompanyUserId(param.getCompanyUserId());
+        timeEntity.setCompanyId(param.getCompanyId());
+//        timeEntity.setDeptId(param.getDeptId());
+        timeEntity.setOrderType(param.getOrderType());
+        timeEntity.setOrderMedium(param.getOrderMedium());
+        timeEntity.setUserIds(param.getUsers());
+        Map<String,Object> map = timeEntity.toMap();
+        map.put("queryType",param.getQueryType());
+        map.put("amountType",param.getAmountType());
+
         if(param.getUsers()!=null&&param.getUsers().length>0){
-            TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
-            timeEntity.setUserIds(param.getUsers());
-            Integer cycleNum = timeEntity.getCycleNum();
-            Integer beginTime = timeEntity.getBeginTime();
-            List<Integer> timeList = new ArrayList<>();
-            for (int i = 1; i <= cycleNum; i++) {
-                timeList.add(beginTime);
-                beginTime = TimeUtils.formatTime(beginTime);
-            }
-            List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(timeEntity.toMap());
+//            TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
+//            timeEntity.setUserIds(param.getUsers());
+//            Integer cycleNum = timeEntity.getCycleNum();
+//            Integer beginTime = timeEntity.getBeginTime();
+//            List<Integer> timeList = new ArrayList<>();
+//            for (int i = 1; i <= cycleNum; i++) {
+//                timeList.add(beginTime);
+//                beginTime = TimeUtils.formatTime(beginTime);
+//            }
+            List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(map);
             List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
             List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
             List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
             //表格数据
-            List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(timeEntity.toMap(),param.getDeptId());
+            List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(map,param.getDeptId());
             return R.ok().put("dates",dates).put("orderCount",orderCount).put("payPrice",payPrice).put("tableData",tableData);
         }
         else {

+ 13 - 10
fs-company/src/main/java/com/fs/hisStore/controller/FsStoreStatisticsScrmController.java

@@ -223,21 +223,24 @@ public class FsStoreStatisticsScrmController extends BaseController {
             param.setUsers(userIds.toArray(new Long[userIds.size()]));
         }
         if (param.getUsers() != null && param.getUsers().length > 0) {
-            TimeUtils.TimeEntity timeEntity = TimeUtils.parseTime(param.getType() == null ? null : param.getType().toString(), param.getStartTime(), param.getEndTime());
+            TimeUtils.TimeEntity timeEntity=TimeUtils.parseTimeTwo(param.getType()==null?null:param.getType().toString(),param.getStartTime(),param.getEndTime());
+            // 判断 员工是否为空
+//        timeEntity.setCompanyUserId(param.getCompanyUserId());
+            timeEntity.setCompanyId(param.getCompanyId());
+//        timeEntity.setDeptId(param.getDeptId());
+            timeEntity.setOrderType(param.getOrderType());
+            timeEntity.setOrderMedium(param.getOrderMedium());
             timeEntity.setUserIds(param.getUsers());
-            Integer cycleNum = timeEntity.getCycleNum();
-            Integer beginTime = timeEntity.getBeginTime();
-            List<Integer> timeList = new ArrayList<>();
-            for (int i = 1; i <= cycleNum; i++) {
-                timeList.add(beginTime);
-                beginTime = TimeUtils.formatTime(beginTime);
-            }
-            List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(timeEntity.toMap());
+            Map<String,Object> map = timeEntity.toMap();
+            map.put("queryType",param.getQueryType());
+            map.put("amountType",param.getAmountType());
+
+            List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(map);
             List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
             List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
             List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
             //表格数据
-            List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(timeEntity.toMap(), param.getDeptId());
+            List<FsStoreProductCountsVO> tableData = storeOrderService.selectFsStoreProductCountsByDept(map, param.getDeptId());
             return R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice).put("tableData", tableData);
         } else {
             return R.ok("未查找到数据");

+ 23 - 3
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -446,12 +446,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT  count(t.id ) AS orderCount,  t.type, sum(IFNULL(t.pay_price,0)) as payPrice
         FROM
         (
-        SELECT DATE_FORMAT( o.create_time, #{sqlDateFormat} ) AS type,  o.id,o.pay_price
+        SELECT
+            case when #{queryType}=2 then
+            DATE_FORMAT( o.delivery_send_time, #{sqlDateFormat} )
+            else
+            DATE_FORMAT( o.create_time, #{sqlDateFormat} )
+            end AS type,
+            o.id,o.pay_price
         FROM
         fs_store_order_scrm  AS o
         <where>
             o.status  &gt; 0 and
-            (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+            <choose>
+                <when test="queryType == null and queryType==1">
+                      (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+                </when>
+                <when test="queryType != null and queryType==2">
+                      (DATE_FORMAT(o.delivery_send_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+                </when>
+            </choose>
             <if test="userIds != null and userIds.length>0">
                 AND o.company_user_id IN
                 <foreach item="item" collection="userIds" open="(" separator="," close=")">
@@ -879,7 +892,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where i.product_id = #{productId}
         and o.`status` = 3
         and
-        (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+        <choose>
+            <when test="queryType == null and queryType==1">
+                  (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+            </when>
+            <when test="queryType != null and queryType==2">
+                  (DATE_FORMAT(o.delivery_send_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+            </when>
+        </choose>
         <if test="userIds != null and userIds.length>0">AND o.company_user_id IN
             <foreach item="item" collection="userIds" open="(" separator="," close=")">
                 #{item}