Explorar o código

后台制单是否需要付款,客户协作

ct hai 2 días
pai
achega
ef3de95adb
Modificáronse 18 ficheiros con 366 adicións e 63 borrados
  1. 10 0
      fs-company/src/main/java/com/fs/company/controller/CompanyController.java
  2. 28 5
      fs-company/src/main/java/com/fs/crm/controller/CrmCustomerAssistController.java
  3. 5 1
      fs-company/src/main/java/com/fs/crm/controller/CrmCustomerController.java
  4. 11 0
      fs-service-system/src/main/java/com/fs/company/domain/Company.java
  5. 10 0
      fs-service-system/src/main/java/com/fs/company/param/CompanyConfigParam.java
  6. 3 0
      fs-service-system/src/main/java/com/fs/company/service/ICompanyService.java
  7. 15 0
      fs-service-system/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  8. 2 0
      fs-service-system/src/main/java/com/fs/crm/domain/CrmCustomerAssist.java
  9. 2 0
      fs-service-system/src/main/java/com/fs/crm/mapper/CrmCustomerAssistMapper.java
  10. 10 0
      fs-service-system/src/main/java/com/fs/crm/param/CrmCustomerAssistOperationParam.java
  11. 11 0
      fs-service-system/src/main/java/com/fs/crm/service/ICrmCustomerAssistService.java
  12. 0 3
      fs-service-system/src/main/java/com/fs/crm/service/ICrmCustomerService.java
  13. 212 1
      fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerAssistServiceImpl.java
  14. 0 51
      fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java
  15. 12 0
      fs-service-system/src/main/java/com/fs/crm/vo/CrmCustomerAssistVo.java
  16. 20 0
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java
  17. 4 0
      fs-service-system/src/main/resources/mapper/company/CompanyMapper.xml
  18. 11 2
      fs-service-system/src/main/resources/mapper/crm/CrmCustomerAssistMapper.xml

+ 10 - 0
fs-company/src/main/java/com/fs/company/controller/CompanyController.java

@@ -7,6 +7,7 @@ import com.fs.common.utils.ServletUtils;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanySms;
 import com.fs.company.domain.CompanyVoice;
+import com.fs.company.param.CompanyConfigParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanySmsService;
@@ -115,4 +116,13 @@ public class CompanyController extends BaseController
         return R.ok();
     }
 
+    @ApiOperation("其他配置")
+    @PostMapping(value = "/config")
+    public R configUserCheck(@RequestBody CompanyConfigParam param) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompany(loginUser.getCompany());
+        companyService.config(param);
+        return R.ok();
+    }
+
 }

+ 28 - 5
fs-company/src/main/java/com/fs/crm/controller/CrmCustomerAssistController.java

@@ -2,7 +2,12 @@ package com.fs.crm.controller;
 
 import java.util.List;
 
+import com.fs.common.core.domain.R;
+import com.fs.common.utils.ServletUtils;
+import com.fs.core.security.LoginUser;
+import com.fs.core.web.service.TokenService;
 import com.fs.crm.param.CrmCustomerAssistDeLParam;
+import com.fs.crm.param.CrmCustomerAssistOperationParam;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -32,6 +37,8 @@ import com.fs.common.core.page.TableDataInfo;
 @RequestMapping("/crm/assist")
 public class CrmCustomerAssistController extends BaseController
 {
+    @Autowired
+    private TokenService tokenService;
     @Autowired
     private ICrmCustomerAssistService crmCustomerAssistService;
 
@@ -71,14 +78,17 @@ public class CrmCustomerAssistController extends BaseController
     }
 
     /**
-     * 新增客户员工协作
+     * 批量新增或修改客户员工协作
      */
     @PreAuthorize("@ss.hasPermi('crm:assist:add')")
-    @Log(title = "客户员工协作", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody CrmCustomerAssist crmCustomerAssist)
+    @Log(title = "客户员工协作", businessType = BusinessType.UPDATE)
+    @PostMapping("/allOperation")
+    public AjaxResult allOperation(@RequestBody List<CrmCustomerAssistOperationParam> params)
     {
-        return toAjax(crmCustomerAssistService.insertCrmCustomerAssist(crmCustomerAssist));
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        Long companyUserId = loginUser.getUser().getUserId();
+        return toAjax(crmCustomerAssistService.allOperation(params,companyId,companyUserId));
     }
 
     /**
@@ -112,4 +122,17 @@ public class CrmCustomerAssistController extends BaseController
     {
         return toAjax(crmCustomerAssistService.deleteCrmCustomerAssistByIds(ids));
     }
+
+    /**
+     * 批量查询
+     */
+    @PostMapping("/selectByCustomerIds")
+    public R selectByCustomerIds(@RequestBody List<Long> customerIds)
+    {
+        if (customerIds!=null && customerIds.size()>10) {
+            return R.error("手动分佣每次仅支持10个客户以内的分配");
+        }
+        return R.ok().put("data",crmCustomerAssistService.selectByCustomerIds(customerIds));
+    }
+
 }

+ 5 - 1
fs-company/src/main/java/com/fs/crm/controller/CrmCustomerController.java

@@ -18,8 +18,10 @@ import com.fs.core.security.LoginUser;
 import com.fs.core.web.service.TokenService;
 import com.fs.crm.domain.CrmCustomer;
 import com.fs.crm.param.*;
+import com.fs.crm.service.ICrmCustomerAssistService;
 import com.fs.crm.service.ICrmCustomerService;
 import com.fs.crm.service.ICrmCustomerUserService;
+import com.fs.crm.service.impl.CrmCustomerAssistServiceImpl;
 import com.fs.crm.vo.*;
 import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.ApiOperation;
@@ -52,6 +54,8 @@ public class CrmCustomerController extends BaseController
     private TokenService tokenService;
     @Autowired
     ICrmCustomerUserService crmCustomerUserService;
+    @Autowired
+    private ICrmCustomerAssistService crmCustomerAssistService;
 
     @ApiOperation("获取线索客户")
     @PreAuthorize("@ss.hasPermi('crm:customer:lineList')")
@@ -245,7 +249,7 @@ public class CrmCustomerController extends BaseController
         }
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
-        return crmCustomerService.assistToUser(loginUser.getUsername(),loginUser.getUser().getUserId(),param);
+        return crmCustomerAssistService.assistToUser(loginUser.getUsername(),loginUser.getUser().getUserId(),param);
     }
 
 

+ 11 - 0
fs-service-system/src/main/java/com/fs/company/domain/Company.java

@@ -94,6 +94,9 @@ public class Company extends BaseEntity
     /** 会员是否默认黑名单,1-是;0-否(用于销售分享成为会员的操作) */
     private Integer fsUserIsDefaultBlack;
 
+    /** 后台制单是否需要付款 默认1 0-否 1-是*/
+    private Integer isPay;
+
     public String getOmsCode() {
         return omsCode;
     }
@@ -314,4 +317,12 @@ public class Company extends BaseEntity
     public void setRules(List<String> rules) {
         this.rules = rules;
     }
+
+    public Integer getIsPay() {
+        return isPay;
+    }
+
+    public void setIsPay(Integer isPay) {
+        this.isPay = isPay;
+    }
 }

+ 10 - 0
fs-service-system/src/main/java/com/fs/company/param/CompanyConfigParam.java

@@ -0,0 +1,10 @@
+package com.fs.company.param;
+
+import com.fs.company.domain.Company;
+import lombok.Data;
+
+@Data
+public class CompanyConfigParam {
+    private Company company;
+    private Integer isPay;
+}

+ 3 - 0
fs-service-system/src/main/java/com/fs/company/service/ICompanyService.java

@@ -2,6 +2,7 @@ package com.fs.company.service;
 
 import com.fs.common.core.domain.R;
 import com.fs.company.domain.Company;
+import com.fs.company.param.CompanyConfigParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.vo.*;
 import com.fs.his.vo.OptionsVO;
@@ -123,5 +124,7 @@ public interface ICompanyService
      */
     List<DeptDataVO> getDeptData(Long companyId);
 
+    int config(CompanyConfigParam param);
+
     void addRedPacketCompanyMoney(BigDecimal money, Long companyId);
 }

+ 15 - 0
fs-service-system/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -5,6 +5,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.*;
+import com.fs.company.param.CompanyConfigParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.vo.CompanyCrmVO;
@@ -21,6 +22,7 @@ import com.fs.system.service.ISysConfigService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -538,6 +540,19 @@ public class CompanyServiceImpl implements ICompanyService
 
         return result.stream().filter(e -> CollectionUtils.isNotEmpty(e.getChildren())).collect(Collectors.toList());
     }
+
+    @Override
+    public int config(CompanyConfigParam param) {
+        if (param.getCompany() != null){
+            Company company = new Company();
+            company.setCompanyId(param.getCompany().getCompanyId());
+            company.setIsPay(param.getIsPay());
+            return companyMapper.updateCompany(company);
+        } else {
+            return 0;
+        }
+    }
+
     /**
      * 构建公司节点,包含其下属部门和用户
      * @param company 公司对象

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

@@ -33,4 +33,6 @@ public class CrmCustomerAssist extends BaseEntity
     /** 销售公司ID */
     @Excel(name = "销售公司ID")
     private Long customerId;
+
+    private Integer Rate;
 }

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

@@ -81,4 +81,6 @@ public interface CrmCustomerAssistMapper
      * @return
      */
     List<Long> selectCompanyUserIdByCustomerId(@Param("customerId") Long customerId,@Param("createTime") Date createTime);
+
+    List<CrmCustomerAssist> selectByCustomerId(Long customerId);
 }

+ 10 - 0
fs-service-system/src/main/java/com/fs/crm/param/CrmCustomerAssistOperationParam.java

@@ -0,0 +1,10 @@
+package com.fs.crm.param;
+
+import com.fs.crm.domain.CrmCustomerAssist;
+import lombok.Data;
+
+
+@Data
+public class CrmCustomerAssistOperationParam extends CrmCustomerAssist {
+    private String operation;
+}

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

@@ -1,8 +1,13 @@
 package com.fs.crm.service;
 
 import java.util.List;
+
+import com.fs.common.core.domain.R;
 import com.fs.crm.domain.CrmCustomerAssist;
+import com.fs.crm.param.CrmCustomeAssignParam;
 import com.fs.crm.param.CrmCustomerAssistDeLParam;
+import com.fs.crm.param.CrmCustomerAssistOperationParam;
+import com.fs.crm.vo.CrmCustomerAssistVo;
 
 /**
  * 客户员工协作Service接口
@@ -61,4 +66,10 @@ public interface ICrmCustomerAssistService
     public int deleteCrmCustomerAssistById(Long id);
 
     int removeByCustomer(CrmCustomerAssistDeLParam param);
+
+    R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param);
+
+    List<CrmCustomerAssistVo> selectByCustomerIds(List<Long> customerIds);
+
+    int allOperation(List<CrmCustomerAssistOperationParam> params,Long companyId,Long companyUserId);
 }

+ 0 - 3
fs-service-system/src/main/java/com/fs/crm/service/ICrmCustomerService.java

@@ -117,9 +117,6 @@ public interface ICrmCustomerService
 
     R assignCompanys(CrmCompanyAssignParam param, String operUserName,Long operUserId);
 
-    R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param);
-
-
     int updateCrmCustomerSource(CrmCustomerEditSourceParam param);
 
     List<CrmCustomer> selectCrmCustomerListByIds(String customerIds);

+ 212 - 1
fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerAssistServiceImpl.java

@@ -1,13 +1,36 @@
 package com.fs.crm.service.impl;
 
-import java.util.List;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import cn.jiguang.common.resp.APIConnectionException;
+import cn.jiguang.common.resp.APIRequestException;
+import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.StringUtils;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyUserMapper;
+import com.fs.crm.domain.CrmCustomer;
+import com.fs.crm.domain.CrmCustomerLogs;
+import com.fs.crm.domain.CrmCustomerUser;
+import com.fs.crm.dto.CrmCustomerAssignUserDTO;
+import com.fs.crm.enums.CustomerLogEnum;
+import com.fs.crm.mapper.CrmCustomerLogsMapper;
+import com.fs.crm.mapper.CrmCustomerMapper;
+import com.fs.crm.mapper.CrmCustomerUserMapper;
+import com.fs.crm.param.CrmCustomeAssignParam;
 import com.fs.crm.param.CrmCustomerAssistDeLParam;
+import com.fs.crm.param.CrmCustomerAssistOperationParam;
+import com.fs.crm.vo.CrmCustomerAssistVo;
+import com.fs.jpush.service.JpushService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.crm.mapper.CrmCustomerAssistMapper;
 import com.fs.crm.domain.CrmCustomerAssist;
 import com.fs.crm.service.ICrmCustomerAssistService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 客户员工协作Service业务层处理
@@ -20,6 +43,16 @@ public class CrmCustomerAssistServiceImpl implements ICrmCustomerAssistService
 {
     @Autowired
     private CrmCustomerAssistMapper crmCustomerAssistMapper;
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+    @Autowired
+    private CrmCustomerMapper crmCustomerMapper;
+    @Autowired
+    private CrmCustomerUserMapper crmCustomerUserMapper;
+    @Autowired
+    private CrmCustomerLogsMapper logsMapper;
+    @Autowired
+    private JpushService jpushService;
 
     /**
      * 查询客户员工协作
@@ -95,10 +128,188 @@ public class CrmCustomerAssistServiceImpl implements ICrmCustomerAssistService
     }
 
     @Override
+    @Transactional
     public int removeByCustomer(CrmCustomerAssistDeLParam param) {
         if (param.getCustomerIds() == null || param.getCustomerIds().isEmpty()) {
             return 0;
         }
+        //计算分佣
+        delComputeRate(param);
         return crmCustomerAssistMapper.removeByCustomer(param);
     }
+
+    /**
+     *  删除协作人分配佣金
+     * @param param
+     */
+    private void delComputeRate(CrmCustomerAssistDeLParam param) {
+        List<Long> customerIds = param.getCustomerIds();
+        Long companyUserId = param.getCompanyUserId();
+        customerIds.forEach(customerId -> {
+            List<CrmCustomerAssist> assistList = crmCustomerAssistMapper.selectByCustomerId(customerId);
+            if (assistList != null && !assistList.isEmpty()) {
+                int i = assistList.size() - 1; //-1因为需要删除一个协作者
+                if (i>0){
+                    //+1因为还有原所属人
+                    int rate = BigDecimal.valueOf(100).divide(BigDecimal.valueOf(i+1), 2, BigDecimal.ROUND_HALF_UP).intValue();
+                    int num = 0;
+                    for (int t = 0; t < i + 1; t++) {
+                        num += rate;
+                    }
+                    int specialRate;
+                    if (num > 100) {
+                        //如果小于100 那就是原所属人分配多的佣金
+                        specialRate = rate-(num - 100);
+                    } else {
+                        specialRate = 0;
+                    }
+                    int index = 0;
+                    List<CrmCustomerAssist> newAssistList = assistList.stream().filter(temp -> !Objects.equals(temp.getCompanyUserId(), companyUserId)).collect(Collectors.toList());
+                    for (CrmCustomerAssist crmCustomerAssist : newAssistList) {
+                        //更新
+                        if (specialRate > 0 && index == newAssistList.size()-1){
+                            crmCustomerAssist.setRate(specialRate);
+                        }else {
+                            crmCustomerAssist.setRate(rate);
+                        }
+                        crmCustomerAssistMapper.updateCrmCustomerAssist(crmCustomerAssist);
+                        index++;
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     *  添加协作人分配佣金
+     * @param param
+     */
+    private Integer addComputeRate(CrmCustomerAssist param) {
+        Long customerId = param.getCustomerId();
+        List<CrmCustomerAssist> assistList = crmCustomerAssistMapper.selectByCustomerId(customerId);
+        if (assistList != null) {
+            int i = assistList.size() + 2; //+2因为还有原所属人和添加协作者
+            int rate = BigDecimal.valueOf(100).divide(BigDecimal.valueOf(i), 2, BigDecimal.ROUND_HALF_UP).intValue();
+            int num = 0;
+            for (int t = 0; t < i ; t++) {
+                num += rate;
+            }
+            int specialRate;
+            if (num > 100) {
+                specialRate = rate-(num - 100);
+            } else {
+                //如果小于100 那就是原所属人分配多的佣金
+                specialRate = 0;
+            }
+            for (CrmCustomerAssist crmCustomerAssist : assistList) {
+                //更新
+                crmCustomerAssist.setRate(rate);
+                crmCustomerAssistMapper.updateCrmCustomerAssist(crmCustomerAssist);
+            }
+            if (specialRate > 0){
+                return specialRate;
+            } else {
+                return rate;
+            }
+        }
+        return 50;
+    }
+
+    @Override
+    @Transactional
+    public R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param) {
+        Integer index = 0;
+        for (CrmCustomerAssignUserDTO userDTO : param.getUsers()) {
+            CompanyUser companyUser = companyUserMapper.selectCompanyUserById(userDTO.getCompanyUserId());
+            for (int i = 0; i < userDTO.getCount(); i++) {
+                CrmCustomer customer = crmCustomerMapper.selectCrmCustomerById(param.getCustomerIds().get(index));
+                //不能选择客户拥有者本人
+                CrmCustomerUser crmCustomerUser = crmCustomerUserMapper.selectCrmCustomerUserById(customer.getCustomerUserId());
+                if (Objects.equals(crmCustomerUser.getCompanyUserId(), userDTO.getCompanyUserId())) {
+                    return R.error("不能选择自己来协作!");
+                }
+                //查询协作客户
+                CrmCustomerAssist customerAssist = new CrmCustomerAssist();
+                customerAssist.setCustomerId(customer.getCustomerId());
+                customerAssist.setCompanyUserId(userDTO.getCompanyUserId());
+                List<CrmCustomerAssist> tempList = crmCustomerAssistMapper.selectCrmCustomerAssistList(customerAssist);
+                if (tempList != null && !tempList.isEmpty()) {
+                    return R.error("销售:" + companyUser.getNickName() + "(" + userDTO.getCompanyUserId() + ")已拥有改该协作客户:" + customer.getCustomerName());
+                }
+                customerAssist.setCompanyId(param.getCompanyId());
+                customerAssist.setCompanyUserName(companyUser.getNickName());
+                customerAssist.setCreateTime(new Date());
+                //分配佣金
+                Integer rate = addComputeRate(customerAssist);
+                customerAssist.setRate(rate);
+                crmCustomerAssistMapper.insertCrmCustomerAssist(customerAssist);
+                //写日志
+                CrmCustomerLogs logs = new CrmCustomerLogs();
+                logs.setCustomerId(customer.getCustomerId());
+                logs.setCreateTime(new Date());
+                logs.setLogsType(CustomerLogEnum.ASSIST_USER.getValue());
+                logs.setTitle(CustomerLogEnum.ASSIST_USER.getDesc());
+                logs.setRemark(opeUserName + "为客户" + customer.getCustomerName() + "添加协作人:" + companyUser.getNickName());
+                logs.setCompanyUserId(userDTO.getCompanyUserId());
+                logsMapper.insertCrmCustomerLogs(logs);
+
+                if (StringUtils.isNotEmpty(companyUser.getJpushId())) {
+                    Map<String, String> extrasMap = new HashMap<>();
+                    extrasMap.put("customerId", customer.getCustomerId().toString());
+                    extrasMap.put("type", "1");
+                    try {
+                        jpushService.sendRegisterIdPush("客户消息", "您收到 一个客户协作邀请", extrasMap, companyUser.getJpushId());
+                    } catch (APIConnectionException e) {
+                    } catch (APIRequestException e) {
+                    }
+                }
+                index++;
+            }
+        }
+        return R.ok();
+    }
+
+    @Override
+    public List<CrmCustomerAssistVo> selectByCustomerIds(List<Long> customerIds) {
+        if (customerIds != null && !customerIds.isEmpty()) {
+            //如果超过10个建议用多线程
+            ArrayList<CrmCustomerAssistVo> vos = new ArrayList<>(customerIds.size());
+            customerIds.forEach(customerId->{
+                CrmCustomerAssistVo vo = new CrmCustomerAssistVo();
+                List<CrmCustomerAssist> assists = crmCustomerAssistMapper.selectByCustomerId(customerId);
+                vo.setCustomerId(customerId);
+                vo.setAssistList(assists);
+                vos.add(vo);
+            });
+            return vos;
+        }
+        return null;
+    }
+
+    @Override
+    public int allOperation(List<CrmCustomerAssistOperationParam> params,Long companyId,Long companyUserId) {
+        AtomicInteger count = new AtomicInteger();
+        params.forEach(param->{
+            String operation = param.getOperation();
+            switch (operation){
+                case "ADD":
+                    if (!Objects.equals(companyUserId, param.getCompanyUserId())){
+                        param.setCompanyId(companyId);
+                        crmCustomerAssistMapper.insertCrmCustomerAssist(param);
+                    }
+                    break;
+                case "DELETE":
+                    crmCustomerAssistMapper.deleteCrmCustomerAssistById(param.getId());
+                    break;
+                case "UPDATE":
+                    param.setCompanyId(companyId);
+                    crmCustomerAssistMapper.updateCrmCustomerAssist(param);
+                    break;
+                default:
+                    break;
+            }
+            count.getAndIncrement();
+        });
+        return count.get();
+    }
 }

+ 0 - 51
fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java

@@ -796,57 +796,6 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
         return R.ok("分配成功");
     }
 
-    @Override
-    @Transactional
-    public R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param) {
-        Integer index=0;
-        for(CrmCustomerAssignUserDTO userDTO:param.getUsers()){
-            CompanyUser companyUser=companyUserMapper.selectCompanyUserById(userDTO.getCompanyUserId());
-            for(int i=0;i<userDTO.getCount();i++){
-                CrmCustomer customer=crmCustomerMapper.selectCrmCustomerById(param.getCustomerIds().get(index));
-                //不能选择客户拥有者本人
-                CrmCustomerUser crmCustomerUser = crmCustomerUserMapper.selectCrmCustomerUserById(customer.getCustomerUserId());
-                if (Objects.equals(crmCustomerUser.getCompanyUserId(), userDTO.getCompanyUserId())){
-                    return R.error("不能选择自己来协作!");
-                }
-                //查询协作客户
-                CrmCustomerAssist customerAssist=new CrmCustomerAssist();
-                customerAssist.setCustomerId(customer.getCustomerId());
-                customerAssist.setCompanyUserId(userDTO.getCompanyUserId());
-                List<CrmCustomerAssist> tempList = assistMapper.selectCrmCustomerAssistList(customerAssist);
-                if(tempList!=null && !tempList.isEmpty()){
-                    return R.error("销售:" + companyUser.getNickName() +"(" + userDTO.getCompanyUserId() + ")已拥有改该协作客户:" + customer.getCustomerName());
-                }
-                customerAssist.setCompanyId(param.getCompanyId());
-                customerAssist.setCompanyUserName(companyUser.getNickName());
-                customerAssist.setCreateTime(new Date());
-                assistMapper.insertCrmCustomerAssist(customerAssist);
-                //写日志
-                CrmCustomerLogs logs=new CrmCustomerLogs();
-                logs.setCustomerId(customer.getCustomerId());
-                logs.setCreateTime(new Date());
-                logs.setLogsType(CustomerLogEnum.ASSIST_USER.getValue());
-                logs.setTitle(CustomerLogEnum.ASSIST_USER.getDesc());
-                logs.setRemark(opeUserName+"为客户"+customer.getCustomerName()+"添加协作人:" + companyUser.getNickName());
-                logs.setCompanyUserId(userDTO.getCompanyUserId());
-                logsMapper.insertCrmCustomerLogs(logs);
-
-                if(StringUtils.isNotEmpty(companyUser.getJpushId())){
-                    Map<String, String> extrasMap=new HashMap<>();
-                    extrasMap.put("customerId",customer.getCustomerId().toString());
-                    extrasMap.put("type","1");
-                    try {
-                        jpushService.sendRegisterIdPush("客户消息","您收到 一个客户协作邀请",extrasMap,companyUser.getJpushId());
-                    } catch (APIConnectionException e) {
-                    } catch (APIRequestException e) {
-                    }
-                }
-                index++;
-            }
-        }
-        return R.ok();
-    }
-
     @Override
     public int updateCrmCustomerSource(CrmCustomerEditSourceParam param) {
         return crmCustomerMapper.updateCrmCustomerSource(param);

+ 12 - 0
fs-service-system/src/main/java/com/fs/crm/vo/CrmCustomerAssistVo.java

@@ -0,0 +1,12 @@
+package com.fs.crm.vo;
+
+import com.fs.crm.domain.CrmCustomerAssist;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CrmCustomerAssistVo {
+    private Long customerId;
+    private List<CrmCustomerAssist> assistList;
+}

+ 20 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -25,6 +25,7 @@ import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyMoneyLogs;
 import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyMapper;
 import com.fs.company.mapper.CompanyMoneyLogsMapper;
 import com.fs.company.service.ICompanyDeptService;
 import com.fs.company.service.ICompanyService;
@@ -216,6 +217,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     private IFsStoreOrderAuditService orderAuditService;
     @Autowired
     private IFsStoreOrderAuditLogService orderAuditLogService;
+    @Autowired
+    private CompanyMapper companyMapper;
 
     /**
      * 查询订单
@@ -593,6 +596,18 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                     storeOrder.setStatus(1);
                 }
             }
+            Boolean isPay = true;
+            if (param.getOrderCreateType() != null && param.getOrderCreateType() == 3 && param.getCompanyId()!=null){
+                //后台制单 判断是否需要付款
+                Company company = companyMapper.selectCompanyById(param.getCompanyId());
+                if(company!=null){
+                    if (company.getIsPay() != null && company.getIsPay() == 0) {
+                        //不需要付款
+                        storeOrder.setStatus(1); //待发货
+                        isPay = false;
+                    }
+                }
+            }
             storeOrder.setOrderCreateType(param.getOrderCreateType());
             Long prescribe = carts.stream().filter(item -> item.getProductType()!=null&&item.getProductType()==2).count();
             if(prescribe>0){
@@ -607,6 +622,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             if (flag==0) {
                 return R.error("订单创建失败");
             }
+            if (!isPay){
+                // 添加订单审核
+                addOrderAudit(storeOrder);
+            }
             //使用了积分扣积分
             if (dto.getUsedIntegral() > 0) {
                 this.decIntegral(userId, dto.getUsedIntegral(), dto.getDeductionPrice().doubleValue(),storeOrder.getId().toString());
@@ -1010,6 +1029,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             createParam.setPayPrice(param.getPayPrice());
             createParam.setCustomerId(param.getCustomerId());
             createParam.setAmount(param.getAmount());
+            createParam.setOrderCreateType(3); //后台制单
             return this.createOrder(param.getUserId(),createParam);
         }
         else{

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

@@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isDel"    column="is_del"    />
         <result property="voiceCallerNumber"    column="voice_caller_number"    />
         <result property="omsCode"    column="oms_code"    />
+        <result property="isPay"    column="is_pay"    />
     </resultMap>
 
     <sql id="selectCompanyVo">
@@ -90,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isDel != null">is_del,</if>
             <if test="omsCode != null ">oms_code,</if>
             <if test="voiceCallerNumber != null">voice_caller_number,</if>
+            <if test="isPay != null">is_pay,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyName != null">#{companyName},</if>
@@ -113,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isDel != null">#{isDel},</if>
             <if test="omsCode != null ">#{omsCode},</if>
             <if test="voiceCallerNumber != null">#{voiceCallerNumber},</if>
+            <if test="isPay != null">#{isPay},</if>
          </trim>
     </insert>
 
@@ -141,6 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="voiceCallerNumber != null">voice_caller_number = #{voiceCallerNumber},</if>
             <if test="omsCode != null ">oms_code = #{omsCode},</if>
             <if test="fsUserIsDefaultBlack != null ">fs_user_is_default_black = #{fsUserIsDefaultBlack},</if>
+            <if test="isPay != null ">is_pay = #{isPay},</if>
         </trim>
         where company_id = #{companyId}
     </update>

+ 11 - 2
fs-service-system/src/main/resources/mapper/crm/CrmCustomerAssistMapper.xml

@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <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 from crm_customer_assist
+        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">
@@ -32,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
     <select id="selectCompanyUserNameByCustomerId" resultType="java.lang.String">
-        select  CONCAT(company_user_name, '(', company_user_id, ')') AS assistUser
+        select  CONCAT(company_user_name, '(', company_user_id, ')','分佣:',rate,'%') AS assistUser
         from crm_customer_assist
         where customer_id = #{customerId}
     </select>
@@ -42,6 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <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
@@ -51,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>
@@ -58,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>
 
@@ -69,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>