Преглед на файлове

商城订单档期统计

wjj преди 2 седмици
родител
ревизия
87131ebe94

+ 31 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -1,9 +1,11 @@
 package com.fs.hisStore.controller;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
+import com.fs.common.constant.HttpStatus;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
@@ -24,9 +26,11 @@ import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.framework.web.service.TokenService;
 import com.fs.his.domain.FsUser;
+import com.fs.his.param.FsStoreOrderScheduleStatisticsParam;
 import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.vo.FsStoreOrderScheduleStatisticsVO;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -39,6 +43,7 @@ import com.fs.hisStore.enums.ShipperCodeEnum;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.*;
+import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +54,9 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -744,6 +752,29 @@ public class FsStoreOrderScrmController extends BaseController {
         return util.exportExcel(list, "订单员工维度统计");
     }
 
+    @GetMapping("/scheduleStatistics")
+    public TableDataInfo scheduleStatistics(FsStoreOrderScheduleStatisticsParam param){
+        PageHelper.startPage(param);
+        List<FsStoreOrderScheduleStatisticsVO> list = fsStoreOrderService.selectScheduleStatisticsVOList(param);
+        if (CollectionUtil.isNotEmpty(list)) {
+            for (FsStoreOrderScheduleStatisticsVO order : list) {
+                if (order.getShippingOrderCount() != 0 && order.getReceiveOrderCount() != 0){
+                    BigDecimal divide = new BigDecimal(order.getReceiveOrderCount()).divide(new BigDecimal(order.getShippingOrderCount()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+                    DecimalFormat df = new DecimalFormat("#.00");
+                    order.setReceiveOrderRate(df.format(divide)+"%");
+                } else {
+                    order.setReceiveOrderRate("0.00%");
+                }
+            }
+        }
+        TableDataInfo dataTable = new TableDataInfo();
+        dataTable.setCode(HttpStatus.SUCCESS);
+        dataTable.setMsg("查询成功");
+        dataTable.setRows(list);
+        dataTable.setTotal(fsStoreOrderService.selectScheduleStatisticsVOListCount(param));
+        return dataTable;
+    }
+
     /**
      * 对象列表类型转换
      */

+ 0 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -673,8 +673,6 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         fsPrescribe.setCreateTime(DateUtils.getNowDate());
         fsPrescribe.setUsageJson("{}");
         fsPrescribe.setDiagnose(fsPackage.getTags());
-        //医生操作开始时间
-        fsPrescribe.setStartOperateTime(DateUtils.getNowDate());
         FsPrescribeUsageDTO fsPrescribeUsageDTO = new FsPrescribeUsageDTO();
         if (fsPackage.getProductType()==2){
             fsPrescribeUsageDTO.setCounts(fsPackage.getCounts()+0L);

+ 9 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -11,8 +11,10 @@ import com.fs.company.param.CompanyStatisticsParam;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
+import com.fs.his.param.FsStoreOrderScheduleStatisticsParam;
 import com.fs.his.vo.FsStoreOrderAmountScrmStatsDetailVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.his.vo.FsStoreOrderScheduleStatisticsVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.ReportScrm;
@@ -1224,4 +1226,11 @@ public interface FsStoreOrderScrmMapper
 
     @Select("SELECT order_id FROM fs_store_order_scrm WHERE `status` = 2 AND refund_status = 0")
     List<Long> selectSyncExpressScrm();
+
+
+    //订单档期统计
+    List<FsStoreOrderScheduleStatisticsVO> selectScheduleStatisticsScrmVOList(@Param("map") FsStoreOrderScheduleStatisticsParam param);
+
+    //订单档期统计数量
+    Long selectScheduleStatisticsScrmVOListCount(@Param("map") FsStoreOrderScheduleStatisticsParam param);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -15,7 +15,9 @@ import com.fs.erp.domain.ErpOrder;
 import com.fs.his.domain.FsStorePayment;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.param.FsStoreOrderSalesParam;
+import com.fs.his.param.FsStoreOrderScheduleStatisticsParam;
 import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.his.vo.FsStoreOrderScheduleStatisticsVO;
 import com.fs.his.vo.FsStoreOrderStatsRowVo;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
@@ -302,4 +304,8 @@ public interface IFsStoreOrderScrmService
      * 查询app商城订单金额统计信息
      * */
     List<FsStoreOrderStatsRowVo> selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
+
+    List<FsStoreOrderScheduleStatisticsVO> selectScheduleStatisticsVOList(FsStoreOrderScheduleStatisticsParam param);
+
+    Long selectScheduleStatisticsVOListCount(FsStoreOrderScheduleStatisticsParam param);
 }

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -59,6 +59,7 @@ import com.fs.his.enums.FsStoreOrderLogEnum;
 import com.fs.his.enums.FsStoreOrderStatusEnum;
 import com.fs.his.mapper.*;
 import com.fs.his.param.FsStoreOrderSalesParam;
+import com.fs.his.param.FsStoreOrderScheduleStatisticsParam;
 import com.fs.his.service.IFsOrderSopLogService;
 import com.fs.his.service.IFsPrescribeService;
 import com.fs.his.service.IFsUserWatchService;
@@ -4591,4 +4592,14 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
         return rows;
     }
+
+    @Override
+    public List<FsStoreOrderScheduleStatisticsVO> selectScheduleStatisticsVOList(FsStoreOrderScheduleStatisticsParam param) {
+        return fsStoreOrderMapper.selectScheduleStatisticsScrmVOList(param);
+    }
+
+    @Override
+    public Long selectScheduleStatisticsVOListCount(FsStoreOrderScheduleStatisticsParam param) {
+        return fsStoreOrderMapper.selectScheduleStatisticsScrmVOListCount(param);
+    }
 }

+ 70 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -1055,4 +1055,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND company_user_id = #{companyUserId}
         </if>
     </select>
+
+
+    <select id="selectScheduleStatisticsScrmVOList" resultType="com.fs.his.vo.FsStoreOrderScheduleStatisticsVO">
+        SELECT dis.*,cd.dept_name FROM
+        (
+        SELECT
+        (SELECT dept_id  FROM company_user WHERE user_id = o.company_user_id) as dept_id,
+        CASE
+        WHEN o.tag_names IS NULL OR JSON_LENGTH(o.tag_names) = 0 THEN '无档期'
+        ELSE JSON_UNQUOTE(JSON_EXTRACT(o.tag_names, CONCAT('$[', idx, ']')))
+        END AS tagName,
+        SUM(o.pay_price) as shippingOrderAmount,
+        COUNT(*) as shippingOrderCount,
+        SUM(case WHEN (o.`status` = 1 OR o.`status` = 2) THEN o.pay_price ELSE 0 END) as transitOrderAmount,
+        SUM(case WHEN (o.`status` = 2 OR o.`status` = 2) THEN 1 ELSE 0 END) as transitOrderCount,
+        SUM(CASE WHEN o.delivery_type = '404' THEN o.pay_price ELSE 0 END) AS rejectOrderAmount,
+        SUM(CASE WHEN o.delivery_type = '404' THEN 1 ELSE 0 END) AS rejectOrderCount,
+        SUM(CASE WHEN o.delivery_status = 3 THEN o.pay_price ELSE 0 END) AS receiveOrderAmount,
+        SUM(CASE WHEN o.delivery_status = 3 THEN 1 ELSE 0 END) AS receiveOrderCount,
+        o.company_user_id
+        FROM fs_store_order_scrm o
+        LEFT JOIN (
+        SELECT 0 AS idx UNION SELECT 1 UNION SELECT 2 UNION SELECT 3
+        ) AS indices ON idx &lt; JSON_LENGTH(COALESCE(o.tag_names, '[]'))
+        WHERE o.company_user_id IS NOT null AND o.company_user_id != 1 AND o.`status` != -1 AND o.`status` != -2 AND o.`status` != -3 AND o.company_user_id IS NOT NULL
+        GROUP BY tagName,dept_id) as dis
+        LEFT JOIN company_dept cd ON dis.dept_id = cd.dept_id
+        where 1 = 1
+        <if test="map.tagName != null and map.tagName != '' ">
+            and dis.tagName = #{map.tagName}
+        </if>
+        <if test="map.deptId != null ">
+            and cd.dept_id = #{map.deptId}
+        </if>
+        GROUP BY dis.tagName,dis.dept_id
+    </select>
+
+    <select id="selectScheduleStatisticsScrmVOListCount" resultType="java.lang.Long">
+        SELECT count(*) FROM
+        (
+        SELECT
+        (SELECT dept_id  FROM company_user WHERE user_id = o.company_user_id) as dept_id,
+        CASE
+        WHEN o.tag_names IS NULL OR JSON_LENGTH(o.tag_names) = 0 THEN '无档期'
+        ELSE JSON_UNQUOTE(JSON_EXTRACT(o.tag_names, CONCAT('$[', idx, ']')))
+        END AS tagName,
+        SUM(o.pay_price) as shippingOrderAmount,
+        COUNT(*) as shippingOrderCount,
+        SUM(case WHEN (o.`status` = 1 OR o.`status` = 2) THEN o.pay_price ELSE 0 END) as transitOrderAmount,
+        SUM(case WHEN (o.`status` = 1 OR o.`status` = 2) THEN 1 ELSE 0 END) as transitOrderCount,
+        SUM(CASE WHEN o.delivery_type = '404' THEN o.pay_price ELSE 0 END) AS rejectOrderAmount,
+        SUM(CASE WHEN o.delivery_type = '404' THEN 1 ELSE 0 END) AS rejectOrderCount,
+        SUM(CASE WHEN o.delivery_status = 3 THEN o.pay_price ELSE 0 END) AS receiveOrderAmount,
+        SUM(CASE WHEN o.delivery_status = 3 THEN 1 ELSE 0 END) AS receiveOrderCount,
+        o.company_user_id
+        FROM fs_store_order_scrm o
+        LEFT JOIN (
+        SELECT 0 AS idx UNION SELECT 1 UNION SELECT 2 UNION SELECT 3
+        ) AS indices ON idx &lt; JSON_LENGTH(COALESCE(o.tag_names, '[]'))
+        WHERE o.company_user_id IS NOT null AND o.company_user_id != 1 AND o.`status` != -1 AND o.`status` != -2 AND o.`status` != -3 AND o.company_user_id IS NOT NULL
+        GROUP BY tagName,dept_id) as dis
+        LEFT JOIN company_dept cd ON dis.dept_id = cd.dept_id
+        where 1 = 1
+        <if test="map.tagName != null and map.tagName != '' ">
+            and dis.tagName = #{map.tagName}
+        </if>
+        <if test="map.deptId != null ">
+            and cd.dept_id = #{map.deptId}
+        </if>
+    </select>
 </mapper>