소스 검색

营期修改优化 复制营期调整创建时间

wangxy 3 일 전
부모
커밋
7fb9c1d4bf

+ 3 - 1
fs-admin/src/main/java/com/fs/his/controller/FsExternalOrderController.java

@@ -6,6 +6,7 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.SecurityUtils;
 import com.fs.his.domain.FsExternalOrder;
 import com.fs.his.domain.vo.FsExternalOrderListVO;
 import com.fs.his.service.IFsExternalOrderService;
@@ -42,7 +43,8 @@ public class FsExternalOrderController extends BaseController {
     @PostMapping("/audit/{orderId}")
     @PreAuthorize("@ss.hasPermi('his:externalOrder:audit')")
     public R audit(@PathVariable("orderId") Long orderId) {
-        return fsExternalOrderService.auditExternalOrder(orderId);
+        String auditor = SecurityUtils.getLoginUser().getUser().getUserName();
+        return fsExternalOrderService.auditExternalOrder(orderId,auditor);
     }
 
     @Log(title = "取消外部订单", businessType = BusinessType.UPDATE)

+ 23 - 1
fs-company/src/main/java/com/fs/company/controller/store/FsExternalOrderController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.his.domain.FsExternalOrder;
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 
 @RestController
@@ -68,12 +70,20 @@ public class FsExternalOrderController extends BaseController {
         LoginUser loginUser = SecurityUtils.getLoginUser();
         param.setCompanyId(loginUser.getCompany().getCompanyId());
         param.setCompanyUserId(loginUser.getUser().getUserId());
+        param.setCreateBy(loginUser.getUser().getUserName());
         return fsExternalOrderService.createExternalOrder(param);
     }
 
     @Log(title = "修改外部订单", businessType = BusinessType.UPDATE)
     @PostMapping("/edit")
     public AjaxResult edit(@RequestBody FsExternalOrder fsExternalOrder) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsExternalOrder.setUpdateBy(loginUser.getUser().getUserName());
+        // 签收状态变更时,写入签收状态更新人和时间
+        if (fsExternalOrder.getDeliveryStatus() != null) {
+            fsExternalOrder.setDeliveryStatusUpdateTime(new Date());
+            fsExternalOrder.setDeliveryStatusUpdateBy(loginUser.getUser().getUserName());
+        }
         return toAjax(fsExternalOrderService.updateFsExternalOrder(fsExternalOrder));
     }
 
@@ -87,7 +97,8 @@ public class FsExternalOrderController extends BaseController {
     @PostMapping("/audit/{orderId}")
     @PreAuthorize("@ss.hasPermi('store:externalOrder:audit')")
     public R audit(@PathVariable("orderId") Long orderId) {
-        return fsExternalOrderService.auditExternalOrder(orderId);
+        String auditor = SecurityUtils.getLoginUser().getUser().getUserName();
+        return fsExternalOrderService.auditExternalOrder(orderId, auditor);
     }
 
     @Log(title = "取消外部订单", businessType = BusinessType.UPDATE)
@@ -129,4 +140,15 @@ public class FsExternalOrderController extends BaseController {
     public R syncExpress(@PathVariable("orderId") Long orderId) {
         return fsExternalOrderService.syncExpress(orderId);
     }
+
+    @Log(title = "导出外部订单", businessType = BusinessType.EXPORT)
+    @PreAuthorize("@ss.hasPermi('store:externalOrder:export')")
+    @GetMapping("/export")
+    public AjaxResult export(FsExternalOrder fsExternalOrder) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsExternalOrder.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<FsExternalOrder> list = fsExternalOrderService.selectFsExternalOrderList(fsExternalOrder);
+        ExcelUtil<FsExternalOrder> util = new ExcelUtil<>(FsExternalOrder.class);
+        return util.exportExcel(list, "外部订单数据");
+    }
 }

+ 155 - 0
fs-company/src/main/java/com/fs/company/controller/store/FsFinanceOrderController.java

@@ -0,0 +1,155 @@
+package com.fs.company.controller.store;
+
+import com.fs.common.annotation.DataScope;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.framework.security.LoginUser;
+import com.fs.framework.security.SecurityUtils;
+import com.fs.his.domain.FsExternalOrder;
+import com.fs.his.domain.vo.FsFinanceOrderListVO;
+import com.fs.his.dto.FsFinanceOrderImportDTO;
+import com.fs.his.dto.FsFinanceOrderImportFailDTO;
+import com.fs.his.mapper.FsExternalOrderMapper;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@RestController
+@RequestMapping("/store/financeOrder")
+public class FsFinanceOrderController extends BaseController {
+
+    @Autowired
+    private FsExternalOrderMapper fsExternalOrderMapper;
+
+    @GetMapping("/list")
+    @Log(title = "财务外部订单列表", businessType = BusinessType.OTHER)
+    @PreAuthorize("@ss.hasPermi('store:financeOrder:list')")
+    @DataScope(deptAlias = "cu", userAlias = "cu")
+    public TableDataInfo list(FsExternalOrder fsExternalOrder) {
+        startPage();
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsExternalOrder.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<FsFinanceOrderListVO> list = fsExternalOrderMapper.selectFinanceOrderListVO(fsExternalOrder);
+        return getDataTable(list);
+    }
+
+    @Log(title = "导出财务外部订单", businessType = BusinessType.EXPORT)
+    @PreAuthorize("@ss.hasPermi('store:financeOrder:export')")
+    @GetMapping("/export")
+    public AjaxResult export(FsExternalOrder fsExternalOrder) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsExternalOrder.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<FsFinanceOrderListVO> list = fsExternalOrderMapper.selectFinanceOrderListVO(fsExternalOrder);
+        ExcelUtil<FsFinanceOrderListVO> util = new ExcelUtil<>(FsFinanceOrderListVO.class);
+        return util.exportExcel(list, "财务外部订单数据");
+    }
+
+    /**
+     * 下载回款导入模板
+     */
+    @GetMapping("/importTemplate")
+    @PreAuthorize("@ss.hasPermi('store:financeOrder:import')")
+    public AjaxResult importTemplate() {
+        ExcelUtil<FsFinanceOrderImportDTO> util = new ExcelUtil<>(FsFinanceOrderImportDTO.class);
+        return util.importTemplateExcel("回款导入模板");
+    }
+
+    /**
+     * 导入回款数据(以快递单号或订单编号匹配)
+     */
+    @Log(title = "财务回款导入", businessType = BusinessType.IMPORT)
+    @PreAuthorize("@ss.hasPermi('store:financeOrder:import')")
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file) throws Exception {
+        ExcelUtil<FsFinanceOrderImportDTO> util = new ExcelUtil<>(FsFinanceOrderImportDTO.class);
+        List<FsFinanceOrderImportDTO> importList = util.importExcel(file.getInputStream());
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        String updateBy = loginUser.getUser().getUserName();
+
+        int successCount = 0;
+        List<FsFinanceOrderImportFailDTO> failList = new ArrayList<>();
+
+        for (FsFinanceOrderImportDTO dto : importList) {
+            // 匹配订单
+            FsExternalOrder order = matchOrder(dto);
+            if (order == null) {
+                failList.add(new FsFinanceOrderImportFailDTO(
+                        dto.getOrderCode(), dto.getDeliverySn(), null, null, dto.getReturnPrice(), "订单不存在"));
+                continue;
+            }
+
+            BigDecimal totalPrice = order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO;
+            BigDecimal payPrice = order.getPayPrice() != null ? order.getPayPrice() : BigDecimal.ZERO;
+            BigDecimal collectionPrice = totalPrice.subtract(payPrice);
+            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;
+            }
+
+            // 更新回款信息
+            FsExternalOrder update = new FsExternalOrder();
+            update.setOrderId(order.getOrderId());
+            update.setReturnPrice(importReturnPrice);
+            update.setUpdateBy(updateBy);
+            if (dto.getReturnTime() != null) {
+                update.setUpdateTime(dto.getReturnTime());
+            }
+            // 如果状态不是已回款,更新为已回款
+            if (order.getStatus() == null || order.getStatus() != 4) {
+                update.setStatus(4);
+            }
+            fsExternalOrderMapper.updateFsExternalOrder(update);
+            successCount++;
+        }
+
+        if (CollectionUtils.isNotEmpty(failList)) {
+            ExcelUtil<FsFinanceOrderImportFailDTO> failUtil = new ExcelUtil<>(FsFinanceOrderImportFailDTO.class);
+            AjaxResult failResult = failUtil.exportExcel(failList, "回款导入失败记录");
+            String msg = "导入成功 " + successCount + " 条,失败 " + failList.size() + " 条";
+            // data 返回失败文件下载名
+            return AjaxResult.success(msg, failResult.get("msg"));
+        }
+        return AjaxResult.success("导入成功 " + successCount + " 条,失败 0 条");
+    }
+
+    /** 根据订单编号匹配订单 */
+    private FsExternalOrder matchOrder(FsFinanceOrderImportDTO dto) {
+        if (dto.getOrderCode() != null && !dto.getOrderCode().isEmpty()) {
+            return fsExternalOrderMapper.selectFsExternalOrderByOrderCode(dto.getOrderCode());
+        }
+        return null;
+    }
+
+    @Log(title = "修改回款金额", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('store:financeOrder:edit')")
+    @PostMapping("/edit")
+    public AjaxResult edit(@RequestBody FsExternalOrder fsExternalOrder) {
+        if (fsExternalOrder.getOrderId() == null) {
+            return AjaxResult.error("订单ID不能为空");
+        }
+        if (fsExternalOrder.getReturnPrice() == null) {
+            return AjaxResult.error("回款金额不能为空");
+        }
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsExternalOrder.setUpdateBy(loginUser.getUser().getUserName());
+        int rows = fsExternalOrderMapper.updateFsExternalOrder(fsExternalOrder);
+        return toAjax(rows);
+    }
+}

+ 36 - 16
fs-service/src/main/java/com/fs/his/domain/FsExternalOrder.java

@@ -2,6 +2,7 @@ package com.fs.his.domain;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
@@ -23,7 +24,6 @@ public class FsExternalOrder extends BaseEntity
     @Excel(name = "外部订单号")
     private String orderCode;
 
-    @Excel(name = "外部来源")
     private String source;
 
     @Excel(name = "用户id")
@@ -42,27 +42,26 @@ public class FsExternalOrder extends BaseEntity
     private Long totalNum;
 
     /** 订单总价(即商品总额) */
-    @Excel(name = "订单总价")
+    @Excel(name = "商品总额")
     private BigDecimal totalPrice;
 
     /** 实际支付金额(即定金) */
-    @Excel(name = "实际支付金额")
+    @Excel(name = "定金")
     private BigDecimal payPrice;
 
     @Excel(name = "运费金额")
     private BigDecimal freightPrice;
 
-    @Excel(name = "支付状态 0待支付 1已支付")
+    @Excel(name = "支付状态", readConverterExp = "0=待支付,1=已支付")
     private Integer isPay;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date payTime;
 
-    @Excel(name = "支付方式 1微信 2支付宝 3其他")
     private Integer payType;
 
-    @Excel(name = "订单状态 1待审核 2待发货 3待收货 4已完成 5已取消")
+    @Excel(name = "订单状态", readConverterExp = "-3=已取消,1=未审核,2=审核通过,3=已发货,4=已回款")
     private Integer status;
 
     @Excel(name = "快递公司编号")
@@ -88,10 +87,14 @@ public class FsExternalOrder extends BaseEntity
     @Excel(name = "物流更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date deliveryUpdateTime;
 
-    @Excel(name = "配送方式 1快递 2门店自提")
+    /** 签收状态更新时间(拒收/签收) */
+    private Date deliveryStatusUpdateTime;
+
+    /** 签收状态更新人(拒收人/签收人) */
+    private String deliveryStatusUpdateBy;
+
     private Integer shippingType;
 
-    @Excel(name = "公司ID")
     private Long companyId;
 
     private Long companyUserId;
@@ -114,11 +117,6 @@ public class FsExternalOrder extends BaseEntity
 
     private Long storeId;
 
-    /** 定金回款时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "定金回款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date depositReturnTime;
-
     /** 代收金额 */
     @Excel(name = "代收金额")
     private BigDecimal collectionPrice;
@@ -132,13 +130,17 @@ public class FsExternalOrder extends BaseEntity
     @Excel(name = "退款金额")
     private BigDecimal refundPrice;
 
+    /** 回款金额 */
+    @Excel(name = "回款金额")
+    private BigDecimal returnPrice;
+
     /** 退款日期 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "退款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date refundTime;
 
-    /** 订单类型 */
-    @Excel(name = "订单类型")
+    /** 订单类型  1.外部订单  2。套餐包订单 3.问诊订单 4.积分订单*/
+    @Excel(name = "订单类型", readConverterExp = "1=外部订单,2=套餐包,3=问诊,4=积分")
     private Integer orderType;
 
     /** 审核人 */
@@ -153,4 +155,22 @@ public class FsExternalOrder extends BaseEntity
     /** 病名 */
     @Excel(name = "病名")
     private String diseaseName;
-}
+
+    /** 查询开始时间 */
+    private String sTime;
+
+    /** 查询结束时间 */
+    private String eTime;
+
+    /** 回款状态筛选: 0=未回款 1=已回款 */
+    @TableField(exist = false)
+    private String returnStatus;
+
+    /** 发货开始时间 */
+    @TableField(exist = false)
+    private String deliveryStartTime;
+
+    /** 发货结束时间 */
+    @TableField(exist = false)
+    private String deliveryEndTime;
+}

+ 23 - 1
fs-service/src/main/java/com/fs/his/domain/FsUserAddress.java

@@ -105,6 +105,7 @@ public class FsUserAddress extends BaseEntity
     {
         return addressId;
     }
+
     public void setUserId(Long userId) 
     {
         this.userId = userId;
@@ -114,6 +115,7 @@ public class FsUserAddress extends BaseEntity
     {
         return userId;
     }
+
     public void setRealName(String realName) 
     {
         this.realName = realName;
@@ -123,6 +125,7 @@ public class FsUserAddress extends BaseEntity
     {
         return realName;
     }
+
     public void setPhone(String phone) 
     {
         this.phone = phone;
@@ -132,6 +135,7 @@ public class FsUserAddress extends BaseEntity
     {
         return phone;
     }
+
     public void setProvince(String province) 
     {
         this.province = province;
@@ -141,6 +145,7 @@ public class FsUserAddress extends BaseEntity
     {
         return province;
     }
+
     public void setCity(String city) 
     {
         this.city = city;
@@ -150,6 +155,7 @@ public class FsUserAddress extends BaseEntity
     {
         return city;
     }
+
     public void setDistrict(String district) 
     {
         this.district = district;
@@ -159,6 +165,17 @@ public class FsUserAddress extends BaseEntity
     {
         return district;
     }
+
+    public void setTownship(String township)
+    {
+        this.township = township;
+    }
+
+    public String getTownship()
+    {
+        return township;
+    }
+
     public void setCityIds(String cityIds) 
     {
         this.cityIds = cityIds;
@@ -168,6 +185,7 @@ public class FsUserAddress extends BaseEntity
     {
         return cityIds;
     }
+
     public void setDetail(String detail) 
     {
         this.detail = detail;
@@ -177,6 +195,7 @@ public class FsUserAddress extends BaseEntity
     {
         return detail;
     }
+
     public void setPostCode(String postCode) 
     {
         this.postCode = postCode;
@@ -186,6 +205,7 @@ public class FsUserAddress extends BaseEntity
     {
         return postCode;
     }
+
     public void setLongitude(String longitude) 
     {
         this.longitude = longitude;
@@ -195,6 +215,7 @@ public class FsUserAddress extends BaseEntity
     {
         return longitude;
     }
+
     public void setLatitude(String latitude) 
     {
         this.latitude = latitude;
@@ -204,6 +225,7 @@ public class FsUserAddress extends BaseEntity
     {
         return latitude;
     }
+
     public void setIsDefault(Integer isDefault)
     {
         this.isDefault = isDefault;
@@ -213,6 +235,7 @@ public class FsUserAddress extends BaseEntity
     {
         return isDefault;
     }
+
     public void setIsDel(Integer isDel)
     {
         this.isDel = isDel;
@@ -223,5 +246,4 @@ public class FsUserAddress extends BaseEntity
         return isDel;
     }
 
-
 }

+ 56 - 0
fs-service/src/main/java/com/fs/his/domain/vo/FsExternalOrderListVO.java

@@ -11,22 +11,38 @@ public class FsExternalOrderListVO {
 
     private Long orderId;
 
+    private  Long userId;
+
     private String orderCode;
 
     private String companyName;
 
+    private String deptName;
+
     private String companyUserName;
 
     private String userName;
 
     private String userPhone;
 
+    private String memberPhone;
+
+    private Integer memberAge;
+
+    private Integer memberSex;
+
+    private Integer memberBuyCount;
+
     private String productNames;
 
     private BigDecimal receivablePrice;
 
     private BigDecimal payPrice;
 
+    private BigDecimal totalPrice;
+
+    private BigDecimal collectionPrice;
+
     private Integer payType;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -34,8 +50,17 @@ public class FsExternalOrderListVO {
 
     private Integer status;
 
+    private Integer orderType;
+
     private String deliverySn;
 
+    private String deliveryCode;
+
+    private String deliveryName;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryTime;
+
     private Integer deliveryStatus;
 
     private String deliveryType;
@@ -43,6 +68,37 @@ public class FsExternalOrderListVO {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date deliveryUpdateTime;
 
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    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;
+
+    private BigDecimal refundPrice;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date refundTime;
+
+    private String remark;
+
+    private String auditor;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date auditTime;
+
+    private String diseaseName;
+
+    private String province;
+
+    private String city;
+
+    private String district;
+
+    private String township;
+
     private String statusDesc;
 
     private Boolean isApplyAudit;

+ 74 - 0
fs-service/src/main/java/com/fs/his/domain/vo/FsFinanceOrderListVO.java

@@ -0,0 +1,74 @@
+package com.fs.his.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class FsFinanceOrderListVO {
+
+    private Long orderId;
+
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date externalCreateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "回款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date returnTime;
+
+    @Excel(name = "回款人")
+    private String returnUser;
+
+    @Excel(name = "会员姓名")
+    private String userName;
+
+    @Excel(name = "快递公司")
+    private String deliveryName;
+
+    @Excel(name = "运单号")
+    private String deliverySn;
+
+    @Excel(name = "订单金额")
+    private BigDecimal totalPrice;
+
+    @Excel(name = "代收金额")
+    private BigDecimal collectionPrice;
+
+    @Excel(name = "回款金额")
+    private BigDecimal returnPrice;
+
+    @Excel(name = "收件人电话")
+    private String receiverPhone;
+
+    @Excel(name = "订购产品")
+    private String productNames;
+
+    @Excel(name = "备注")
+    private String remark;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryTime;
+
+    @Excel(name = "销售姓名")
+    private String companyUserName;
+
+    @Excel(name = "公司")
+    private String companyName;
+
+    @Excel(name = "部门")
+    private String deptName;
+
+    @Excel(name = "付款方式", readConverterExp = "1=微信,2=支付宝,3=其他")
+    private Integer payType;
+
+    @Excel(name = "回款状态", readConverterExp = "0=未回款,1=已回款")
+    private Integer returnStatus;
+}

+ 28 - 0
fs-service/src/main/java/com/fs/his/dto/FsFinanceOrderImportDTO.java

@@ -0,0 +1,28 @@
+package com.fs.his.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 财务外部订单导入DTO
+ */
+@Data
+public class FsFinanceOrderImportDTO {
+
+    @Excel(name = "快递单号")
+    private String deliverySn;
+
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "回款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date returnTime;
+
+    @Excel(name = "回款金额")
+    private BigDecimal returnPrice;
+}

+ 43 - 0
fs-service/src/main/java/com/fs/his/dto/FsFinanceOrderImportFailDTO.java

@@ -0,0 +1,43 @@
+package com.fs.his.dto;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 财务回款导入失败记录
+ */
+@Data
+public class FsFinanceOrderImportFailDTO {
+
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    @Excel(name = "快递单号")
+    private String deliverySn;
+
+    @Excel(name = "订单金额")
+    private BigDecimal totalPrice;
+
+    @Excel(name = "代收金额")
+    private BigDecimal collectionPrice;
+
+    @Excel(name = "导入回款金额")
+    private BigDecimal importReturnPrice;
+
+    @Excel(name = "失败原因")
+    private String failReason;
+
+    public FsFinanceOrderImportFailDTO() {}
+
+    public FsFinanceOrderImportFailDTO(String orderCode, String deliverySn, BigDecimal totalPrice,
+                                        BigDecimal collectionPrice, BigDecimal importReturnPrice, String failReason) {
+        this.orderCode = orderCode;
+        this.deliverySn = deliverySn;
+        this.totalPrice = totalPrice;
+        this.collectionPrice = collectionPrice;
+        this.importReturnPrice = importReturnPrice;
+        this.failReason = failReason;
+    }
+}

+ 3 - 0
fs-service/src/main/java/com/fs/his/mapper/FsExternalOrderMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.fs.his.domain.FsExternalOrder;
 import com.fs.his.domain.vo.FsExternalOrderListVO;
+import com.fs.his.domain.vo.FsFinanceOrderListVO;
 import com.fs.his.vo.FsExternalOrderDetailVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -39,4 +40,6 @@ public interface FsExternalOrderMapper {
     List<FsExternalOrder> selectSyncedOrders();
 
     List<FsExternalOrder> selectSignedOrdersWithoutAudit();
+
+    List<FsFinanceOrderListVO> selectFinanceOrderListVO(FsExternalOrder fsExternalOrder);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/param/FsExternalOrderAddParam.java

@@ -33,6 +33,8 @@ public class FsExternalOrderAddParam {
 
     private Long companyUserId;
 
+    private String createBy;
+
     private String remark;
 
     private List<ExternalOrderProductDTO> products;

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

@@ -51,7 +51,7 @@ public interface IFsExternalOrderService {
      * @param orderId 订单ID
      * @return 结果
      */
-    R auditExternalOrder(Long orderId);
+    R auditExternalOrder(Long orderId, String auditor);
 
     /**
      * 取消外部订单

+ 22 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsExternalOrderServiceImpl.java

@@ -142,7 +142,15 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
     @Override
     @DataScope(deptAlias = "cu",userAlias = "cu")
     public List<FsExternalOrderListVO> selectExternalOrderListVO(FsExternalOrder fsExternalOrder) {
-        return fsExternalOrderMapper.selectExternalOrderListVO(fsExternalOrder);
+        List<FsExternalOrderListVO> list = fsExternalOrderMapper.selectExternalOrderListVO(fsExternalOrder);
+        if (list != null) {
+            for (FsExternalOrderListVO vo : list) {
+                if (vo.getMemberPhone() != null && vo.getMemberPhone().length() > 11) {
+                    try { vo.setMemberPhone(PhoneUtil.decryptPhone(vo.getMemberPhone())); } catch (Exception ignored) {}
+                }
+            }
+        }
+        return list;
     }
 
     @Override
@@ -151,6 +159,9 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         if (detailVO != null) {
             List<FsExternalOrderDetailVO.ProductItemVO> productList = fsExternalOrderItemMapper.selectProductItemVOByOrderId(orderId);
             detailVO.setProductList(productList);
+            if (detailVO.getMemberPhone() != null && detailVO.getMemberPhone().length() > 11) {
+                try { detailVO.setMemberPhone(PhoneUtil.decryptPhone(detailVO.getMemberPhone())); } catch (Exception ignored) {}
+            }
         }
         return detailVO;
     }
@@ -311,11 +322,14 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         order.setPayType(param.getPayType());
         order.setCompanyId(param.getCompanyId());
         order.setCompanyUserId(param.getCompanyUserId());
+        order.setCreateBy(param.getCreateBy());
         order.setRemark(param.getRemark());
         order.setStatus(1);
         order.setIsPay(1);
         order.setIsSync(0);
         order.setShippingType(1);
+        //订单类型
+        order.setOrderType(1);
         order.setReceiverPhone(param.getReceiverPhone());
         order.setExternalCreateTime(new Date());
 
@@ -360,6 +374,10 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         order.setTotalNum(totalNum);
         order.setTotalPrice(param.getTotalPrice()!=null?param.getTotalPrice():totalPrice);
         order.setPayPrice(param.getPayMoney() != null ? param.getPayMoney() : totalPrice);
+        // 代收金额 = 商品总额 - 定金
+        BigDecimal tp = order.getTotalPrice() != null ? order.getTotalPrice() : BigDecimal.ZERO;
+        BigDecimal pp = order.getPayPrice() != null ? order.getPayPrice() : BigDecimal.ZERO;
+        order.setCollectionPrice(tp.subtract(pp));
         if (fsExternalOrderMapper.insertFsExternalOrder(order) > 0) {
             for (FsExternalOrderItem item : items) {
                 item.setOrderId(order.getOrderId());
@@ -798,7 +816,7 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
     }
 
     @Override
-    public R auditExternalOrder(Long orderId) {
+    public R auditExternalOrder(Long orderId, String auditor) {
         FsExternalOrder order = fsExternalOrderMapper.selectFsExternalOrderByOrderId(orderId);
         if (order == null) {
             return R.error("订单不存在");
@@ -809,6 +827,8 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         FsExternalOrder updateOrder = new FsExternalOrder();
         updateOrder.setOrderId(orderId);
         updateOrder.setStatus(2);
+        updateOrder.setAuditor(auditor);
+        updateOrder.setAuditTime(new java.util.Date());
         int result = fsExternalOrderMapper.updateFsExternalOrder(updateOrder);
         if (result > 0) {
             return R.ok("审核成功");

+ 47 - 4
fs-service/src/main/java/com/fs/his/vo/FsExternalOrderDetailVO.java

@@ -25,8 +25,24 @@ public class FsExternalOrderDetailVO implements Serializable {
 
     private String userPhone;
 
+    private String memberPhone;
+
+    private Integer memberAge;
+
+    private Integer memberSex;
+
+    private Integer memberBuyCount;
+
     private String userAddress;
 
+    private String province;
+
+    private String city;
+
+    private String district;
+
+    private String township;
+
     private Long totalNum;
 
     private BigDecimal totalPrice;
@@ -35,6 +51,8 @@ public class FsExternalOrderDetailVO implements Serializable {
 
     private BigDecimal payPrice;
 
+    private BigDecimal collectionPrice;
+
     private BigDecimal freightPrice;
 
     private Integer isPay;
@@ -46,6 +64,8 @@ public class FsExternalOrderDetailVO implements Serializable {
 
     private Integer status;
 
+    private Integer orderType;
+
     private String deliveryCode;
 
     private String deliveryName;
@@ -57,25 +77,48 @@ public class FsExternalOrderDetailVO implements Serializable {
     private String deliveryType;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date deliveryUpdateTime;
+    private Date deliveryTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date deliveryTime;
+    private Date deliveryUpdateTime;
 
     private Integer shippingType;
 
     private String remark;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date externalCreateTime;
+    private Date followTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date createTime;
+    private Date updateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date depositReturnTime;
+
+    private BigDecimal refundPrice;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date refundTime;
+
+    private String auditor;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date auditTime;
+
+    private String diseaseName;
 
     private String companyName;
 
+    private String deptName;
+
     private String companyUserName;
 
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date externalCreateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
     private List<ProductItemVO> productList;
 
     @Data

+ 194 - 59
fs-service/src/main/resources/mapper/his/FsExternalOrderMapper.xml

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
@@ -26,7 +26,9 @@
         <result property="deliveryTime"        column="delivery_time"        />
         <result property="deliveryStatus"      column="delivery_status"      />
         <result property="deliveryType"        column="delivery_type"        />
-        <result property="deliveryUpdateTime"  column="delivery_update_time" />
+        <result property="deliveryUpdateTime" column="delivery_update_time" />
+        <result property="deliveryStatusUpdateTime" column="delivery_status_update_time" />
+        <result property="deliveryStatusUpdateBy" column="delivery_status_update_by" />
         <result property="shippingType"        column="shipping_type"        />
         <result property="companyId"           column="company_id"           />
         <result property="companyUserId"       column="company_user_id"      />
@@ -35,14 +37,16 @@
         <result property="isSync"              column="is_sync"              />
         <result property="syncMsg"             column="sync_msg"             />
         <result property="createTime"          column="create_time"          />
+        <result property="createBy"            column="create_by"            />
         <result property="updateTime"          column="update_time"          />
+        <result property="updateBy"            column="update_by"            />
         <result property="extendOrderId"       column="extend_order_id"      />
         <result property="storeId"             column="store_id"             />
         <result property="receiverPhone"       column="receiver_phone"       />
-        <result property="depositReturnTime"   column="deposit_return_time"  />
         <result property="collectionPrice"     column="collection_price"     />
         <result property="followTime"          column="follow_time"          />
         <result property="refundPrice"         column="refund_price"         />
+        <result property="returnPrice"        column="return_price"        />
         <result property="refundTime"          column="refund_time"          />
         <result property="orderType"           column="order_type"           />
         <result property="auditor"             column="auditor"              />
@@ -54,26 +58,26 @@
         select order_id, order_code, source, user_id, user_name, user_phone, user_address,
                total_num, total_price, pay_price, freight_price, is_pay, pay_time, pay_type,
                status, delivery_code, delivery_name, delivery_sn, delivery_time, delivery_status,
-               delivery_type, delivery_update_time, shipping_type, company_id, company_user_id,
-               remark, external_create_time, is_sync, sync_msg, create_time, update_time,
+               delivery_type, delivery_update_time, delivery_status_update_time, delivery_status_update_by, shipping_type, company_id, company_user_id,
+               remark, external_create_time, is_sync, sync_msg, create_time, create_by, update_time, update_by,
                extend_order_id, store_id, receiver_phone,
-               deposit_return_time, collection_price, follow_time,
-               refund_price, refund_time, order_type, auditor, audit_time, disease_name
+               collection_price, follow_time,
+               refund_price, return_price, refund_time, order_type, auditor, audit_time, disease_name
         from fs_external_order
     </sql>
 
     <select id="selectFsExternalOrderList" parameterType="FsExternalOrder" resultMap="FsExternalOrderResult">
         <include refid="selectFsExternalOrderVo"/>
         <where>
-            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
-            <if test="source != null  and source != ''"> and source = #{source}</if>
-            <if test="userId != null "> and user_id = #{userId}</if>
-            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
-            <if test="userPhone != null  and userPhone != ''"> and user_phone = #{userPhone}</if>
-            <if test="isPay != null "> and is_pay = #{isPay}</if>
-            <if test="status != null "> and status = #{status}</if>
-            <if test="companyId != null "> and company_id = #{companyId}</if>
-            <if test="isSync != null "> and is_sync = #{isSync}</if>
+            <if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
+            <if test="source != null and source != ''"> and source = #{source}</if>
+            <if test="userId != null"> and user_id = #{userId}</if>
+            <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
+            <if test="userPhone != null and userPhone != ''"> and user_phone = #{userPhone}</if>
+            <if test="isPay != null"> and is_pay = #{isPay}</if>
+            <if test="status != null"> and status = #{status}</if>
+            <if test="companyId != null"> and company_id = #{companyId}</if>
+            <if test="isSync != null"> and is_sync = #{isSync}</if>
         </where>
         order by create_time desc
     </select>
@@ -122,6 +126,8 @@
             <if test="deliveryStatus != null">delivery_status,</if>
             <if test="deliveryType != null and deliveryType != ''">delivery_type,</if>
             <if test="deliveryUpdateTime != null">delivery_update_time,</if>
+            <if test="deliveryStatusUpdateTime != null">delivery_status_update_time,</if>
+            <if test="deliveryStatusUpdateBy != null and deliveryStatusUpdateBy != ''">delivery_status_update_by,</if>
             <if test="shippingType != null">shipping_type,</if>
             <if test="companyId != null">company_id,</if>
             <if test="companyUserId != null">company_user_id,</if>
@@ -132,15 +138,16 @@
             <if test="extendOrderId != null and extendOrderId != ''">extend_order_id,</if>
             <if test="storeId != null">store_id,</if>
             <if test="receiverPhone != null and receiverPhone != ''">receiver_phone,</if>
-            <if test="depositReturnTime != null">deposit_return_time,</if>
             <if test="collectionPrice != null">collection_price,</if>
             <if test="followTime != null">follow_time,</if>
             <if test="refundPrice != null">refund_price,</if>
+            <if test="returnPrice != null">return_price,</if>
             <if test="refundTime != null">refund_time,</if>
             <if test="orderType != null">order_type,</if>
             <if test="auditor != null and auditor != ''">auditor,</if>
             <if test="auditTime != null">audit_time,</if>
             <if test="diseaseName != null and diseaseName != ''">disease_name,</if>
+            create_by,
             create_time
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -165,6 +172,8 @@
             <if test="deliveryStatus != null">#{deliveryStatus},</if>
             <if test="deliveryType != null and deliveryType != ''">#{deliveryType},</if>
             <if test="deliveryUpdateTime != null">#{deliveryUpdateTime},</if>
+            <if test="deliveryStatusUpdateTime != null">#{deliveryStatusUpdateTime},</if>
+            <if test="deliveryStatusUpdateBy != null and deliveryStatusUpdateBy != ''">#{deliveryStatusUpdateBy},</if>
             <if test="shippingType != null">#{shippingType},</if>
             <if test="companyId != null">#{companyId},</if>
             <if test="companyUserId != null">#{companyUserId},</if>
@@ -175,15 +184,16 @@
             <if test="extendOrderId != null and extendOrderId != ''">#{extendOrderId},</if>
             <if test="storeId != null">#{storeId},</if>
             <if test="receiverPhone != null and receiverPhone != ''">#{receiverPhone},</if>
-            <if test="depositReturnTime != null">#{depositReturnTime},</if>
             <if test="collectionPrice != null">#{collectionPrice},</if>
             <if test="followTime != null">#{followTime},</if>
             <if test="refundPrice != null">#{refundPrice},</if>
+            <if test="returnPrice != null">#{returnPrice},</if>
             <if test="refundTime != null">#{refundTime},</if>
             <if test="orderType != null">#{orderType},</if>
             <if test="auditor != null and auditor != ''">#{auditor},</if>
             <if test="auditTime != null">#{auditTime},</if>
             <if test="diseaseName != null and diseaseName != ''">#{diseaseName},</if>
+            #{createBy},
             sysdate()
         </trim>
     </insert>
@@ -212,26 +222,29 @@
             <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
             <if test="deliveryType != null and deliveryType != ''">delivery_type = #{deliveryType},</if>
             <if test="deliveryUpdateTime != null">delivery_update_time = #{deliveryUpdateTime},</if>
+            <if test="deliveryStatusUpdateTime != null">delivery_status_update_time = #{deliveryStatusUpdateTime},</if>
+            <if test="deliveryStatusUpdateBy != null and deliveryStatusUpdateBy != ''">delivery_status_update_by = #{deliveryStatusUpdateBy},</if>
             <if test="shippingType != null">shipping_type = #{shippingType},</if>
             <if test="companyId != null">company_id = #{companyId},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
-            <if test="remark != null and remark != ''">remark = #{remark},</if>
+            <if test="remark != null">remark = #{remark},</if>
             <if test="externalCreateTime != null">external_create_time = #{externalCreateTime},</if>
             <if test="isSync != null">is_sync = #{isSync},</if>
             <if test="syncMsg != null and syncMsg != ''">sync_msg = #{syncMsg},</if>
             <if test="extendOrderId != null and extendOrderId != ''">extend_order_id = #{extendOrderId},</if>
             <if test="storeId != null">store_id = #{storeId},</if>
             <if test="receiverPhone != null and receiverPhone != ''">receiver_phone = #{receiverPhone},</if>
-            <if test="depositReturnTime != null">deposit_return_time = #{depositReturnTime},</if>
             <if test="collectionPrice != null">collection_price = #{collectionPrice},</if>
             <if test="followTime != null">follow_time = #{followTime},</if>
             <if test="refundPrice != null">refund_price = #{refundPrice},</if>
+            <if test="returnPrice != null">return_price = #{returnPrice},</if>
             <if test="refundTime != null">refund_time = #{refundTime},</if>
             <if test="orderType != null">order_type = #{orderType},</if>
             <if test="auditor != null and auditor != ''">auditor = #{auditor},</if>
             <if test="auditTime != null">audit_time = #{auditTime},</if>
-            <if test="diseaseName != null and diseaseName != ''">disease_name = #{diseaseName},</if>
-            update_time = sysdate()
+            <if test="diseaseName != null">disease_name = #{diseaseName},</if>
+            update_by = #{updateBy},
+            update_time = #{updateTime}
         </trim>
         where order_id = #{orderId}
     </update>
@@ -247,38 +260,78 @@
         </foreach>
     </delete>
 
+
     <select id="selectExternalOrderListVO" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsExternalOrderListVO">
         SELECT
-        o.order_id,
-        o.order_code,
-        c.company_name AS companyName,
-        cu.user_name AS companyUserName,
-        o.user_name AS userName,
-        o.user_phone AS userPhone,
-        GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
-        IFNULL(o.total_price, SUM(oi.price)) AS receivablePrice,
-        o.pay_price AS payPrice,
-        o.pay_type AS payType,
-        o.external_create_time AS externalCreateTime,
-        o.status,
-        o.delivery_sn AS deliverySn,
-        o.delivery_status AS deliveryStatus,
-        o.delivery_type AS deliveryType,
-        o.delivery_update_time AS deliveryUpdateTime,
-        CASE o.status
-        WHEN 1 THEN '待审核'
-        WHEN 2 THEN '待发货'
-        WHEN 3 THEN '待收货'
-        WHEN 4 THEN '已完成'
-        WHEN -3 THEN '已取消'
-        ELSE '未知'
-        END AS statusDesc,
-        IF(fa.id IS NOT NULL AND fa.audit_status = 0, true, false) AS isApplyAudit
+            o.order_id AS orderId,
+            o.order_code AS orderCode,
+            o.user_id AS userId,
+            c.company_name AS companyName,
+            d.dept_name AS deptName,
+            cu.user_name AS companyUserName,
+            o.user_name AS userName,
+            o.user_phone AS userPhone,
+            u.phone AS memberPhone,
+            u.sex AS memberSex,
+            CASE
+                WHEN u.birthday IS NOT NULL AND u.birthday > 0
+                THEN TIMESTAMPDIFF(YEAR, FROM_UNIXTIME(u.birthday), CURDATE())
+                ELSE NULL
+            END AS memberAge,
+            (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2
+             WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) AS memberBuyCount,
+            GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
+            IFNULL(o.total_price, SUM(oi.price * oi.num)) AS receivablePrice,
+            o.pay_price AS payPrice,
+            o.total_price AS totalPrice,
+            o.collection_price AS collectionPrice,
+            o.pay_type AS payType,
+            o.external_create_time AS externalCreateTime,
+            o.status,
+            o.order_type AS orderType,
+            o.delivery_sn AS deliverySn,
+            o.delivery_code AS deliveryCode,
+            o.delivery_name AS deliveryName,
+            o.delivery_time AS deliveryTime,
+            o.delivery_status AS deliveryStatus,
+            o.delivery_type AS deliveryType,
+            o.delivery_update_time AS deliveryUpdateTime,
+            o.follow_time AS followTime,
+            o.update_time AS updateTime,
+            o.deposit_return_time AS depositReturnTime,
+            o.refund_price AS refundPrice,
+            o.refund_time AS refundTime,
+            o.remark,
+            o.auditor,
+            o.audit_time AS auditTime,
+            o.disease_name AS diseaseName,
+            ua.province,
+            ua.city,
+            ua.district,
+            ua.town_ship AS township,
+            CASE o.status
+                WHEN 1  THEN '未审核'
+                WHEN 2  THEN '审核通过'
+                WHEN 3  THEN '已发货'
+                WHEN 4  THEN '已回款'
+                WHEN -3 THEN '已取消'
+                ELSE '未知'
+            END AS statusDesc,
+            IF(fa.id IS NOT NULL AND fa.audit_status = 0, true, false) AS isApplyAudit
         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
-        LEFT JOIN fs_external_order_item oi ON o.order_id = oi.order_id
+        LEFT JOIN company c                       ON o.company_id      = c.company_id
+        LEFT JOIN company_user cu                 ON o.company_user_id = cu.user_id
+        LEFT JOIN company_dept d                  ON cu.dept_id        = d.dept_id
+        LEFT JOIN fs_external_order_item oi       ON o.order_id        = oi.order_id
         LEFT JOIN fs_store_order_finance_audit fa ON fa.order_id = o.order_id AND fa.order_type = 0 AND fa.audit_status = 0
+        LEFT JOIN fs_user u                       ON o.user_id         = u.user_id
+        LEFT JOIN fs_user_address ua              ON ua.address_id = (
+            SELECT ua2.address_id
+            FROM fs_user_address ua2
+            WHERE ua2.user_id = o.user_id AND IFNULL(ua2.is_del, 0) = 0
+            ORDER BY ua2.is_default DESC, ua2.update_time DESC, ua2.create_time DESC, ua2.address_id DESC
+            LIMIT 1
+        )
         <where>
             <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
             <if test="userId != null"> AND o.user_id = #{userId}</if>
@@ -289,6 +342,8 @@
             <if test="companyId != null"> AND o.company_id = #{companyId}</if>
             <if test="companyUserId != null"> AND o.company_user_id = #{companyUserId}</if>
             <if test="isSync != null"> AND o.is_sync = #{isSync}</if>
+            <if test="sTime != null and sTime != ''"> AND o.external_create_time &gt;= #{sTime}</if>
+            <if test="eTime != null and eTime != ''"> AND o.external_create_time &lt;= CONCAT(#{eTime},' 23:59:59')</if>
             ${params.dataScope}
         </where>
         GROUP BY o.order_id
@@ -303,15 +358,31 @@
             o.user_id AS userId,
             o.user_name AS userName,
             o.user_phone AS userPhone,
+            u.phone AS memberPhone,
+            u.sex AS memberSex,
+            CASE
+                WHEN u.birthday IS NOT NULL AND u.birthday > 0
+                THEN TIMESTAMPDIFF(YEAR, FROM_UNIXTIME(u.birthday), CURDATE())
+                ELSE NULL
+            END AS memberAge,
+            (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2
+             WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) AS memberBuyCount,
             o.user_address AS userAddress,
+            ua.province,
+            ua.city,
+            ua.district,
+            ua.town_ship AS township,
             o.total_num AS totalNum,
-            o.total_price AS receivablePrice,
+            o.total_price AS totalPrice,
+            IFNULL(o.total_price, 0) AS receivablePrice,
             o.pay_price AS payPrice,
+            o.collection_price AS collectionPrice,
             o.freight_price AS freightPrice,
             o.is_pay AS isPay,
             o.pay_time AS payTime,
             o.pay_type AS payType,
             o.status,
+            o.order_type AS orderType,
             o.delivery_code AS deliveryCode,
             o.delivery_name AS deliveryName,
             o.delivery_sn AS deliverySn,
@@ -321,23 +392,87 @@
             o.delivery_time AS deliveryTime,
             o.shipping_type AS shippingType,
             o.remark,
+            o.follow_time AS followTime,
+            o.update_time AS updateTime,
+            o.deposit_return_time AS depositReturnTime,
+            o.refund_price AS refundPrice,
+            o.refund_time AS refundTime,
+            o.auditor,
+            o.audit_time AS auditTime,
+            o.disease_name AS diseaseName,
             o.external_create_time AS externalCreateTime,
             o.create_time AS createTime,
             c.company_name AS companyName,
+            d.dept_name AS deptName,
             cu.nick_name AS companyUserName
         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
+        LEFT JOIN company c           ON o.company_id      = c.company_id
+        LEFT JOIN company_user cu     ON o.company_user_id = cu.user_id
+        LEFT JOIN company_dept d      ON cu.dept_id        = d.dept_id
+        LEFT JOIN fs_user u           ON o.user_id         = u.user_id
+        LEFT JOIN fs_user_address ua  ON ua.address_id = (
+            SELECT ua2.address_id
+            FROM fs_user_address ua2
+            WHERE ua2.user_id = o.user_id AND IFNULL(ua2.is_del, 0) = 0
+            ORDER BY ua2.is_default DESC, ua2.update_time DESC, ua2.create_time DESC, ua2.address_id DESC
+            LIMIT 1
+        )
         WHERE o.order_id = #{orderId}
     </select>
 
     <select id="selectSignedOrdersWithoutAudit" resultMap="FsExternalOrderResult">
-        select * from fs_external_order o
-        where o.delivery_status = 3 and o.status != -3
-        and not exists (
-            select 1 from fs_store_order_finance_audit fa
-            where fa.order_id = o.order_id and fa.audit_type = 2 and fa.order_type = 0
+        SELECT * FROM fs_external_order o
+        WHERE o.delivery_status = 3 AND o.status != -3
+        AND NOT EXISTS (
+            SELECT 1 FROM fs_store_order_finance_audit fa
+            WHERE fa.order_id = o.order_id AND fa.audit_type = 2 AND fa.order_type = 0
         )
     </select>
 
-</mapper>
+    <select id="selectFinanceOrderListVO" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsFinanceOrderListVO">
+        SELECT
+            o.order_id AS orderId,
+            o.order_code AS orderCode,
+            o.external_create_time AS externalCreateTime,
+            o.update_time AS returnTime,
+            o.update_by AS returnUser,
+            o.user_name AS userName,
+            o.delivery_name AS deliveryName,
+            o.delivery_sn AS deliverySn,
+            o.total_price AS totalPrice,
+            o.collection_price AS collectionPrice,
+            o.return_price AS returnPrice,
+            o.receiver_phone AS receiverPhone,
+            GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
+            o.remark,
+            o.delivery_time AS deliveryTime,
+            cu.user_name AS companyUserName,
+            c.company_name AS companyName,
+            d.dept_name AS deptName,
+            o.pay_type AS payType,
+            CASE WHEN o.status = 4 THEN 1 ELSE 0 END AS returnStatus
+        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
+        LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
+        LEFT JOIN fs_external_order_item oi ON o.order_id = oi.order_id
+        <where>
+            <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
+            <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
+            <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
+            <if test="status != null"> AND o.status = #{status}</if>
+            <if test="companyId != null"> AND o.company_id = #{companyId}</if>
+            <if test="returnStatus != null">
+                <if test="returnStatus == 1"> AND o.status = 4</if>
+                <if test="returnStatus == 0"> AND o.status != 4</if>
+            </if>
+            <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
+            <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time &lt;= #{deliveryEndTime}</if>
+            ${params.dataScope}
+        </where>
+        GROUP BY o.order_id
+        ORDER BY o.create_time DESC
+    </select>
+
+</mapper>
+

+ 4 - 4
fs-service/src/main/resources/mapper/his/FsUserAddressMapper.xml

@@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="province"    column="province"    />
         <result property="city"    column="city"    />
         <result property="district"    column="district"    />
-        <result property="township"    column="township"    />
+        <result property="township"    column="town_ship"    />
         <result property="cityIds"    column="city_ids"    />
         <result property="detail"    column="detail"    />
         <result property="postCode"    column="post_code"    />
@@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectFsUserAddressVo">
-        select address_id, user_id, real_name, phone, province, city, district, township, city_ids, detail, post_code, longitude, latitude, is_default, is_del, create_time, update_time, is_confirm, help_company_user_id from fs_user_address
+        select address_id, user_id, real_name, phone, province, city, district, town_ship, city_ids, detail, post_code, longitude, latitude, is_default, is_del, create_time, update_time, is_confirm, help_company_user_id from fs_user_address
     </sql>
 
     <select id="selectFsUserAddressList" parameterType="FsUserAddress" resultMap="FsUserAddressResult">
@@ -65,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="province != null and province != ''">province,</if>
             <if test="city != null and city != ''">city,</if>
             <if test="district != null and district != ''">district,</if>
-            <if test="township != null and township != ''">township,</if>
+            <if test="township != null and township != ''">town_ship,</if>
             <if test="cityIds != null">city_ids,</if>
             <if test="detail != null and detail != ''">detail,</if>
             <if test="postCode != null and postCode != ''">post_code,</if>
@@ -109,7 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="province != null and province != ''">province = #{province},</if>
             <if test="city != null and city != ''">city = #{city},</if>
             <if test="district != null and district != ''">district = #{district},</if>
-            <if test="township != null and township != ''">township = #{township},</if>
+            <if test="township != null and township != ''">town_ship = #{township},</if>
             <if test="cityIds != null">city_ids = #{cityIds},</if>
             <if test="detail != null and detail != ''">detail = #{detail},</if>
             <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>

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

@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="nickName"    column="nick_name"    />
         <result property="avatar"    column="avatar"    />
         <result property="phone"    column="phone"    />
+        <result property="birthday"    column="birthday"    />
         <result property="integral"    column="integral"    />
         <result property="status"    column="status"    />
         <result property="tuiUserId"    column="tui_user_id"    />
@@ -667,6 +668,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nickName != null">nick_name,</if>
             <if test="avatar != null">avatar,</if>
             <if test="phone != null">phone,</if>
+            <if test="birthday != null">birthday,</if>
             <if test="integral != null">integral,</if>
             <if test="signNum != null">sign_num,</if>
             <if test="status != null">status,</if>
@@ -719,6 +721,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nickName != null">#{nickName},</if>
             <if test="avatar != null">#{avatar},</if>
             <if test="phone != null">#{phone},</if>
+            <if test="birthday != null">#{birthday},</if>
             <if test="integral != null">#{integral},</if>
             <if test="signNum != null">#{signNum},</if>
             <if test="status != null">#{status},</if>
@@ -2785,6 +2788,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             fu.nick_name,
             fu.avatar,
             fu.phone,
+            fu.sex,
+            fu.birthday,
             fu.status,
             fu.source,
             fu.login_device as loginDevice,