|
@@ -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.RecPayHandleItemConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.mac.RecPayItemConvert;
|
|
import com.dk.mdm.infrastructure.convert.mac.RecPayItemConvert;
|
|
|
import com.dk.mdm.mapper.mac.*;
|
|
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.MoneyAccountItemMapper;
|
|
|
import com.dk.mdm.mapper.mst.MoneyAccountMapper;
|
|
import com.dk.mdm.mapper.mst.MoneyAccountMapper;
|
|
|
|
|
+import com.dk.mdm.mapper.mst.SaleChannelMapper;
|
|
|
import com.dk.mdm.model.pojo.mac.*;
|
|
import com.dk.mdm.model.pojo.mac.*;
|
|
|
import com.dk.common.service.BaseService;
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
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.MoneyAccount;
|
|
|
import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
|
|
import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
|
|
|
import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
|
|
import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
|
|
|
import com.dk.mdm.model.query.mac.RecPayItemQuery;
|
|
import com.dk.mdm.model.query.mac.RecPayItemQuery;
|
|
|
import com.dk.mdm.model.query.mac.RecPayQuery;
|
|
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.RecPayHandleItemResponse;
|
|
|
import com.dk.mdm.model.response.mac.RecPayItemResponse;
|
|
import com.dk.mdm.model.response.mac.RecPayItemResponse;
|
|
|
import com.dk.mdm.model.response.mac.RecPayResponse;
|
|
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.RecPayHandleItemVO;
|
|
|
import com.dk.mdm.model.vo.mac.RecPayItemVO;
|
|
import com.dk.mdm.model.vo.mac.RecPayItemVO;
|
|
|
import com.dk.mdm.model.vo.mac.RecPayVO;
|
|
import com.dk.mdm.model.vo.mac.RecPayVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
|
|
+import com.dk.mdm.service.mst.CustomerService;
|
|
|
import com.dk.mdm.service.mst.MoneyAccountService;
|
|
import com.dk.mdm.service.mst.MoneyAccountService;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -91,6 +97,15 @@ public class ReceiptService extends BaseService<RecPay> {
|
|
|
private CommonService commonService;
|
|
private CommonService commonService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private CustomerMapper customerMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SaleChannelMapper saleChannelMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CustomerService customerService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private RecPayConvert recPayConvert;
|
|
private RecPayConvert recPayConvert;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -167,6 +182,33 @@ public class ReceiptService extends BaseService<RecPay> {
|
|
|
recPayVO.setRpId(codeMap.get("outId").toString()).setRpNo(codeMap.get("outNote").toString());
|
|
recPayVO.setRpId(codeMap.get("outId").toString()).setRpNo(codeMap.get("outNote").toString());
|
|
|
// 转化实体
|
|
// 转化实体
|
|
|
RecPay recPay = recPayConvert.convertToPo(recPayVO);
|
|
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);
|
|
super.insert(recPay);
|
|
|
|
|
|