Browse Source

根据客户类型 生成不同编码规则

yzc 11 months ago
parent
commit
0f9ccae02a

+ 1 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerSelectDto.java

@@ -14,7 +14,7 @@ import lombok.Setter;
 @Setter
 public class CustomerSelectDto extends BaseSelectDto {
     /**
-     * 客户类型(字典表customer_status
+     * 客户类型(字典表customer_type
      */
     private String status;
 

+ 9 - 2
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -32,6 +32,7 @@ import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
 import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
 import com.fjhx.tenant.service.dict.DictTenantDataService;
 import com.fjhx.tenant.utils.DeptUstil;
+import com.fjhx.tenant.utils.DictCodingService;
 import com.fjhx.tenant.utils.DictUtils;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -70,6 +71,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
     private DictTenantDataService dictTenantDataService;
     @Autowired
     private ISysDeptService deptService;
+    @Autowired
+    private DictCodingService dictCodingService;
 
 
     @Override
@@ -226,7 +229,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         //获取客户类型字典
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
         DictTenantDataSelectDto dictTenantDataSelectDto = new DictTenantDataSelectDto();
-        dictTenantDataSelectDto.setDictCode("customer_status");
+        dictTenantDataSelectDto.setDictCode("customer_type");
         List<DictTenantDataVo> dictTenantDataVoList = dictTenantDataService.getList(dictTenantDataSelectDto);
         Map<String, String> customerStatusDic = dictTenantDataVoList.stream().collect(Collectors.toMap(DictTenantDataVo::getDictKey, DictTenantDataVo::getDictValue));
         DynamicDataSourceContextHolder.poll();
@@ -306,6 +309,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         CustomizeAreaUtil.setAreaId(customerDto);
 
         customerDto.setCode(CodeEnum.CUSTOMER.getCode());
+
+        //根据客户类型不同 使用对应规则生成编码
+        customerDto.setCustomerCode(dictCodingService.createCode("customer_type", customerDto.getStatus()));
+
         this.save(customerDto);
         //添加库户-联系人表的信息
         saveCustomerUse(customerDto);
@@ -612,7 +619,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         for (CustomerVo customerVo : list) {
             customerVo.setCompanySize(allDictMap.get("customer_scale").get(customerVo.getCompanySize()));
             customerVo.setSettlementMode(allDictMap.get("settlement_way").get(customerVo.getSettlementMode()));
-            customerVo.setStatus(allDictMap.get("customer_status").get(customerVo.getStatus()));
+            customerVo.setStatus(allDictMap.get("customer_type").get(customerVo.getStatus()));
             customerVo.setLevel(allDictMap.get("customer_slevel").get(customerVo.getLevel()));
             customerVo.setNewOld(allDictMap.get("newold_customer").get(customerVo.getNewOld()));
             customerVo.setState(allDictMap.get("customer_state").get(customerVo.getState()));

+ 1 - 1
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -804,7 +804,7 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
 
         //获取类型的字典数据
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
-        List<DictTenantDataVo> dictTenantDataVoList = DictUtils.getDictList("customer_status");
+        List<DictTenantDataVo> dictTenantDataVoList = DictUtils.getDictList("customer_type");
 
         if (dictTenantDataVoList.size() == 0) {
             throw new ServiceException("数据有误:该租户没有配客户类型字典");