Forráskód Böngészése

客户收款 新建客户

姜永辉 1 éve
szülő
commit
cbdded2f9a

+ 57 - 0
src/main/java/com/dk/mdm/model/vo/mac/RecPayVO.java

@@ -256,6 +256,63 @@ public class RecPayVO extends PageInfo<RecPayVO> implements Serializable {
     @ApiModelProperty(value = "应付冲抵明细")
     private List<RecPayHandleItemVO> payableList;
 
+    // 新增客户用240521
+    /**
+     * 客户编号
+     */
+    @ApiModelProperty(value = "客户编号")
+    private String cusCode;
+
+
+    /**
+     * 客户名称
+     */
+    @ApiModelProperty(value = "客户名称")
+    private String cusName;
+
+
+    /**
+     * 客户电话
+     */
+    @ApiModelProperty(value = "客户电话")
+    private String cusPhone;
+
+
+    /**
+     * 行政区划 (a1:省 a2:市 a3:区)
+     */
+    @ApiModelProperty(value = "行政区划 (a1:省 a2:市 a3:区)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressArea;
+
+
+    /**
+     * 小区或POI
+     */
+    @ApiModelProperty(value = "小区或POI")
+    private String addressName;
+
+
+    /**
+     * 门牌号
+     */
+    @ApiModelProperty(value = "门牌号")
+    private String addressNo;
+
+
+    /**
+     * 地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)
+     */
+    @ApiModelProperty(value = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressGcj02;
+
+    /**
+     * 详细地址
+     */
+    @ApiModelProperty(value = "详细地址")
+    private String addressFull;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 42 - 0
src/main/java/com/dk/mdm/service/mac/ReceiptService.java

@@ -12,23 +12,29 @@ import com.dk.mdm.infrastructure.convert.mac.RecPayConvert;
 import com.dk.mdm.infrastructure.convert.mac.RecPayHandleItemConvert;
 import com.dk.mdm.infrastructure.convert.mac.RecPayItemConvert;
 import com.dk.mdm.mapper.mac.*;
+import com.dk.mdm.mapper.mst.CustomerMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountMapper;
+import com.dk.mdm.mapper.mst.SaleChannelMapper;
 import com.dk.mdm.model.pojo.mac.*;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.mst.Customer;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
 import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
 import com.dk.mdm.model.query.mac.RecPayItemQuery;
 import com.dk.mdm.model.query.mac.RecPayQuery;
+import com.dk.mdm.model.query.mst.SaleChannelQuery;
 import com.dk.mdm.model.response.mac.RecPayHandleItemResponse;
 import com.dk.mdm.model.response.mac.RecPayItemResponse;
 import com.dk.mdm.model.response.mac.RecPayResponse;
+import com.dk.mdm.model.response.mst.SaleChannelResponse;
 import com.dk.mdm.model.vo.mac.RecPayHandleItemVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
 import com.dk.mdm.model.vo.mac.RecPayVO;
 import com.dk.mdm.service.common.CommonService;
+import com.dk.mdm.service.mst.CustomerService;
 import com.dk.mdm.service.mst.MoneyAccountService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -91,6 +97,15 @@ public class ReceiptService extends BaseService<RecPay> {
     private CommonService commonService;
 
     @Autowired
+    private CustomerMapper customerMapper;
+
+    @Autowired
+    private SaleChannelMapper saleChannelMapper;
+
+    @Autowired
+    private CustomerService customerService;
+
+    @Autowired
     private RecPayConvert recPayConvert;
 
     @Autowired
@@ -167,6 +182,33 @@ public class ReceiptService extends BaseService<RecPay> {
         recPayVO.setRpId(codeMap.get("outId").toString()).setRpNo(codeMap.get("outNote").toString());
         // 转化实体
         RecPay recPay = recPayConvert.convertToPo(recPayVO);
+
+
+//        客户的新增和更新跟进人
+        // 如果没有客户id,要新建
+        if (recPay.getObjectId() == null) {
+            List<Customer> listCustomer = customerMapper.selectByCond(new Customer().setCpId(recPay.getCpId()).setCusPhone(recPayVO.getCusPhone()));
+            // 如果客户电话已存在
+            if (listCustomer == null || listCustomer.size() == 0) {
+                String channelId;
+                List<SaleChannelResponse> saleChannelResponses = saleChannelMapper.selectByCond(new SaleChannelQuery());
+                channelId = (saleChannelResponses!=null && saleChannelResponses.size() > 0)?saleChannelResponses.get(0).getChannelId():"";
+                // 创建客户,获取编码和主键UuId
+                Map<String, Object> codeMapCus = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMER.getName(), true);
+                Customer customer = new Customer();
+                customer.setCusId(codeMapCus.get("outId").toString()).setCusCode(codeMapCus.get("outNote").toString()).setCusName(recPayVO.getCusName())
+                        .setCusPhone(recPayVO.getCusPhone()).setAddressArea(recPayVO.getAddressArea()).setAddressName(recPayVO.getAddressName())
+                        .setAddressNo(recPayVO.getAddressNo()).setAddressGcj02(recPayVO.getAddressGcj02()).setAddressFull(recPayVO.getAddressFull())
+                        .setChannelId(channelId).setOrgId(recPayVO.getOrgId()).setStaffId(recPayVO.getStaffId())
+                        .setReportStaff(recPayVO.getStaffId()).setSaleStatus(Constant.SaleStatus.QIANKE.getName()).setCpId(recPayVO.getCpId());
+                customerMapper.insert(customer);
+                recPayVO.setObjectId(customer.getCusId());
+                recPay.setObjectId(customer.getCusId());
+            } else{
+                recPayVO.setObjectId(listCustomer.get(0).getCusId());
+                recPay.setObjectId(listCustomer.get(0).getCusId());
+            }
+        }
         // 总单保存
         super.insert(recPay);