|
|
@@ -3,6 +3,7 @@ package org.dromara.customer.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.crypto.digest.BCrypt;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -14,6 +15,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.constant.GlobalConstants;
|
|
|
import org.dromara.common.core.context.PlatformContext;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.enums.FormatsType;
|
|
|
import org.dromara.common.core.enums.IsDefault;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
@@ -25,6 +27,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.common.redis.utils.SequenceUtils;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.customer.api.erp.domain.push.BusConn;
|
|
|
+import org.dromara.customer.api.erp.domain.push.CustInfo;
|
|
|
+import org.dromara.customer.api.erp.domain.push.DlvAddr;
|
|
|
+import org.dromara.customer.api.erp.domain.push.GathBn;
|
|
|
import org.dromara.customer.domain.*;
|
|
|
import org.dromara.customer.domain.bo.*;
|
|
|
import org.dromara.customer.domain.vo.*;
|
|
|
@@ -1130,7 +1136,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
// 3. 插入新的关联数据
|
|
|
saveAssociatedData(customerId, bo);
|
|
|
-
|
|
|
+ customerInfoJson(customerId);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -1232,10 +1238,15 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return baseMapper.update(null,
|
|
|
+
|
|
|
+ Integer num = baseMapper.update(null,
|
|
|
new LambdaUpdateWrapper<CustomerInfo>()
|
|
|
.set(CustomerInfo::getStatus, status)
|
|
|
.eq(CustomerInfo::getId, customerId));
|
|
|
+ if (num > 0) {
|
|
|
+ customerInfoJson(customerId);
|
|
|
+ }
|
|
|
+ return num;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -2386,4 +2397,128 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
return exportList;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String customerInfoJson(Long customerId) {
|
|
|
+ // 1. 查询客户主信息
|
|
|
+ CustomerInfoVo customerInfoVo = baseMapper.selectVoById(customerId);
|
|
|
+ if (customerInfoVo == null) {
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 查询关联数据
|
|
|
+ CustomerSalesInfo salesInfo = customerSalesInfoMapper.selectByCustomerId(customerInfoVo.getId());
|
|
|
+ CustomerBusinessInfo businessInfo = customerBusinessInfoMapper.selectByCustomerId(customerInfoVo.getId());
|
|
|
+ List<CustomerContact> customerContacts = customerContactMapper.selectListByCustomerId(customerInfoVo.getId());
|
|
|
+ List<CustomerShippingAddressVo> shippingAddressVos = shippingAddressMapper.selectVoList(
|
|
|
+ new LambdaQueryWrapper<CustomerShippingAddress>()
|
|
|
+ .eq(CustomerShippingAddress::getCustomerId, customerInfoVo.getId()));
|
|
|
+ List<CustomerInvoiceInfo> invoiceInfos = customerInvoiceInfoMapper.selectListByCustomerId(customerInfoVo.getId());
|
|
|
+
|
|
|
+ // 3. 映射 CustInfo
|
|
|
+ CustInfo custInfo = new CustInfo();
|
|
|
+ custInfo.setCustId(customerInfoVo.getCustomerNo());
|
|
|
+ custInfo.setCustNm(customerInfoVo.getCustomerName());
|
|
|
+ custInfo.setPerId(remoteComStaffService.selectStaffCodeById((customerInfoVo.getSalesPersonId())));
|
|
|
+ custInfo.setSalAsstId(remoteComStaffService.selectStaffCodeById((customerInfoVo.getServiceStaffId())));
|
|
|
+ custInfo.setAddr(customerInfoVo.getAddress());
|
|
|
+ if (businessInfo != null) {
|
|
|
+ try {
|
|
|
+ custInfo.setCapAmt(new BigDecimal(businessInfo.getRegisteredCapital()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("解析注册资本失败: {}", businessInfo.getRegisteredCapital());
|
|
|
+ }
|
|
|
+ custInfo.setPrincipal(businessInfo.getLegalPersonName());
|
|
|
+ }
|
|
|
+ if (salesInfo != null) {
|
|
|
+ custInfo.setChkHalfDa(salesInfo.getBillingDay());
|
|
|
+ custInfo.setChkoutDa(salesInfo.getBillDate());
|
|
|
+ custInfo.setChkWeekDa(salesInfo.getAccountPeriod());
|
|
|
+ custInfo.setCreCls(remoteCreditLevelService.selectCreditLevelCodeById(salesInfo.getCreditLevelId()));
|
|
|
+ custInfo.setCurId(remoteComCurrencyService.selectCurrencyCodeById(salesInfo.getDealCurrencyId()));
|
|
|
+ custInfo.setCustSrcId(salesInfo.getCustomerSource());
|
|
|
+ custInfo.setGathCnd(salesInfo.getSettlementMethod() != null ? salesInfo.getSettlementMethod().intValue() : null);
|
|
|
+ custInfo.setGathDays(salesInfo.getPayDays());
|
|
|
+ }
|
|
|
+ custInfo.setCityId(customerInfoVo.getRegCityNo());
|
|
|
+ custInfo.setCropSclId(customerInfoVo.getEnterpriseScaleId() != null ? enterpriseScaleMapper.selectVoById(customerInfoVo.getEnterpriseScaleId()).getEnterpriseScaleCode() : null);
|
|
|
+ custInfo.setCU_comCo(customerInfoVo.getCompanyName());
|
|
|
+ custInfo.setCU_SalesInvoice(customerInfoVo.getSellInvoiceTypeNo());
|
|
|
+ custInfo.setCustTyId(remoteComCustomerTypeService.selectCustomerTypeNoNameById(customerInfoVo.getCustomerTypeId()));
|
|
|
+ custInfo.setEmail(customerInfoVo.getEmail());
|
|
|
+ custInfo.setFaxNo(customerInfoVo.getFax());
|
|
|
+ custInfo.setInvoAddr(customerInfoVo.getAddress());
|
|
|
+ custInfo.setInvoTt(customerInfoVo.getCustomerName());
|
|
|
+ custInfo.setLkUrl(customerInfoVo.getUrl());
|
|
|
+ custInfo.setOfiTel(customerInfoVo.getLandline());
|
|
|
+ custInfo.setPrvnId(customerInfoVo.getRegProvincialNo());
|
|
|
+ custInfo.setRemark(customerInfoVo.getRemark());
|
|
|
+ custInfo.setSrtNm(customerInfoVo.getShortName());
|
|
|
+ custInfo.setTaxChkNo(customerInfoVo.getSocialCreditCode());
|
|
|
+ custInfo.setGadId(remoteComCustomerLevelService.selectCustomerLevelNoById(customerInfoVo.getCustomerLevelId()));
|
|
|
+ custInfo.setTradTy(customerInfoVo.getIndustryCategoryId() != null ? industryCategoryMapper.selectVoById(customerInfoVo.getIndustryCategoryId()).getIndustryCode() : null);
|
|
|
+ if (customerInfoVo.getValidityFromDate() != null) {
|
|
|
+ custInfo.setValidityFromDate(Integer.parseInt(DateUtils.parseDateToStr(FormatsType.YYYYMMDD, customerInfoVo.getValidityFromDate())));
|
|
|
+ }
|
|
|
+ if (customerInfoVo.getValidityToDate() != null) {
|
|
|
+ custInfo.setValidityToDate(Integer.parseInt(DateUtils.parseDateToStr(FormatsType.YYYYMMDD, customerInfoVo.getValidityToDate())));
|
|
|
+ }
|
|
|
+ custInfo.setCountryId(customerInfoVo.getRegCountyNo());
|
|
|
+ custInfo.setQQMSN(customerInfoVo.getEmail());
|
|
|
+
|
|
|
+ // 4. 映射 DlvAddr 列表
|
|
|
+ List<DlvAddr> dlvAddrList = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(shippingAddressVos)) {
|
|
|
+ for (CustomerShippingAddressVo vo : shippingAddressVos) {
|
|
|
+ DlvAddr dlvAddr = new DlvAddr();
|
|
|
+ dlvAddr.setAddr(vo.getAddress());
|
|
|
+ dlvAddr.setAddrNo(vo.getShippingAddressNo());
|
|
|
+ dlvAddr.setCustId(customerInfoVo.getCustomerNo());
|
|
|
+ dlvAddr.setConnPer(vo.getConsignee());
|
|
|
+ dlvAddr.setConnPos(vo.getDeptName());
|
|
|
+ dlvAddr.setConnTel(vo.getPhone());
|
|
|
+ dlvAddr.setIsMainAddr("0".equals(vo.getDefaultAddress()));
|
|
|
+ dlvAddr.setPtC(vo.getPostal());
|
|
|
+ dlvAddrList.add(dlvAddr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 映射 GathBn 列表
|
|
|
+ List<GathBn> gathBnList = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(invoiceInfos)) {
|
|
|
+ int rowNo = 1;
|
|
|
+ for (CustomerInvoiceInfo info : invoiceInfos) {
|
|
|
+ GathBn gathBn = new GathBn();
|
|
|
+ gathBn.setBnAccNo(info.getBankAccount());
|
|
|
+ gathBn.setCustId(customerInfoVo.getCustomerNo());
|
|
|
+ gathBn.setAccBn(info.getBankName());
|
|
|
+ gathBn.setAccNm(customerInfoVo.getCustomerName());
|
|
|
+ gathBn.setMainAcc("0".equals(info.getIsPrimaryAccount()));
|
|
|
+ gathBn.setRowNo(rowNo++);
|
|
|
+ gathBn.setTelNo(info.getPhone());
|
|
|
+ gathBnList.add(gathBn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 映射 BusConn 列表
|
|
|
+ List<BusConn> busConnList = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(customerContacts)) {
|
|
|
+ for (CustomerContact contact : customerContacts) {
|
|
|
+ BusConn busConn = new BusConn();
|
|
|
+ busConn.setCustId(customerInfoVo.getCustomerNo());
|
|
|
+ busConn.setFrLkmId(contact.getId() != null ? String.valueOf(contact.getId()) : null);
|
|
|
+ busConn.setIsMainPer("0".equals(contact.getIsPrimary()));
|
|
|
+ busConn.setRowCd(contact.getId() != null ? contact.getId().intValue() : null);
|
|
|
+ busConnList.add(busConn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 组装返回JSON
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("CustInfo", custInfo);
|
|
|
+ result.put("DlvAddr", dlvAddrList);
|
|
|
+ result.put("GathBn", gathBnList);
|
|
|
+ result.put("BusConn", busConnList);
|
|
|
+ return JSONUtil.toJsonStr(result);
|
|
|
+ }
|
|
|
}
|