Przeglądaj źródła

Merge branch 'refs/heads/master' into openIm

caoliqin 1 tydzień temu
rodzic
commit
6c87322bdf
32 zmienionych plików z 1673 dodań i 36 usunięć
  1. 54 0
      fs-admin/src/main/java/com/fs/crm/controller/ReportController.java
  2. 99 0
      fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleCategoryController.java
  3. 94 0
      fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleController.java
  4. 93 0
      fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleViewController.java
  5. 62 0
      fs-admin/src/main/java/com/fs/stats/FsStatsMemberController.java
  6. 3 0
      fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java
  7. 38 0
      fs-service/src/main/java/com/fs/crm/domain/CrmCustomerAssist.java
  8. 43 0
      fs-service/src/main/java/com/fs/crm/domain/Report.java
  9. 87 0
      fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerAssistMapper.java
  10. 7 0
      fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java
  11. 11 0
      fs-service/src/main/java/com/fs/crm/param/CrmCustomerAssistDeLParam.java
  12. 21 0
      fs-service/src/main/java/com/fs/crm/param/ReportParam.java
  13. 11 0
      fs-service/src/main/java/com/fs/crm/service/ReportService.java
  14. 70 0
      fs-service/src/main/java/com/fs/crm/service/impl/ReportServiceImpl.java
  15. 6 1
      fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java
  16. 6 0
      fs-service/src/main/java/com/fs/his/service/IFsStorePaymentService.java
  17. 124 1
      fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java
  18. 14 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStorePaymentGetWxaCodeParam.java
  19. 5 4
      fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java
  20. 141 11
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java
  21. 138 0
      fs-service/src/main/resources/application-config-bly.yml
  22. 144 0
      fs-service/src/main/resources/application-druid-bly-test.yml
  23. 144 0
      fs-service/src/main/resources/application-druid-bly.yml
  24. 8 0
      fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml
  25. 108 0
      fs-service/src/main/resources/mapper/crm/CrmCustomerAssistMapper.xml
  26. 3 1
      fs-service/src/main/resources/mapper/crm/CrmCustomerMapper.xml
  27. 36 0
      fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml
  28. 1 1
      fs-service/src/main/resources/mapper/his/FsUserMapper.xml
  29. 8 0
      fs-user-app/src/main/java/com/fs/app/controller/CompanyUserController.java
  30. 62 0
      fs-user-app/src/main/java/com/fs/app/controller/PaymentController.java
  31. 9 0
      fs-user-app/src/main/java/com/fs/app/controller/store/CompanyUserScrmController.java
  32. 23 17
      fs-user-app/src/main/java/com/fs/app/controller/store/PaymentScrmController.java

+ 54 - 0
fs-admin/src/main/java/com/fs/crm/controller/ReportController.java

@@ -0,0 +1,54 @@
+package com.fs.crm.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.model.LoginUser;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.crm.domain.Report;
+import com.fs.framework.web.service.TokenService;
+import com.fs.crm.param.ReportParam;
+import com.fs.crm.service.ReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@RestController
+@RequestMapping("/crm/report")
+public class ReportController extends BaseController {
+    @Autowired
+    private ReportService reportService;
+    @Autowired
+    private TokenService tokenService;
+    @GetMapping("/reportList")
+    public TableDataInfo getReport(ReportParam param, HttpServletRequest request)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+
+        Long userId = loginUser.getUser().getUserId();
+        param.setCompanyUserId(userId);
+        List<Report> list = reportService.getReport(param);
+        return getDataTable(list);
+    }
+    @GetMapping("/export")
+    public AjaxResult export(ReportParam param,HttpServletRequest request)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(request);
+
+        Long userId = loginUser.getUser().getUserId();
+        param.setCompanyUserId(userId);
+        List<Report> list = reportService.getReport(param);
+        if (CollectionUtils.isEmpty(list)){
+            return AjaxResult.error("请选择导出数据");
+        }
+        ExcelUtil<Report> util = new ExcelUtil<Report>(Report.class);
+        return util.exportExcel(list, "report");
+    }
+
+}

+ 99 - 0
fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleCategoryController.java

@@ -0,0 +1,99 @@
+package com.fs.his.controller;
+
+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.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.hisStore.domain.FsHomeArticleCategoryScrm;
+import com.fs.hisStore.service.IFsHomeArticleCategoryScrmService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 期刊分类Controller
+ *
+ * @author fs
+ * @date 2025-05-21
+ */
+@RestController
+@RequestMapping("/his/homeCategory")
+public class FsHomeArticleCategoryController extends BaseController {
+    @Autowired
+    private IFsHomeArticleCategoryScrmService fsHomeArticleCategoryService;
+
+    /**
+     * 查询期刊分类列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(FsHomeArticleCategoryScrm fsHomeArticleCategory) {
+        startPage();
+        List<FsHomeArticleCategoryScrm> list = fsHomeArticleCategoryService.selectFsHomeArticleCategoryList(fsHomeArticleCategory);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出期刊分类列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:export')")
+    @Log(title = "期刊分类", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsHomeArticleCategoryScrm fsHomeArticleCategory) {
+        List<FsHomeArticleCategoryScrm> list = fsHomeArticleCategoryService.selectFsHomeArticleCategoryList(fsHomeArticleCategory);
+        ExcelUtil<FsHomeArticleCategoryScrm> util = new ExcelUtil<FsHomeArticleCategoryScrm>(FsHomeArticleCategoryScrm.class);
+        return util.exportExcel(list, "homeCategory");
+    }
+
+    /**
+     * 获取期刊分类详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:query')")
+    @GetMapping(value = "/{categoryId}")
+    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId) {
+        return AjaxResult.success(fsHomeArticleCategoryService.selectFsHomeArticleCategoryById(categoryId));
+    }
+
+    /**
+     * 新增期刊分类
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:add')")
+    @Log(title = "期刊分类", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsHomeArticleCategoryScrm fsHomeArticleCategory) {
+        return toAjax(fsHomeArticleCategoryService.insertFsHomeArticleCategory(fsHomeArticleCategory));
+    }
+
+    /**
+     * 修改期刊分类
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:edit')")
+    @Log(title = "期刊分类", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsHomeArticleCategoryScrm fsHomeArticleCategory) {
+        return toAjax(fsHomeArticleCategoryService.updateFsHomeArticleCategory(fsHomeArticleCategory));
+    }
+
+    /**
+     * 删除期刊分类
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeCategory:remove')")
+    @Log(title = "期刊分类", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{categoryIds}")
+    public AjaxResult remove(@PathVariable Long[] categoryIds) {
+        return toAjax(fsHomeArticleCategoryService.deleteFsHomeArticleCategoryByIds(categoryIds));
+    }
+
+    @GetMapping("/allList")
+    public R getAllList(FsHomeArticleCategoryScrm fsHomeArticleCategory) {
+        fsHomeArticleCategory.setStatus(1);
+        List<FsHomeArticleCategoryScrm> list = fsHomeArticleCategoryService.selectFsHomeArticleCategoryList(fsHomeArticleCategory);
+        return R.ok().put("rows", list);
+    }
+
+}

+ 94 - 0
fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleController.java

@@ -0,0 +1,94 @@
+package com.fs.his.controller;
+
+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.domain.R;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.hisStore.domain.FsHomeArticleScrm;
+import com.fs.hisStore.service.IFsHomeArticleScrmService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 期刊Controller
+ *
+ * @author fs
+ * @date 2025-05-21
+ */
+@RestController
+@RequestMapping("/his/homeArticle")
+public class FsHomeArticleController extends BaseController {
+    @Autowired
+    private IFsHomeArticleScrmService fsHomeArticleService;
+
+    /**
+     * 查询期刊列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:list')")
+    @GetMapping("/list")
+    public R list(FsHomeArticleScrm fsHomeArticle)
+    {
+        PageHelper.startPage(fsHomeArticle.getPageNum(), fsHomeArticle.getPageSize());
+        List<FsHomeArticleScrm> list = fsHomeArticleService.selectFsHomeArticleList(fsHomeArticle);
+        PageInfo<FsHomeArticleScrm> listPageInfo = new PageInfo<>(list);
+        return R.ok().put("rows", listPageInfo);
+    }
+
+    /**
+     * 导出期刊列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:export')")
+    @Log(title = "期刊", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsHomeArticleScrm fsHomeArticle) {
+        List<FsHomeArticleScrm> list = fsHomeArticleService.selectFsHomeArticleList(fsHomeArticle);
+        ExcelUtil<FsHomeArticleScrm> util = new ExcelUtil<FsHomeArticleScrm>(FsHomeArticleScrm.class);
+        return util.exportExcel(list, "homArticle");
+    }
+
+    /**
+     * 获取期刊详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:query')")
+    @GetMapping(value = "/{articleId}")
+    public AjaxResult getInfo(@PathVariable("articleId") Long articleId) {
+        return AjaxResult.success(fsHomeArticleService.selectFsHomeArticleById(articleId));
+    }
+
+    /**
+     * 新增期刊
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:add')")
+    @Log(title = "期刊", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsHomeArticleScrm fsHomeArticle) {
+        return toAjax(fsHomeArticleService.insertFsHomeArticle(fsHomeArticle));
+    }
+
+    /**
+     * 修改期刊
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:edit')")
+    @Log(title = "期刊", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsHomeArticleScrm fsHomeArticle) {
+        return toAjax(fsHomeArticleService.updateFsHomeArticle(fsHomeArticle));
+    }
+
+    /**
+     * 删除期刊
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeArticle:remove')")
+    @Log(title = "期刊", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{articleIds}")
+    public AjaxResult remove(@PathVariable Long[] articleIds) {
+        return toAjax(fsHomeArticleService.deleteFsHomeArticleByIds(articleIds));
+    }
+}

+ 93 - 0
fs-admin/src/main/java/com/fs/his/controller/FsHomeArticleViewController.java

@@ -0,0 +1,93 @@
+package com.fs.his.controller;
+
+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.domain.R;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.hisStore.domain.FsHomeArticleViewScrm;
+import com.fs.hisStore.service.IFsHomeArticleViewScrmService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 期刊阅读Controller
+ *
+ * @author fs
+ * @date 2025-05-21
+ */
+@RestController
+@RequestMapping("/his/homeView")
+public class FsHomeArticleViewController extends BaseController {
+    @Autowired
+    private IFsHomeArticleViewScrmService fsHomeArticleViewService;
+
+    /**
+     * 查询期刊阅读列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:list')")
+    @GetMapping("/list")
+    public R list(FsHomeArticleViewScrm fsHomeArticleView) {
+        PageHelper.startPage(fsHomeArticleView.getPageNum(), fsHomeArticleView.getPageSize());
+        List<FsHomeArticleViewScrm> list = fsHomeArticleViewService.selectFsHomeArticleViewList(fsHomeArticleView);
+        PageInfo<FsHomeArticleViewScrm> listPageInfo = new PageInfo<>(list);
+        return R.ok().put("rows", listPageInfo);
+    }
+
+    /**
+     * 导出期刊阅读列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:export')")
+    @Log(title = "期刊阅读", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsHomeArticleViewScrm fsHomeArticleView) {
+        List<FsHomeArticleViewScrm> list = fsHomeArticleViewService.selectFsHomeArticleViewList(fsHomeArticleView);
+        ExcelUtil<FsHomeArticleViewScrm> util = new ExcelUtil<FsHomeArticleViewScrm>(FsHomeArticleViewScrm.class);
+        return util.exportExcel(list, "homeView");
+    }
+
+    /**
+     * 获取期刊阅读详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:query')")
+    @GetMapping(value = "/{viewId}")
+    public AjaxResult getInfo(@PathVariable("viewId") Long viewId) {
+        return AjaxResult.success(fsHomeArticleViewService.selectFsHomeArticleViewById(viewId));
+    }
+
+    /**
+     * 新增期刊阅读
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:add')")
+    @Log(title = "期刊阅读", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsHomeArticleViewScrm fsHomeArticleView) {
+        return toAjax(fsHomeArticleViewService.insertFsHomeArticleView(fsHomeArticleView));
+    }
+
+    /**
+     * 修改期刊阅读
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:edit')")
+    @Log(title = "期刊阅读", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsHomeArticleViewScrm fsHomeArticleView) {
+        return toAjax(fsHomeArticleViewService.updateFsHomeArticleView(fsHomeArticleView));
+    }
+
+    /**
+     * 删除期刊阅读
+     */
+    @PreAuthorize("@ss.hasPermi('store:homeView:remove')")
+    @Log(title = "期刊阅读", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{viewIds}")
+    public AjaxResult remove(@PathVariable Long[] viewIds) {
+        return toAjax(fsHomeArticleViewService.deleteFsHomeArticleViewByIds(viewIds));
+    }
+}

+ 62 - 0
fs-admin/src/main/java/com/fs/stats/FsStatsMemberController.java

@@ -0,0 +1,62 @@
+package com.fs.stats;
+
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.statis.service.IFsStatsMemberDailyService;
+import com.fs.statis.vo.FsStatsMemberDailyVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDate;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/stats/member")
+@AllArgsConstructor
+public class FsStatsMemberController {
+
+    private final IFsStatsMemberDailyService statsMemberDailyService;
+
+    @GetMapping("/dailyData")
+    public AjaxResult dailyData(@RequestParam String startDate,
+                                @RequestParam String endDate,
+                                @RequestParam Integer type,
+                                @RequestParam(required = false) Long companyId,
+                                @RequestParam(required = false) Long companyUserId,
+                                @RequestParam(required = false) Long userId,
+                                @RequestParam(required = false) String phone,
+                                @RequestParam(required = false) Long trainCampId,
+                                @RequestParam(required = false) Long periodId,
+                                @RequestParam(required = false) Long courseId,
+                                @RequestParam(required = false) Long videoId,
+                                @RequestParam(required = false, defaultValue = "1") Integer pageNum,
+                                @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("companyId", companyId);
+        params.put("companyUserId", companyUserId);
+        params.put("userId", userId);
+        params.put("phone", phone);
+        params.put("trainCampId", trainCampId);
+        params.put("periodId", periodId);
+        params.put("courseId", courseId);
+        params.put("videoId", videoId);
+
+        if (type == 1) {
+            params.put("startDate", LocalDate.parse(startDate));
+            params.put("endDate", LocalDate.parse(endDate).plusDays(1));
+        } else {
+            params.put("startDate", LocalDate.parse(startDate).withDayOfMonth(1));
+            params.put("endDate", LocalDate.parse(endDate).withDayOfMonth(1).plusMonths(1));
+        }
+
+        PageHelper.startPage(pageNum, pageSize);
+        List<FsStatsMemberDailyVO> list = statsMemberDailyService.selectDailyData(params);
+        return AjaxResult.success(new PageInfo<>(list));
+    }
+}

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

@@ -315,4 +315,7 @@ public interface CompanyUserMapper
 
     @Update("update company_user set doctor_id = null where user_id = #{userId}")
     public int unBindDoctorId(@Param("userId")Long userId);
+
+
+    List<String> selectCompanyUserNameByIdsList(@Param("companyUserIDs")List<Long> companyUserID);
 }

+ 38 - 0
fs-service/src/main/java/com/fs/crm/domain/CrmCustomerAssist.java

@@ -0,0 +1,38 @@
+package com.fs.crm.domain;
+
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 客户员工协作对象 crm_customer_assist
+ *
+ * @author fs
+ * @date 2025-05-27
+ */
+@Data
+public class CrmCustomerAssist extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** $column.columnComment */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private Long companyId;
+
+    /** 销售ID */
+    @Excel(name = "销售ID")
+    private Long companyUserId;
+
+    /** 销售名字 */
+    @Excel(name = "销售名字")
+    private String companyUserName;
+
+    /** 销售公司ID */
+    @Excel(name = "销售公司ID")
+    private Long customerId;
+
+    private Integer Rate;
+}

+ 43 - 0
fs-service/src/main/java/com/fs/crm/domain/Report.java

@@ -0,0 +1,43 @@
+package com.fs.crm.domain;
+
+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 Report {
+    //订单编号
+    @Excel(name = "订单编号")
+    private String orderSn;
+    //成单金额
+    @Excel(name = "成单金额")
+    private BigDecimal money;
+    //支付时间
+    @Excel(name = "支付时间" ,width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+    //订单状态
+    @Excel(name = "订单状态")
+    private String orderStatus;
+    //客户名称
+    @Excel(name = "客户名称")
+    private String userName;
+    //是否共享客户1是0否
+    @Excel(name = "是否共享客户")
+    private String status;
+    //共享销售
+    @Excel(name = "共享销售")
+    private String companyUserNames;
+    //分成比例
+    @Excel(name = "分成比例")
+    private BigDecimal proportion;
+    //我的业绩
+    @Excel(name = "我的业绩")
+    private BigDecimal myPerformance;
+    //客户id
+    @Excel(name = "客户id")
+    private Long customerId;
+}

+ 87 - 0
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerAssistMapper.java

@@ -0,0 +1,87 @@
+package com.fs.crm.mapper;
+
+import com.fs.crm.domain.CrmCustomerAssist;
+import com.fs.crm.param.CrmCustomerAssistDeLParam;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 客户员工协作Mapper接口
+ *
+ * @author fs
+ * @date 2025-05-27
+ */
+public interface CrmCustomerAssistMapper
+{
+    /**
+     * 查询客户员工协作
+     *
+     * @param id 客户员工协作ID
+     * @return 客户员工协作
+     */
+    public CrmCustomerAssist selectCrmCustomerAssistById(Long id);
+
+    /**
+     * 查询客户员工协作列表
+     *
+     * @param crmCustomerAssist 客户员工协作
+     * @return 客户员工协作集合
+     */
+    public List<CrmCustomerAssist> selectCrmCustomerAssistList(CrmCustomerAssist crmCustomerAssist);
+
+    /**
+     * 新增客户员工协作
+     *
+     * @param crmCustomerAssist 客户员工协作
+     * @return 结果
+     */
+    public int insertCrmCustomerAssist(CrmCustomerAssist crmCustomerAssist);
+
+    /**
+     * 修改客户员工协作
+     *
+     * @param crmCustomerAssist 客户员工协作
+     * @return 结果
+     */
+    public int updateCrmCustomerAssist(CrmCustomerAssist crmCustomerAssist);
+
+    /**
+     * 删除客户员工协作
+     *
+     * @param id 客户员工协作ID
+     * @return 结果
+     */
+    public int deleteCrmCustomerAssistById(Long id);
+
+    /**
+     * 批量删除客户员工协作
+     *
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteCrmCustomerAssistByIds(Long[] ids);
+
+    List<String> selectCompanyUserNameByCustomerId(@Param("customerId") Long customerId);
+
+    int removeByCustomer(@Param("maps") CrmCustomerAssistDeLParam param);
+
+    int deleteCrmCustomerAssistByCustomerId(Long customerId);
+
+    /**
+     * 查询当前销售协作的客户
+     * @param companyUserId
+     * @return
+     */
+    List<Long> selectCustomerIdByCompanyUserId(@Param("companyUserId") Long companyUserId);
+
+    /**
+     * 根据客户id查询销售
+     * @param customerId
+     * @return
+     */
+    List<Long> selectCompanyUserIdByCustomerId(@Param("customerId") Long customerId,@Param("createTime") Date createTime);
+
+    List<CrmCustomerAssist> selectByCustomerId(Long customerId);
+}

+ 7 - 0
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -959,4 +959,11 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
 
     List<CrmMyCustomerListQueryVO> selectCrmMyAssistListQuery(@Param("maps") CrmMyCustomerListQueryParam param);
 
+    /**
+     * 查询当前销售的客户
+     * @param companyUserId
+     * @return
+     */
+    List<Long> selectCustomerIdByCompanyUserId(@Param("companyUserId") Long companyUserId);
+
 }

+ 11 - 0
fs-service/src/main/java/com/fs/crm/param/CrmCustomerAssistDeLParam.java

@@ -0,0 +1,11 @@
+package com.fs.crm.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CrmCustomerAssistDeLParam {
+    private List<Long> customerIds;
+    private Long companyUserId;
+}

+ 21 - 0
fs-service/src/main/java/com/fs/crm/param/ReportParam.java

@@ -0,0 +1,21 @@
+package com.fs.crm.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.param.BaseQueryParam;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class ReportParam extends BaseQueryParam {
+    private Long companyId;
+    private Long companyUserId;
+    private Double money;
+    private String rechargeNo;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date payTime;
+    private String status;
+    private String orderStatus;
+    private List<Long> customerIds;
+}

+ 11 - 0
fs-service/src/main/java/com/fs/crm/service/ReportService.java

@@ -0,0 +1,11 @@
+package com.fs.crm.service;
+
+
+import com.fs.crm.domain.Report;
+import com.fs.crm.param.ReportParam;
+
+import java.util.List;
+
+public interface ReportService {
+    List<Report> getReport(ReportParam param);
+}

+ 70 - 0
fs-service/src/main/java/com/fs/crm/service/impl/ReportServiceImpl.java

@@ -0,0 +1,70 @@
+package com.fs.crm.service.impl;
+
+import com.fs.company.mapper.CompanyUserMapper;
+import com.fs.crm.domain.Report;
+import com.fs.crm.mapper.CrmCustomerAssistMapper;
+import com.fs.crm.mapper.CrmCustomerMapper;
+import com.fs.crm.service.ReportService;
+import com.fs.his.mapper.FsStoreOrderMapper;
+import com.fs.crm.param.ReportParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Service
+public class ReportServiceImpl implements ReportService {
+    @Autowired
+    private CrmCustomerMapper crmCustomerMapper;
+    @Autowired
+    private CrmCustomerAssistMapper crmCustomerAssistMapper;
+    @Autowired
+    private FsStoreOrderMapper storeOrderMapper;
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+    @Override
+    public List<Report> getReport(ReportParam param) {
+        Set<Long> mergedSet = new HashSet<>();
+
+        if (param.getCompanyUserId()!=null){
+            //查询当前销售的客户以及协作客户
+            List<Long> customerIds = Optional.ofNullable(crmCustomerMapper.selectCustomerIdByCompanyUserId(param.getCompanyUserId()))
+                    .orElse(Collections.emptyList());
+            List<Long> assistCustomerIds = Optional.ofNullable(crmCustomerAssistMapper.selectCustomerIdByCompanyUserId(param.getCompanyUserId()))
+                    .orElse(Collections.emptyList());
+            mergedSet = Stream.concat(customerIds.stream(), assistCustomerIds.stream())
+                    .collect(Collectors.toSet());
+            mergedSet.addAll(customerIds);
+            mergedSet.addAll(assistCustomerIds);
+            if (mergedSet.isEmpty()){
+                return Collections.emptyList();
+            }
+            param.setCustomerIds(new ArrayList<>(mergedSet));
+        }
+        //查询客户的订单记录
+        List<Report> reports = storeOrderMapper.selectOrderByCustomerIds(param);
+        for (Report report : reports) {
+            //查询用户下单时是否共享客户,有哪些销售共享
+            List<Long> companyUserIds = crmCustomerAssistMapper.selectCompanyUserIdByCustomerId(report.getCustomerId(), report.getPayTime());
+            if (companyUserIds.size()>0){
+                report.setStatus("1");
+                String s = companyUserMapper.selectCompanyUserNameByIdsList(companyUserIds).toString();
+                String replace = s.replace("[", "");
+                String replace1 = replace.replace("]", "");
+                report.setCompanyUserNames(replace1);
+            }
+            //计算销售的业绩
+            //分成比例
+            BigDecimal bigDecimal = new BigDecimal("100.00");
+            BigDecimal ratio = bigDecimal.divide(new BigDecimal(companyUserIds.size()), 2, RoundingMode.HALF_UP);
+            report.setProportion(ratio);
+            report.setMyPerformance(ratio.multiply(report.getMoney()).divide(bigDecimal));
+            //修改对象
+        }
+        return reports;
+    }
+}

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

@@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.fs.company.param.FsStoreStatisticsParam;
 import com.fs.company.vo.FsStoreOrderStatisticsVO;
 import com.fs.company.vo.FsStoreProductStatisticsVO;
+import com.fs.crm.domain.Report;
+import com.fs.crm.param.ReportParam;
 import com.fs.his.domain.FsInquiryOrderMsg;
 import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.domain.FsStoreOrderItem;
@@ -641,7 +643,7 @@ public interface FsStoreOrderMapper
             "</if>" +
             "</script>"})
     Long selectFsStoreOrderTotalCount(@Param("type") int type, @Param("companyId") Long companyId);
-    @Select("select order_id from fs_store_order WHERE `status`= 2 and order_type=1 and store_id in (select store_id from fs_store where delivery_type=2) and  extend_order_id is null ")
+    @Select("select order_id from fs_store_order WHERE `status`= 2 and  extend_order_id is null ")
     List<Long> selectFsStoreOrderNoCreateOms();
     @Select("select order_id from fs_store_order WHERE `status`= 2 and order_type=2 and store_id in(select store_id from fs_store where delivery_type=1) and  extend_order_id is null ")
     List<Long> selectFsStoreOrderNoTuiOrder();
@@ -1163,4 +1165,7 @@ public interface FsStoreOrderMapper
     Long selectFsStoreOrderListVOByErpAccountByExportCount(@Param("maps")FsStoreOrderParam param);
 
     List<FsStoreOrderErpExportVO> selectFsStoreOrderListErpVOByExport(@Param("maps")FsStoreOrderParam fsStoreOrder);
+
+
+    List<Report> selectOrderByCustomerIds(@Param("map") ReportParam param);
 }

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

@@ -13,6 +13,8 @@ import com.fs.his.param.PayOrderParam;
 import com.fs.his.param.WxSendRedPacketParam;
 import com.fs.his.vo.FsStorePaymentExcelVO;
 import com.fs.his.vo.FsStorePaymentVO;
+import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
+import com.fs.hisStore.param.FsStorePaymentPayParam;
 import me.chanjar.weixin.common.error.WxErrorException;
 
 import javax.servlet.http.HttpServletRequest;
@@ -114,4 +116,8 @@ public interface IFsStorePaymentService
      * @return R
      */
     R processPayment(PayOrderParam payOrderParam);
+
+    R paymentByWxaCode(FsStorePaymentPayParam payment);
+
+    R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param);
 }

+ 124 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java

@@ -5,9 +5,11 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.common.annotation.DataScope;
@@ -20,10 +22,15 @@ import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.ip.IpUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.Company;
+import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyConfigMapper;
 import com.fs.company.param.FsStoreStatisticsParam;
+import com.fs.company.service.ICompanyService;
+import com.fs.company.service.ICompanyUserService;
 import com.fs.company.vo.FsStorePaymentStatisticsVO;
 import com.fs.config.cloud.CloudHostProper;
+import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.config.CourseConfig;
@@ -48,9 +55,12 @@ import com.fs.his.param.WxSendRedPacketParam;
 import com.fs.his.service.IFsInquiryOrderService;
 import com.fs.his.service.IFsPackageOrderService;
 import com.fs.his.service.IFsStoreOrderService;
+import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.FsStorePaymentExcelVO;
 import com.fs.his.vo.FsStorePaymentVO;
+import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
+import com.fs.hisStore.param.FsStorePaymentPayParam;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
@@ -60,6 +70,8 @@ import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
+import com.fs.system.oss.CloudStorageService;
+import com.fs.system.oss.OSSFactory;
 import com.fs.system.service.ISysConfigService;
 import com.fs.tzBankPay.TzBankService.TzBankService;
 import com.fs.tzBankPay.TzBankService.TzBankServiceImpl.TzBankServiceImpl;
@@ -103,7 +115,6 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
-import com.fs.his.service.IFsStorePaymentService;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
@@ -153,6 +164,10 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
     private FsUserMapper userMapper;
     @Autowired
     private FsUserWxMapper userWxMapper;
+    @Autowired
+    private ICompanyUserService companyUserService;
+    @Autowired
+    private ICompanyService companyService;
 
     @Autowired
     private CloudHostProper cloudHostProper;
@@ -1156,4 +1171,112 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         return storePayment;
     }
 
+
+    @Override
+    public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param)  {
+        final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
+        String scene;
+        //判断销售id
+        if (param.getCompanyUserId() == null){
+            scene = "companyId="+ param.getCompanyId();
+        }else {
+            scene = "companyId="+ param.getCompanyId()+"&"+"companyUserId="+ param.getCompanyUserId();
+        }
+        byte[] file;
+        try {
+            file = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(
+                    scene,
+                    "pages_user/user/pay",
+                    true,
+                    "release",
+                    430,
+                    true,
+                    null,
+                    false);
+
+            // 上传图片到存储桶
+            String suffix = ".png";
+            CloudStorageService storage = OSSFactory.build();
+            String url;
+            try {
+                url = storage.uploadSuffix(file, suffix);
+            }  catch (Exception e) {
+                // 记录错误日志
+                logger.error("生成图片失败:{}",e.getMessage(),e);
+                return R.error("生成图片失败");
+            }
+            // 返回成功信息
+            return R.ok().put("url",url);
+
+        } catch (WxErrorException e) {
+            logger.error(e.getMessage(), e);
+            return R.error("微信接口调用失败: " + e.getMessage());
+        }
+    }
+
+
+
+    @Override
+    public R paymentByWxaCode(FsStorePaymentPayParam param) {
+        FsUser user = userMapper.selectFsUserById(param.getUserId());
+        if (user==null){
+            return R.error("用户不存在!");
+        }
+        Company company = companyService.selectCompanyById(param.getCompanyId());
+        if (company==null || company.getStatus()==0){
+            return R.error("服务商不存在,或已被停用!");
+        }
+        if(param.getPayMoney().compareTo(new BigDecimal(0.0))<1){
+            return R.error("支付金额必须大于0");
+        }
+        if (param.getCompanyUserId()!=null){
+            CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
+            if(companyUser == null || companyUser.getStatus().equals("1")){
+                return R.error("注册失败客服已停用,或不存在!");
+            }
+        }
+
+
+        //生成支付流水
+        String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
+        FsStorePayment storePayment=new FsStorePayment();
+        storePayment.setCompanyId(param.getCompanyId());
+        //判断销售是否存在
+        if (param.getCompanyUserId()!=null){
+            storePayment.setCompanyUserId(param.getCompanyUserId());
+        }
+        storePayment.setStatus(0);
+        storePayment.setPayCode(orderSn);
+        storePayment.setPayMoney(param.getPayMoney());
+        storePayment.setCreateTime(new Date());
+        storePayment.setPayTypeCode("weixin");
+        storePayment.setBusinessType(1);
+        storePayment.setRemark("商城收款订单支付");
+        storePayment.setOpenId(user.getMaOpenId());
+        storePayment.setUserId(user.getUserId());
+        fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+        //汇付支付
+        HuiFuCreateOrder o = new HuiFuCreateOrder();
+        o.setTradeType("T_MINIAPP");
+        o.setOpenid(user.getMaOpenId());
+        o.setReqSeqId("payment-"+storePayment.getPayCode());
+        o.setTransAmt(storePayment.getPayMoney().toString());
+        o.setGoodsDesc("商城订单支付");
+        HuifuCreateOrderResult result = huiFuService.createOrder(o);
+        if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+            FsStorePayment mt=new FsStorePayment();
+            mt.setPaymentId(storePayment.getPaymentId());
+            mt.setTradeNo(result.getHf_seq_id());
+            fsStorePaymentMapper.updateFsStorePayment(mt);
+            Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+            String s = (String) resultMap.get("package");
+            resultMap.put("packageValue",s);
+            return R.ok().put("result",resultMap);
+        }
+        else{
+            return R.error(result.getResp_desc());
+        }
+    }
+
 }

+ 14 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStorePaymentGetWxaCodeParam.java

@@ -0,0 +1,14 @@
+package com.fs.hisStore.param;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class FsStorePaymentGetWxaCodeParam {
+    private Long companyId;
+
+    private Long companyUserId;
+
+    private String appId;
+}

+ 5 - 4
fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java

@@ -6,10 +6,7 @@ import java.util.Map;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
-import com.fs.hisStore.param.FsStorePaymentPayParam;
-import com.fs.hisStore.param.FsStorePaymentParam;
-import com.fs.hisStore.param.FsStoreStatisticsParam;
-import com.fs.hisStore.param.WxSendRedPacketParam;
+import com.fs.hisStore.param.*;
 import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
 import com.fs.hisStore.vo.FsStorePaymentVO;
 
@@ -115,4 +112,8 @@ public interface IFsStorePaymentScrmService
     void bufaRedPacket();
 
     R sendRewardByTest(Long userId);
+
+    R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param);
+
+    R paymentByWxaCode(FsStorePaymentPayParam param);
 }

+ 141 - 11
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -1,21 +1,25 @@
 package com.fs.hisStore.service.impl;
 
+
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+
+import java.util.*;
+
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyConfigMapper;
 import com.fs.company.service.ICompanyService;
@@ -26,20 +30,26 @@ import com.fs.course.config.RedPacketConfig;
 import com.fs.course.domain.FsCourseRedPacketLog;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.service.IFsCourseRedPacketLogService;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserWx;
+import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.HttpUtil;
 import com.fs.hisStore.enums.SysConfigEnum;
+import com.fs.hisStore.param.*;
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.service.HuiFuService;
 import com.fs.pay.pay.config.PayConfig;
 import com.fs.pay.pay.dto.WxJspayDTO;
-import com.fs.hisStore.param.FsStoreStatisticsParam;
-import com.fs.hisStore.param.WxSendRedPacketParam;
 import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
+import com.fs.system.oss.CloudStorageService;
+import com.fs.system.oss.OSSFactory;
 import com.fs.system.service.ISysConfigService;
 import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.hisStore.domain.FsUserScrm;
-import com.fs.hisStore.param.FsStorePaymentPayParam;
-import com.fs.hisStore.param.FsStorePaymentParam;
 import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.vo.FsStorePaymentVO;
 import com.fs.pay.service.IPayService;
@@ -54,6 +64,8 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.TransferService;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -104,6 +116,13 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
 
     @Autowired
     private CompanyConfigMapper companyConfigMapper;
+
+    @Autowired
+    private HuiFuService huiFuService;
+
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 查询支付明细
      *
@@ -322,9 +341,9 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         storePayment.setBankTransactionId(bankTransactionId);
         fsStorePaymentMapper.updateFsStorePayment(storePayment);
         //增加佣金
-        if(storePayment.getCompanyId()!=null&&storePayment.getCompanyId()>0){
-            companyService.addCompanyPaymentMoney(storePayment);
-        }
+//        if(storePayment.getCompanyId()!=null&&storePayment.getCompanyId()>0){
+//            companyService.addCompanyPaymentMoney(storePayment);
+//        }
         return "SUCCESS";
     }
 
@@ -768,4 +787,115 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         }
         return R.ok();
         }
+
+
+    @Override
+    public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param)  {
+        final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
+        String scene;
+        //判断销售id
+        if (param.getCompanyUserId() == null){
+            scene = "companyId="+ param.getCompanyId();
+        }else {
+            scene = "companyId="+ param.getCompanyId()+"&"+"companyUserId="+ param.getCompanyUserId();
+        }
+        byte[] file;
+        try {
+            file = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(
+                    scene,
+                    "pages_user/user/pay",
+                    true,
+                    "release",
+                    430,
+                    true,
+                    null,
+                    false);
+
+            // 上传图片到存储桶
+            String suffix = ".png";
+            CloudStorageService storage = OSSFactory.build();
+            String url;
+            try {
+                url = storage.uploadSuffix(file, suffix);
+            }  catch (Exception e) {
+                // 记录错误日志
+                logger.error("生成图片失败:{}",e.getMessage(),e);
+                return R.error("生成图片失败");
+            }
+            redisCache.setCacheObject("company-wxa-code:"+param.getCompanyId(),url);
+            // 返回成功信息
+            return R.ok().put("url",url);
+
+        } catch (WxErrorException e) {
+            logger.error(e.getMessage(), e);
+            return R.error("微信接口调用失败: " + e.getMessage());
+        }
+    }
+
+
+    @Autowired
+    private IFsUserService fsUserService;
+
+    @Override
+    public R paymentByWxaCode(FsStorePaymentPayParam param) {
+        FsUser user = fsUserService.selectFsUserById(param.getUserId());
+        if (user==null){
+            return R.error("用户不存在!");
+        }
+        Company company = companyService.selectCompanyById(param.getCompanyId());
+        if (company==null || company.getStatus()==0){
+            return R.error("服务商不存在,或已被停用!");
+        }
+        if(param.getPayMoney().compareTo(new BigDecimal(0.0))<1){
+            return R.error("支付金额必须大于0");
+        }
+        if (param.getCompanyUserId()!=null){
+            CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
+            if(companyUser == null || companyUser.getStatus().equals("1")){
+                return R.error("注册失败客服已停用,或不存在!");
+            }
+        }
+
+
+        //生成支付流水
+        String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
+        FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
+        storePayment.setCompanyId(param.getCompanyId());
+        //判断销售是否存在
+        if (param.getCompanyUserId()!=null){
+            storePayment.setCompanyUserId(param.getCompanyUserId());
+        }
+        storePayment.setStatus(0);
+        storePayment.setPayCode(orderSn);
+        storePayment.setPayMoney(param.getPayMoney());
+        storePayment.setCreateTime(new Date());
+        storePayment.setPayTypeCode("weixin");
+        storePayment.setBusinessType(1);
+        storePayment.setRemark("商城收款订单支付");
+        storePayment.setOpenId(user.getMaOpenId());
+        storePayment.setUserId(user.getUserId());
+        fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+        //汇付支付
+        HuiFuCreateOrder o = new HuiFuCreateOrder();
+        o.setTradeType("T_MINIAPP");
+        o.setOpenid(user.getMaOpenId());
+        o.setReqSeqId("payment-"+storePayment.getPayCode());
+        o.setTransAmt(storePayment.getPayMoney().toString());
+        o.setGoodsDesc("商城订单支付");
+        HuifuCreateOrderResult result = huiFuService.createOrder(o);
+        if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+            FsStorePaymentScrm mt=new FsStorePaymentScrm();
+            mt.setPaymentId(storePayment.getPaymentId());
+            mt.setTradeNo(result.getHf_seq_id());
+            fsStorePaymentMapper.updateFsStorePayment(mt);
+            Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+            String s = (String) resultMap.get("package");
+            resultMap.put("packageValue",s);
+            return R.ok().put("result",resultMap);
+        }
+        else{
+            return R.error(result.getResp_desc());
+        }
+    }
 }

+ 138 - 0
fs-service/src/main/resources/application-config-bly.yml

@@ -0,0 +1,138 @@
+#配置
+fsConfig:
+  #快递鸟
+  kdnId: 1886082
+  kdnKeyId: 5a66df03-3d88-469a-ab42-23cb082b57ac
+  kdnUrl: http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx
+  kdnSubscribeUrl: https://api.kdniao.com/api/dist
+  kdnAddressUrl: https://api.kdniao.com/api/dist
+  #ERP配置
+  erpOpen: 1
+  erpAppKey: 108123
+  erpSessionKey: 9caae15474cb443ea22235e7bb86016b
+  erpSecret: 96f774dbd60847b59a16f92fd963a0c8
+  erpUrl: http://v2.api.guanyierp.com/rest/erp_open
+  erpShopCode: test
+  #ERP-hc
+  erpWdAppKey: beiliyou2-gw
+  erpWdAppsecret: 37c7cebf6e5af56c783d865b63553993
+  erpWdSid: beiliyou2
+  erpWdShopCode: ziyou123456
+  erpWdBaseUrl: https://api.wangdian.cn/openapi2/
+  erpWarehouseCode: "02"
+  #第三方支付配置
+  payOpen: 1
+  payPartnerId: 22051909542647100020
+  payKey: f256bd35aa36115d729537e1a1e01b92
+  payGateWayUrl: https://openapi.t2bank.cn/gateway.html
+  payNotifyUrl: https://api.yjf.runtzh.com/app/pay/payNotify
+  refundNotifyUrl: https://api.yjf.runtzh.com/app/pay/refundNotify
+  # 腾讯云IM
+  sdkAppId: 1400693126
+  sdkAppKey: 9afa6e63db943293680e37b3ba032e52cdb238112750806e82e58e9240604b70
+  # 处方接口Test
+  #  prescribeUrl: https://yixian-new-test.yixianmedical.com/platform-shenfang/nethosp/webservice/jsonapi
+  #  actId:  uporder
+  #  appId: 1646204278
+  #  manuId:  3981112bfcc64bf68f7744ffec7e3ca7
+  #  callbackUrl:  https://api.hospital.ifeiyu100.com/app/prescribe/presribeNotify
+  # 处方接口g
+  prescribeUrl: https://app3.nxk520.com/platform-shenfang/nethosp/webservice/jsonapi
+  actId: uporder
+  appId: 1661496555
+  manuId: 0212af1e742b41b09089afeec98f8276
+  callbackUrl: https://api.yjf.runtzh.com/app/prescribe/presribeNotify
+  commonApi: http://192.168.0.224:7011
+logging:
+  level:
+    org.springframework.web: INFO
+    com.github.binarywang.demo.wx.cp: DEBUG
+    me.chanjar.weixin: DEBUG
+wx:
+  cp:
+    corpId: wwb2a1055fb6c9a7c2
+    appConfigs:
+      - agentId: 1000002
+        secret: bhj3402rPCT0YGcosffyTO3eUMs1G2MFHMspXVBNf-c
+        token: PPKOdAlCoMO
+        aesKey: PKvaxtpSv8NGpfTDm7VUHIK8Wok2ESyYX24qpXJAdMP
+  miniapp:
+    configs:
+      - appid: wx11a2ce7c2bbc4521   #倍力优会员商城
+        secret: d680dc8ff20258b158c9355f8b7769ae
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
+      - appid: wx301ab2fad04c658a   #倍力优看课小程序
+        secret: 35018f10929b84c8c4a225de253bbcc6
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
+
+  pay:
+    appId: wx11a2ce7c2bbc4521 #微信公众号或者小程序等的appid
+    mchId: 1703311381 #微信支付商户号
+    mchKey: FotTIbIzn4AisMW7de712LJQIazSqqAl #微信支付商户密钥
+    v3Key: y5Eo99q93qzdQRAs6E2BDKIF7f3EnS3G
+    subAppId:  #服务商模式下的子商户公众账号ID
+    subMchId:  #服务商模式下的子商户号
+    keyPath: c:\\Tools\\cert\\apiclient_cert.p12 # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头)
+    notifyUrl:  https://userapp.bly.ylrztop.com/app/wxpay/wxPayNotify
+  mp:
+    useRedis: false
+    redisConfig:
+      host: 127.0.0.1
+      port: 6379
+      timeout: 2000
+    configs:
+      - appId: wx568ea6b70350c585 # 第一个公众号的appid  倍力优
+        secret: b14343e22871b1c207df5d3321e826b4 # 公众号的appsecret
+        token: PPKOdAlCoMO # 接口配置里的Token值
+        aesKey: Eswa6VjwtVMCcw03qZy6fWllgrv5aytIA1SZPEU0kU2 # 接口配置里的EncodingAESKey值
+jpush:
+  appKey: cc9a0120a3e4270c9cba340d
+  masterSecret: cfc2575d3cd7470d584c990c
+  liveTime: 1000
+  apnsProduction: true
+aifabu:  #爱链接
+  appKey: 7b471be905ab17e00f3b858c6710dd117601d008
+
+tencent_cloud_config:
+  secret_id: AKIDiMq9lDf2EOM9lIfqqfKo7FNgM5meD0sT
+  secret_key: u5SuS80342xzx8FRBukza9lVNHKNMSaB
+  bucket: beliyo-1323137866
+  app_id: 1323137866
+  region: ap-chongqing
+  proxy: beliyo
+cloud_host:
+  company_name: 倍力优
+  projectCode: BLY
+headerImg:
+  imgUrl: https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736944490230.png
+
+baidu:
+  token: 1231321232
+  back-domain: admin.muyi88.com
+watch:
+  watchUrl: watch.ylrzcloud.com/prod-api
+  #  account: tcloud
+  #  password: mdf-m2h_6yw2$hq
+  account1: ccif #866655060138751
+  password1: cp-t5or_6xw7$mt
+  account2: tcloud #rt500台
+  password2: mdf-m2h_6yw2$hq
+  account3: whr
+  password3: v9xsKuqn_$d2y
+
+fs:
+  commonApi: http://172.21.76.167:8010
+nuonuo:
+  key: 10924508
+  secret: A2EB20764D304D16
+ipad:
+  ipadUrl:
+  aiApi:
+wx_miniapp_temp:
+  pay_order_temp_id: VXEvKaGNPFuJmhWK9O_QPrTZxe9umDCukq-maI8Vdek
+  inquiry_temp_id: 9POPYeqhI48LOPvq-Rfoklze7H-9SlunJKh10Qt4_2I
+

+ 144 - 0
fs-service/src/main/resources/application-druid-bly-test.yml

@@ -0,0 +1,144 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-bly,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 127.0.0.1
+        # 端口,默认为6379
+        port: 6379
+        # 密码
+        password:
+        # 连接超时时间
+        timeout: 30s
+        lettuce:
+            pool:
+                # 连接池中的最小空闲连接
+                min-idle: 0
+                # 连接池中的最大空闲连接
+                max-idle: 8
+                # 连接池的最大数据库连接数
+                max-active: 8
+                # #连接池最大阻塞等待时间(使用负值表示没有限制)
+                max-wait: -1ms
+        database: 0
+    datasource:
+        mysql:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://113.44.133.86:3306/bly_store2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: bly@2025
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+        sop:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://113.44.133.86:3306/sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: bly@2025
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+rocketmq:
+    name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+    producer:
+        group: my-producer-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+    consumer:
+        group: test-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+openIM:
+    secret: openIM123
+    userID: imAdmin
+#是否为新商户,新商户不走mpOpenId
+isNewWxMerchant: false

+ 144 - 0
fs-service/src/main/resources/application-druid-bly.yml

@@ -0,0 +1,144 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-bly,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 192.168.0.224
+        # 端口,默认为6379
+        port: 6379
+        # 密码
+        password:
+        # 连接超时时间
+        timeout: 30s
+        lettuce:
+            pool:
+                # 连接池中的最小空闲连接
+                min-idle: 0
+                # 连接池中的最大空闲连接
+                max-idle: 8
+                # 连接池的最大数据库连接数
+                max-active: 8
+                # #连接池最大阻塞等待时间(使用负值表示没有限制)
+                max-wait: -1ms
+        database: 0
+    datasource:
+        mysql:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://192.168.0.224:3306/bly_store?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: bly@2025
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+        sop:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://192.168.0.224:3306/sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: bly@2025
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+rocketmq:
+    name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+    producer:
+        group: my-producer-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+    consumer:
+        group: test-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+openIM:
+    secret: openIM123
+    userID: imAdmin
+#是否为新商户,新商户不走mpOpenId
+isNewWxMerchant: false

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

@@ -565,4 +565,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{userId}
         </foreach>
     </update>
+
+    <select id="selectCompanyUserNameByIdsList" resultType="java.lang.String">
+        SELECT nick_name from company_user where user_id in
+        <foreach collection="companyUserIDs" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
+
 </mapper>

+ 108 - 0
fs-service/src/main/resources/mapper/crm/CrmCustomerAssistMapper.xml

@@ -0,0 +1,108 @@
+<?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.crm.mapper.CrmCustomerAssistMapper">
+
+    <resultMap type="CrmCustomerAssist" id="CrmCustomerAssistResult">
+        <result property="id"    column="id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="companyUserName"    column="company_user_name"    />
+        <result property="customerId"    column="customer_id"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="rate"    column="rate"    />
+    </resultMap>
+
+    <sql id="selectCrmCustomerAssistVo">
+        select id, company_id, company_user_id,company_user_name, customer_id, create_time,rate from crm_customer_assist
+    </sql>
+
+    <select id="selectCrmCustomerAssistList" parameterType="CrmCustomerAssist" resultMap="CrmCustomerAssistResult">
+        <include refid="selectCrmCustomerAssistVo"/>
+        <where>
+            <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="companyUserName != null and companyUserName != ''"> and company_user_name = #{companyUserName}</if>
+            <if test="customerId != null "> and customer_id = #{customerId}</if>
+        </where>
+    </select>
+
+    <select id="selectCrmCustomerAssistById" parameterType="Long" resultMap="CrmCustomerAssistResult">
+        <include refid="selectCrmCustomerAssistVo"/>
+        where id = #{id}
+    </select>
+    <select id="selectCompanyUserNameByCustomerId" resultType="java.lang.String">
+        select  CONCAT(company_user_name, '(', company_user_id, ')','分佣:',rate,'%') AS assistUser
+        from crm_customer_assist
+        where customer_id = #{customerId}
+    </select>
+    <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
+        SELECT customer_id FROM crm_customer_assist where company_user_id = #{companyUserId}
+    </select>
+    <select id="selectCompanyUserIdByCustomerId" resultType="java.lang.Long">
+        select company_user_id from crm_customer_assist where customer_id = #{customerId} and create_time &lt; #{createTime}
+    </select>
+    <select id="selectByCustomerId" resultType="com.fs.crm.domain.CrmCustomerAssist">
+        <include refid="selectCrmCustomerAssistVo"/>
+        where  customer_id = #{customerId}
+
+    </select>
+
+    <insert id="insertCrmCustomerAssist" parameterType="CrmCustomerAssist" useGeneratedKeys="true" keyProperty="id">
+        insert into crm_customer_assist
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">company_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="companyUserName != null">company_user_name,</if>
+            <if test="customerId != null">customer_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="rate != null">rate,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">#{companyId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="companyUserName != null">#{companyUserName},</if>
+            <if test="customerId != null">#{customerId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="rate != null">#{rate},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCrmCustomerAssist" parameterType="CrmCustomerAssist">
+        update crm_customer_assist
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="companyUserName != null">company_user_name = #{companyUserName},</if>
+            <if test="customerId != null">customer_id = #{customerId},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="rate != null">rate = #{rate},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteCrmCustomerAssistById" parameterType="Long">
+        delete from crm_customer_assist where id = #{id}
+    </delete>
+
+    <delete id="deleteCrmCustomerAssistByIds" parameterType="String">
+        delete from crm_customer_assist where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    <delete id="removeByCustomer">
+        delete from crm_customer_assist where customer_id in
+        <foreach collection="maps.customerIds" item="customerId" open="(" separator="," close=")">
+            #{customerId}
+        </foreach>
+        <if test="maps.companyUserId != null">
+            and company_user_id = #{maps.companyUserId}
+        </if>
+    </delete>
+    <delete id="deleteCrmCustomerAssistByCustomerId">
+        delete from crm_customer_assist where customer_id = #{customerId}
+    </delete>
+
+</mapper>

+ 3 - 1
fs-service/src/main/resources/mapper/crm/CrmCustomerMapper.xml

@@ -362,7 +362,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY t.type
     </select>
 
-
+    <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
+        SELECT customer_id FROM crm_customer_assist where company_user_id = #{companyUserId}
+    </select>
 
     <select id="selectCrmMyAssistListQuery" resultType="com.fs.crm.vo.CrmMyCustomerListQueryVO">
         select cu.*,c.create_time as customer_create_time,c.visit_status,c.remark,c.register_desc,c.register_submit_time,

+ 36 - 0
fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml

@@ -1599,4 +1599,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     </select>
+
+
+    <select id="selectOrderByCustomerIds" resultType="com.fs.crm.domain.Report">
+        SELECT
+        order_code AS orderSn,
+        real_name AS userName,
+        pay_price AS money,
+        pay_time AS payTime,
+        status AS orderStatus,
+        customer_id AS customerId
+        FROM
+        fs_store_order
+        WHERE
+        <choose>
+            <when test="map.orderStatus != null and map.orderStatus != ''">
+                status = #{map.orderStatus}
+            </when>
+            <otherwise>
+                status &gt;= 2
+            </otherwise>
+        </choose>
+        <if test="map.companyId != null and map.companyId!=''">
+            AND company_id = #{map.companyId}
+        </if>
+        <if test="map.customerIds!=null and map.customerIds.size() > 0">
+            AND customer_id IN
+            <foreach collection="map.customerIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="map.payTime!=null">
+            AND pay_time &gt;= STR_TO_DATE(#{map.payTime}, '%Y-%m-%d')
+            AND pay_time &lt; DATE_ADD(STR_TO_DATE(#{map.payTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
+        </if>
+    </select>
+
 </mapper>

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

@@ -1917,7 +1917,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
             count( DISTINCT fs_user.user_id ) as userNum,
             count( DISTINCT CASE WHEN to_days( fs_user.create_time ) = to_days( now()) THEN fs_user.user_id END ) as newUserNum,
-            fs_user.company_id
+            fs_user_company_user.company_id
         FROM
             fs_user
                 LEFT JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id

+ 8 - 0
fs-user-app/src/main/java/com/fs/app/controller/CompanyUserController.java

@@ -187,4 +187,12 @@ public class CompanyUserController extends  AppBaseController {
         return companyUserService.unBindDoctor(userId);
     }
 
+    @ApiOperation("获取公司收款码")
+    @GetMapping("/getCompanyWxaCodeByPayment")
+    public R getCompanyWxaCodeByPayment(@RequestParam("companyId")Long companyId,HttpServletRequest request){
+        //获取用户码
+        String WxaCode = redisCache.getCacheObject("company-wxa-code:"+companyId);
+        return R.ok().put("data",WxaCode);
+    }
+
 }

+ 62 - 0
fs-user-app/src/main/java/com/fs/app/controller/PaymentController.java

@@ -0,0 +1,62 @@
+package com.fs.app.controller;
+
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import com.fs.app.annotation.Login;
+import com.fs.common.annotation.RepeatSubmit;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.utils.IpUtil;
+import com.fs.core.config.WxMaConfiguration;
+import com.fs.his.service.IFsStorePaymentService;
+import com.fs.hisStore.domain.FsUserScrm;
+import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
+import com.fs.hisStore.param.FsStorePaymentPayParam;
+import com.fs.hisStore.service.IFsStorePaymentScrmService;
+import com.fs.hisStore.service.IFsUserScrmService;
+import com.fs.wx.miniapp.config.WxMaProperties;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Api("支付接口")
+@RestController
+@RequestMapping("/app/payment")
+public class PaymentController extends AppBaseController {
+    @Autowired
+    private WxMaProperties properties;
+    protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
+
+    @Autowired
+    private IFsStorePaymentService paymentService;
+
+
+    @Login
+    @ApiOperation("收款订单支付")
+    @PostMapping("/paymentByWxaCode")
+    @RepeatSubmit
+    public R paymentByWxaCode(@Validated @RequestBody FsStorePaymentPayParam payment)
+    {
+        payment.setUserId(Long.parseLong(getUserId()));
+        return paymentService.paymentByWxaCode(payment);
+    }
+
+    @ApiOperation("生成收款页面小程序码")
+    @GetMapping("/getWxaCodeByPayment")
+    public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param)
+    {
+        return paymentService.getWxaCodeByPayment(param);
+    }
+
+
+
+
+}

+ 9 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/CompanyUserScrmController.java

@@ -11,6 +11,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.sign.Md5Utils;
+import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.domain.CompanyUserCard;
 import com.fs.company.param.CompanyUserLoginParam;
@@ -173,6 +174,14 @@ public class CompanyUserScrmController extends AppBaseController {
         }
     }
 
+    @ApiOperation("获取公司收款码")
+    @GetMapping("/getCompanyWxaCodeByPayment")
+    public R getCompanyWxaCodeByPayment(@RequestParam("companyId")Long companyId,HttpServletRequest request){
+        //获取用户码
+        String WxaCode = redisCache.getCacheObject("company-wxa-code:"+companyId);
+        return R.ok().put("data",WxaCode);
+    }
+
 
 
 }

+ 23 - 17
fs-user-app/src/main/java/com/fs/app/controller/store/PaymentController.java → fs-user-app/src/main/java/com/fs/app/controller/store/PaymentScrmController.java

@@ -3,6 +3,7 @@ package com.fs.app.controller.store;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.controller.BaseController;
@@ -10,6 +11,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.utils.IpUtil;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.hisStore.domain.FsUserScrm;
+import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
 import com.fs.hisStore.param.FsStorePaymentPayParam;
 import com.fs.hisStore.service.IFsStorePaymentScrmService;
 import com.fs.hisStore.service.IFsUserScrmService;
@@ -21,18 +23,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Date;
 
 @Api("支付接口")
 @RestController
 @RequestMapping("/store/app/payment")
-public class PaymentController extends AppBaseController {
+public class PaymentScrmController extends AppBaseController {
     @Autowired
     private WxMaProperties properties;
     protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
@@ -41,6 +39,7 @@ public class PaymentController extends AppBaseController {
     private IFsStorePaymentScrmService paymentService;
     @Autowired
     private IFsUserScrmService userService;
+
     @ApiOperation("支付")
     @PostMapping("/payment")
     @RepeatSubmit
@@ -51,17 +50,7 @@ public class PaymentController extends AppBaseController {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(payment.getCode());
             FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
             if(user==null){
-                //创建
-                user=new FsUserScrm();
-                user.setUsername("");
-                user.setNickname("微信用户");
-                user.setStatus(1);
-                user.setMaOpenId(session.getOpenid());
-                user.setUnionId(session.getUnionid());
-                user.setIsWeixinAuth(0);
-                user.setLastIp(ip);
-                user.setCreateTime(new Date());
-                userService.insertFsUser(user);
+                return R.error("用户不存在,返回主页授权登录!");
             }
             payment.setUserId(user.getUserId());
             return paymentService.payment(payment);
@@ -74,6 +63,23 @@ public class PaymentController extends AppBaseController {
 
     }
 
+    @Login
+    @ApiOperation("收款订单支付")
+    @PostMapping("/paymentByWxaCode")
+    @RepeatSubmit
+    public R paymentByWxaCode(@Validated @RequestBody FsStorePaymentPayParam payment)
+    {
+        payment.setUserId(Long.parseLong(getUserId()));
+        return paymentService.paymentByWxaCode(payment);
+    }
+
+    @ApiOperation("生成收款页面小程序码")
+    @GetMapping("/getWxaCodeByPayment")
+    public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param)
+    {
+        return paymentService.getWxaCodeByPayment(param);
+    }
+