Selaa lähdekoodia

Merge remote-tracking branch 'origin/红德堂' into 红德堂

wangxy 2 viikkoa sitten
vanhempi
commit
4bfb317ad2
21 muutettua tiedostoa jossa 927 lisäystä ja 176 poistoa
  1. 3 1
      fs-admin/src/main/java/com/fs/his/controller/FsExternalOrderController.java
  2. 23 1
      fs-company/src/main/java/com/fs/company/controller/store/FsExternalOrderController.java
  3. 155 0
      fs-company/src/main/java/com/fs/company/controller/store/FsFinanceOrderController.java
  4. 1 1
      fs-company/src/main/resources/application.yml
  5. 16 2
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodServiceImpl.java
  6. 89 72
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  7. 72 16
      fs-service/src/main/java/com/fs/his/domain/FsExternalOrder.java
  8. 27 1
      fs-service/src/main/java/com/fs/his/domain/FsUserAddress.java
  9. 56 0
      fs-service/src/main/java/com/fs/his/domain/vo/FsExternalOrderListVO.java
  10. 74 0
      fs-service/src/main/java/com/fs/his/domain/vo/FsFinanceOrderListVO.java
  11. 28 0
      fs-service/src/main/java/com/fs/his/dto/FsFinanceOrderImportDTO.java
  12. 43 0
      fs-service/src/main/java/com/fs/his/dto/FsFinanceOrderImportFailDTO.java
  13. 3 0
      fs-service/src/main/java/com/fs/his/mapper/FsExternalOrderMapper.java
  14. 2 0
      fs-service/src/main/java/com/fs/his/param/FsExternalOrderAddParam.java
  15. 1 1
      fs-service/src/main/java/com/fs/his/service/IFsExternalOrderService.java
  16. 22 2
      fs-service/src/main/java/com/fs/his/service/impl/FsExternalOrderServiceImpl.java
  17. 47 4
      fs-service/src/main/java/com/fs/his/vo/FsExternalOrderDetailVO.java
  18. 254 74
      fs-service/src/main/resources/mapper/his/FsExternalOrderMapper.xml
  19. 5 1
      fs-service/src/main/resources/mapper/his/FsUserAddressMapper.xml
  20. 5 0
      fs-service/src/main/resources/mapper/his/FsUserMapper.xml
  21. 1 0
      fs-user-app/src/main/java/com/fs/app/controller/course/CourseFsUserController.java

+ 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);
+    }
+}

+ 1 - 1
fs-company/src/main/resources/application.yml

@@ -3,7 +3,7 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: druid-jnsyj-test
+    active: dev
 #    active: druid-jnmy-test
 #    active: druid-jzzx-test
 #    active: druid-hdt

+ 16 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodServiceImpl.java

@@ -109,6 +109,7 @@ public class FsUserCoursePeriodServiceImpl implements IFsUserCoursePeriodService
     @Override
     public int updateFsUserCoursePeriod(FsUserCoursePeriod fsUserCoursePeriod) {
         // 1. 查询原始数据
+        fsUserCoursePeriod.setCreateTime(null);
         fsUserCoursePeriod.setUpdateTime(LocalDateTime.now());
 
         if(LocalDate.now().isBefore(fsUserCoursePeriod.getPeriodStartingTime())){
@@ -145,17 +146,29 @@ public class FsUserCoursePeriodServiceImpl implements IFsUserCoursePeriodService
             LocalDate adjustedDate = coursePeriodDays.getDayDate().plusDays(daysDifference);
             LocalDateTime startDateTime = coursePeriodDays.getStartDateTime().plusDays(daysDifference);
             LocalDateTime endDateTime = coursePeriodDays.getEndDateTime().plusDays(daysDifference);
-            LocalDateTime lastJsonTime = coursePeriodDays.getLastJoinTime().plusDays(daysDifference);
+            LocalDateTime lastJoinTime = coursePeriodDays.getLastJoinTime() == null ? null : coursePeriodDays.getLastJoinTime().plusDays(daysDifference);
             coursePeriodDays.setDayDate(adjustedDate);
             coursePeriodDays.setStartDateTime(startDateTime);
             coursePeriodDays.setEndDateTime(endDateTime);
-            coursePeriodDays.setLastJoinTime(lastJsonTime);
+            coursePeriodDays.setLastJoinTime(lastJoinTime);
+            coursePeriodDays.setStatus(calculateCourseStatus(startDateTime, endDateTime));
             fsUserCoursePeriodDaysMapper.updateFsUserCoursePeriodDays(coursePeriodDays); // 更新数据库中的课程日期
         }
 
         return flag;
     }
 
+    private Integer calculateCourseStatus(LocalDateTime startDateTime, LocalDateTime endDateTime) {
+        LocalDateTime now = LocalDateTime.now();
+        if (startDateTime != null && now.isBefore(startDateTime)) {
+            return 0;
+        }
+        if (endDateTime != null && now.isAfter(endDateTime)) {
+            return 2;
+        }
+        return 1;
+    }
+
     /**
      * 批量删除会员营期
      *
@@ -240,6 +253,7 @@ public class FsUserCoursePeriodServiceImpl implements IFsUserCoursePeriodService
         BeanUtils.copyProperties(source, copy, "periodId");
         copy.setPeriodName(source.getPeriodName() + " - 副本");
         copy.setDelFlag(0);
+        copy.setCreateTime(LocalDateTime.now());
         copy.setUpdateTime(null);
         insertFsUserCoursePeriod(copy);
 

+ 89 - 72
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -2122,7 +2122,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
 
     @Override
     @Transactional
-    @RepeatSubmit(interval = 5000)
     public ResponseResult<FsUser> isAddCompanyUser(FsUserCourseAddCompanyUserParam param) {
         logger.info("\n 【进入个微-判断是否添加客服】,入参:{}", param);
 
@@ -2142,36 +2141,45 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
         }
         //公开课
         if (param.getIsOpenCourse() != null && param.getIsOpenCourse() == 1) {
-            FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId(), null);
-            //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
-            if (watchCourseVideo != null) {
-                FsCourseWatchLog updateLog = new FsCourseWatchLog();
-                updateLog.setUpdateTime(new Date());
-                if (param.getTypeFlag() != null) {
-                    updateLog.setWatchType(param.getTypeFlag());
+            String watchLogLockKey = "course:watch:log:" + param.getUserId() + ":" + param.getVideoId() + ":0:1";
+            RLock watchLogLock = redissonClient.getLock(watchLogLockKey);
+            watchLogLock.lock(10, TimeUnit.SECONDS);
+            try {
+                FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId(), null);
+                //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
+                if (watchCourseVideo != null) {
+                    FsCourseWatchLog updateLog = new FsCourseWatchLog();
+                    updateLog.setUpdateTime(new Date());
+                    if (param.getTypeFlag() != null) {
+                        updateLog.setWatchType(param.getTypeFlag());
+                    }
+                    courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
+                } else {
+                    FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
+                    BeanUtils.copyProperties(param, fsCourseWatchLog);
+                    fsCourseWatchLog.setCompanyId(companyUser.getCompanyId());
+                    fsCourseWatchLog.setSendType(1);
+                    fsCourseWatchLog.setDuration(0L);
+                    fsCourseWatchLog.setCreateTime(new Date());
+                    fsCourseWatchLog.setLogType(1);
+                    if (param.getTypeFlag() != null) {
+                        fsCourseWatchLog.setWatchType(param.getTypeFlag());
+                    }
+                    courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
+
+                    String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId() + ":" + 0;
+                    redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
+                    redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
+                    //记录活跃用户
+                    fsAppActiveUserDailyService.recordActiveUserToRedis(param.getUserId(), companyUser.getCompanyId(), param.getCompanyUserId());
                 }
-                courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
-            } else {
-                FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
-                BeanUtils.copyProperties(param, fsCourseWatchLog);
-                fsCourseWatchLog.setCompanyId(companyUser.getCompanyId());
-                fsCourseWatchLog.setSendType(1);
-                fsCourseWatchLog.setDuration(0L);
-                fsCourseWatchLog.setCreateTime(new Date());
-                fsCourseWatchLog.setLogType(1);
-                if (param.getTypeFlag() != null) {
-                    fsCourseWatchLog.setWatchType(param.getTypeFlag());
+            } finally {
+                if (watchLogLock.isHeldByCurrentThread()) {
+                    watchLogLock.unlock();
                 }
-                courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
-
-            String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId() + ":" + 0;
-            redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
-            redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
-            //记录活跃用户
-            fsAppActiveUserDailyService.recordActiveUserToRedis(param.getUserId(), companyUser.getCompanyId(), param.getCompanyUserId());
+            }
+            return ResponseResult.ok(fsUser);
         }
-        return ResponseResult.ok(fsUser);
-    }
 
         if (!isUserCoursePeriodValid(param)) {
             return ResponseResult.fail(504, "请观看最新的课程项目");
@@ -2265,56 +2273,65 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
             return ResponseResult.fail(504, "已被拉黑,请联系管理员#" + userCompanyUser.getUserId());
         }
 
-        //查询看课记录
-        FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.selectWatchLogByUserIdAndVideoIdAndPeriodId(param.getUserId(), param.getVideoId(), param.getPeriodId());
-
-        // 项目看课数限制
-        Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
+        String watchLogLockKey = "course:watch:log:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getPeriodId() + ":1";
+        RLock watchLogLock = redissonClient.getLock(watchLogLockKey);
+        watchLogLock.lock(10, TimeUnit.SECONDS);
+        try {
+            //查询看课记录
+            FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.selectWatchLogByUserIdAndVideoIdAndPeriodId(param.getUserId(), param.getVideoId(), param.getPeriodId());
 
-        // 院长大讲堂#11  要求可以看两节
-        int maxWatchCount = courseProject == 11 ? 2 : 1;
-        if (Objects.isNull(watchCourseVideo) && logCount >= maxWatchCount) {
-            return ResponseResult.fail(504, "今日学习打卡成功!坚持的你真棒,明天见。");
-        }
+            // 项目看课数限制
+            Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
 
-        //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
-        if (watchCourseVideo != null) {
-            if (!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
-                //提示
-                log.error("数据库存在销售信息:{},分享得销售信息:{}", watchCourseVideo.getCompanyUserId(), param.getCompanyUserId());
-                return ResponseResult.fail(504, "已看过其他销售分享的此课程,不能重复观看");
+            // 院长大讲堂#11  要求可以看两节
+            int maxWatchCount = courseProject == 11 ? 2 : 1;
+            if (Objects.isNull(watchCourseVideo) && logCount >= maxWatchCount) {
+                return ResponseResult.fail(504, "今日学习打卡成功!坚持的你真棒,明天见。");
             }
 
-            FsCourseWatchLog updateLog = new FsCourseWatchLog();
-            updateLog.setLogId(watchCourseVideo.getLogId());
-            updateLog.setCompanyId(companyUser.getCompanyId());
-            updateLog.setPeriodId(param.getPeriodId());
-            updateLog.setProject(courseProject);
-            updateLog.setUpdateTime(new Date());
-            if (param.getTypeFlag() != null) {
-                updateLog.setWatchType(param.getTypeFlag());
-            }
-            courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
-        } else {
-            FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
-            BeanUtils.copyProperties(param, fsCourseWatchLog);
-            fsCourseWatchLog.setCompanyId(companyUser.getCompanyId());
-            fsCourseWatchLog.setSendType(1);
-            fsCourseWatchLog.setDuration(0L);
-            fsCourseWatchLog.setCreateTime(new Date());
-            fsCourseWatchLog.setLogType(1);
-            fsCourseWatchLog.setProject(courseProject);
-            if (param.getTypeFlag() != null) {
-                fsCourseWatchLog.setWatchType(param.getTypeFlag());
-            }
-            courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
+            //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
+            if (watchCourseVideo != null) {
+                if (!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
+                    //提示
+                    log.error("数据库存在销售信息:{},分享得销售信息:{}", watchCourseVideo.getCompanyUserId(), param.getCompanyUserId());
+                    return ResponseResult.fail(504, "已看过其他销售分享的此课程,不能重复观看");
+                }
 
-            String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
-            redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
-            redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
+                FsCourseWatchLog updateLog = new FsCourseWatchLog();
+                updateLog.setLogId(watchCourseVideo.getLogId());
+                updateLog.setCompanyId(companyUser.getCompanyId());
+                updateLog.setPeriodId(param.getPeriodId());
+                updateLog.setProject(courseProject);
+                updateLog.setUpdateTime(new Date());
+                if (param.getTypeFlag() != null) {
+                    updateLog.setWatchType(param.getTypeFlag());
+                }
+                courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
+            } else {
+                FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
+                BeanUtils.copyProperties(param, fsCourseWatchLog);
+                fsCourseWatchLog.setCompanyId(companyUser.getCompanyId());
+                fsCourseWatchLog.setSendType(1);
+                fsCourseWatchLog.setDuration(0L);
+                fsCourseWatchLog.setCreateTime(new Date());
+                fsCourseWatchLog.setLogType(1);
+                fsCourseWatchLog.setProject(courseProject);
+                if (param.getTypeFlag() != null) {
+                    fsCourseWatchLog.setWatchType(param.getTypeFlag());
+                }
+                courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
 
-            //记录活跃用户
-            fsAppActiveUserDailyService.recordActiveUserToRedis(param.getUserId(), companyUser.getCompanyId(), param.getCompanyUserId());
+                String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
+                redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
+                redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
+
+                //记录活跃用户
+                fsAppActiveUserDailyService.recordActiveUserToRedis(param.getUserId(), companyUser.getCompanyId(), param.getCompanyUserId());
+            }
+        } finally {
+            if (watchLogLock.isHeldByCurrentThread()) {
+                watchLogLock.unlock();
+            }
         }
         //导入im好友
         openIMService.checkAndImportFriendByDianBoNew(param.getCompanyUserId(), param.getUserId().toString(), true);

+ 72 - 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")
@@ -41,26 +41,27 @@ public class FsExternalOrder extends BaseEntity
     @Excel(name = "订单商品总数")
     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 = "快递公司编号")
@@ -86,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;
@@ -108,13 +113,64 @@ public class FsExternalOrder extends BaseEntity
     @Excel(name = "收件人电话")
     private String receiverPhone;
 
-    /**
-     * 扩展订单id
-     */
-    private  String extendOrderId;
+    private String extendOrderId;
 
-    /**
-     * 店铺id
-     */
     private Long storeId;
-}
+
+    /** 代收金额 */
+    @Excel(name = "代收金额")
+    private BigDecimal collectionPrice;
+
+    /** 跟单时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "跟单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date followTime;
+
+    /** 退款金额 */
+    @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;
+
+    /** 订单类型  1.外部订单  2。套餐包订单 3.问诊订单 4.积分订单*/
+    @Excel(name = "订单类型", readConverterExp = "1=外部订单,2=套餐包,3=问诊,4=积分")
+    private Integer orderType;
+
+    /** 审核人 */
+    @Excel(name = "审核人")
+    private String auditor;
+
+    /** 审核时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date auditTime;
+
+    /** 病名 */
+    @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;
+}

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

@@ -42,6 +42,10 @@ public class FsUserAddress extends BaseEntity
     @Excel(name = "收货人所在区")
     private String district;
 
+    /** 乡镇 */
+    @Excel(name = "乡镇")
+    private String township;
+
     /** 城市IDS */
     @Excel(name = "城市IDS")
     private String cityIds;
@@ -101,6 +105,7 @@ public class FsUserAddress extends BaseEntity
     {
         return addressId;
     }
+
     public void setUserId(Long userId) 
     {
         this.userId = userId;
@@ -110,6 +115,7 @@ public class FsUserAddress extends BaseEntity
     {
         return userId;
     }
+
     public void setRealName(String realName) 
     {
         this.realName = realName;
@@ -119,6 +125,7 @@ public class FsUserAddress extends BaseEntity
     {
         return realName;
     }
+
     public void setPhone(String phone) 
     {
         this.phone = phone;
@@ -128,6 +135,7 @@ public class FsUserAddress extends BaseEntity
     {
         return phone;
     }
+
     public void setProvince(String province) 
     {
         this.province = province;
@@ -137,6 +145,7 @@ public class FsUserAddress extends BaseEntity
     {
         return province;
     }
+
     public void setCity(String city) 
     {
         this.city = city;
@@ -146,6 +155,7 @@ public class FsUserAddress extends BaseEntity
     {
         return city;
     }
+
     public void setDistrict(String district) 
     {
         this.district = district;
@@ -155,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;
@@ -164,6 +185,7 @@ public class FsUserAddress extends BaseEntity
     {
         return cityIds;
     }
+
     public void setDetail(String detail) 
     {
         this.detail = detail;
@@ -173,6 +195,7 @@ public class FsUserAddress extends BaseEntity
     {
         return detail;
     }
+
     public void setPostCode(String postCode) 
     {
         this.postCode = postCode;
@@ -182,6 +205,7 @@ public class FsUserAddress extends BaseEntity
     {
         return postCode;
     }
+
     public void setLongitude(String longitude) 
     {
         this.longitude = longitude;
@@ -191,6 +215,7 @@ public class FsUserAddress extends BaseEntity
     {
         return longitude;
     }
+
     public void setLatitude(String latitude) 
     {
         this.latitude = latitude;
@@ -200,6 +225,7 @@ public class FsUserAddress extends BaseEntity
     {
         return latitude;
     }
+
     public void setIsDefault(Integer isDefault)
     {
         this.isDefault = isDefault;
@@ -209,6 +235,7 @@ public class FsUserAddress extends BaseEntity
     {
         return isDefault;
     }
+
     public void setIsDel(Integer isDel)
     {
         this.isDel = isDel;
@@ -219,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

+ 254 - 74
fs-service/src/main/resources/mapper/his/FsExternalOrderMapper.xml

@@ -1,66 +1,87 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.his.mapper.FsExternalOrderMapper">
-    
+
     <resultMap type="FsExternalOrder" id="FsExternalOrderResult">
-        <result property="orderId"    column="order_id"    />
-        <result property="orderCode"    column="order_code"    />
-        <result property="source"    column="source"    />
-        <result property="userId"    column="user_id"    />
-        <result property="userName"    column="user_name"    />
-        <result property="userPhone"    column="user_phone"    />
-        <result property="userAddress"    column="user_address"    />
-        <result property="totalNum"    column="total_num"    />
-        <result property="totalPrice"    column="total_price"    />
-        <result property="payPrice"    column="pay_price"    />
-        <result property="freightPrice"    column="freight_price"    />
-        <result property="isPay"    column="is_pay"    />
-        <result property="payTime"    column="pay_time"    />
-        <result property="payType"    column="pay_type"    />
-        <result property="status"    column="status"    />
-        <result property="deliveryCode"    column="delivery_code"    />
-        <result property="deliveryName"    column="delivery_name"    />
-        <result property="deliverySn"    column="delivery_sn"    />
-        <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="shippingType"    column="shipping_type"    />
-        <result property="companyId"    column="company_id"    />
-        <result property="companyUserId"    column="company_user_id"    />
-        <result property="remark"    column="remark"    />
-        <result property="externalCreateTime"    column="external_create_time"    />
-        <result property="isSync"    column="is_sync"    />
-        <result property="syncMsg"    column="sync_msg"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="extendOrderId"    column="extend_order_id"    />
-        <result property="storeId"    column="store_id"    />
-        <result property="receiverPhone"    column="receiver_phone"    />
+        <result property="orderId"             column="order_id"             />
+        <result property="orderCode"           column="order_code"           />
+        <result property="source"              column="source"               />
+        <result property="userId"              column="user_id"              />
+        <result property="userName"            column="user_name"            />
+        <result property="userPhone"           column="user_phone"           />
+        <result property="userAddress"         column="user_address"         />
+        <result property="totalNum"            column="total_num"            />
+        <result property="totalPrice"          column="total_price"          />
+        <result property="payPrice"            column="pay_price"            />
+        <result property="freightPrice"        column="freight_price"        />
+        <result property="isPay"               column="is_pay"               />
+        <result property="payTime"             column="pay_time"             />
+        <result property="payType"             column="pay_type"             />
+        <result property="status"              column="status"               />
+        <result property="deliveryCode"        column="delivery_code"        />
+        <result property="deliveryName"        column="delivery_name"        />
+        <result property="deliverySn"          column="delivery_sn"          />
+        <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="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"      />
+        <result property="remark"              column="remark"               />
+        <result property="externalCreateTime"  column="external_create_time" />
+        <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="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"              />
+        <result property="auditTime"           column="audit_time"           />
+        <result property="diseaseName"         column="disease_name"         />
     </resultMap>
 
     <sql id="selectFsExternalOrderVo">
-        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, extend_order_id, store_id, receiver_phone from fs_external_order
+        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, 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,
+               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>
+        <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>
         </where>
         order by create_time desc
     </select>
-    
+
     <select id="selectFsExternalOrderByOrderId" parameterType="Long" resultMap="FsExternalOrderResult">
         <include refid="selectFsExternalOrderVo"/>
         where order_id = #{orderId}
@@ -105,6 +126,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>
@@ -112,9 +135,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="externalCreateTime != null">external_create_time,</if>
             <if test="isSync != null">is_sync,</if>
             <if test="syncMsg != null and syncMsg != ''">sync_msg,</if>
-            <if test="extendOrderId !=null and extendOrderId !=''">extend_order_id,</if>
+            <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="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=",">
@@ -139,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>
@@ -146,9 +181,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="externalCreateTime != null">#{externalCreateTime},</if>
             <if test="isSync != null">#{isSync},</if>
             <if test="syncMsg != null and syncMsg != ''">#{syncMsg},</if>
-            <if test="extendOrderId !=null and extendOrderId !=''">#{extendOrderId},</if>
+            <if test="extendOrderId != null and extendOrderId != ''">#{extendOrderId},</if>
             <if test="storeId != null">#{storeId},</if>
             <if test="receiverPhone != null and receiverPhone != ''">#{receiverPhone},</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>
@@ -177,17 +222,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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="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>
-            update_time = sysdate()
+            <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">disease_name = #{diseaseName},</if>
+            update_by = #{updateBy},
+            update_time = #{updateTime}
         </trim>
         where order_id = #{orderId}
     </update>
@@ -197,44 +254,84 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteFsExternalOrderByOrderIds" parameterType="String">
-        delete from fs_external_order where order_id in 
+        delete from fs_external_order where order_id in
         <foreach item="orderId" collection="array" open="(" separator="," close=")">
             #{orderId}
         </foreach>
     </delete>
 
+
     <select id="selectExternalOrderListVO" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsExternalOrderListVO">
-        SELECT 
-            o.order_id,
-            o.order_code,
+        SELECT
+            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)) AS receivablePrice,
+            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 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>
@@ -245,6 +342,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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
@@ -259,15 +358,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             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,
@@ -277,22 +392,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             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>
+
+    <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>
+

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

@@ -12,6 +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="town_ship"    />
         <result property="cityIds"    column="city_ids"    />
         <result property="detail"    column="detail"    />
         <result property="postCode"    column="post_code"    />
@@ -26,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, 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">
@@ -64,6 +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 != ''">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>
@@ -83,6 +85,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="cityIds != null">#{cityIds},</if>
             <if test="detail != null and detail != ''">#{detail},</if>
             <if test="postCode != null and postCode != ''">#{postCode},</if>
@@ -106,6 +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 != ''">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,

+ 1 - 0
fs-user-app/src/main/java/com/fs/app/controller/course/CourseFsUserController.java

@@ -93,6 +93,7 @@ public class CourseFsUserController extends AppBaseController {
 
     @Login
     @ApiOperation("判断是否添加客服(是否关联销售)")
+    @RepeatSubmit(interval = 5000)
     @PostMapping("/isAddKf")
     public ResponseResult<FsUser> isAddCompanyUser(@Valid @RequestBody FsUserCourseAddCompanyUserParam param) {
         if (ObjectUtil.isEmpty(param.getUserId())) {