Quellcode durchsuchen

财务管理报表改动/智能手表改动

wangxy vor 1 Woche
Ursprung
Commit
f6de52d5ae

+ 11 - 0
fs-company/src/main/java/com/fs/company/controller/store/FsExternalOrderController.java

@@ -100,6 +100,17 @@ public class FsExternalOrderController extends BaseController {
             fsExternalOrder.setDeliveryStatusUpdateTime(new Date());
             fsExternalOrder.setDeliveryStatusUpdateBy(loginUser.getUser().getUserName());
         }
+        // 回款时间=update_time:已回款必须填写回款时间;非已回款清空回款时间
+        if (fsExternalOrder.getStatus() != null) {
+            if (fsExternalOrder.getStatus() == 4) {
+                if (fsExternalOrder.getUpdateTime() == null) {
+                    return AjaxResult.error("选择已回款时,回款时间不能为空");
+                }
+            } else {
+                fsExternalOrder.getParams().put("clearUpdateTime", true);
+                fsExternalOrder.setUpdateTime(null);
+            }
+        }
         return toAjax(fsExternalOrderService.updateFsExternalOrder(fsExternalOrder));
     }
 

+ 43 - 23
fs-company/src/main/java/com/fs/company/controller/store/FsFinanceOrderController.java

@@ -102,32 +102,27 @@ public class FsFinanceOrderController extends BaseController {
                 continue;
             }
 
-//            BigDecimal totalPrice = order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO;
-//            BigDecimal collectionPrice = order.getCollectionPrice();
-//            BigDecimal importReturnPrice = dto.getReturnPrice() != null ? dto.getReturnPrice() : BigDecimal.ZERO;
-//
-//            // 回款金额与代收金额一致性校验
-//            if (collectionPrice.compareTo(importReturnPrice) != 0) {
-//                failList.add(new FsFinanceOrderImportFailDTO(
-//                        order.getOrderCode(), order.getDeliverySn(),
-//                        totalPrice, collectionPrice, importReturnPrice,
-//                        "回款金额与代收金额不一致"));
-//                continue;
-//            }
-
-            // 更新回款信息
+            // 回款金额与代收金额一致性校验
+            String amountMsg = validateReturnPriceMatch(order, dto.getReturnPrice());
+            if (amountMsg != null) {
+                BigDecimal totalPrice = order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO;
+                BigDecimal collectionPrice = order.getCollectionPrice() != null ? order.getCollectionPrice() : BigDecimal.ZERO;
+                failList.add(new FsFinanceOrderImportFailDTO(
+                        order.getOrderCode(), order.getDeliverySn(),
+                        totalPrice, collectionPrice, dto.getReturnPrice(),
+                        amountMsg));
+                continue;
+            }
+
+            // 更新回款信息(已回款必须有回款时间 = update_time)
             FsExternalOrder update = new FsExternalOrder();
             update.setOrderId(order.getOrderId());
             update.setReturnPrice(dto.getReturnPrice() != null ? dto.getReturnPrice() : BigDecimal.ZERO);
             update.setDeliverySn(dto.getDeliverySn());
             update.setUpdateBy(updateBy);
-            if (dto.getReturnTime() != null) {
-                update.setUpdateTime(dto.getReturnTime());
-            }
-            // 如果状态不是已回款,更新为已回款
-            if (order.getStatus() == null || order.getStatus() != 4) {
-                update.setStatus(4);
-            }
+            // 有回款状态就必须有回款时间:导入有值用导入值,否则用当前时间
+            update.setUpdateTime(dto.getReturnTime() != null ? dto.getReturnTime() : new Date());
+            update.setStatus(4);
             fsExternalOrderMapper.updateFsExternalOrder(update);
             successCount++;
         }
@@ -156,6 +151,19 @@ public class FsFinanceOrderController extends BaseController {
         return null;
     }
 
+    /**
+     * 校验导入回款金额与订单代收金额是否一致。
+     * @return null 表示一致,否则返回失败原因
+     */
+    private String validateReturnPriceMatch(FsExternalOrder order, BigDecimal importReturnPrice) {
+        BigDecimal collectionPrice = order.getCollectionPrice() != null ? order.getCollectionPrice() : BigDecimal.ZERO;
+        BigDecimal returnPrice = importReturnPrice != null ? importReturnPrice : BigDecimal.ZERO;
+        if (collectionPrice.compareTo(returnPrice) != 0) {
+            return "回款金额与代收金额不一致";
+        }
+        return null;
+    }
+
     /**
      * 预览导入数据(解析Excel并匹配订单,不执行写入)。
      * 返回结构与正式导入对齐:含 list/total/successCount/failCount,并在存在失败记录时生成失败 Excel。
@@ -198,6 +206,16 @@ public class FsFinanceOrderController extends BaseController {
             preview.setTotalPrice(order.getTotalPrice());
             preview.setPayPrice(order.getPayPrice());
             preview.setCollectionPrice(order.getCollectionPrice());
+
+            // 回款金额与代收金额一致性校验(不通过仍回填订单信息,便于预览/导出明细)
+            String amountMsg = validateReturnPriceMatch(order, dto.getReturnPrice());
+            if (amountMsg != null) {
+                preview.setMatched(false);
+                preview.setFailReason(amountMsg);
+                previewList.add(preview);
+                continue;
+            }
+
             preview.setMatched(true);
             previewList.add(preview);
         }
@@ -272,7 +290,7 @@ public class FsFinanceOrderController extends BaseController {
 
     /**
      * 批量转未回款:将选中订单置为「未回款」状态(status=3 已发货,等价于 status!=4)。
-     * 仅修改 status,不动 return_price;对已是未回款的记录幂等处理
+     * 同时清空回款时间(update_time),保持状态与回款时间一致;不动 return_price
      */
     @Log(title = "批量转未回款", businessType = BusinessType.UPDATE)
     @PreAuthorize("@ss.hasPermi('store:financeOrder:edit')")
@@ -289,6 +307,7 @@ public class FsFinanceOrderController extends BaseController {
             update.setOrderId(orderId);
             update.setStatus(3);              // 已发货 = 未回款(status != 4)
             update.setUpdateBy(updateBy);
+            update.getParams().put("clearUpdateTime", true); // 清空回款时间
             int rows = fsExternalOrderMapper.updateFsExternalOrder(update);
             if (rows > 0) {
                 successCount++;
@@ -298,7 +317,7 @@ public class FsFinanceOrderController extends BaseController {
     }
 
     /**
-     * 一键转未回款:将当前筛选条件下的所有订单置为「未回款」状态
+     * 一键转未回款:将当前筛选条件下的所有订单置为「未回款」状态,并清空回款时间
      */
     @Log(title = "一键转未回款", businessType = BusinessType.UPDATE)
     @PreAuthorize("@ss.hasPermi('store:financeOrder:edit')")
@@ -317,6 +336,7 @@ public class FsFinanceOrderController extends BaseController {
             update.setOrderId(vo.getOrderId());
             update.setStatus(3);
             update.setUpdateBy(updateBy);
+            update.getParams().put("clearUpdateTime", true);
             int rows = fsExternalOrderMapper.updateFsExternalOrder(update);
             if (rows > 0) {
                 successCount++;

+ 87 - 75
fs-service/src/main/java/com/fs/his/domain/vo/FsExternalOrderListVO.java

@@ -7,158 +7,170 @@ import lombok.Data;
 import java.math.BigDecimal;
 import java.util.Date;
 
+
 @Data
 public class FsExternalOrderListVO {
 
     private Long orderId;
 
-    @Excel(name = "用户id")
-    private  Long userId;
-
-    @Excel(name = "外部订单号")
+    @Excel(name = "外部订单号", sort = 1)
     private String orderCode;
 
+    @Excel(name = "会员ID", sort = 2)
+    private Long userId;
+
+    @Excel(name = "订单状态", readConverterExp = "-4=订单拒收,-3=已取消,1=未审核,2=审核通过,3=已发货,4=已回款", sort = 3)
+    private Integer status;
+
+    @Excel(name = "订单类型", readConverterExp = "1=外部订单,2=套餐包,3=问诊,4=积分", sort = 4)
+    private Integer orderType;
+
+    @Excel(name = "所属公司", sort = 5)
     private String companyName;
 
+    @Excel(name = "部门", sort = 6)
     private String deptName;
 
+    @Excel(name = "坐席姓名", sort = 7)
     private String companyUserName;
 
-    @Excel(name = "收货人")
-    private String userName;
+    /** 工号(company_user.user_id) */
+    @Excel(name = "工号", sort = 8)
+    private Long companyUserId;
 
-    @Excel(name = "收货人电话")
-    private String userPhone;
+    @Excel(name = "收货人", sort = 9)
+    private String userName;
 
+    @Excel(name = "会员手机号", sort = 10)
     private String memberPhone;
 
+    @Excel(name = "会员年龄", sort = 11)
     private Integer memberAge;
 
+    @Excel(name = "会员性别", readConverterExp = "1=男,2=女", sort = 12)
     private Integer memberSex;
 
+    @Excel(name = "复购次数", sort = 13)
     private Integer memberBuyCount;
 
+    @Excel(name = "省", sort = 14)
+    private String province;
+
+    @Excel(name = "二级市", sort = 15)
+    private String city;
+
+    @Excel(name = "区县", sort = 16)
+    private String district;
+
+    @Excel(name = "乡镇", sort = 17)
+    private String township;
+
+    @Excel(name = "病名", sort = 18)
+    private String diseaseName;
+
     private String productNames;
 
     /** 商品名称*数量(多商品逗号分隔,如:商品A*2,商品B*3) */
-    @Excel(name = "商品名称*数量")
+    @Excel(name = "商品名称*数量", sort = 19)
     private String productInfo;
 
     /** 商品数量(订单商品总件数,从明细表实时汇总) */
     private Long productNum;
 
+    @Excel(name = "商品总额", sort = 20)
+    private BigDecimal totalPrice;
+
+    @Excel(name = "应收金额", sort = 21)
     private BigDecimal receivablePrice;
 
-    @Excel(name = "定金")
+    @Excel(name = "定金(实收)", sort = 22)
     private BigDecimal payPrice;
 
-    @Excel(name = "商品总额")
-    private BigDecimal totalPrice;
-
-    @Excel(name = "代收金额")
+    @Excel(name = "代收金额", sort = 23)
     private BigDecimal collectionPrice;
 
-    @Excel(name = "运费金额")
-    private BigDecimal freightPrice;
-
-    @Excel(name = "支付状态", readConverterExp = "0=待支付,1=已支付")
-    private Integer isPay;
+    @Excel(name = "支付方式", dictType = "sys_package_pay_type", sort = 24)
+    private Integer payType;
 
+    /** 回款时间(已回款时取 updateTime,与列表展示一致) */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date payTime;
+    @Excel(name = "回款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 25)
+    private Date returnTime;
 
-    @Excel(name = "收件人电话")
-    private String receiverPhone;
-
-    @Excel(name = "回款金额")
-    private BigDecimal returnPrice;
-
-    @Excel(name = "是否还货", readConverterExp = "1=是,2=否")
-    private Integer isReturnGoods;
-
-    @Excel(name = "订单商品总数")
-    private Long totalNum;
-
-    @Excel(name = "详细地址")
-    private String userAddress;
-
-    private Integer payType;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "外部订单创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 26)
     private Date externalCreateTime;
 
-    @Excel(name = "订单状态", readConverterExp = "-3=已取消,1=未审核,2=审核通过,3=已发货,4=已回款")
-    private Integer status;
-
-    @Excel(name = "订单类型", readConverterExp = "1=外部订单,2=套餐包,3=问诊,4=积分")
-    private Integer orderType;
-
-    @Excel(name = "快递单号")
+    @Excel(name = "快递单号", sort = 27)
     private String deliverySn;
 
-    @Excel(name = "快递公司编号")
+    @Excel(name = "快递公司", sort = 28)
     private String deliveryCode;
 
-    @Excel(name = "快递名称")
+    @Excel(name = "快递类型", sort = 29)
     private String deliveryName;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发货时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 30)
     private Date deliveryTime;
 
-    @Excel(name = "物流状态")
+    @Excel(name = "签收状态", dictType = "sys_store_order_delivery_status", sort = 31)
     private Integer deliveryStatus;
 
-    @Excel(name = "物流状态类型")
-    private String deliveryType;
-
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "物流更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date deliveryUpdateTime;
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "跟单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "跟单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 32)
     private Date followTime;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date updateTime;
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date depositReturnTime;
-
-    @Excel(name = "退款金额")
+    @Excel(name = "退款金额", sort = 33)
     private BigDecimal refundPrice;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "退款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "退款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 34)
     private Date refundTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "拒收回退时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "拒收回退时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 35)
     private Date rejectReturnTime;
 
-    @Excel(name = "备注")
+    @Excel(name = "备注", sort = 36)
     private String remark;
 
-    @Excel(name = "审核人")
+    @Excel(name = "审核人", sort = 37)
     private String auditor;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 38)
     private Date auditTime;
 
-    @Excel(name = "病名")
-    private String diseaseName;
+    private String userPhone;
 
-    private String province;
+    private BigDecimal freightPrice;
 
-    private String city;
+    private Integer isPay;
 
-    private String district;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
 
-    private String township;
+    private String receiverPhone;
+
+    private BigDecimal returnPrice;
+
+    private Integer isReturnGoods;
+
+    private Long totalNum;
+
+    private String userAddress;
+
+    private String deliveryType;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryUpdateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date depositReturnTime;
 
     private String statusDesc;
 

+ 27 - 25
fs-service/src/main/java/com/fs/his/domain/vo/FsFinanceOrderListVO.java

@@ -7,74 +7,76 @@ import lombok.Data;
 import java.math.BigDecimal;
 import java.util.Date;
 
+
 @Data
 public class FsFinanceOrderListVO {
 
     private Long orderId;
 
-    @Excel(name = "订单编号")
+    @Excel(name = "订单编号", sort = 1)
     private String orderCode;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 2)
     private Date externalCreateTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "回款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "回款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 3)
     private Date returnTime;
 
-    @Excel(name = "回款人")
+    @Excel(name = "回款人", sort = 4)
     private String returnUser;
 
-    @Excel(name = "会员姓名")
+    @Excel(name = "会员姓名", sort = 5)
     private String userName;
 
-    @Excel(name = "快递公司")
+    @Excel(name = "快递公司", sort = 6)
     private String deliveryName;
 
-    @Excel(name = "运单号")
+    @Excel(name = "运单号", sort = 7)
     private String deliverySn;
 
-    @Excel(name = "订单金额", isStatistics = true)
+    @Excel(name = "订单金额", isStatistics = true, sort = 8)
     private BigDecimal totalPrice;
 
-    @Excel(name = "定金", isStatistics = true)
+    @Excel(name = "定金", isStatistics = true, sort = 9)
     private BigDecimal payPrice;
 
-    @Excel(name = "代收金额", isStatistics = true)
+    @Excel(name = "代收金额", isStatistics = true, sort = 10)
     private BigDecimal collectionPrice;
 
-    @Excel(name = "回款金额", isStatistics = true)
+    @Excel(name = "回款金额", isStatistics = true, sort = 11)
     private BigDecimal returnPrice;
 
-    @Excel(name = "收件人电话")
+    @Excel(name = "收件人电话", sort = 12)
     private String receiverPhone;
 
-    @Excel(name = "订购产品")
     private String productNames;
 
-    @Excel(name = "产品数量")
+    @Excel(name = "商品名称*数量", sort = 13)
+    private String productInfo;
+
     private Integer productNum;
 
-    @Excel(name = "备注")
+    @Excel(name = "付款方式", dictType = "sys_package_pay_type", sort = 14)
+    private Integer payType;
+
+    @Excel(name = "回款状态", readConverterExp = "0=未回款,1=已回款", sort = 15)
+    private Integer returnStatus;
+
+    @Excel(name = "备注", sort = 16)
     private String remark;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 17)
     private Date deliveryTime;
 
-    @Excel(name = "销售姓名")
+    @Excel(name = "坐席姓名", sort = 18)
     private String companyUserName;
 
-    @Excel(name = "公司")
+    @Excel(name = "公司", sort = 19)
     private String companyName;
 
-    @Excel(name = "部门")
+    @Excel(name = "部门", sort = 20)
     private String deptName;
-
-    @Excel(name = "付款方式", readConverterExp = "1=微信,2=支付宝,3=其他")
-    private Integer payType;
-
-    @Excel(name = "回款状态", readConverterExp = "0=未回款,1=已回款")
-    private Integer returnStatus;
 }

+ 17 - 15
fs-service/src/main/java/com/fs/his/domain/vo/FsRejectOrderReportVO.java

@@ -13,52 +13,54 @@ import java.util.Date;
 @Data
 public class FsRejectOrderReportVO {
 
-    @Excel(name = "订单编号")
+    @Excel(name = "订单编号", sort = 1)
     private String orderCode;
 
-    @Excel(name = "快递单号")
+    @Excel(name = "快递单号", sort = 2)
     private String deliverySn;
 
-    @Excel(name = "会员姓名")
+    @Excel(name = "会员姓名", sort = 3)
     private String userName;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 4)
     private Date externalCreateTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 5)
     private Date deliveryTime;
 
-    @Excel(name = "金额")
+    @Excel(name = "金额", sort = 6)
     private BigDecimal totalPrice;
 
-    @Excel(name = "快递公司")
+    @Excel(name = "快递公司", sort = 7)
     private String deliveryName;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "跟单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "跟单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 8)
     private Date followTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "拒收退回日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "拒收退回日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 9)
     private Date rejectReturnTime;
 
-    @Excel(name = "拒收人")
+    @Excel(name = "拒收人", sort = 10)
     private String rejectUser;
 
-    @Excel(name = "电话1")
+    @Excel(name = "电话1", sort = 11)
     private String userPhone;
 
-    @Excel(name = "电话2")
+    @Excel(name = "电话2", sort = 12)
     private String memberPhone;
 
-    @Excel(name = "销售姓名")
+    @Excel(name = "坐席姓名", sort = 13)
     private String companyUserName;
 
-    @Excel(name = "订购产品")
     private String productNames;
 
-    @Excel(name = "地址")
+    @Excel(name = "商品名称*数量", sort = 14)
+    private String productInfo;
+
+    @Excel(name = "地址", sort = 15)
     private String userAddress;
 }

+ 18 - 16
fs-service/src/main/java/com/fs/his/domain/vo/FsReturnOrderReportVO.java

@@ -13,54 +13,56 @@ import java.util.Date;
 @Data
 public class FsReturnOrderReportVO {
 
-    @Excel(name = "订单编号")
+    @Excel(name = "订单编号", sort = 1)
     private String orderCode;
 
-    @Excel(name = "快递单号")
+    @Excel(name = "快递单号", sort = 2)
     private String deliverySn;
 
-    @Excel(name = "姓名")
+    @Excel(name = "姓名", sort = 3)
     private String userName;
 
-    @Excel(name = "地址")
+    @Excel(name = "地址", sort = 4)
     private String userAddress;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 5)
     private Date externalCreateTime;
 
-    @Excel(name = "定金")
+    @Excel(name = "定金", sort = 6)
     private BigDecimal payPrice;
 
-    @Excel(name = "金额")
+    @Excel(name = "金额", sort = 7)
     private BigDecimal totalPrice;
 
-    @Excel(name = "快递公司")
+    @Excel(name = "快递公司", sort = 8)
     private String deliveryName;
 
-    @Excel(name = "回款人")
+    @Excel(name = "回款人", sort = 9)
     private String returnUser;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "回款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "回款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 10)
     private Date returnTime;
 
-    @Excel(name = "电话1")
+    @Excel(name = "电话1", sort = 11)
     private String userPhone;
 
-    @Excel(name = "电话2")
+    @Excel(name = "电话2", sort = 12)
     private String memberPhone;
 
-    @Excel(name = "销售")
+    @Excel(name = "坐席姓名", sort = 13)
     private String companyUserName;
 
-    @Excel(name = "部门")
+    @Excel(name = "部门", sort = 14)
     private String deptName;
 
-    @Excel(name = "订购产品")
     private String productNames;
 
+    @Excel(name = "商品名称*数量", sort = 15)
+    private String productInfo;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 16)
     private Date deliveryTime;
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/vo/FsExternalOrderDetailVO.java

@@ -118,6 +118,9 @@ public class FsExternalOrderDetailVO implements Serializable {
 
     private String companyUserName;
 
+    /** 工号(company_user.user_id) */
+    private Long companyUserId;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date externalCreateTime;
 

+ 18 - 71
fs-service/src/main/java/com/fs/watch/service/impl/WatchUserServiceImpl.java

@@ -458,12 +458,11 @@ public class WatchUserServiceImpl implements WatchUserService {
     @Override
     public R editXHSDevice(HashMap<String, String> param) {
         String userId = param.get("userId");
+        // 前端会传该用户全部设备,直接覆盖写入
         String xhsDeviceId = param.get("xhsDeviceId");
         String newXhsDeviceId = param.get("newXhsDeviceId");
         String smartWatchDeviceId = param.get("smartWatchDeviceId");
-        //查询设备是否已经绑定自己
         long userIdL = Long.parseLong(userId);
-        //1.编辑绑定设备 ,更新用户表
         WatchFsUser watchFsUser = selectWatchFsUserById(userIdL);
         if (watchFsUser == null) {
             WatchUser watchUser = new WatchUser();
@@ -480,88 +479,37 @@ public class WatchUserServiceImpl implements WatchUserService {
             insert(watchUser);
         } else {
             if (StringUtils.isNotBlank(xhsDeviceId)) {
-                String deviceId = watchFsUser.getXhsDeviceId();
-                if (StringUtils.isBlank(deviceId)) {
-                    watchFsUser.setXhsDeviceId(xhsDeviceId);
-                } else {
-                    watchFsUser.setXhsDeviceId(deviceId + "," + xhsDeviceId);
-                }
+                watchFsUser.setXhsDeviceId(xhsDeviceId);
             }
             if (StringUtils.isNotBlank(newXhsDeviceId)) {
-                String deviceId = watchFsUser.getNewXhsDeviceId();
-                if (StringUtils.isBlank(deviceId)) {
-                    watchFsUser.setNewXhsDeviceId(newXhsDeviceId);
-                } else {
-                    watchFsUser.setNewXhsDeviceId(deviceId + "," + newXhsDeviceId);
-                }
+                watchFsUser.setNewXhsDeviceId(newXhsDeviceId);
             }
             if (StringUtils.isNotBlank(smartWatchDeviceId)) {
-                String deviceId = watchFsUser.getSmartWatchDeviceId();
-                if (StringUtils.isBlank(deviceId)) {
-                    watchFsUser.setSmartWatchDeviceId(smartWatchDeviceId);
-                } else {
-                    watchFsUser.setSmartWatchDeviceId(deviceId + "," + smartWatchDeviceId);
-                }
+                watchFsUser.setSmartWatchDeviceId(smartWatchDeviceId);
             }
-
             WatchUser watchUser = setWatchUser(watchFsUser);
-            //查询是否含有腕表用户信息
             updateWatchUser(watchUser);
         }
 
+        ensureDeviceSetups(xhsDeviceId);
+        ensureDeviceSetups(newXhsDeviceId);
+        ensureDeviceSetups(smartWatchDeviceId);
+        return R.ok("绑定成功!");
+    }
 
-        //3.添加设备设置信息
-        if (StringUtils.isNotBlank(xhsDeviceId)) {
-            WatchDeviceSetup temp = deviceSetupService.selectDeviceSetupByDeviceId(xhsDeviceId);
-            if (temp == null) {
-                WatchDeviceSetup deviceSetup = new WatchDeviceSetup();
-                deviceSetup.setDeviceId(xhsDeviceId);
-                deviceSetup.setSmartDoctor(0);
-                deviceSetup.setSedentary(JSONUtil.toJsonStr(new DeviceSedentary()));
-                deviceSetup.setFallcheck(0);
-                deviceSetup.setHeartHealth(0);
-                deviceSetup.setHralarm(JSONUtil.toJsonStr(new DeviceHralarm()));
-                deviceSetup.setSpo2alarm(JSONUtil.toJsonStr(new DeviceSpo2alarm()));
-                deviceSetup.setAlarmClock(JSONUtil.toJsonStr(new DeviceAlarmClock()));
-                deviceSetup.setPower(JSONUtil.toJsonStr(new DevicePower()));
-                deviceSetup.setPhonebook(JSONUtil.toJsonStr(new DevicePhonebooks()));
-                deviceSetup.setTime(JSONUtil.toJsonStr(new DeviceTime()));
-                deviceSetup.setLcdgesture(JSONUtil.toJsonStr(new DeviceLcdgesture()));
-                deviceSetup.setUnit(JSONUtil.toJsonStr(new DeviceUnit()));
-                deviceSetup.setMode(JSONUtil.toJsonStr(new DeviceMode()));
-                deviceSetup.setVersion("1.1.0");
-                deviceSetupService.insertDeviceSetup(deviceSetup);
-            }
+    private void ensureDeviceSetups(String deviceIds) {
+        if (StringUtils.isBlank(deviceIds)) {
+            return;
         }
-
-        if (StringUtils.isNotBlank(newXhsDeviceId)) {
-            WatchDeviceSetup temp = deviceSetupService.selectDeviceSetupByDeviceId(newXhsDeviceId);
-            if (temp == null) {
-                WatchDeviceSetup deviceSetup = new WatchDeviceSetup();
-                deviceSetup.setDeviceId(newXhsDeviceId);
-                deviceSetup.setSmartDoctor(0);
-                deviceSetup.setSedentary(JSONUtil.toJsonStr(new DeviceSedentary()));
-                deviceSetup.setFallcheck(0);
-                deviceSetup.setHeartHealth(0);
-                deviceSetup.setHralarm(JSONUtil.toJsonStr(new DeviceHralarm()));
-                deviceSetup.setSpo2alarm(JSONUtil.toJsonStr(new DeviceSpo2alarm()));
-                deviceSetup.setAlarmClock(JSONUtil.toJsonStr(new DeviceAlarmClock()));
-                deviceSetup.setPower(JSONUtil.toJsonStr(new DevicePower()));
-                deviceSetup.setPhonebook(JSONUtil.toJsonStr(new DevicePhonebooks()));
-                deviceSetup.setTime(JSONUtil.toJsonStr(new DeviceTime()));
-                deviceSetup.setLcdgesture(JSONUtil.toJsonStr(new DeviceLcdgesture()));
-                deviceSetup.setUnit(JSONUtil.toJsonStr(new DeviceUnit()));
-                deviceSetup.setMode(JSONUtil.toJsonStr(new DeviceMode()));
-                deviceSetup.setVersion("1.1.0");
-                deviceSetupService.insertDeviceSetup(deviceSetup);
+        for (String deviceId : deviceIds.split(",")) {
+            if (StringUtils.isBlank(deviceId)) {
+                continue;
             }
-        }
-
-        if (StringUtils.isNotBlank(smartWatchDeviceId)) {
-            WatchDeviceSetup temp = deviceSetupService.selectDeviceSetupByDeviceId(smartWatchDeviceId);
+            deviceId = deviceId.trim();
+            WatchDeviceSetup temp = deviceSetupService.selectDeviceSetupByDeviceId(deviceId);
             if (temp == null) {
                 WatchDeviceSetup deviceSetup = new WatchDeviceSetup();
-                deviceSetup.setDeviceId(smartWatchDeviceId);
+                deviceSetup.setDeviceId(deviceId);
                 deviceSetup.setSmartDoctor(0);
                 deviceSetup.setSedentary(JSONUtil.toJsonStr(new DeviceSedentary()));
                 deviceSetup.setFallcheck(0);
@@ -579,7 +527,6 @@ public class WatchUserServiceImpl implements WatchUserService {
                 deviceSetupService.insertDeviceSetup(deviceSetup);
             }
         }
-        return R.ok("绑定成功!");
     }
 
     @Override

+ 19 - 10
fs-service/src/main/resources/mapper/his/FsExternalOrderMapper.xml

@@ -255,8 +255,9 @@
             <if test="auditTime != null">audit_time = #{auditTime},</if>
             <if test="diseaseName != null">disease_name = #{diseaseName},</if>
             <if test="isReturnGoods != null">is_return_goods = #{isReturnGoods},</if>
-            update_by = #{updateBy},
-            update_time = #{updateTime}
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="params != null and params.clearUpdateTime != null and params.clearUpdateTime == true">update_time = null,</if>
         </trim>
         where order_id = #{orderId}
     </update>
@@ -280,7 +281,8 @@
             o.user_id AS userId,
             c.company_name AS companyName,
             d.dept_name AS deptName,
-            cu.user_name AS companyUserName,
+            cu.nick_name AS companyUserName,
+            cu.user_id AS companyUserId,
             o.user_name AS userName,
             o.user_phone AS userPhone,
             u.phone AS memberPhone,
@@ -320,6 +322,7 @@
             o.delivery_update_time AS deliveryUpdateTime,
             o.follow_time AS followTime,
             o.update_time AS updateTime,
+            CASE WHEN o.status = 4 THEN o.update_time ELSE NULL END AS returnTime,
             o.deposit_return_time AS depositReturnTime,
             o.refund_price AS refundPrice,
             o.refund_time AS refundTime,
@@ -360,7 +363,7 @@
             <if test="orderCode != null and orderCode != ''"> AND FIND_IN_SET(IFNULL(o.order_code, ''), #{orderCode}) &gt; 0</if>
             <if test="userId != null"> AND FIND_IN_SET(IFNULL(o.user_id, ''), #{userId}) &gt; 0</if>
             <if test="companyUserId != null"> AND FIND_IN_SET(IFNULL(o.company_user_id, ''), #{companyUserId}) &gt; 0</if>
-            <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.user_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
+            <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.nick_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.nick_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
             <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
             <if test="userName != null and userName != ''"><choose><when test='userName.contains(",")'> AND FIND_IN_SET(IFNULL(o.user_name, ''), #{userName}) &gt; 0</when><otherwise> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</otherwise></choose></if>
             <if test="userPhone != null and userPhone != ''"> AND FIND_IN_SET(IFNULL(o.user_phone, ''), #{userPhone}) &gt; 0</if>
@@ -487,7 +490,8 @@
             o.create_time AS createTime,
             c.company_name AS companyName,
             d.dept_name AS deptName,
-            cu.nick_name AS companyUserName
+            cu.nick_name AS companyUserName,
+            cu.user_id AS companyUserId
         FROM fs_external_order o
         LEFT JOIN company c           ON o.company_id      = c.company_id
         LEFT JOIN company_user cu     ON o.company_user_id = cu.user_id
@@ -517,7 +521,7 @@
             o.order_id AS orderId,
             o.order_code AS orderCode,
             o.external_create_time AS externalCreateTime,
-            o.update_time AS returnTime,
+            CASE WHEN o.status = 4 THEN o.update_time ELSE NULL END AS returnTime,
             o.update_by AS returnUser,
             o.user_name AS userName,
             o.delivery_name AS deliveryName,
@@ -528,10 +532,11 @@
             o.return_price AS returnPrice,
             o.receiver_phone AS receiverPhone,
             GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
+            GROUP_CONCAT(CONCAT(oi.product_name, '*', oi.num) SEPARATOR ',') AS productInfo,
             IFNULL(SUM(oi.num), 0) AS productNum,
             o.remark,
             o.delivery_time AS deliveryTime,
-            cu.user_name AS companyUserName,
+            cu.nick_name AS companyUserName,
             c.company_name AS companyName,
             d.dept_name AS deptName,
             o.pay_type AS payType,
@@ -557,6 +562,7 @@
                 <if test='returnStatus.contains("0") and !returnStatus.contains("1")'> AND o.status != 4</if>
             </if>
             <if test="returnUser != null and returnUser != ''"> AND o.update_by LIKE CONCAT('%', #{returnUser}, '%')</if>
+            <if test="(returnTimeStart != null and returnTimeStart != '') or (returnTimeEnd != null and returnTimeEnd != '')"> AND o.status = 4</if>
             <if test="returnTimeStart != null and returnTimeStart != ''"> AND o.update_time >= #{returnTimeStart}</if>
             <if test="returnTimeEnd != null and returnTimeEnd != ''"> AND o.update_time &lt;= #{returnTimeEnd}</if>
             <if test="totalPrice != null"> AND o.total_price IN
@@ -574,7 +580,7 @@
             <if test="receiverPhone != null and receiverPhone != ''"> AND o.receiver_phone LIKE CONCAT('%', #{receiverPhone}, '%')</if>
             <if test="remark != null and remark != ''"><choose><when test='remark.contains(",")'> AND FIND_IN_SET(IFNULL(o.remark, ''), #{remark}) &gt; 0</when><otherwise> AND o.remark LIKE CONCAT('%', #{remark}, '%')</otherwise></choose></if>
             <if test="payType != null"> AND o.pay_type = #{payType}</if>
-            <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.user_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
+            <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.nick_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.nick_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
             <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
             <if test="sTime != null and sTime != ''"> AND o.external_create_time >= #{sTime}</if>
             <if test="eTime != null and eTime != ''"> AND o.external_create_time &lt;= #{eTime}</if>
@@ -615,6 +621,7 @@
             cu.nick_name AS companyUserName,
             d.dept_name AS deptName,
             GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
+            GROUP_CONCAT(CONCAT(oi.product_name, '*', oi.num) SEPARATOR ',') AS productInfo,
             o.delivery_time AS deliveryTime
         FROM fs_external_order o
         LEFT JOIN company c ON o.company_id = c.company_id
@@ -722,6 +729,7 @@
             o.receiver_phone AS memberPhone,
             cu.nick_name AS companyUserName,
             GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
+            GROUP_CONCAT(CONCAT(oi.product_name, '*', oi.num) SEPARATOR ',') AS productInfo,
             o.user_address AS userAddress
         FROM fs_external_order o
         LEFT JOIN company c ON o.company_id = c.company_id
@@ -1039,7 +1047,7 @@
                 <if test="orderCode != null and orderCode != ''"> AND FIND_IN_SET(IFNULL(o.order_code, ''), #{orderCode}) &gt; 0</if>
                 <if test="userId != null"> AND FIND_IN_SET(IFNULL(o.user_id, ''), #{userId}) &gt; 0</if>
                 <if test="companyUserId != null"> AND FIND_IN_SET(IFNULL(o.company_user_id, ''), #{companyUserId}) &gt; 0</if>
-                <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.user_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
+                <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.nick_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.nick_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
                 <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
                 <if test="userName != null and userName != ''"><choose><when test='userName.contains(",")'> AND FIND_IN_SET(IFNULL(o.user_name, ''), #{userName}) &gt; 0</when><otherwise> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</otherwise></choose></if>
                 <if test="userPhone != null and userPhone != ''"> AND FIND_IN_SET(IFNULL(o.user_phone, ''), #{userPhone}) &gt; 0</if>
@@ -1143,6 +1151,7 @@
                     <if test='returnStatus.contains("0") and !returnStatus.contains("1")'> AND o.status != 4</if>
                 </if>
                 <if test="returnUser != null and returnUser != ''"> AND o.update_by LIKE CONCAT('%', #{returnUser}, '%')</if>
+                <if test="(returnTimeStart != null and returnTimeStart != '') or (returnTimeEnd != null and returnTimeEnd != '')"> AND o.status = 4</if>
                 <if test="returnTimeStart != null and returnTimeStart != ''"> AND o.update_time >= #{returnTimeStart}</if>
                 <if test="returnTimeEnd != null and returnTimeEnd != ''"> AND o.update_time &lt;= #{returnTimeEnd}</if>
                 <if test="totalPrice != null"> AND o.total_price IN
@@ -1160,7 +1169,7 @@
                 <if test="receiverPhone != null and receiverPhone != ''"> AND o.receiver_phone LIKE CONCAT('%', #{receiverPhone}, '%')</if>
                 <if test="remark != null and remark != ''"><choose><when test='remark.contains(",")'> AND FIND_IN_SET(IFNULL(o.remark, ''), #{remark}) &gt; 0</when><otherwise> AND o.remark LIKE CONCAT('%', #{remark}, '%')</otherwise></choose></if>
                 <if test="payType != null"> AND o.pay_type = #{payType}</if>
-                <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.user_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
+                <if test="companyUserName != null and companyUserName != ''"><choose><when test='companyUserName.contains(",")'> AND FIND_IN_SET(IFNULL(cu.nick_name, ''), #{companyUserName}) &gt; 0</when><otherwise> AND cu.nick_name LIKE CONCAT('%', #{companyUserName}, '%')</otherwise></choose></if>
                 <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
                 <if test="sTime != null and sTime != ''"> AND o.external_create_time >= #{sTime}</if>
                 <if test="eTime != null and eTime != ''"> AND o.external_create_time &lt;= #{eTime}</if>

+ 0 - 1
fs-watch/src/main/java/com/fs/app/controller/WatchUserController.java

@@ -375,7 +375,6 @@ public class WatchUserController extends AppBaseController {
     @ApiOperation("绑定小护士设备(自己)")
     @PostMapping("/editXHSDevice")
     public R editXHSDevice(@RequestBody HashMap<String,String> param) {
-        //1.获取当前登录用户信息
         String userId = getUserId();
         String xhsDeviceId = param.get("xhsDeviceId");
         String newXhsDeviceId = param.get("newXhsDeviceId");