浏览代码

Merge remote-tracking branch 'origin/master_feat_ysy_20250929' into master_feat_ysy_20250929

# Conflicts:
#	fs-service/src/main/java/com/fs/his/service/impl/PrescriptionImageServiceImpl.java
zx 4 天之前
父节点
当前提交
76529aee7a

+ 5 - 6
fs-admin/src/main/java/com/fs/company/controller/CompanyStatisticsController.java

@@ -23,8 +23,7 @@ import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.dto.FsStoreOrderAmountStatsQueryDto;
 import com.fs.his.dto.FsStoreOrderAmountStatsQueryDto;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.service.IFsStorePaymentService;
-import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
-import com.fs.his.vo.FsStoreOrderAmountStatsVo;
+import com.fs.his.vo.FsStoreOrderStatsRowVo;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -657,8 +656,8 @@ public class CompanyStatisticsController extends BaseController
      * */
      * */
     @GetMapping("/hisOrderCountStats")
     @GetMapping("/hisOrderCountStats")
     public AjaxResult getHisOrderCount(FsStoreOrderAmountStatsQueryDto statsQueryDto){
     public AjaxResult getHisOrderCount(FsStoreOrderAmountStatsQueryDto statsQueryDto){
-        FsStoreOrderAmountStatsVo fsStoreOrderAmountStatsVo = storeOrderService.selectFsStoreOrderAmountStats(statsQueryDto);
-        return AjaxResult.success(fsStoreOrderAmountStatsVo);
+        List<FsStoreOrderStatsRowVo> fsStoreOrderStatsRowVos = storeOrderService.selectFsStoreOrderAmountStats(statsQueryDto);
+        return AjaxResult.success(fsStoreOrderStatsRowVos);
     }
     }
 
 
     /**
     /**
@@ -666,8 +665,8 @@ public class CompanyStatisticsController extends BaseController
      * */
      * */
     @GetMapping("/appOrderCountStats")
     @GetMapping("/appOrderCountStats")
     public AjaxResult getAppOrderCount(FsStoreOrderAmountScrmStatsQueryDto statsQueryDto){
     public AjaxResult getAppOrderCount(FsStoreOrderAmountScrmStatsQueryDto statsQueryDto){
-        FsStoreOrderAmountScrmStatsVo scrmStatsVo = fsStoreOrderScrmService.selectFsStoreOrderAmountScrmStats(statsQueryDto);
-        return AjaxResult.success(scrmStatsVo);
+        List<FsStoreOrderStatsRowVo> fsStoreOrderStatsRowVos = fsStoreOrderScrmService.selectFsStoreOrderAmountScrmStats(statsQueryDto);
+        return AjaxResult.success(fsStoreOrderStatsRowVos);
     }
     }
 
 
 }
 }

+ 1 - 1
fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java

@@ -1196,5 +1196,5 @@ public interface FsStoreOrderMapper
     List<FsStoreOrderScrm> selectOrdersBy2();
     List<FsStoreOrderScrm> selectOrdersBy2();
 
 
 
 
-    FsStoreOrderAmountStatsVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto);
+    FsStoreOrderAmountStatsDetailVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto);
 }
 }

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/IFsStoreOrderService.java

@@ -275,5 +275,5 @@ public interface IFsStoreOrderService
     /**
     /**
      * 查询互联网医院订单金额统计信息
      * 查询互联网医院订单金额统计信息
      * */
      * */
-    FsStoreOrderAmountStatsVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto);
+    List<FsStoreOrderStatsRowVo> selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto);
 }
 }

+ 45 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -1705,7 +1705,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 if (order.getTotalPrice().compareTo(minThreshold) >= 0) {
                 if (order.getTotalPrice().compareTo(minThreshold) >= 0) {
                     //根据用户id获取fs_user表对应的下单次数并更新
                     //根据用户id获取fs_user表对应的下单次数并更新
                     FsUser user = fsUserMapper.selectFsUserById(order.getUserId());
                     FsUser user = fsUserMapper.selectFsUserById(order.getUserId());
-                    user.setOrderCount(user.getOrderCount() + 1);
+                    //处理 orderCount 为 null 的情况:null 视为 0
+                    long currentCount = user.getOrderCount() != null ? user.getOrderCount() : 0;
+                    user.setOrderCount(currentCount + 1);
                     fsUserMapper.updateFsUser(user);
                     fsUserMapper.updateFsUser(user);
                 }
                 }
             } catch (Exception ex) {
             } catch (Exception ex) {
@@ -4542,7 +4544,47 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
 //    }
 //    }
 
 
     @Override
     @Override
-    public FsStoreOrderAmountStatsVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto) {
-        return fsStoreOrderMapper.selectFsStoreOrderAmountStats(queryDto);
+    public List<FsStoreOrderStatsRowVo> selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto) {
+        // 1. 查询聚合明细(单行)
+        FsStoreOrderAmountStatsDetailVo  detail = fsStoreOrderMapper.selectFsStoreOrderAmountStats(queryDto);
+        List<FsStoreOrderStatsRowVo> rows = new ArrayList<>();
+
+        // 1. 全款订单
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("全款订单");
+            setOrderCount(detail.getFullPayOrderCount());
+            setOrderAmount(detail.getFullPayOrderAmount());
+            setDepositAmount(detail.getFullPayActualAmount());
+            setCodAmount(detail.getFullPayCodAmount());
+        }});
+
+        // 2. 物流代收(总)
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("物流代收");
+            setOrderCount(detail.getCodOrderCount());
+            setOrderAmount(detail.getCodOrderAmount());
+            setDepositAmount(detail.getDepositAmount());
+            setCodAmount(detail.getCodAmount());
+        }});
+
+        // 3. 付定金物流代收
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("付定金");
+            setOrderCount(detail.getDepositCodOrderCount());
+            setOrderAmount(detail.getDepositCodOrderAmount());
+            setDepositAmount(detail.getDepositCodDepositAmount());
+            setCodAmount(detail.getDepositCodCodAmount());
+        }});
+
+        // 4. 0定金物流代收
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("0定金");
+            setOrderCount(detail.getNoDepositCodOrderCount());
+            setOrderAmount(detail.getNoDepositCodOrderAmount());
+            setDepositAmount(BigDecimal.ZERO);
+            setCodAmount(detail.getNoDepositCodCodAmount());
+        }});
+
+        return rows;
     }
     }
 }
 }

+ 129 - 27
fs-service/src/main/java/com/fs/his/service/impl/PrescriptionImageServiceImpl.java

@@ -244,8 +244,9 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
     }
     }
 
 
     /**
     /**
-     * 绘制药品列表
-     * @return 返回最后一行的Y坐标
+     * 绘制药品列表(每药两行:第一行药名规格数量,第二行用法用量)
+     * 药品内部两行之间无空行,每个药品(包括最后一个)之后都加一个空白行
+     * @return 返回最后一行的Y坐标(即最后一个空白行之后的位置)
      */
      */
     public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
     public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
         if (drugs == null || drugs.isEmpty()) {
         if (drugs == null || drugs.isEmpty()) {
@@ -253,48 +254,149 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
         }
         }
 
 
         int x = 133;
         int x = 133;
-        int y = 728;
-        int lineHeight = 30;
+        int y = 680;
 
 
-        for (FsPrescribeDrug drug : drugs) {
-            // 格式: 药品名 规格 用法 频次 每次用量 x 数量
-            StringBuilder sb = new StringBuilder();
+        // 行高设置(可根据实际字体微调)
+        int innerLineSpacing = 40;  // 药品内部两行之间的间距(含呼吸感,避免粘连)
+        int blankLine = 40;         // 药品之间的空白行(比内部稍大,形成视觉分组)
 
 
+        for (FsPrescribeDrug drug : drugs) {
+            // ========== 第一行:药名 + 规格 + 数量 ==========
+            StringBuilder line1 = new StringBuilder();
             if (StringUtils.isNotBlank(drug.getDrugName())) {
             if (StringUtils.isNotBlank(drug.getDrugName())) {
-                sb.append(drug.getDrugName()).append(" ");
+                line1.append(drug.getDrugName());
             }
             }
             if (StringUtils.isNotBlank(drug.getDrugSpec())) {
             if (StringUtils.isNotBlank(drug.getDrugSpec())) {
-                sb.append(drug.getDrugSpec()).append(" ");
-            }
-            if (StringUtils.isNotBlank(drug.getUsageMethod())) {
-                sb.append(drug.getUsageMethod()).append(" ");
+                line1.append(" ").append(drug.getDrugSpec());
             }
             }
-            if (StringUtils.isNotBlank(drug.getUsageFrequencyUnit())) {
-                sb.append(drug.getUsageFrequencyUnit()).append(" ");
+            if (drug.getDrugNum() != null) {
+                line1.append("x").append(drug.getDrugNum());
+                if (StringUtils.isNotBlank(drug.getDrugUnit())) {
+                    line1.append(drug.getDrugUnit()).append("。");
+                }
             }
             }
-            if (StringUtils.isNotBlank(drug.getUsagePerUseCount())) {
-                sb.append(drug.getUsagePerUseCount());
+
+            String firstLine = line1.toString().trim();
+            if (StringUtils.isNotBlank(firstLine)) {
+                y = drawDrugTextLine(pen, firstLine, x, y, 1000, innerLineSpacing);
             }
             }
-            if (StringUtils.isNotBlank(drug.getUsagePerUseUnit())) {
-                sb.append(drug.getUsagePerUseUnit()).append(" ");
+            y += innerLineSpacing; // 第一行占位(即使无内容也占)
+
+            // ========== 第二行:用法用量 ==========
+            StringBuilder line2 = new StringBuilder();
+            if (StringUtils.isNotBlank(drug.getUsageMethod())) {
+                line2.append("用法用量:").append(drug.getUsageMethod());
             }
             }
-            if (drug.getDrugNum() != null) {
-                sb.append("x ").append(drug.getDrugNum());
+            if (StringUtils.isNotBlank(drug.getUsagePerUseCount())) {
+                line2.append(",").append(drug.getUsagePerUseCount());
+                if (StringUtils.isNotBlank(drug.getUsagePerUseUnit())) {
+                    line2.append(drug.getUsagePerUseUnit());
+                }
             }
             }
-            if (StringUtils.isNotBlank(drug.getDrugUnit())) {
-                sb.append(drug.getDrugUnit());
+            if (StringUtils.isNotBlank(drug.getUsageFrequencyUnit())) {
+                line2.append(",").append(drug.getUsageFrequencyUnit()).append("。");
             }
             }
 
 
-            String drugInfo = sb.toString().trim();
-            if (StringUtils.isNotBlank(drugInfo)) {
-                y = drawMultiLineText(pen, drugInfo, x, y, 1000);
-                y += lineHeight;
+            String secondLine = line2.toString().trim();
+            if (StringUtils.isNotBlank(secondLine)) {
+                y = drawDrugTextLine(pen, secondLine, x, y, 1000, innerLineSpacing);
             }
             }
+            y += innerLineSpacing; // 第二行占位(即使无内容也占)
+
+            // ========== 每个药品之后(包括最后一个)加一个空白行 ==========
+            y += blankLine;
         }
         }
 
 
         return y;
         return y;
     }
     }
 
 
+    /**
+     * 专用于药品列表的文本绘制:支持自动换行,返回最后一行文本的基线 Y 坐标
+     * 不额外增加行高,由调用方控制换行(如 y += innerLineSpacing)
+     */
+    private int drawDrugTextLine(Graphics2D pen, String text, int x, int y, int maxWidth, int lineHeight) {
+        if (StringUtils.isBlank(text)) {
+            return y;
+        }
+
+        FontMetrics fm = pen.getFontMetrics();
+        StringBuilder currentLine = new StringBuilder();
+        int currentY = y;
+
+        for (char c : text.toCharArray()) {
+            String testLine = currentLine.toString() + c;
+            int testWidth = fm.stringWidth(testLine);
+
+            // 如果加上当前字符会超宽,且当前行已有内容,则换行
+            if (testWidth > maxWidth && currentLine.length() > 0) {
+                pen.drawString(currentLine.toString(), x, currentY);
+                currentY += lineHeight; // 使用固定 lineHeight 换行
+                currentLine = new StringBuilder().append(c);
+            } else {
+                currentLine.append(c);
+            }
+        }
+
+        // 绘制最后一行(不额外增加 lineHeight)
+        if (currentLine.length() > 0) {
+            pen.drawString(currentLine.toString(), x, currentY);
+        }
+
+        return currentY;
+    }
+
+//    /**
+//     * 绘制药品列表
+//     * @return 返回最后一行的Y坐标
+//     */
+//    public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
+//        if (drugs == null || drugs.isEmpty()) {
+//            return 330;
+//        }
+//
+//        int x = 133;
+//        int y = 728;
+//        int lineHeight = 30;
+//
+//        for (FsPrescribeDrug drug : drugs) {
+//            // 格式: 药品名 规格 用法 频次 每次用量 x 数量
+//            StringBuilder sb = new StringBuilder();
+//
+//            if (StringUtils.isNotBlank(drug.getDrugName())) {
+//                sb.append(drug.getDrugName()).append(" ");
+//            }
+//            if (StringUtils.isNotBlank(drug.getDrugSpec())) {
+//                sb.append(drug.getDrugSpec()).append(" ");
+//            }
+//            if (StringUtils.isNotBlank(drug.getUsageMethod())) {
+//                sb.append(drug.getUsageMethod()).append(" ");
+//            }
+//            if (StringUtils.isNotBlank(drug.getUsageFrequencyUnit())) {
+//                sb.append(drug.getUsageFrequencyUnit()).append(" ");
+//            }
+//            if (StringUtils.isNotBlank(drug.getUsagePerUseCount())) {
+//                sb.append(drug.getUsagePerUseCount());
+//            }
+//            if (StringUtils.isNotBlank(drug.getUsagePerUseUnit())) {
+//                sb.append(drug.getUsagePerUseUnit()).append(" ");
+//            }
+//            if (drug.getDrugNum() != null) {
+//                sb.append("x ").append(drug.getDrugNum());
+//            }
+//            if (StringUtils.isNotBlank(drug.getDrugUnit())) {
+//                sb.append(drug.getDrugUnit());
+//            }
+//
+//            String drugInfo = sb.toString().trim();
+//            if (StringUtils.isNotBlank(drugInfo)) {
+//                y = drawMultiLineText(pen, drugInfo, x, y, 760);
+//                y += lineHeight;
+//            }
+//        }
+//
+//        return y;
+//    }
+
 
 
     /**
     /**
      * 绘制医嘱
      * 绘制医嘱
@@ -329,7 +431,7 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
         // 药师签名
         // 药师签名
         if (StringUtils.isNotBlank(param.getDrugDoctorUrl())) {
         if (StringUtils.isNotBlank(param.getDrugDoctorUrl())) {
             try {
             try {
-                BufferedImage pharmacistSign = downloadSignatureImage("https://ysy-1329817240.cos.ap-guangzhou.myqcloud.com/ysy/20251021/be7ef2dda6d94b6c97c9b41bdb3a9cb8.png");
+                BufferedImage pharmacistSign = downloadSignatureImage("https://ysy-1329817240.cos.ap-guangzhou.myqcloud.com/ysy/20251028/ed509381390049c9ad2a17e95d8b8732.png");
                 if (pharmacistSign != null) {
                 if (pharmacistSign != null) {
                     Image scaledSign = pharmacistSign.getScaledInstance(120, 80, Image.SCALE_SMOOTH);
                     Image scaledSign = pharmacistSign.getScaledInstance(120, 80, Image.SCALE_SMOOTH);
                     pen.drawImage(scaledSign, 1076, 1528, null);
                     pen.drawImage(scaledSign, 1076, 1528, null);

+ 34 - 0
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderAmountScrmStatsDetailVo.java

@@ -0,0 +1,34 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+@Data
+public class FsStoreOrderAmountScrmStatsDetailVo {
+
+    // 1. 订单总数
+    private Integer totalOrderCount;
+
+    // 2. 全款订单
+    private Integer fullPayOrderCount;
+    private BigDecimal fullPayOrderAmount;
+    private BigDecimal fullPayActualAmount;
+    private BigDecimal fullPayCodAmount; // 应为0,但保留结构一致
+
+    // 3. 物流代收(总)
+    private Integer codOrderCount;
+    private BigDecimal codOrderAmount;
+    private BigDecimal depositAmount;
+    private BigDecimal codAmount;
+
+    // 4. 付定金物流代收
+    private Integer depositCodOrderCount;
+    private BigDecimal depositCodOrderAmount;
+    private BigDecimal depositCodDepositAmount;
+    private BigDecimal depositCodCodAmount;
+
+    // 5. 0定金物流代收
+    private Integer noDepositCodOrderCount;
+    private BigDecimal noDepositCodOrderAmount;
+    private BigDecimal noDepositCodCodAmount;
+}

+ 0 - 44
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderAmountScrmStatsVo.java

@@ -1,44 +0,0 @@
-package com.fs.his.vo;
-
-import lombok.Data;
-
-import java.math.BigDecimal;
-/**
- *  app商城订单金额统计Vo对象
- * */
-@Data
-public class FsStoreOrderAmountScrmStatsVo {
-    /**
-     * 订单总数
-     * */
-    private Integer totalOrderCount;
-    /**
-     * 全款支付订单数
-     * */
-    private Integer fullPayOrderCount;
-    /**
-     * 物流代收支付订单数
-     * */
-    private Integer codOrderCount;
-
-    /**
-     * 付定金的物流代收订单数
-     * */
-    private Integer depositCodOrderCount;
-    /**
-     * 0定金的物流代收订单数
-     * */
-    private Integer noDepositCodOrderCount;
-    /**
-     * 订单总金额
-     * */
-    private BigDecimal totalOrderAmount;
-    /**
-     * 定金总金额
-     * */
-    private BigDecimal depositAmount;
-    /**
-     * 物流代收总金额
-     * */
-    private BigDecimal codAmount;
-}

+ 38 - 0
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderAmountStatsDetailVo.java

@@ -0,0 +1,38 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+/**
+ * 互联网医院订单金额统计 - 详细聚合结果(单行)
+ * 对应你那个包含所有 CASE WHEN 的 SQL 查询
+ */
+@Data
+public class FsStoreOrderAmountStatsDetailVo {
+
+    // 1. 订单总数
+    private Integer totalOrderCount;
+
+    // 2. 全款订单 (pay_type = 1)
+    private Integer fullPayOrderCount;
+    private BigDecimal fullPayOrderAmount;      // pay_price
+    private BigDecimal fullPayActualAmount;     // pay_money
+    private BigDecimal fullPayCodAmount;        // pay_remain
+
+    // 3. 物流代收订单总数 (pay_type IN (2,3))
+    private Integer codOrderCount;
+    private BigDecimal codOrderAmount;          // pay_price
+    private BigDecimal depositAmount;           // pay_money(定金)
+    private BigDecimal codAmount;               // pay_remain(尾款)
+
+    // 4. 付定金的物流代收 (pay_type IN (2,3) AND pay_money > 0)
+    private Integer depositCodOrderCount;
+    private BigDecimal depositCodOrderAmount;
+    private BigDecimal depositCodDepositAmount;
+    private BigDecimal depositCodCodAmount;
+
+    // 5. 0元定金物流代收 (pay_type IN (2,3) AND pay_money = 0)
+    private Integer noDepositCodOrderCount;
+    private BigDecimal noDepositCodOrderAmount;
+    private BigDecimal noDepositCodCodAmount;
+}

+ 0 - 44
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderAmountStatsVo.java

@@ -1,44 +0,0 @@
-package com.fs.his.vo;
-
-import lombok.Data;
-
-import java.math.BigDecimal;
-/**
- *  互联网医院订单金额统计Vo对象
- * */
-@Data
-public class FsStoreOrderAmountStatsVo {
-    /**
-     * 订单总数
-     * */
-    private Integer totalOrderCount;
-    /**
-     * 全款支付订单数
-     * */
-    private Integer fullPayOrderCount;
-    /**
-     * 物流代收支付订单数
-     * */
-    private Integer codOrderCount;
-
-    /**
-     * 付定金的物流代收订单数
-     * */
-    private Integer depositCodOrderCount;
-    /**
-     * 0定金的物流代收订单数
-     * */
-    private Integer noDepositCodOrderCount;
-    /**
-     * 订单总金额
-     * */
-    private BigDecimal totalOrderAmount;
-    /**
-     * 定金总金额
-     * */
-    private BigDecimal depositAmount;
-    /**
-     * 物流代收总金额
-     * */
-    private BigDecimal codAmount;
-}

+ 25 - 0
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderStatsRowVo.java

@@ -0,0 +1,25 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+import java.math.BigDecimal;
+
+/**
+ * 订单统计表格中的一行数据
+ */
+@Data
+public class FsStoreOrderStatsRowVo {
+    /** 类别名称,如"全款订单"、"物流代收(总)"等 */
+    private String category;
+
+    /** 订单数量 */
+    private Integer orderCount;
+
+    /** 订单总金额(pay_price) */
+    private BigDecimal orderAmount;
+
+    /** 定金金额(pay_money) */
+    private BigDecimal depositAmount;
+
+    /** 物流代收金额(pay_remain) */
+    private BigDecimal codAmount;
+}

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

@@ -11,7 +11,7 @@ import com.fs.company.param.CompanyStatisticsParam;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
-import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
+import com.fs.his.vo.FsStoreOrderAmountScrmStatsDetailVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
 import com.fs.his.vo.FsStoreOrderExcelVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
@@ -1220,5 +1220,5 @@ public interface FsStoreOrderScrmMapper
             "</script>"})
             "</script>"})
     int updateFsStoreOrderByOrderCode(FsStoreOrderScrm fsStoreOrder);
     int updateFsStoreOrderByOrderCode(FsStoreOrderScrm fsStoreOrder);
 
 
-    FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
+    FsStoreOrderAmountScrmStatsDetailVo selectFsStoreOrderAmountScrmStatsDetail(FsStoreOrderAmountScrmStatsQueryDto queryDto);
 }
 }

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

@@ -15,8 +15,8 @@ import com.fs.erp.domain.ErpOrder;
 import com.fs.his.domain.FsStorePayment;
 import com.fs.his.domain.FsStorePayment;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
 import com.fs.his.param.FsStoreOrderSalesParam;
 import com.fs.his.param.FsStoreOrderSalesParam;
-import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
 import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.his.vo.FsStoreOrderStatsRowVo;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
 import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -301,5 +301,5 @@ public interface IFsStoreOrderScrmService
     /**
     /**
      * 查询app商城订单金额统计信息
      * 查询app商城订单金额统计信息
      * */
      * */
-    FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
+    List<FsStoreOrderStatsRowVo> selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
 }
 }

+ 48 - 6
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -63,16 +63,19 @@ import com.fs.his.service.IFsPrescribeService;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.service.IFsUserWatchService;
 import com.fs.his.service.IFsUserWatchService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.ConfigUtil;
-import com.fs.his.vo.FsInquiryOrderVO;
-import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
-import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.his.vo.*;
+import com.fs.his.vo.FsPrescribeVO;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.constants.ErpTypeEnum;
 import com.fs.hisStore.constants.ErpTypeEnum;
 import com.fs.hisStore.dto.*;
 import com.fs.hisStore.dto.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.vo.*;
 import com.fs.hisStore.vo.*;
-import com.fs.his.vo.FsPrescribeVO;
+import com.fs.hisStore.vo.FsStoreOrderExportVO;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.hisStore.vo.FsStoreOrderVO;
+import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
+import com.fs.hisStore.vo.FsStoreProductDeliverExcelVO;
 import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.RecipeDetailParam;
 import com.fs.hisapi.param.RecipeDetailParam;
@@ -4453,7 +4456,46 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     }
     }
 
 
     @Override
     @Override
-    public FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto) {
-        return fsStoreOrderMapper.selectFsStoreOrderAmountScrmStats(queryDto);
+    public List<FsStoreOrderStatsRowVo> selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto) {
+        FsStoreOrderAmountScrmStatsDetailVo detail = fsStoreOrderMapper.selectFsStoreOrderAmountScrmStatsDetail(queryDto);
+        List<FsStoreOrderStatsRowVo> rows = new ArrayList<>();
+
+        // 1. 全款订单
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("全款订单");
+            setOrderCount(detail.getFullPayOrderCount());
+            setOrderAmount(detail.getFullPayOrderAmount());
+            setDepositAmount(detail.getFullPayActualAmount());
+            setCodAmount(detail.getFullPayCodAmount());
+        }});
+
+        // 2. 物流代收(总)
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("物流代收");
+            setOrderCount(detail.getCodOrderCount());
+            setOrderAmount(detail.getCodOrderAmount());
+            setDepositAmount(detail.getDepositAmount());
+            setCodAmount(detail.getCodAmount());
+        }});
+
+        // 3. 付定金物流代收
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("付定金");
+            setOrderCount(detail.getDepositCodOrderCount());
+            setOrderAmount(detail.getDepositCodOrderAmount());
+            setDepositAmount(detail.getDepositCodDepositAmount());
+            setCodAmount(detail.getDepositCodCodAmount());
+        }});
+
+        // 4. 0定金物流代收
+        rows.add(new FsStoreOrderStatsRowVo() {{
+            setCategory("0定金");
+            setOrderCount(detail.getNoDepositCodOrderCount());
+            setOrderAmount(detail.getNoDepositCodOrderAmount());
+            setDepositAmount(BigDecimal.ZERO);
+            setCodAmount(detail.getNoDepositCodCodAmount());
+        }});
+
+        return rows;
     }
     }
 }
 }

+ 25 - 15
fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml

@@ -2038,23 +2038,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND pay_time &lt; DATE_ADD(STR_TO_DATE(#{map.payTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
             AND pay_time &lt; DATE_ADD(STR_TO_DATE(#{map.payTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
         </if>
         </if>
     </select>
     </select>
-    <select id="selectFsStoreOrderAmountStats" resultType="com.fs.his.vo.FsStoreOrderAmountStatsVo">
+    <select id="selectFsStoreOrderAmountStats" resultType="com.fs.his.vo.FsStoreOrderAmountStatsDetailVo">
         SELECT
         SELECT
-        COUNT(*) AS totalOrderCount,
-        COUNT(CASE WHEN pay_type = '1' THEN 1 END) AS fullPayOrderCount,
-        COUNT(CASE WHEN pay_type IN ('2', '3') THEN 1 END) AS codOrderCount,
-        COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN 1 END) AS depositCodOrderCount,
-        COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) =0 THEN 1 END) AS noDepositCodOrderCount,
-        SUM(pay_price) AS totalOrderAmount,
-        SUM(
-        CASE
-        WHEN pay_type IN ('2', '3')
-        THEN COALESCE(pay_money, 0)
-        ELSE 0
-        END
-        ) AS depositAmount,
+        -- 1. 订单总数
+        COUNT(*) AS totalOrderCount, -- 订单总数
 
 
-        SUM(COALESCE(pay_remain, 0)) AS codAmount
+        -- 2. 全款订单 (pay_type = 1)
+        COUNT(CASE WHEN pay_type = '1' THEN 1 END) AS fullPayOrderCount, -- 全款支付订单数
+        SUM(CASE WHEN pay_type = '1' THEN COALESCE(pay_price, 0) ELSE 0 END) AS fullPayOrderAmount, -- 全款订单总金额(应收)
+        SUM(CASE WHEN pay_type = '1' THEN COALESCE(pay_money, 0) ELSE 0 END) AS fullPayActualAmount, -- 全款订单实际支付金额(通常等于应收)
+        SUM(CASE WHEN pay_type = '1' THEN COALESCE(pay_remain, 0) ELSE 0 END) AS fullPayCodAmount, -- 全款订单物流代收金额(理论上应为0)
+
+        -- 3. 物流代收订单总数 (pay_type IN (2,3))
+        COUNT(CASE WHEN pay_type IN ('2', '3') THEN 1 END) AS codOrderCount, -- 物流代收支付订单总数(含定金/0定金)
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_price, 0) ELSE 0 END) AS codOrderAmount, -- 物流代收订单总应收金额(pay_price)
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_money, 0) ELSE 0 END) AS depositAmount, -- 物流代收订单定金总金额(已付部分)
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_remain, 0) ELSE 0 END) AS codAmount, -- 物流代收订单尾款总金额(待收部分)
+
+        -- 4. 付定金的物流代收 (pay_type IN (2,3) AND pay_money > 0)
+        COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN 1 END) AS depositCodOrderCount, -- 付定金的物流代收订单数
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN COALESCE(pay_price, 0) ELSE 0 END) AS depositCodOrderAmount, -- 付定金物流代收订单总应收金额
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN COALESCE(pay_money, 0) ELSE 0 END) AS depositCodDepositAmount, -- 付定金物流代收订单定金总金额
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN COALESCE(pay_remain, 0) ELSE 0 END) AS depositCodCodAmount, -- 付定金物流代收订单尾款总金额
+
+        -- 5. 0元定金物流代收 (pay_type IN (2,3) AND pay_money = 0)
+        COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN 1 END) AS noDepositCodOrderCount, -- 0定金的物流代收订单数
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN COALESCE(pay_price, 0) ELSE 0 END) AS noDepositCodOrderAmount, -- 0定金物流代收订单总应收金额
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN COALESCE(pay_remain, 0) ELSE 0 END) AS noDepositCodCodAmount -- 0定金物流代收订单尾款总金额
 
 
         FROM fs_store_order
         FROM fs_store_order
         WHERE is_del = 0 AND status > 1
         WHERE is_del = 0 AND status > 1

+ 3 - 0
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -604,6 +604,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="courseMaOpenId != null">course_ma_open_id,</if>
             <if test="courseMaOpenId != null">course_ma_open_id,</if>
             <if test="qwExtId != null">qw_ext_id,</if>
             <if test="qwExtId != null">qw_ext_id,</if>
             <if test="companyId != null">company_id,</if>
             <if test="companyId != null">company_id,</if>
+            <if test="orderCount != null">order_count,</if>
             <if test="companyUserId != null">company_user_id,</if>
             <if test="companyUserId != null">company_user_id,</if>
          </trim>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -646,6 +647,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="courseMaOpenId != null">#{courseMaOpenId},</if>
             <if test="courseMaOpenId != null">#{courseMaOpenId},</if>
             <if test="qwExtId != null">#{qwExtId},</if>
             <if test="qwExtId != null">#{qwExtId},</if>
             <if test="companyId != null">#{companyId},</if>
             <if test="companyId != null">#{companyId},</if>
+            <if test="orderCount != null">#{orderCount},</if>
             <if test="companyUserId != null">#{companyUserId},</if>
             <if test="companyUserId != null">#{companyUserId},</if>
          </trim>
          </trim>
     </insert>
     </insert>
@@ -693,6 +695,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="courseMaOpenId != null">course_ma_open_id = #{courseMaOpenId},</if>
             <if test="courseMaOpenId != null">course_ma_open_id = #{courseMaOpenId},</if>
             <if test="parentId != null">parent_id = #{parentId},</if>
             <if test="parentId != null">parent_id = #{parentId},</if>
             <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
             <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
+            <if test="orderCount != null">order_count = #{orderCount},</if>
             <if test="companyId != null">company_id = #{companyId},</if>
             <if test="companyId != null">company_id = #{companyId},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
         </trim>
         </trim>

+ 31 - 7
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -972,21 +972,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{item}
             #{item}
     </foreach>
     </foreach>
     </select>
     </select>
-    <select id="selectFsStoreOrderAmountScrmStats" resultType="com.fs.his.vo.FsStoreOrderAmountScrmStatsVo">
+    <select id="selectFsStoreOrderAmountScrmStatsDetail"
+            resultType="com.fs.his.vo.FsStoreOrderAmountScrmStatsDetailVo">
         SELECT
         SELECT
+        -- 1. 订单总数
         COUNT(*) AS totalOrderCount,
         COUNT(*) AS totalOrderCount,
+
+        -- 2. 全款订单 (pay_type = '1')
         COUNT(CASE WHEN pay_type = '1' THEN 1 END) AS fullPayOrderCount,
         COUNT(CASE WHEN pay_type = '1' THEN 1 END) AS fullPayOrderCount,
+        SUM(CASE WHEN pay_type = '1' THEN COALESCE(pay_price, 0) ELSE 0 END) AS fullPayOrderAmount,
+        SUM(CASE WHEN pay_type = '1' THEN COALESCE(pay_money, 0) ELSE 0 END) AS fullPayActualAmount,
+        SUM(CASE WHEN pay_type = '1' THEN
+        COALESCE(pay_price, 0) - COALESCE(pay_money, 0)
+        ELSE 0 END) AS fullPayCodAmount,  -- 全款订单理论上 pay_remain = 0,但按逻辑计算
+
+        -- 3. 物流代收订单总数 (pay_type IN ('2', '3'))
         COUNT(CASE WHEN pay_type IN ('2', '3') THEN 1 END) AS codOrderCount,
         COUNT(CASE WHEN pay_type IN ('2', '3') THEN 1 END) AS codOrderCount,
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_price, 0) ELSE 0 END) AS codOrderAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_money, 0) ELSE 0 END) AS depositAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') THEN
+        COALESCE(pay_price, 0) - COALESCE(pay_money, 0)
+        ELSE 0 END) AS codAmount,
+
+        -- 4. 付定金的物流代收 (pay_type IN ('2','3') AND pay_money > 0)
         COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN 1 END) AS depositCodOrderCount,
         COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN 1 END) AS depositCodOrderCount,
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN COALESCE(pay_price, 0) ELSE 0 END) AS depositCodOrderAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN COALESCE(pay_money, 0) ELSE 0 END) AS depositCodDepositAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) > 0 THEN
+        COALESCE(pay_price, 0) - COALESCE(pay_money, 0)
+        ELSE 0 END) AS depositCodCodAmount,
+
+        -- 5. 0元定金物流代收 (pay_type IN ('2','3') AND pay_money = 0)
         COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN 1 END) AS noDepositCodOrderCount,
         COUNT(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN 1 END) AS noDepositCodOrderCount,
-        SUM(pay_price) AS totalOrderAmount,
-        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_money, 0) ELSE 0 END) AS depositAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN COALESCE(pay_price, 0) ELSE 0 END) AS noDepositCodOrderAmount,
+        SUM(CASE WHEN pay_type IN ('2', '3') AND COALESCE(pay_money, 0) = 0 THEN
+        COALESCE(pay_price, 0) - COALESCE(pay_money, 0)
+        ELSE 0 END) AS noDepositCodCodAmount
 
 
-        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_price, 0) ELSE 0 END)
-        -
-        SUM(CASE WHEN pay_type IN ('2', '3') THEN COALESCE(pay_money, 0) ELSE 0 END) AS codAmount
         FROM fs_store_order_scrm
         FROM fs_store_order_scrm
-        WHERE is_del = 0 AND status > 0
+        WHERE is_del = 0 AND status > 1
         <if test="startTime != null and startTime !=''">
         <if test="startTime != null and startTime !=''">
             AND create_time &gt;= #{startTime}
             AND create_time &gt;= #{startTime}
         </if>
         </if>