Selaa lähdekoodia

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

wjj 3 päivää sitten
vanhempi
commit
f49f488b38
42 muutettua tiedostoa jossa 1317 lisäystä ja 55 poistoa
  1. 12 0
      fs-admin/src/main/java/com/fs/company/controller/CompanyStatisticsController.java
  2. 184 0
      fs-company/src/main/java/com/fs/company/controller/qw/FsCompanyCustomerController.java
  3. 96 0
      fs-doctor-app/src/main/java/com/fs/app/controller/FsDoctorPatientController.java
  4. 7 1
      fs-service/src/main/java/com/fs/company/mapper/CompanyStatisticsCIDMapper.java
  5. 3 0
      fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java
  6. 2 2
      fs-service/src/main/java/com/fs/company/param/SalesStatCIDParam.java
  7. 6 0
      fs-service/src/main/java/com/fs/company/service/ICompanyStatisticsCIDService.java
  8. 7 0
      fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java
  9. 11 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyStatisticsCIDCIDServiceImpl.java
  10. 41 2
      fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java
  11. 19 0
      fs-service/src/main/java/com/fs/company/vo/SalesAccountStatCIDVO.java
  12. 1 1
      fs-service/src/main/java/com/fs/company/vo/SalesStatCIDVO.java
  13. 4 0
      fs-service/src/main/java/com/fs/course/param/FsCourseLinkMiniParam.java
  14. 16 2
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  15. 6 0
      fs-service/src/main/java/com/fs/his/domain/FsDoctorPatient.java
  16. 3 0
      fs-service/src/main/java/com/fs/his/domain/FsPrescribe.java
  17. 3 0
      fs-service/src/main/java/com/fs/his/mapper/FsDoctorMapper.java
  18. 10 0
      fs-service/src/main/java/com/fs/his/mapper/FsPrescribeMapper.java
  19. 11 0
      fs-service/src/main/java/com/fs/his/param/CollectionPhoneParam.java
  20. 11 0
      fs-service/src/main/java/com/fs/his/param/PrescribePhoneParam.java
  21. 5 0
      fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java
  22. 32 1
      fs-service/src/main/java/com/fs/his/service/impl/FsDoctorPatientServiceImpl.java
  23. 17 0
      fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java
  24. 9 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserInformationCollectionMapper.java
  25. 5 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsUserInformationCollectionService.java
  26. 111 10
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java
  27. 7 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsUserInformationCollectionOverviewVo.java
  28. 86 0
      fs-service/src/main/java/com/fs/qw/domain/FsCompanyCustomer.java
  29. 51 0
      fs-service/src/main/java/com/fs/qw/mapper/FsCompanyCustomerMapper.java
  30. 2 0
      fs-service/src/main/java/com/fs/qw/param/QwGroupMsgParam.java
  31. 25 0
      fs-service/src/main/java/com/fs/qw/service/IFsCompanyCustomerService.java
  32. 89 0
      fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java
  33. 13 3
      fs-service/src/main/java/com/fs/qw/service/impl/QwGroupMsgServiceImpl.java
  34. 11 0
      fs-service/src/main/java/com/fs/qw/vo/CompanyUserAndDoctorVO.java
  35. 105 7
      fs-service/src/main/resources/mapper/company/CompanyStatisticsCIDMapper.xml
  36. 4 0
      fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml
  37. 9 0
      fs-service/src/main/resources/mapper/his/FsDoctorMapper.xml
  38. 69 25
      fs-service/src/main/resources/mapper/his/FsDoctorPatientMapper.xml
  39. 17 0
      fs-service/src/main/resources/mapper/his/FsPrescribeMapper.xml
  40. 28 0
      fs-service/src/main/resources/mapper/hisStore/FsUserInformationCollectionMapper.xml
  41. 167 0
      fs-service/src/main/resources/mapper/qw/FsCompanyCustomerMapper.xml
  42. 2 1
      fs-user-app/src/main/java/com/fs/app/controller/PatientController.java

+ 12 - 0
fs-admin/src/main/java/com/fs/company/controller/CompanyStatisticsController.java

@@ -687,6 +687,18 @@ public class CompanyStatisticsController extends BaseController
         List<SalesStatCIDVO> voList = statisticsCIDService.getSalesStatisticsCID(param);
         return getDataTable(voList);
     }
+
+    /**
+     * 员工销售CID订单统计(-企微用户维度统计)
+     */
+    @PostMapping("/salesAccountStat")
+    public TableDataInfo salesAccountStat(@RequestBody SalesStatCIDParam param) {
+        if (param.getPageNum() != null && param.getPageSize() != null) {
+            PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        }
+        List<SalesAccountStatCIDVO> voList = statisticsCIDService.getSalesAccountStatCID(param);
+        return getDataTable(voList);
+    }
     /**
      *  员工销售CID订单明细
      * */

+ 184 - 0
fs-company/src/main/java/com/fs/company/controller/qw/FsCompanyCustomerController.java

@@ -0,0 +1,184 @@
+package com.fs.company.controller.qw;
+
+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.exception.CustomException;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.mapper.CompanyUserRoleMapper;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.framework.security.LoginUser;
+import com.fs.framework.security.SecurityUtils;
+import com.fs.his.domain.FsDoctorPatient;
+import com.fs.his.domain.FsPrescribe;
+import com.fs.his.param.CollectionPhoneParam;
+import com.fs.his.param.PrescribePhoneParam;
+import com.fs.his.service.IFsDoctorPatientService;
+import com.fs.his.service.IFsPrescribeService;
+import com.fs.hisStore.service.IFsUserInformationCollectionService;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
+import com.fs.qw.domain.FsCompanyCustomer;
+import com.fs.qw.service.IFsCompanyCustomerService;
+import com.fs.qw.vo.CompanyUserAndDoctorVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 客户基础信息Controller
+ *
+ * @author cgp
+ * @date 2026-04-30
+ */
+@Slf4j
+@RestController
+@RequestMapping("/qw/companyCustomer")
+public class FsCompanyCustomerController extends BaseController {
+
+    @Autowired
+    private IFsCompanyCustomerService fsCompanyCustomerService;
+
+    @Autowired
+    private ICompanyUserService companyUserService;
+
+    @Autowired
+    private CompanyUserRoleMapper roleMapper;
+
+    @Autowired
+    private IFsPrescribeService fsPrescribeService;
+
+    @Autowired
+    private IFsUserInformationCollectionService fsUserInformationCollectionService;
+
+    @Autowired
+    private IFsDoctorPatientService fsDoctorPatientService;
+
+    /**
+     * 查询客户列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(FsCompanyCustomer fsCompanyCustomer) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        fsCompanyCustomer.setCompanyUserId(loginUser.getUser().getUserId());
+        //管理员查看所有数据
+        Long isAdmin = roleMapper.companyUserIsAdmin(fsCompanyCustomer.getCompanyUserId());
+        if (isAdmin != null) {
+            fsCompanyCustomer.setCompanyUserId(null);
+        }
+        PageHelper.startPage(fsCompanyCustomer.getPageNum(), fsCompanyCustomer.getPageSize());
+        List<FsCompanyCustomer> list = fsCompanyCustomerService.selectFsCompanyCustomerList(fsCompanyCustomer);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出客户信息
+     */
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, FsCompanyCustomer fsCompanyCustomer) {
+        List<FsCompanyCustomer> list = fsCompanyCustomerService.selectFsCompanyCustomerList(fsCompanyCustomer);
+        ExcelUtil<FsCompanyCustomer> util = new ExcelUtil<>(FsCompanyCustomer.class);
+        try {
+            util.exportExcel(response, list, "客户信息数据");
+        }catch (Exception e){
+            log.error("导出客户信息数据异常",e);
+            throw new CustomException("客户信息数据异常");
+        }
+
+    }
+
+    /**
+     * 获取客户详情
+     */
+    @GetMapping("/{id}")
+    public AjaxResult getInfo(@PathVariable Long id) {
+        return AjaxResult.success(fsCompanyCustomerService.selectFsCompanyCustomerById(id));
+    }
+
+    /**
+     * 新增客户
+     */
+    @PostMapping
+    public AjaxResult add(@RequestBody FsCompanyCustomer fsCompanyCustomer) {
+        return AjaxResult.success(fsCompanyCustomerService.insertFsCompanyCustomer(fsCompanyCustomer));
+    }
+
+    /**
+     * 修改客户
+     */
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsCompanyCustomer fsCompanyCustomer) {
+        return AjaxResult.success(fsCompanyCustomerService.updateFsCompanyCustomer(fsCompanyCustomer));
+    }
+
+    /**
+     * 删除客户
+     */
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return AjaxResult.success(fsCompanyCustomerService.deleteFsCompanyCustomerByIds(ids));
+    }
+
+    /**
+     * 获取当前登录销售id信息以及绑定的医生信息
+     * */
+    @GetMapping("/getCompanyUserAndDoctor")
+    public AjaxResult getSaleAndDoctor(){
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Long companyUserId = loginUser.getUser().getUserId();
+        CompanyUserAndDoctorVO companyUserAndDoctorVO = companyUserService.getCompanyUserAndDoctor(companyUserId);
+        return AjaxResult.success(companyUserAndDoctorVO);
+    }
+
+    /**
+     * 根据传入手机号获取处方列表信息
+     * */
+    @PostMapping("/getPrescribeListByPhone")
+    public TableDataInfo getPrescribeListByPhone(@RequestBody PrescribePhoneParam param){
+        PageHelper.startPage(param.getPageNum(),param.getPageSize());
+        List<FsPrescribe> list = fsPrescribeService.selectPrescribeListByEncryptPhone(param.getPhone());
+        return getDataTable(list);
+    }
+
+    /**
+     * 根据传入手机号获取信息采集列表数据
+     * */
+    @PostMapping("/getCollectionInfoListByPhone")
+    public TableDataInfo getCollectionInfoListByPhone(@RequestBody CollectionPhoneParam param){
+        PageHelper.startPage(param.getPageNum(),param.getPageSize());
+        List<FsUserInformationCollectionOverviewVo> list = fsUserInformationCollectionService.selectUserInformationCollectionByPhone(param.getPhone());
+        return getDataTable(list);
+    }
+    /**
+     * 销售端-查询医生设置指定可见的患者信息列表
+     */
+    @ApiOperation("查询医生设置指定可见的患者信息列表")
+    @GetMapping("/doctorPatientList")
+    public TableDataInfo doctorPatientList(FsDoctorPatient fsDoctorPatient) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Long companyUserId = loginUser.getUser().getUserId();
+        if (companyUserId == null){
+            throw new CustomException("销售登录信息获取异常");
+        }
+        fsDoctorPatient.setCompanyUserId(companyUserId);
+        PageHelper.startPage(fsDoctorPatient.getPageNum(), fsDoctorPatient.getPageSize());
+        List<FsDoctorPatient> list = fsDoctorPatientService.selectFsDoctorPatientList(fsDoctorPatient);
+        PageInfo<FsDoctorPatient> listPageInfo=new PageInfo<>(list);
+        return getDataTable(list);
+    }
+
+    /**
+     * 销售端-查询绑定医生的患者详细信息
+     */
+    @ApiOperation("查询绑定医生的患者详细信息")
+    @GetMapping(value = "/getDoctorPatientInfo/{id}")
+    public AjaxResult getDoctorPatientInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(fsDoctorPatientService.selectFsDoctorPatientById(id));
+    }
+
+}

+ 96 - 0
fs-doctor-app/src/main/java/com/fs/app/controller/FsDoctorPatientController.java

@@ -1,23 +1,39 @@
 package com.fs.app.controller;
 
+
+
+import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyUserService;
 import com.fs.his.domain.FsDoctor;
 import com.fs.his.domain.FsDoctorPatient;
+import com.fs.his.domain.FsPrescribe;
+import com.fs.his.param.CollectionPhoneParam;
+import com.fs.his.param.PrescribePhoneParam;
 import com.fs.his.service.IFsDoctorPatientService;
 import com.fs.his.service.IFsDoctorService;
+import com.fs.his.service.IFsPrescribeService;
+import com.fs.hisStore.service.IFsUserInformationCollectionService;
+import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
+import com.fs.qw.domain.FsCompanyCustomer;
+import com.fs.qw.service.IFsCompanyCustomerService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import com.fs.common.core.domain.AjaxResult;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 患者信息Controller
@@ -36,6 +52,19 @@ public class FsDoctorPatientController extends AppBaseController {
 
     @Autowired
     private IFsDoctorService fsDoctorService;
+
+    @Autowired
+    private IFsPrescribeService fsPrescribeService;
+
+    @Autowired
+    private IFsUserInformationCollectionService fsUserInformationCollectionService;
+
+    @Autowired
+    private IFsCompanyCustomerService fsCompanyCustomerService;
+
+    @Autowired
+    private ICompanyUserService companyUserService;
+
     /**
      * 查询患者信息列表
      */
@@ -119,4 +148,71 @@ public class FsDoctorPatientController extends AppBaseController {
         FsDoctor fsDoctor = fsDoctorService.selectFsDoctorByDoctorId(Long.valueOf(doctorId));
         return AjaxResult.success(fsDoctor);
     }
+
+    /**
+     * 根据传入手机号获取处方列表信息
+     * */
+    @PostMapping("/getPrescribeListByPhone")
+    public AjaxResult getPrescribeListByPhone(@RequestBody PrescribePhoneParam param){
+        PageHelper.startPage(param.getPageNum(),param.getPageSize());
+        List<FsPrescribe> list = fsPrescribeService.selectPrescribeListByEncryptPhone(param.getPhone());
+        PageInfo<FsPrescribe> listPageInfo=new PageInfo<>(list);
+        return AjaxResult.success(listPageInfo);
+    }
+
+    /**
+     * 根据传入手机号获取信息采集列表数据
+     * */
+    @PostMapping("/getCollectionInfoListByPhone")
+    public AjaxResult getCollectionInfoListByPhone(@RequestBody CollectionPhoneParam param){
+        PageHelper.startPage(param.getPageNum(),param.getPageSize());
+        List<FsUserInformationCollectionOverviewVo> list = fsUserInformationCollectionService.selectUserInformationCollectionByPhone(param.getPhone());
+        PageInfo<FsUserInformationCollectionOverviewVo> listPageInfo=new PageInfo<>(list);
+        return AjaxResult.success(listPageInfo);
+    }
+
+    /**
+     * 医生端-查询可关联销售列表
+     */
+    @GetMapping("/companyUserList")
+    public AjaxResult companyUserList() {
+        String doctorId = getDoctorId();
+        if (StringUtils.isBlank(doctorId)){
+            return AjaxResult.error("请重新登录");
+        }
+        // 查询关联的销售集合
+        List<CompanyUser> companyUserList = companyUserService.selectCompanyUserListByDoctorId(Long.valueOf(doctorId));
+        return AjaxResult.success(companyUserList);
+    }
+
+    /**
+     * 医生端-查询关联销售的所有客户列表
+     */
+    @GetMapping("/companyCustomerList")
+    public AjaxResult companyCustomerList(FsCompanyCustomer fsCompanyCustomer) {
+        String doctorId = getDoctorId();
+        if (StringUtils.isBlank(doctorId)){
+            return AjaxResult.error("请重新登录");
+        }
+        AjaxResult AjaxResult = new AjaxResult();
+        // 查询关联的销售id集合
+        List<CompanyUser> companyUserList = companyUserService.selectCompanyUserListByDoctorId(Long.valueOf(doctorId));
+        List<Long> companyUserIds = companyUserList.stream().map(CompanyUser::getUserId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(companyUserIds)){
+            AjaxResult.put("data", new PageInfo<>(Collections.emptyList()));
+        }
+        fsCompanyCustomer.setCompanyUserIds(companyUserIds);
+        PageHelper.startPage(fsCompanyCustomer.getPageNum(), fsCompanyCustomer.getPageSize());
+        List<FsCompanyCustomer> list = fsCompanyCustomerService.selectFsCompanyCustomerListByCompanyUserIds(fsCompanyCustomer);
+        AjaxResult.put("data", new PageInfo<>(list));
+        return AjaxResult;
+    }
+
+    /**
+     * 医生端-查询关联销售的客户详情
+     */
+    @GetMapping("/companyCustomer/{id}")
+    public AjaxResult getCompanyCustomerInfo(@PathVariable Long id) {
+        return AjaxResult.success(fsCompanyCustomerService.selectFsCompanyCustomerById(id));
+    }
 }

+ 7 - 1
fs-service/src/main/java/com/fs/company/mapper/CompanyStatisticsCIDMapper.java

@@ -2,6 +2,7 @@ package com.fs.company.mapper;
 
 import com.fs.company.param.SalesStatCIDParam;
 import com.fs.company.param.SalesUserDetailCIDParam;
+import com.fs.company.vo.SalesAccountStatCIDVO;
 import com.fs.company.vo.SalesStatCIDVO;
 import com.fs.company.vo.SalesUserDetailCIDVO;
 import org.apache.ibatis.annotations.Param;
@@ -9,9 +10,14 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface CompanyStatisticsCIDMapper {
-    //获取CID订单统计
+
+    //获取CID订单统计-销售维度统计
     List<SalesStatCIDVO> getSalesStatisticsCID(@Param("param") SalesStatCIDParam param);
 
+    //获取CID订单统计-企微用户维度统计
+    List<SalesAccountStatCIDVO> getSalesAccountStatCID(@Param("param") SalesStatCIDParam param);
+
     //获取CID订单明细
     List<SalesUserDetailCIDVO> getSalesUserDetailCID(@Param("param") SalesUserDetailCIDParam param);
+
 }

+ 3 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -337,4 +337,7 @@ public interface CompanyUserMapper
             "update company_user set ai_sip_call_user_id=#{aiSipCallId} where user_id=#{companyUserId} " +
             "</script>")
     public int updateCompanyUserByAiSipCall(@Param("companyUserId") Long companyUserId, @Param("aiSipCallId") Long aiSipCallId);
+
+    //根据医生id获取医生对应的销售
+    List<CompanyUser> selectCompanyUserListByDoctorId(Long doctorId);
 }

+ 2 - 2
fs-service/src/main/java/com/fs/company/param/SalesStatCIDParam.java

@@ -10,8 +10,8 @@ public class SalesStatCIDParam {
     private Long userId;
     private Long companyId;
     private String corpId; //主体id qw_user.corp_id
-    private String qwUserName; //销售账号名称 qw_user.qw_user_name 模糊匹配
-    private String companyUserNickName;
+    private String qwUserName; //企微用户名 qw_user.qw_user_name 模糊匹配
+    private String companyUserName;
     private String startAddTime;    // 进粉开始时间
     private String endAddTime;      // 进粉结束时间
     private String startOrderTime;  // 下单开始时间

+ 6 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyStatisticsCIDService.java

@@ -1,6 +1,7 @@
 package com.fs.company.service;
 
 import com.fs.company.param.SalesUserDetailCIDParam;
+import com.fs.company.vo.SalesAccountStatCIDVO;
 import com.fs.company.vo.SalesStatCIDVO;
 import com.fs.company.param.SalesStatCIDParam;
 import com.fs.company.vo.SalesUserDetailCIDVO;
@@ -13,6 +14,11 @@ public interface ICompanyStatisticsCIDService {
      * */
     List<SalesStatCIDVO> getSalesStatisticsCID(SalesStatCIDParam param);
 
+    /**
+     *  获取销售统计CID(企微用户维度统计)
+     * */
+    List<SalesAccountStatCIDVO> getSalesAccountStatCID(SalesStatCIDParam param);
+
     /**
      *  获取销售人员明细CID
      * */

+ 7 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java

@@ -10,6 +10,7 @@ import com.fs.his.vo.CitysAreaVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.vo.FsStoreProductExportVO;
 import com.fs.qw.dto.UserProjectDTO;
+import com.fs.qw.vo.CompanyUserAndDoctorVO;
 import com.fs.qw.vo.CompanyUserQwVO;
 import com.fs.qw.vo.QwOptionsVO;
 import com.fs.qw.vo.QwUserVO;
@@ -246,4 +247,10 @@ public interface ICompanyUserService {
     R getBindInfo(Long companyUserId);
 
     Boolean bindCompanyUserReplyTxt(String replyText, List<Long> userIds);
+
+    //根据销售id获取销售绑定的医生信息
+    CompanyUserAndDoctorVO getCompanyUserAndDoctor(Long companyUserId);
+
+    //根据医生id获取绑定医生的销售列表
+    List<CompanyUser> selectCompanyUserListByDoctorId(Long doctorId);
 }

+ 11 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyStatisticsCIDCIDServiceImpl.java

@@ -4,6 +4,7 @@ import com.fs.company.mapper.CompanyStatisticsCIDMapper;
 import com.fs.company.param.SalesStatCIDParam;
 import com.fs.company.param.SalesUserDetailCIDParam;
 import com.fs.company.service.ICompanyStatisticsCIDService;
+import com.fs.company.vo.SalesAccountStatCIDVO;
 import com.fs.company.vo.SalesStatCIDVO;
 import com.fs.company.vo.SalesUserDetailCIDVO;
 import org.apache.commons.collections4.CollectionUtils;
@@ -29,6 +30,16 @@ public class CompanyStatisticsCIDCIDServiceImpl implements ICompanyStatisticsCID
         return salesStatisticsCID;
     }
 
+    @Override
+    public List<SalesAccountStatCIDVO> getSalesAccountStatCID(SalesStatCIDParam param) {
+        param.setCompanyId(2L);//只查询益寿缘中医院的CID订单
+        List<SalesAccountStatCIDVO> salesAccountStatCIDVOS = companyStatisticsMapper.getSalesAccountStatCID(param);
+        if (CollectionUtils.isEmpty(salesAccountStatCIDVOS)){
+            return Collections.emptyList();
+        }
+        return salesAccountStatCIDVOS;
+    }
+
     @Override
     public List<SalesUserDetailCIDVO> getSalesUserDetailCID(SalesUserDetailCIDParam param) {
         List<SalesUserDetailCIDVO> salesUserDetailCID = companyStatisticsMapper.getSalesUserDetailCID(param);

+ 41 - 2
fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -1,13 +1,11 @@
 package com.fs.company.service.impl;
 
-import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.QRutils;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.constant.UserConstants;
-import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
@@ -27,6 +25,8 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.company.vo.*;
 import com.fs.course.service.IFsUserCompanyUserQwService;
 import com.fs.course.service.IFsUserCompanyUserService;
+import com.fs.his.domain.FsDoctor;
+import com.fs.his.mapper.FsDoctorMapper;
 import com.fs.his.mapper.FsUserMapper;
 import com.fs.his.service.IFsCityService;
 import com.fs.his.vo.CitysAreaVO;
@@ -40,6 +40,7 @@ import com.fs.qw.domain.QwUser;
 import com.fs.qw.dto.UserProjectDTO;
 import com.fs.qw.mapper.QwUserMapper;
 import com.fs.qw.service.IQwUserService;
+import com.fs.qw.vo.CompanyUserAndDoctorVO;
 import com.fs.qw.vo.CompanyUserQwVO;
 import com.fs.qw.vo.QwOptionsVO;
 import com.fs.qw.vo.QwUserVO;
@@ -47,6 +48,8 @@ import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
 import com.fs.voice.utils.StringUtil;
 import com.fs.wxUser.domain.CompanyWxUser;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +70,7 @@ import java.util.stream.Collectors;
  * @author fs
  * @date 2021-05-25
  */
+@Slf4j
 @Service
 public class CompanyUserServiceImpl implements ICompanyUserService
 {
@@ -115,6 +119,9 @@ public class CompanyUserServiceImpl implements ICompanyUserService
     @Autowired
     private IQwUserService qwUserService;
 
+    @Autowired
+    private FsDoctorMapper doctorMapper;
+
     /**
      * 查询物业公司管理员信息
      *
@@ -1072,4 +1079,36 @@ public class CompanyUserServiceImpl implements ICompanyUserService
         }
         return true;
     }
+
+    @Override
+    public CompanyUserAndDoctorVO getCompanyUserAndDoctor(Long companyUserId) {
+        if (companyUserId==null){
+            throw new ServiceException("销售人员不存在");
+        }
+
+        CompanyUser companyUser = companyUserService.selectCompanyUserById(companyUserId);
+        if (companyUser==null){
+            throw new ServiceException("销售人员不存在");
+        }
+        CompanyUserAndDoctorVO companyUserAndDoctorVO=new CompanyUserAndDoctorVO();
+        companyUserAndDoctorVO.setCompanyUserId(companyUser.getUserId());
+        companyUserAndDoctorVO.setCompanyUserName(companyUser.getUserName());
+        FsDoctor fsDoctor = doctorMapper.selectFsDoctorByDoctorId(companyUser.getDoctorId());
+        if (fsDoctor==null){
+            log.error("销售人员所绑定的医生不存在,销售companyUserId:{}",companyUserId);
+            return companyUserAndDoctorVO;
+        }
+        companyUserAndDoctorVO.setDoctorId(fsDoctor.getDoctorId());
+        companyUserAndDoctorVO.setDoctorName(fsDoctor.getDoctorName());
+        return companyUserAndDoctorVO;
+    }
+
+    @Override
+    public List<CompanyUser> selectCompanyUserListByDoctorId(Long doctorId) {
+        List<CompanyUser> companyUserList=companyUserMapper.selectCompanyUserListByDoctorId(doctorId);
+        if (CollectionUtils.isEmpty(companyUserList)){
+            return Collections.emptyList();
+        }
+        return companyUserList;
+    }
 }

+ 19 - 0
fs-service/src/main/java/com/fs/company/vo/SalesAccountStatCIDVO.java

@@ -0,0 +1,19 @@
+package com.fs.company.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class SalesAccountStatCIDVO {
+    private Long qwUserId;          // qw_user.id
+    private String qwUserName;      // 企微用户名
+    private Long companyUserId;     // 所属销售ID
+    private String companyUserName; // 销售姓名
+    private String deptName;        // 部门
+
+    private Integer fansCount;      // 进粉数
+    private BigDecimal totalAmount; // 订单总金额
+    private Integer orderCount;     // 购买次数
+    private Integer buyerCount;     // 购买人数
+}

+ 1 - 1
fs-service/src/main/java/com/fs/company/vo/SalesStatCIDVO.java

@@ -6,7 +6,7 @@ import java.math.BigDecimal;
 @Data
 public class SalesStatCIDVO {
     private Long userId;
-    private String nickName;
+    private String companyUserName;
     private String deptName;
     private Integer fansCount;       // 进粉数
     private BigDecimal totalAmount;  // 订单总金额

+ 4 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseLinkMiniParam.java

@@ -9,8 +9,12 @@ public class FsCourseLinkMiniParam {
 
     private String qwUserId;
 
+    //主体id
     private String corpId;
 
+    //应用id(等价于agentId)
+    private String appAgentId;
+
     private Long courseId;
 
     private String title;//视频标题

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

@@ -2239,7 +2239,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         String linkByMiniApp = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),2,null,0);
 
         JSONObject news = new JSONObject(true);
-        news.put("miniprogramAppid", qwCompany.getMiniAppId());
+        // 获取配置的小程序id
+        QwAppMiniProgramRelation qwAppMiniProgramRelation = qwAppMiniProgramRelationMapper.selectQwAppMiniProgramRelationByAgentIdAndCorpId(param.getAppAgentId(), param.getCorpId());
+        if (qwAppMiniProgramRelation == null){
+            log.error("createMiniLink()未找到侧边栏配置的小程序,appAgentId:{},corpId:{}", param.getAppAgentId(), param.getCorpId());
+            news.put("miniprogramAppid", qwCompany.getMiniAppId());
+        }else{
+            news.put("miniprogramAppid", qwAppMiniProgramRelation.getMiniAppId());
+        }
         news.put("miniprogramTitle", param.getTitle());
         news.put("miniprogramPicUrl", config.getSidebarImageUrl());
         news.put("miniprogramPage", linkByMiniApp);
@@ -2534,7 +2541,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         String linkByMiniApp = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),2,null,1);
 
         JSONObject news = new JSONObject(true);
-        news.put("miniprogramAppid", qwCompany.getMiniAppId());
+        // 获取配置的小程序id
+        QwAppMiniProgramRelation qwAppMiniProgramRelation = qwAppMiniProgramRelationMapper.selectQwAppMiniProgramRelationByAgentIdAndCorpId(param.getAppAgentId(), param.getCorpId());
+        if (qwAppMiniProgramRelation == null){
+            log.error("createRoomMiniLink()未找到侧边栏配置的小程序,appAgentId:{},corpId:{}", param.getAppAgentId(), param.getCorpId());
+            news.put("miniprogramAppid", qwCompany.getMiniAppId());
+        }else{
+            news.put("miniprogramAppid", qwAppMiniProgramRelation.getMiniAppId());
+        }
         news.put("miniprogramTitle", param.getTitle());
         news.put("miniprogramPicUrl", config.getSidebarImageUrl());
         news.put("miniprogramPage", linkByMiniApp);

+ 6 - 0
fs-service/src/main/java/com/fs/his/domain/FsDoctorPatient.java

@@ -92,6 +92,12 @@ public class FsDoctorPatient extends BaseEntity {
     /** 接诊医生ID */
     private Long doctorId;
 
+    /** 可见销售ID */
+    private Long companyUserId;
+
+    /** 可见销售名称 */
+    private String companyUserName;
+
     //分页相关
     private Integer pageNum;
     private Integer pageSize;

+ 3 - 0
fs-service/src/main/java/com/fs/his/domain/FsPrescribe.java

@@ -203,6 +203,9 @@ public class FsPrescribe extends BaseEntity
      * */
     private Long collectionId;
 
+    /** 医生名称 */
+    private String doctorName;
+
     public FsPrescribe() {
     }
 

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

@@ -184,6 +184,9 @@ public interface FsDoctorMapper
     //根据入参类型随机返回一个在线药师
     List<FsDoctor> selectRandomOnlineDoctorForPackage();
 
+    //根据ids集合查询
+    List<FsDoctor> selectDoctorByIds(@Param("ids") List<Long> ids);
+
     @Select("select doctor_id from fs_doctor where doctor_type=1 and  `status`=1 and is_audit=1 and is_agreement_prescribe_doctor=1  and sign_url is not null")
     List<Long>  selectFsDoctorDoctorByPackage();
 

+ 10 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeMapper.java

@@ -339,4 +339,14 @@ public interface FsPrescribeMapper
      * 根据采集信息主键id查询最新审核通过的处方信息
      * */
     FsPrescribe selectNewestAuditedPrescribeByCollectionId(@Param("collectionId") Long collectionId);
+
+    /**
+     * 根据处方id集合批量查询
+     * */
+    List<FsPrescribe> selectFsPrescribeListByPrescribeIds(@Param("prescribeIds") List<Long> prescribeIds);
+
+    /**
+     * 根据加密手机号查询处方列表
+     * */
+    List<FsPrescribe> selectPrescribeListByEncryptPhone(String phone);
 }

+ 11 - 0
fs-service/src/main/java/com/fs/his/param/CollectionPhoneParam.java

@@ -0,0 +1,11 @@
+package com.fs.his.param;
+
+import lombok.Data;
+
+@Data
+public class CollectionPhoneParam {
+    private String phone;
+    //分页相关
+    private Integer pageNum;
+    private Integer pageSize;
+}

+ 11 - 0
fs-service/src/main/java/com/fs/his/param/PrescribePhoneParam.java

@@ -0,0 +1,11 @@
+package com.fs.his.param;
+
+import lombok.Data;
+
+@Data
+public class PrescribePhoneParam {
+    private String phone;
+    //分页相关
+    private Integer pageNum;
+    private Integer pageSize;
+}

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java

@@ -167,4 +167,9 @@ public interface IFsPrescribeService
      * 根据用户id查询最新审核通过的处方信息
      * */
     FsPrescribe selectNewestAuditedPrescribeByCollectionId(Long collectionId);
+
+    /**
+     * 根据加密后的电话号码查询处方列表
+     * */
+    List<FsPrescribe> selectPrescribeListByEncryptPhone(String phone);
 }

+ 32 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsDoctorPatientServiceImpl.java

@@ -1,11 +1,14 @@
 package com.fs.his.service.impl;
 
+import com.fs.common.exception.CustomException;
 import com.fs.his.domain.FsDoctorPatient;
 import com.fs.his.mapper.FsDoctorPatientMapper;
 import com.fs.his.service.IFsDoctorPatientService;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -31,7 +34,35 @@ public class FsDoctorPatientServiceImpl implements IFsDoctorPatientService {
 
     @Override
     public int insertFsDoctorPatient(FsDoctorPatient fsDoctorPatient) {
-        return fsDoctorPatientMapper.insertFsDoctorPatient(fsDoctorPatient);
+        try {
+            return fsDoctorPatientMapper.insertFsDoctorPatient(fsDoctorPatient);
+        } catch (Exception e) {
+            // 判断是否为唯一键冲突(电话号码重复)
+            if (isDuplicatePhoneException(e)) {
+                throw new CustomException("电话号码已存在");
+            }
+            // 其他异常统一提示
+            throw new CustomException("添加失败,请联系管理员");
+        }
+
+    }
+
+    /**
+     * 判断异常是否为“电话号码重复”导致的唯一键冲突
+     */
+    private boolean isDuplicatePhoneException(Exception e) {
+        Throwable cause = e;
+        while (cause != null) {
+            if (cause instanceof java.sql.SQLIntegrityConstraintViolationException) {
+                String msg = cause.getMessage();
+                // 根据实际约束名判断,约束名为 'fs_company_customer.uk_phone'
+                if (msg != null && (msg.contains("Duplicate entry") && msg.contains("uk_phone"))) {
+                    return true;
+                }
+            }
+            cause = cause.getCause();
+        }
+        return false;
     }
 
     @Override

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

@@ -26,6 +26,7 @@ import com.fs.his.mapper.*;
 import com.fs.his.param.*;
 import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.PhoneUtil;
 import com.fs.his.utils.qrcode.QRCodeUtils;
 import com.fs.his.vo.*;
 import com.fs.hisStore.domain.FsUserInformationCollection;
@@ -1612,6 +1613,8 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
 //            Long seconds = DateUtil.between(fsPrescribe.getStartOperateTime(), fsPrescribe.getEndOperateTime(), DateUnit.SECOND);
 //            fsPrescribe.setOperateSecond(seconds);
 //        }
+        //处方类型
+        fsPrescribe.setPrescribeType(param.getPrescribeType());
         //处方诊断
         fsPrescribe.setDiagnose(param.getDiagnose());
         //处方医嘱
@@ -1665,4 +1668,18 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         return fsPrescribeMapper.selectNewestAuditedPrescribeByCollectionId(collectionId);
     }
 
+    @Override
+    public List<FsPrescribe> selectPrescribeListByEncryptPhone(String phone) {
+        if (StringUtils.isBlank(phone)) {
+            throw new CustomException("手机号不能为空");
+        }
+        // 手机号长度为11位时进行加密,否则直接使用原值查询
+        String searchPhone = (phone.length() == 11) ? PhoneUtil.encryptPhone(phone) : phone;
+        List<FsPrescribe> prescribeList = fsPrescribeMapper.selectPrescribeListByEncryptPhone(searchPhone);
+        if (CollectionUtils.isEmpty(prescribeList)){
+            return Collections.emptyList();
+        }
+        return prescribeList;
+    }
+
 }

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

@@ -128,4 +128,13 @@ public interface FsUserInformationCollectionMapper extends BaseMapper<FsUserInfo
      * 重置CID信息采集
      */
     int resetCIDCollection(Long collectionId);
+
+
+    /**
+     * 根据手机号查询用户信息采集表
+     *
+     * @param phone 手机号
+     * @return 用户信息采集表
+     */
+    List<FsUserInformationCollectionOverviewVo> selectFsUserInformationCollectionByPhone(String phone);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserInformationCollectionService.java

@@ -209,4 +209,9 @@ public interface IFsUserInformationCollectionService extends IService<FsUserInfo
      * @return 结果
      */
     int resetCIDCollection(Long collectionId,Long operatorId,String nickName);
+
+    /**
+     * 根据手机号查询已绑定用户的信息采集表数据
+     * */
+    List<FsUserInformationCollectionOverviewVo> selectUserInformationCollectionByPhone(String phone);
 }

+ 111 - 10
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -101,6 +101,8 @@ import com.fs.hisStore.service.IFsUserInformationCollectionService;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import static com.fs.his.utils.PhoneUtil.encryptPhone;
+
 /**
  * 用户信息采集Service业务层处理
  *
@@ -489,7 +491,10 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         }
         fsPrescribe.setPatientId(param.getPatientInfo().getPatientId());
         fsPrescribe.setPatientName(param.getPatientInfo().getPatientName());
-        fsPrescribe.setPatientTel(param.getPatientInfo().getMobile());
+        if (param.getPatientInfo().getMobile() != null){
+            //存储加密字符串到处方表
+            fsPrescribe.setPatientTel(encryptPhone(param.getPatientInfo().getMobile()));
+        }
         fsPrescribe.setPatientGender(String.valueOf(param.getPatientInfo().getSex()));
         return fsPrescribe;
     }
@@ -1722,15 +1727,28 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
             log.error("信息采集id:{}存在必填备注未填写,请完善后再提交", param.getId());//为了不影响业务正常执行这里暂时就不抛异常了
             sourceInfo.setCompleteStatus(0);
         }
-        //如果待完善用户使用患者信息的是"默认就诊人",则需要更新对应处方中的患者信息
         if (sourceInfo.getPrescribeId()!=null){
+            //获取这个信息采集对应的处方信息
             FsPrescribe fsPrescribe = fsPrescribeMapper.selectFsPrescribeByPrescribeId(sourceInfo.getPrescribeId());
-            fsPrescribe.setPatientBirthday(param.getPatientInfo().getBirthday());
-            fsPrescribe.setPatientId(param.getPatientInfo().getPatientId());
-            fsPrescribe.setPatientName(param.getPatientInfo().getPatientName());
-            fsPrescribe.setPatientTel(param.getPatientInfo().getMobile());
-            fsPrescribe.setPatientGender(param.getPatientInfo().getSex());
-            fsPrescribeMapper.updateFsPrescribe(fsPrescribe);
+            if (fsPrescribe!=null){
+                if (DEFAULT_PATIENT_NAME.equals(fsPrescribe.getPatientName())){
+                    //如果待完善用户的信息采集对应的处方中使用患者名称是"默认就诊人",则需要更新对应处方中的患者信息
+                    fsPrescribe.setPatientBirthday(param.getPatientInfo().getBirthday());
+                    fsPrescribe.setPatientId(param.getPatientInfo().getPatientId());
+                    fsPrescribe.setPatientName(param.getPatientInfo().getPatientName());
+                    if (param.getPatientInfo().getMobile()!=null&&param.getPatientInfo().getMobile().length()==11){
+                        //说明传入的是未加密的手机号,则需要加密后再存储
+                        fsPrescribe.setPatientTel(encryptPhone(param.getPatientInfo().getMobile()));
+                    } else if (param.getPatientInfo().getMobile()!=null&&param.getPatientInfo().getMobile().length()>11) {
+                        //说明传入的是加密后的字符串,无需加密直接赋值
+                        fsPrescribe.setPatientTel(param.getPatientInfo().getMobile());
+                    }
+
+                    fsPrescribe.setPatientGender(param.getPatientInfo().getSex());
+                    fsPrescribeMapper.updateFsPrescribe(fsPrescribe);
+                }
+            }
+
         }
         fsUserInformationCollectionMapper.updateFsUserInformationCollection(sourceInfo);
     }
@@ -1740,13 +1758,84 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         queryDto.setCompleteStatus(1);//已完善信息标识
         queryDto.setQwTag(1);//个微标识
         PageHelper.startPage(queryDto.getPageNum(), queryDto.getPageSize());
-        List<FsUserInformationCollectionOverviewVo> resultList=fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
-        if (CollectionUtils.isEmpty(resultList)){
+        List<FsUserInformationCollectionOverviewVo> resultList = fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
+        if (CollectionUtils.isEmpty(resultList)) {
             return Collections.emptyList();
         }
+        // 填充药师信息(处方对应药师)
+        fillPharmacistInfo(resultList);
         return resultList;
     }
 
+    /**
+     * 填充结果列表中的药师ID与姓名
+     */
+    private void fillPharmacistInfo(List<FsUserInformationCollectionOverviewVo> resultList) {
+        if (CollectionUtils.isEmpty(resultList)) {
+            return;
+        }
+        // 1. 收集非空的处方ID
+        List<Long> prescribeIds = resultList.stream()
+                .map(FsUserInformationCollectionOverviewVo::getPrescribeId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        if (prescribeIds.isEmpty()) {
+            return;
+        }
+
+        // 2. 查询处方表(只需 prescribe_id 和 drug_doctor_id)
+        List<FsPrescribe> prescribeList = fsPrescribeMapper.selectFsPrescribeListByPrescribeIds(prescribeIds);
+        if (CollectionUtils.isEmpty(prescribeList)) {
+            return;
+        }
+
+        // 3. 构建 处方ID -> 药师ID 的映射
+        Map<Long, Long> prescribeToDoctorIdMap = prescribeList.stream()
+                .collect(Collectors.toMap(
+                        FsPrescribe::getPrescribeId,
+                        FsPrescribe::getDrugDoctorId,
+                        (existing, replacement) -> existing
+                ));
+
+        // 4. 收集所有药师ID(去重)
+        List<Long> doctorIds = prescribeList.stream()
+                .map(FsPrescribe::getDrugDoctorId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        if (doctorIds.isEmpty()) {
+            return;
+        }
+
+        // 5. 批量查询医生(药师)信息
+        List<FsDoctor> doctorList = doctorMapper.selectDoctorByIds(doctorIds);
+        if (CollectionUtils.isEmpty(doctorList)) {
+            return;
+        }
+        Map<Long, FsDoctor> doctorMap = doctorList.stream()
+                .collect(Collectors.toMap(
+                        FsDoctor::getDoctorId,
+                        Function.identity(),
+                        (existing, replacement) -> existing
+                ));
+
+        // 6. 回填药师ID与姓名
+        resultList.forEach(vo -> {
+            Long prescribeId = vo.getPrescribeId();
+            if (prescribeId != null) {
+                Long doctorId = prescribeToDoctorIdMap.get(prescribeId);
+                if (doctorId != null) {
+                    vo.setPharmacistId(doctorId.toString()); // 字段类型注意转换
+                    FsDoctor doctor = doctorMap.get(doctorId);
+                    if (doctor != null) {
+                        vo.setPharmacistName(doctor.getDoctorName());
+                    }
+                }
+            }
+        });
+    }
+
     @Override
     @Transactional
     public Long bindCollectionPackage(bindCollectionPackageParam param) {
@@ -1866,6 +1955,18 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         return fsUserInformationCollectionMapper.resetCIDCollection(collectionId);
     }
 
+    @Override
+    public List<FsUserInformationCollectionOverviewVo> selectUserInformationCollectionByPhone(String phone) {
+        if (StringUtils.isEmpty(phone)){
+            throw new CustomException("手机号不能为空");
+        }
+        List<FsUserInformationCollectionOverviewVo> fsUserInformationCollections =fsUserInformationCollectionMapper.selectFsUserInformationCollectionByPhone(phone);
+        if (CollectionUtils.isEmpty(fsUserInformationCollections)){
+            return Collections.emptyList();
+        }
+        return fsUserInformationCollections;
+    }
+
     /**
      * 校验必填备注:对于 open=true 且被勾选的选项,必须填写备注文本
      *

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsUserInformationCollectionOverviewVo.java

@@ -62,6 +62,13 @@ public class FsUserInformationCollectionOverviewVo {
     @Excel(name = "医生姓名")
     private String doctorName;
 
+    /** 药师Id */
+    private String pharmacistId;
+
+    /** 药师姓名 */
+    @Excel(name = "药师姓名")
+    private String pharmacistName;
+
     /** 销售人员姓名 */
     @Excel(name = "销售人员姓名")
     private String companyUserName;

+ 86 - 0
fs-service/src/main/java/com/fs/qw/domain/FsCompanyCustomer.java

@@ -0,0 +1,86 @@
+package com.fs.qw.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 客户基础信息对象 fs_company_customer
+ *
+ * @author yourname
+ * @date 2026-04-30
+ */
+@Data
+public class FsCompanyCustomer extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /** 客户ID */
+    private Long id;
+
+    /** 客户姓名 */
+    @Excel(name = "客户姓名")
+    private String customerName;
+
+    /** 性别(0女 1男 2未知) */
+    @Excel(name = "性别", readConverterExp = "0=女,1=男,2=未知")
+    private String sex;
+
+    /** 年龄 */
+    @Excel(name = "年龄")
+    private Integer age;
+
+    /** 地址(精确到市) */
+    @Excel(name = "地址")
+    private String address;
+
+    /** 电话 */
+    @Excel(name = "电话")
+    private String phone;
+
+    /** 建档时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "建档时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date filingTime;
+
+    /** 销售id */
+    private Long companyUserId;
+
+    /** 销售id集合 */
+    private List<Long> companyUserIds;
+
+    /** 销售姓名 */
+    @Excel(name = "客服姓名")
+    private String companyUserName;
+
+    /** 约诊时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "约诊时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date appointmentTime;
+
+    /** 负责医生id */
+    private Long doctorId;
+
+    /** 负责医生 */
+    @Excel(name = "负责医生")
+    private String doctorName;
+
+    /** 现病史 */
+    @Excel(name = "现病史")
+    private String presentIllness;
+
+    /** 现用药情况 */
+    @Excel(name = "现用药情况")
+    private String currentMedication;
+
+    /** 过敏史 */
+    @Excel(name = "过敏史")
+    private String allergyHistory;
+
+    // 分页相关
+    private Integer pageNum;
+    private Integer pageSize;
+}

+ 51 - 0
fs-service/src/main/java/com/fs/qw/mapper/FsCompanyCustomerMapper.java

@@ -0,0 +1,51 @@
+package com.fs.qw.mapper;
+
+import com.fs.qw.domain.FsCompanyCustomer;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 客户基础信息Mapper接口
+ *
+ * @author yourname
+ * @date 2026-04-30
+ */
+public interface FsCompanyCustomerMapper {
+    /**
+     * 查询客户信息
+     */
+    public FsCompanyCustomer selectFsCompanyCustomerById(Long id);
+
+    /**
+     * 查询客户信息列表
+     */
+    public List<FsCompanyCustomer> selectFsCompanyCustomerList(FsCompanyCustomer fsCompanyCustomer);
+
+    /**
+     * 新增客户信息
+     */
+    public int insertFsCompanyCustomer(FsCompanyCustomer fsCompanyCustomer);
+
+    /**
+     * 修改客户信息
+     */
+    public int updateFsCompanyCustomer(FsCompanyCustomer fsCompanyCustomer);
+
+    /**
+     * 删除客户信息(逻辑删除)
+     */
+    public int deleteFsCompanyCustomerById(Long id);
+
+    /**
+     * 批量删除客户信息(逻辑删除)
+     */
+    public int deleteFsCompanyCustomerByIds(Long[] ids);
+
+    /**
+     * 根据销售ID集合(必传)和客服姓名(可选)查询客户列表
+     * @param fsCompanyCustomer 查询条件对象,必须包含 companyUserIds
+     * @return 客户列表
+     */
+    List<FsCompanyCustomer> selectFsCompanyCustomerListByCompanyUserIds(FsCompanyCustomer fsCompanyCustomer);
+}

+ 2 - 0
fs-service/src/main/java/com/fs/qw/param/QwGroupMsgParam.java

@@ -122,4 +122,6 @@ public class QwGroupMsgParam {
     /** 创建人 */
     private String createName;
 
+    //应用id(等价于agentId)
+    private String appAgentId;
 }

+ 25 - 0
fs-service/src/main/java/com/fs/qw/service/IFsCompanyCustomerService.java

@@ -0,0 +1,25 @@
+package com.fs.qw.service;
+
+import com.fs.qw.domain.FsCompanyCustomer;
+import java.util.List;
+
+/**
+ * 客户基础信息Service接口
+ *
+ * @author yourname
+ * @date 2026-04-30
+ */
+public interface IFsCompanyCustomerService {
+    FsCompanyCustomer selectFsCompanyCustomerById(Long id);
+
+    List<FsCompanyCustomer> selectFsCompanyCustomerList(FsCompanyCustomer fsCompanyCustomer);
+
+    int insertFsCompanyCustomer(FsCompanyCustomer fsCompanyCustomer);
+
+    int updateFsCompanyCustomer(FsCompanyCustomer fsCompanyCustomer);
+
+    int deleteFsCompanyCustomerByIds(Long[] ids);
+
+    //查询关联销售的客户列表
+    List<FsCompanyCustomer> selectFsCompanyCustomerListByCompanyUserIds(FsCompanyCustomer fsCompanyCustomer);
+}

+ 89 - 0
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java

@@ -0,0 +1,89 @@
+package com.fs.qw.service.impl;
+
+import com.fs.common.exception.CustomException;
+import com.fs.qw.domain.FsCompanyCustomer;
+import com.fs.qw.mapper.FsCompanyCustomerMapper;
+import com.fs.qw.service.IFsCompanyCustomerService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 客户基础信息Service业务层处理
+ *
+ * @author yourname
+ * @date 2026-04-30
+ */
+@Service
+public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
+    @Autowired
+    private FsCompanyCustomerMapper fsCompanyCustomerMapper;
+
+    @Override
+    public FsCompanyCustomer selectFsCompanyCustomerById(Long id) {
+        return fsCompanyCustomerMapper.selectFsCompanyCustomerById(id);
+    }
+
+    @Override
+    public List<FsCompanyCustomer> selectFsCompanyCustomerList(FsCompanyCustomer fsCompanyCustomer) {
+        return fsCompanyCustomerMapper.selectFsCompanyCustomerList(fsCompanyCustomer);
+    }
+
+    @Override
+    public int insertFsCompanyCustomer(FsCompanyCustomer customer) {
+        try {
+            return fsCompanyCustomerMapper.insertFsCompanyCustomer(customer);
+        } catch (Exception e) {
+            // 判断是否为唯一键冲突(电话号码重复)
+            if (isDuplicatePhoneException(e)) {
+                throw new CustomException("电话号码已存在");
+            }
+            // 其他异常统一提示
+            throw new CustomException("添加失败,请联系管理员");
+        }
+    }
+
+    /**
+     * 判断异常是否为“电话号码重复”导致的唯一键冲突
+     */
+    private boolean isDuplicatePhoneException(Exception e) {
+        Throwable cause = e;
+        while (cause != null) {
+            if (cause instanceof java.sql.SQLIntegrityConstraintViolationException) {
+                String msg = cause.getMessage();
+                // 根据实际约束名判断,约束名为 'fs_company_customer.uk_phone'
+                if (msg != null && (msg.contains("Duplicate entry") && msg.contains("uk_phone"))) {
+                    return true;
+                }
+            }
+            cause = cause.getCause();
+        }
+        return false;
+    }
+
+    @Override
+    public int updateFsCompanyCustomer(FsCompanyCustomer fsCompanyCustomer) {
+        return fsCompanyCustomerMapper.updateFsCompanyCustomer(fsCompanyCustomer);
+    }
+
+    @Override
+    public int deleteFsCompanyCustomerByIds(Long[] ids) {
+        return fsCompanyCustomerMapper.deleteFsCompanyCustomerByIds(ids);
+    }
+
+    @Override
+    public List<FsCompanyCustomer> selectFsCompanyCustomerListByCompanyUserIds(FsCompanyCustomer fsCompanyCustomer) {
+        if (CollectionUtils.isEmpty(fsCompanyCustomer.getCompanyUserIds())){
+            // 返回空列表
+            return Collections.emptyList();
+        }
+        List<FsCompanyCustomer> list =fsCompanyCustomerMapper.selectFsCompanyCustomerListByCompanyUserIds(fsCompanyCustomer);
+        if (CollectionUtils.isEmpty(list)){
+            return Collections.emptyList();
+        }
+        return list;
+    }
+}

+ 13 - 3
fs-service/src/main/java/com/fs/qw/service/impl/QwGroupMsgServiceImpl.java

@@ -114,6 +114,9 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
     @Autowired
     private CloudHostProper cloudHostProper;
 
+    @Autowired
+    private QwAppMiniProgramRelationMapper qwAppMiniProgramRelationMapper;
+
     /**
      * 查询客户群发记录主
      *
@@ -759,16 +762,23 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
         }
 
         String linkByMiniApp = createLinkByMiniAppGeneral(new Date(), qwGroupMsgParam.getCourseId(), qwGroupMsgParam.getVideoId(), qwUser, 0L,2,null,1);
-
+        // 获取配置的小程序id
+        QwAppMiniProgramRelation qwAppMiniProgramRelation = qwAppMiniProgramRelationMapper.selectQwAppMiniProgramRelationByAgentIdAndCorpId(qwGroupMsgParam.getAppAgentId(), qwGroupMsgParam.getCorpId());
+        if (qwAppMiniProgramRelation == null){
+            log.info("sendSidebarOfficial()未找到侧边栏配置的小程序,appAgentId:{},corpId:{}", qwGroupMsgParam.getAppAgentId(), qwGroupMsgParam.getCorpId());
+            msgTemplate.setMiniprogramAppid(qwCompany.getMiniAppId());
+        }else{
+            msgTemplate.setMiniprogramAppid(qwAppMiniProgramRelation.getMiniAppId());
+        }
         msgTemplate.setSender(qwGroupMsgParam.getSender().trim());
-        msgTemplate.setMiniprogramAppid(qwCompany.getMiniAppId());
+        //msgTemplate.setMiniprogramAppid(qwCompany.getMiniAppId());
         msgTemplate.setMiniprogramTitle(qwGroupMsgParam.getMiniprogramTitle());
         msgTemplate.setMiniprogramPicMediaId(mediaId);
         msgTemplate.setMiniprogramPage(linkByMiniApp);
 
         qwGroupMsgItem.setMsgType(3);
         qwGroupMsgItem.setMiniprogramTitle(qwGroupMsgParam.getMiniprogramTitle());
-        qwGroupMsgItem.setMiniprogramAppid(qwCompany.getMiniAppId());
+        //qwGroupMsgItem.setMiniprogramAppid(qwCompany.getMiniAppId());
         qwGroupMsgItem.setMiniprogramPicUrl(qwGroupMsgParam.getMiniprogramPicUrl());
         qwGroupMsgItem.setMiniprogramPicMediaId(mediaId);
         qwGroupMsgItem.setMiniprogramPage(linkByMiniApp);

+ 11 - 0
fs-service/src/main/java/com/fs/qw/vo/CompanyUserAndDoctorVO.java

@@ -0,0 +1,11 @@
+package com.fs.qw.vo;
+
+import lombok.Data;
+
+@Data
+public class CompanyUserAndDoctorVO {
+    private Long CompanyUserId;
+    private String CompanyUserName;
+    private Long DoctorId;
+    private String DoctorName;
+}

+ 105 - 7
fs-service/src/main/resources/mapper/company/CompanyStatisticsCIDMapper.xml

@@ -10,10 +10,22 @@
         <result column="buyerCount" property="buyerCount"/>
     </resultMap>
 
+    <resultMap id="SalesAccountStatMap" type="com.fs.company.vo.SalesAccountStatCIDVO">
+        <result column="qwUserId" property="qwUserId"/>
+        <result column="qwUserName" property="qwUserName"/>
+        <result column="companyUserId" property="companyUserId"/>
+        <result column="companyUserName" property="companyUserName"/>
+        <result column="deptName" property="deptName"/>
+        <result column="fansCount" property="fansCount"/>
+        <result column="totalAmount" property="totalAmount"/>
+        <result column="orderCount" property="orderCount"/>
+        <result column="buyerCount" property="buyerCount"/>
+    </resultMap>
+
     <select id="getSalesStatisticsCID" resultMap="SalesStatMap">
         SELECT
         cu.user_id AS userId,
-        cu.nick_name AS nickName,
+        cu.nick_name AS companyUserName,
         d.dept_name AS deptName,
         COALESCE(fc.fans_count, 0) AS fansCount,
         COALESCE(oc.total_amount, 0) AS totalAmount,
@@ -53,16 +65,13 @@
         ) oc ON oc.company_user_id = cu.user_id
 
         WHERE cu.del_flag = '0'
-        <if test="(param.corpId != null and param.corpId != '') or (param.qwUserName != null and param.qwUserName.trim() != '')">
+        <if test="(param.corpId != null and param.corpId != '')">
             AND EXISTS (
             SELECT 1 FROM qw_user qu_filter
             WHERE qu_filter.company_user_id = cu.user_id
             <if test="param.corpId != null and param.corpId != ''">
                 AND qu_filter.corp_id = #{param.corpId}
             </if>
-            <if test="param.qwUserName != null and param.qwUserName.trim() != ''">
-                AND qu_filter.qw_user_name LIKE CONCAT('%', #{param.qwUserName}, '%')
-            </if>
             )
         </if>
         <if test="param.companyId != null">
@@ -78,8 +87,8 @@
         <if test="param.userId != null">
             AND cu.user_id = #{param.userId}
         </if>
-        <if test="param.companyUserNickName != null and param.companyUserNickName.trim() != ''">
-            AND cu.nick_name LIKE CONCAT('%', #{param.companyUserNickName}, '%')
+        <if test="param.companyUserName != null and param.companyUserName.trim() != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{param.companyUserName}, '%')
         </if>
         GROUP BY cu.user_id, cu.nick_name, d.dept_name
         -- 动态排序 ↓
@@ -91,6 +100,95 @@
         </if>
     </select>
 
+    <select id="getSalesAccountStatCID" resultMap="SalesAccountStatMap">
+        SELECT
+        qu.id AS qwUserId,
+        qu.qw_user_name AS qwUserName,
+        cu.user_id AS companyUserId,
+        cu.nick_name AS companyUserName,
+        d.dept_name AS deptName,
+        COALESCE(fc.fans_count, 0) AS fansCount,
+        COALESCE(oc.total_amount, 0) AS totalAmount,
+        COALESCE(oc.order_count, 0) AS orderCount,
+        COALESCE(oc.buyer_count, 0) AS buyerCount
+        FROM qw_user qu
+        INNER JOIN company_user cu ON qu.company_user_id = cu.user_id AND cu.del_flag = '0'
+        <if test="param.companyId != null">AND cu.company_id = #{param.companyId}</if>
+        <if test="param.deptId != null">
+            AND (cu.dept_id = #{param.deptId}
+            OR cu.dept_id IN (
+            SELECT t.dept_id FROM company_dept t
+            WHERE t.del_flag = '0' AND FIND_IN_SET(#{param.deptId}, t.ancestors)
+            ))
+        </if>
+        <if test="param.userId != null">AND cu.user_id = #{param.userId}</if>
+        <if test="param.companyUserName != null and param.companyUserName.trim() != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{param.companyUserName}, '%')
+        </if>
+        LEFT JOIN company_dept d ON cu.dept_id = d.dept_id AND d.del_flag = '0'
+
+        <!--进粉统计 -->
+        LEFT JOIN (
+        SELECT qu2.id AS qw_user_id,
+        COUNT(DISTINCT ec.id) AS fans_count
+        FROM qw_user qu2
+        INNER JOIN qw_external_contact ec
+        ON ec.qw_user_id = qu2.id
+        AND ec.add_way = 16
+        <if test="param.startAddTime != null and param.endAddTime != null">
+            AND ec.create_time BETWEEN #{param.startAddTime} AND #{param.endAddTime}
+        </if>
+        WHERE qu2.company_user_id IN (
+        SELECT cu2.user_id FROM company_user cu2
+        WHERE cu2.del_flag = '0'
+        <if test="param.companyId != null">AND cu2.company_id = #{param.companyId}</if>
+        <if test="param.deptId != null">
+            AND (cu2.dept_id = #{param.deptId}
+            OR cu2.dept_id IN (
+            SELECT t.dept_id FROM company_dept t
+            WHERE t.del_flag = '0' AND FIND_IN_SET(#{param.deptId}, t.ancestors)
+            ))
+        </if>
+        <if test="param.userId != null">AND cu2.user_id = #{param.userId}</if>
+        )
+        GROUP BY qu2.id
+        ) fc ON fc.qw_user_id = qu.id
+
+        <!--完整的订单统计-->
+        LEFT JOIN (
+        SELECT log.company_user_id,
+        SUM(o.pay_price) AS total_amount,
+        COUNT(DISTINCT o.order_code) AS order_count,
+        COUNT(DISTINCT o.user_id) AS buyer_count
+        FROM fs_store_order o
+        INNER JOIN (
+        SELECT DISTINCT package_order_code, company_user_id
+        FROM fs_user_information_collection_personal_log
+        WHERE 1 = 1
+        <if test="param.startOrderTime != null and param.endOrderTime != null">
+            AND order_time BETWEEN #{param.startOrderTime} AND #{param.endOrderTime}
+        </if>
+        ) log ON o.order_code = log.package_order_code
+        WHERE o.is_pay = 1 AND o.refund_status = 0
+        GROUP BY log.company_user_id
+        ) oc ON oc.company_user_id = qu.company_user_id
+
+        WHERE 1=1
+        <if test="param.corpId != null and param.corpId != ''">
+            AND qu.corp_id = #{param.corpId}
+        </if>
+        <if test="param.qwUserName != null and param.qwUserName.trim() != ''">
+            AND qu.qw_user_name LIKE CONCAT('%', #{param.qwUserName}, '%')
+        </if>
+        GROUP BY qu.id, cu.user_id, d.dept_name
+        <if test="param.orderByColumn != null">
+            ORDER BY ${param.orderByColumn} ${param.isAsc}
+        </if>
+        <if test="param.orderByColumn == null">
+            ORDER BY qu.id
+        </if>
+    </select>
+
     <select id="getSalesUserDetailCID" resultType="com.fs.company.vo.SalesUserDetailCIDVO">
         SELECT
         log.user_id AS userId,

+ 4 - 0
fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml

@@ -618,6 +618,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </select>
+    <select id="selectCompanyUserListByDoctorId" resultType="com.fs.company.domain.CompanyUser">
+        SELECT * FROM company_user
+        WHERE doctor_id = #{doctorId}
+    </select>
 
     <update id="unbindCidServer" parameterType="java.lang.Long" >
         update company_user

+ 9 - 0
fs-service/src/main/resources/mapper/his/FsDoctorMapper.xml

@@ -125,6 +125,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{doctorId}
         </foreach>
     </select>
+
+    <select id="selectDoctorByIds" resultMap="FsDoctorResult">
+        <include refid="selectFsDoctorVo"/>
+        WHERE doctor_id IN
+        <foreach collection="ids" item="doctorId" open="(" close=")" separator=",">
+            #{doctorId}
+        </foreach>
+    </select>
+
     <select id="selectRandomOnlineDoctorForPackage" resultMap="FsDoctorResult">
         SELECT d.*
         FROM fs_doctor d

+ 69 - 25
fs-service/src/main/resources/mapper/his/FsDoctorPatientMapper.xml

@@ -29,45 +29,51 @@
         <result property="updateTime"           column="update_time"           />
         <result property="remark"               column="remark"                />
         <result property="doctorId"             column="doctor_id"             />
+        <result property="companyUserId"             column="company_user_id"             />
     </resultMap>
 
     <sql id="selectFsDoctorPatientVo">
         select id, patient_name, sex, age, phone, reception_time, reception_doctor, city,
                present_illness, past_history, allergy_history, diagnosis, syndrome_type,
                syndrome_regulation, treatment_opinion, precautions, doctor_signature,
-               practice_certificate_no, doctor_id,
+               practice_certificate_no, doctor_id,company_user_id,
                create_by, create_time, update_by, update_time, remark, del_flag
         from fs_doctor_patient
     </sql>
 
     <select id="selectFsDoctorPatientList" parameterType="com.fs.his.domain.FsDoctorPatient" resultMap="FsDoctorPatientResult">
-        <include refid="selectFsDoctorPatientVo"/>
-        where del_flag = '0'
+        select fdp.*,cu.nick_name as companyUserName
+        from fs_doctor_patient fdp
+        left join company_user cu on fdp.company_user_id = cu.user_id
+        where fdp.del_flag = '0'
         <if test="patientName != null and patientName != ''">
-            and patient_name like concat('%', #{patientName}, '%')
+            and fdp.patient_name like concat('%', #{patientName}, '%')
         </if>
         <if test="sex != null and sex != ''">
-            and sex = #{sex}
+            and fdp.sex = #{sex}
         </if>
         <if test="phone != null and phone != ''">
-            and phone like concat('%', #{phone}, '%')
+            and fdp.phone like concat('%', #{phone}, '%')
         </if>
         <if test="receptionDoctor != null and receptionDoctor != ''">
-            and reception_doctor like concat('%', #{receptionDoctor}, '%')
+            and fdp.reception_doctor like concat('%', #{receptionDoctor}, '%')
         </if>
         <if test="receptionTime != null">
-            and reception_time = #{receptionTime}
+            and fdp.reception_time = #{receptionTime}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and reception_time &gt;= #{params.beginTime}
+            and fdp.reception_time &gt;= #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and reception_time &lt;= #{params.endTime}
+            andfdp.reception_time &lt;= #{endTime}
         </if>
         <if test="doctorId != null">
-            and doctor_id = #{doctorId}
+            and fdp.doctor_id = #{doctorId}
+        </if>
+        <if test="companyUserId != null">
+            and fdp.company_user_id = #{companyUserId}
         </if>
-        order by reception_time desc
+        order by fdp.reception_time desc
     </select>
 
     <select id="selectFsDoctorPatientById" parameterType="Long" resultMap="FsDoctorPatientResult">
@@ -75,20 +81,57 @@
         where id = #{id} and del_flag = '0'
     </select>
 
+    <!-- 动态 insert 语句 -->
     <insert id="insertFsDoctorPatient" parameterType="com.fs.his.domain.FsDoctorPatient" useGeneratedKeys="true" keyProperty="id">
-        insert into fs_doctor_patient (
-            patient_name, sex, age, phone, reception_time, reception_doctor, city,
-            present_illness, past_history, allergy_history, diagnosis, syndrome_type,
-            syndrome_regulation, treatment_opinion, precautions, doctor_signature,
-            practice_certificate_no, doctor_id,
-            create_by, create_time, remark
-        ) values (
-                     #{patientName}, #{sex}, #{age}, #{phone}, #{receptionTime}, #{receptionDoctor}, #{city},
-                     #{presentIllness}, #{pastHistory}, #{allergyHistory}, #{diagnosis}, #{syndromeType},
-                     #{syndromeRegulation}, #{treatmentOpinion}, #{precautions}, #{doctorSignature},
-                     #{practiceCertificateNo}, #{doctorId},
-                     #{createBy}, sysdate(), #{remark}
-                 )
+        insert into fs_doctor_patient
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="patientName != null">patient_name,</if>
+            <if test="sex != null">sex,</if>
+            <if test="age != null">age,</if>
+            <if test="phone != null">phone,</if>
+            <if test="receptionTime != null">reception_time,</if>
+            <if test="receptionDoctor != null">reception_doctor,</if>
+            <if test="city != null">city,</if>
+            <if test="presentIllness != null">present_illness,</if>
+            <if test="pastHistory != null">past_history,</if>
+            <if test="allergyHistory != null">allergy_history,</if>
+            <if test="diagnosis != null">diagnosis,</if>
+            <if test="syndromeType != null">syndrome_type,</if>
+            <if test="syndromeRegulation != null">syndrome_regulation,</if>
+            <if test="treatmentOpinion != null">treatment_opinion,</if>
+            <if test="precautions != null">precautions,</if>
+            <if test="doctorSignature != null">doctor_signature,</if>
+            <if test="practiceCertificateNo != null">practice_certificate_no,</if>
+            <if test="doctorId != null">doctor_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="remark != null">remark,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="patientName != null">#{patientName},</if>
+            <if test="sex != null">#{sex},</if>
+            <if test="age != null">#{age},</if>
+            <if test="phone != null">#{phone},</if>
+            <if test="receptionTime != null">#{receptionTime},</if>
+            <if test="receptionDoctor != null">#{receptionDoctor},</if>
+            <if test="city != null">#{city},</if>
+            <if test="presentIllness != null">#{presentIllness},</if>
+            <if test="pastHistory != null">#{pastHistory},</if>
+            <if test="allergyHistory != null">#{allergyHistory},</if>
+            <if test="diagnosis != null">#{diagnosis},</if>
+            <if test="syndromeType != null">#{syndromeType},</if>
+            <if test="syndromeRegulation != null">#{syndromeRegulation},</if>
+            <if test="treatmentOpinion != null">#{treatmentOpinion},</if>
+            <if test="precautions != null">#{precautions},</if>
+            <if test="doctorSignature != null">#{doctorSignature},</if>
+            <if test="practiceCertificateNo != null">#{practiceCertificateNo},</if>
+            <if test="doctorId != null">#{doctorId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="remark != null">#{remark},</if>
+            NOW()
+        </trim>
     </insert>
 
     <update id="updateFsDoctorPatient" parameterType="com.fs.his.domain.FsDoctorPatient">
@@ -114,6 +157,7 @@
             <if test="remark != null">remark = #{remark},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="doctorId != null">doctor_id = #{doctorId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             update_time = sysdate()
         </set>
         where id = #{id}

+ 17 - 0
fs-service/src/main/resources/mapper/his/FsPrescribeMapper.xml

@@ -582,6 +582,23 @@
         LIMIT 1
     </select>
 
+    <select id="selectFsPrescribeListByPrescribeIds" resultType="com.fs.his.domain.FsPrescribe">
+        select *
+        from fs_prescribe
+        where
+        prescribe_id in
+        <foreach collection="prescribeIds" item="prescribeId" separator="," open="(" close=")">
+            #{prescribeId}
+        </foreach>
+    </select>
+    <select id="selectPrescribeListByEncryptPhone" resultType="com.fs.his.domain.FsPrescribe">
+        select fp.*,dc.doctor_name as doctorName
+        from fs_prescribe fp left join fs_doctor dc on dc.doctor_id = fp.doctor_id
+        where
+        patient_tel = #{encryptPhone}
+        order by fp.audit_time desc
+    </select>
+
     <update id="updateFsPrescribeListDataCPWByPrescribeIds" parameterType="java.util.List">
         update fs_prescribe
         set

+ 28 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserInformationCollectionMapper.xml

@@ -265,6 +265,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY infocollect.create_time DESC
     </select>
 
+    <select id="selectFsUserInformationCollectionByPhone"
+            resultMap="FsUserInformationCollectionVoResult">
+        SELECT infocollect.id,
+               infocollect.user_id,
+               infocollect.json_info,
+               infocollect.create_time,
+               infocollect.doctor_id,
+               infocollect.company_user_id,
+               infocollect.question_id,
+               infocollect.age,
+               infocollect.user_name,
+               infocollect.sex,
+               infocollect.user_phone_four,
+               infocollect.allergy,
+               infocollect.remark,
+               infocollect.qw_tag,
+               infocollect.personal_collect_status,
+               infocollect.package_order_code,
+               infocollect.prescribe_id,
+               cu.nick_name,
+               fd.doctor_name
+        FROM fs_user_information_collection infocollect
+                 LEFT JOIN company_user cu ON infocollect.company_user_id = cu.user_id
+                 LEFT JOIN fs_doctor fd ON infocollect.doctor_id = fd.doctor_id
+        where infocollect.user_phone_four = #{phone}
+        and infocollect.user_id IS NOT NULL
+    </select>
+
     <insert id="insertFsUserInformationCollection" parameterType="FsUserInformationCollection" useGeneratedKeys="true" keyProperty="id">
         insert into fs_user_information_collection
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 167 - 0
fs-service/src/main/resources/mapper/qw/FsCompanyCustomerMapper.xml

@@ -0,0 +1,167 @@
+<?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">
+<mapper namespace="com.fs.qw.mapper.FsCompanyCustomerMapper">
+
+    <resultMap type="com.fs.qw.domain.FsCompanyCustomer" id="FsCompanyCustomerResult">
+        <result property="id"                column="id"                 />
+        <result property="customerName"      column="customer_name"      />
+        <result property="sex"               column="sex"                />
+        <result property="age"               column="age"                />
+        <result property="address"           column="address"            />
+        <result property="phone"             column="phone"              />
+        <result property="filingTime"        column="filing_time"        />
+        <result property="companyUserId"     column="company_user_id"    />
+        <result property="companyUserName"   column="company_user_name"  />
+        <result property="appointmentTime"   column="appointment_time"   />
+        <result property="doctorId"          column="doctor_id"          />
+        <result property="doctorName"        column="doctor_name"        />
+        <result property="presentIllness"    column="present_illness"    />
+        <result property="currentMedication" column="current_medication" />
+        <result property="allergyHistory"    column="allergy_history"    />
+        <result property="createBy"          column="create_by"          />
+        <result property="createTime"        column="create_time"        />
+        <result property="updateBy"          column="update_by"          />
+        <result property="updateTime"        column="update_time"        />
+        <result property="remark"            column="remark"             />
+    </resultMap>
+
+    <sql id="selectFsCompanyCustomerVo">
+        select id, customer_name, sex, age, address, phone, filing_time,
+               company_user_id, company_user_name, appointment_time, doctor_id, doctor_name,
+               present_illness, current_medication, allergy_history,
+               create_by, create_time, update_by, update_time, remark, del_flag
+        from fs_company_customer
+    </sql>
+
+    <select id="selectFsCompanyCustomerList" parameterType="com.fs.qw.domain.FsCompanyCustomer" resultMap="FsCompanyCustomerResult">
+        <include refid="selectFsCompanyCustomerVo"/>
+        where del_flag = '0'
+        <if test="customerName != null and customerName != ''">
+            and customer_name like concat('%', #{customerName}, '%')
+        </if>
+        <if test="phone != null and phone != ''">
+            and phone like concat('%', #{phone}, '%')
+        </if>
+        <if test="companyUserName != null and companyUserName != ''">
+            and company_user_name like concat('%', #{companyUserName}, '%')
+        </if>
+        <if test="companyUserId != null">
+            and company_user_id = #{companyUserId}
+        </if>
+        <if test="beginTime != null and beginTime != ''">
+            and filing_time &gt;= #{beginTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and filing_time &lt;= #{endTime}
+        </if>
+        order by filing_time desc
+    </select>
+
+    <select id="selectFsCompanyCustomerById" parameterType="Long" resultMap="FsCompanyCustomerResult">
+        <include refid="selectFsCompanyCustomerVo"/>
+        where id = #{id} and del_flag = '0'
+    </select>
+
+    <select id="selectFsCompanyCustomerListByCompanyUserIds" resultType="com.fs.qw.domain.FsCompanyCustomer">
+        <include refid="selectFsCompanyCustomerVo"/>
+        <where>
+            del_flag = '0'
+            <!-- 销售ID集合必传,不存在或为空时不生成任何条件(调用前必须确保有值) -->
+            <if test="companyUserIds != null and companyUserIds.size() > 0">
+                and company_user_id IN
+                <foreach collection="companyUserIds" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            <if test="customerName != null and customerName != ''">
+                and customer_name like concat('%', #{customerName}, '%')
+            </if>
+            <if test="phone != null and phone != ''">
+                and phone like concat('%', #{phone}, '%')
+            </if>
+            <if test="companyUserName != null and companyUserName != ''">
+                and company_user_name like concat('%', #{companyUserName}, '%')
+            </if>
+        </where>
+    </select>
+
+    <insert id="insertFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_company_customer
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="customerName != null">customer_name,</if>
+            <if test="sex != null">sex,</if>
+            <if test="age != null">age,</if>
+            <if test="address != null">address,</if>
+            <if test="phone != null">phone,</if>
+            <if test="filingTime != null">filing_time,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="companyUserName != null">company_user_name,</if>
+            <if test="appointmentTime != null">appointment_time,</if>
+            <if test="doctorId != null">doctor_id,</if>
+            <if test="doctorName != null">doctor_name,</if>
+            <if test="presentIllness != null">present_illness,</if>
+            <if test="currentMedication != null">current_medication,</if>
+            <if test="allergyHistory != null">allergy_history,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="remark != null">remark,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="customerName != null">#{customerName},</if>
+            <if test="sex != null">#{sex},</if>
+            <if test="age != null">#{age},</if>
+            <if test="address != null">#{address},</if>
+            <if test="phone != null">#{phone},</if>
+            <if test="filingTime != null">#{filingTime},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="companyUserName != null">#{companyUserName},</if>
+            <if test="appointmentTime != null">#{appointmentTime},</if>
+            <if test="doctorId != null">#{doctorId},</if>
+            <if test="doctorName != null">#{doctorName},</if>
+            <if test="presentIllness != null">#{presentIllness},</if>
+            <if test="currentMedication != null">#{currentMedication},</if>
+            <if test="allergyHistory != null">#{allergyHistory},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="remark != null">#{remark},</if>
+            sysdate()
+        </trim>
+    </insert>
+
+    <update id="updateFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer">
+        update fs_company_customer
+        <set>
+            <if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
+            <if test="sex != null">sex = #{sex},</if>
+            <if test="age != null">age = #{age},</if>
+            <if test="address != null">address = #{address},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="filingTime != null">filing_time = #{filingTime},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="companyUserName != null">company_user_name = #{companyUserName},</if>
+            <if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
+            <if test="doctorId != null">doctor_id = #{doctorId},</if>
+            <if test="doctorName != null">doctor_name = #{doctorName},</if>
+            <if test="presentIllness != null">present_illness = #{presentIllness},</if>
+            <if test="currentMedication != null">current_medication = #{currentMedication},</if>
+            <if test="allergyHistory != null">allergy_history = #{allergyHistory},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            update_time = sysdate()
+        </set>
+        where id = #{id}
+    </update>
+
+    <update id="deleteFsCompanyCustomerById" parameterType="Long">
+        update fs_company_customer set del_flag = '2' where id = #{id}
+    </update>
+
+    <update id="deleteFsCompanyCustomerByIds" parameterType="String">
+        update fs_company_customer set del_flag = '2' where id in
+        <foreach collection="array" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+</mapper>

+ 2 - 1
fs-user-app/src/main/java/com/fs/app/controller/PatientController.java

@@ -59,7 +59,8 @@ public class PatientController extends  AppBaseController {
             List<FsPatient> list=patientService.selectFsPatientList(map);
             for (FsPatient fsPatient : list) {
                 if (fsPatient.getMobile()!=null&&fsPatient.getMobile().length()>11&&!fsPatient.getMobile().matches("\\d+")){
-                    fsPatient.setMobile(decryptPhoneMk(fsPatient.getMobile()));
+                    //fsPatient.setMobile(decryptPhoneMk(fsPatient.getMobile()));
+                    fsPatient.setMobile(decryptPhone(fsPatient.getMobile()));//益寿缘信息采集相关直接解密不需要加*
                 }
             }
             //如果用户关联就诊人为空,就添加默认就诊人返回