|
@@ -122,7 +122,7 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList, Set<Long> allCustomer) {
|
|
|
+ public void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList, Set<Long> allCustomer,boolean flag) {
|
|
|
List<XiaomanCustomer> xiaomanCustomerList = new ArrayList<>(customerApiVoList);
|
|
|
for (XiaomanCustomer customer : xiaomanCustomerList){
|
|
|
try {
|
|
@@ -135,7 +135,8 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
xiaomanCustomerInfoJsonService.updateById(xiaomanCustomerInfoJson);
|
|
|
CustomerInfoVo infoVo = HandleXiaomanData.handleDate(customerDetailJson, new TypeReference<R<CustomerInfoVo>>() {
|
|
|
});
|
|
|
- Long s = customerConversion(infoVo);
|
|
|
+ //true 全量更新
|
|
|
+ Long s = flag ? customerConversionAll(infoVo): customerConversionUpdate(infoVo);
|
|
|
customer.setCustomerId(s);
|
|
|
updateById(customer);
|
|
|
}else {
|
|
@@ -149,7 +150,8 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
CustomerInfoVo infoVo = HandleXiaomanData.handleDate(customerDetailJson, new TypeReference<R<CustomerInfoVo>>() {
|
|
|
});
|
|
|
//小满客户 =》 客户
|
|
|
- Long s = customerConversion(infoVo);
|
|
|
+ //true 全量更新
|
|
|
+ Long s = flag ? customerConversionAll(infoVo): customerConversionUpdate(infoVo);
|
|
|
customer.setCustomerId(s);
|
|
|
save(customer);
|
|
|
System.out.println("2");
|
|
@@ -158,15 +160,67 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小满客户 =》 客户
|
|
|
+ * @param vo
|
|
|
+ */
|
|
|
+ public Long customerConversionAll(CustomerInfoVo vo) {
|
|
|
+ SecurityUtils.setTenantId(XiaomanContant.TENANT_ID);
|
|
|
+
|
|
|
+ Customer customer = new Customer();
|
|
|
+
|
|
|
+ customer.setId(vo.getCompanyId());
|
|
|
+
|
|
|
+ extracted(vo, customer);
|
|
|
+
|
|
|
+
|
|
|
+ //联系人
|
|
|
+ if (!vo.getCustomers().isEmpty()){
|
|
|
+ for (CustomerInfoVo.Customer cus :vo.getCustomers()){
|
|
|
+ if (StringUtils.isNotEmpty(cus.getEmail())){
|
|
|
+ CustomerUser customerUser = new CustomerUser();
|
|
|
+ customerUser.setCustomerId(customer.getId());
|
|
|
+ customerUser.setName(cus.getName());
|
|
|
+ customerUser.setEmail(cus.getEmail());
|
|
|
+ List<Map> maps = new ArrayList<>();
|
|
|
+ if (! cus.getContact().isEmpty()){
|
|
|
+ for (CustomerInfoVo.Contact contact : cus.getContact()) {
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("type", contact.getType());
|
|
|
+ map1.put("contactNo", contact.getValue());
|
|
|
+ maps.add(map1);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("type", "");
|
|
|
+ map1.put("contactNo", "");
|
|
|
+ maps.add(map1);
|
|
|
+ }
|
|
|
+ customerUser.setPhone(cus.getTel());
|
|
|
+ customerUser.setContactJson(JSON.toJSONString(maps));
|
|
|
+ customerUserService.save(customerUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ customer.setCountryName(vo.getCountryName());
|
|
|
+ customerService.save(customer);
|
|
|
+
|
|
|
+
|
|
|
+ return customer.getId();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 小满客户 =》 客户
|
|
|
* @param vo
|
|
|
*/
|
|
|
- public Long customerConversion(CustomerInfoVo vo) {
|
|
|
+ public Long customerConversionUpdate(CustomerInfoVo vo) {
|
|
|
SecurityUtils.setTenantId(XiaomanContant.TENANT_ID);
|
|
|
List<Customer> list = customerService.lambdaQuery()
|
|
|
.eq(StringUtils.isNotEmpty(vo.getName()), Customer::getName, vo.getName())
|
|
@@ -182,84 +236,8 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
customer.setCompanyId(vo.getCompanyId());
|
|
|
//公司编号
|
|
|
customer.setCustomerCode(vo.getSerialId());
|
|
|
- //业务员ID
|
|
|
- if (!vo.getOwner().isEmpty()){
|
|
|
- DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
- SysUser sysUser = sysUserService.lambdaQuery().eq(SysUser::getNickNameEn, vo.getOwner().get(0).getName()).one();
|
|
|
- if (Objects.nonNull(sysUser)){
|
|
|
- customer.setUserId(sysUser.getUserId());
|
|
|
- }
|
|
|
- DynamicDataSourceContextHolder.poll();
|
|
|
- }
|
|
|
- //TODO 标签tag customer_tag
|
|
|
- if (!vo.getTag().isEmpty()){
|
|
|
- Set<String> tags = new HashSet<>();
|
|
|
- vo.getTag().forEach(x->{
|
|
|
- List<DictTenantDataVo> customerTag = DictUtils.getDictList("customer_tag");
|
|
|
- AtomicReference<String> key = new AtomicReference<>("");
|
|
|
- customerTag.forEach(tag ->{
|
|
|
- if (tag.getDictValue().equals(x.getTagName())){
|
|
|
- key.set(tag.getDictKey());
|
|
|
- }
|
|
|
- });
|
|
|
- if (StringUtils.isNull(key)){
|
|
|
- xiaomanApiService.dealCustomerTagDict(x.getTagName(),x.getTagId());
|
|
|
- tags.add(x.getTagId());
|
|
|
- }else {
|
|
|
- tags.add(String.valueOf(key));
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- customer.setTag(String.join(",",tags));
|
|
|
- }
|
|
|
-
|
|
|
- //客户名称
|
|
|
- customer.setName(vo.getName());
|
|
|
- //客户简称
|
|
|
- customer.setShortName(vo.getShortName());
|
|
|
-
|
|
|
- if (!vo.getOriginList().isEmpty()){
|
|
|
- List<DictTenantDataVo> customerSource = DictUtils.getDictList("customer_source");
|
|
|
- Set<String> sources = new HashSet<>();
|
|
|
- vo.getOriginList().forEach(x->{
|
|
|
- customerSource.forEach(tag ->{
|
|
|
- if (tag.getDictValue().equals(x)){
|
|
|
- sources.add(tag.getDictKey());
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- customer.setSource(String.join(",",sources));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //客户规模
|
|
|
- customer.setScaleId(vo.getScaleId());
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(vo.getTrailStatus())){
|
|
|
- AtomicReference<String> status = new AtomicReference<>("");
|
|
|
- List<DictTenantDataVo> customerSource = DictUtils.getDictList("customer_status");
|
|
|
- customerSource.forEach(tag ->{
|
|
|
- if (tag.getDictValue().equals(vo.getTrailStatus())){
|
|
|
- status.set(tag.getDictKey());
|
|
|
- }
|
|
|
- });
|
|
|
- customer.setStatus(String.valueOf(status));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //公司网址
|
|
|
- customer.setHomepage(vo.getHomepage());
|
|
|
- //小满传真
|
|
|
- customer.setFax(vo.getFax());
|
|
|
- //小满电话区号
|
|
|
- customer.setTelAreaCode(vo.getTelAreaCode());
|
|
|
- //小满电话
|
|
|
- customer.setTel(vo.getTel());
|
|
|
- //小满备注
|
|
|
- customer.setRemark(vo.getRemark());
|
|
|
-
|
|
|
|
|
|
+ extracted(vo, customer);
|
|
|
//联系人
|
|
|
if (!vo.getCustomers().isEmpty()){
|
|
|
Map<String, CustomerUser> collect = customerUserService.lambdaQuery()
|
|
@@ -319,17 +297,12 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
collect.put(customerUser.getEmail(),customerUser);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
customer.setCountryName(vo.getCountryName());
|
|
|
customerService.updateById(customer);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
SecurityUtils.clearTenantId();
|
|
|
if (!list.isEmpty()) {
|
|
|
Long collect = list.stream().map(Customer::getId).collect(Collectors.toList()).get(0);
|
|
@@ -340,6 +313,93 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 公用方法
|
|
|
+ * @param vo
|
|
|
+ * @param customer
|
|
|
+ */
|
|
|
+ private void extracted(CustomerInfoVo vo, Customer customer) {
|
|
|
+ customer.setAddress(vo.getAddress());
|
|
|
+ //小满公司ID
|
|
|
+ customer.setCompanyId(vo.getCompanyId());
|
|
|
+ //公司编号
|
|
|
+ customer.setCustomerCode(vo.getSerialId());
|
|
|
+ //业务员ID
|
|
|
+ if (!vo.getOwner().isEmpty()){
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ SysUser sysUser = sysUserService.lambdaQuery().eq(SysUser::getNickNameEn, vo.getOwner().get(0).getName()).one();
|
|
|
+ if (Objects.nonNull(sysUser)){
|
|
|
+ customer.setUserId(sysUser.getUserId());
|
|
|
+ }
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ }
|
|
|
+ //标签tag customer_tag
|
|
|
+ if (!vo.getTag().isEmpty()){
|
|
|
+ Set<String> tags = new HashSet<>();
|
|
|
+ vo.getTag().forEach(x->{
|
|
|
+ List<DictTenantDataVo> customerTag = DictUtils.getDictList("customer_tag");
|
|
|
+ AtomicReference<String> key = new AtomicReference<>("");
|
|
|
+ customerTag.forEach(tag ->{
|
|
|
+ if (tag.getDictValue().equals(x.getTagName())){
|
|
|
+ key.set(tag.getDictKey());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (StringUtils.isEmpty(key.toString())){
|
|
|
+ xiaomanApiService.dealCustomerTagDict(x.getTagName(),x.getTagId());
|
|
|
+ tags.add(x.getTagId());
|
|
|
+ }else {
|
|
|
+ tags.add(String.valueOf(key));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ customer.setTag(String.join(",",tags));
|
|
|
+ }
|
|
|
+
|
|
|
+ //客户名称
|
|
|
+ customer.setName(vo.getName());
|
|
|
+ //客户简称
|
|
|
+ customer.setShortName(vo.getShortName());
|
|
|
+ //客户来源
|
|
|
+ if (!vo.getOriginList().isEmpty()){
|
|
|
+ List<DictTenantDataVo> customerSource = DictUtils.getDictList("customer_source");
|
|
|
+ Set<String> sources = new HashSet<>();
|
|
|
+ vo.getOriginList().forEach(x->{
|
|
|
+ customerSource.forEach(tag ->{
|
|
|
+ if (tag.getDictValue().equals(x)){
|
|
|
+ sources.add(tag.getDictKey());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ customer.setSource(String.join(",",sources));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //客户规模
|
|
|
+ customer.setScaleId(vo.getScaleId());
|
|
|
+ //客户状态
|
|
|
+ if (StringUtils.isNotEmpty(vo.getTrailStatus())){
|
|
|
+ AtomicReference<String> status = new AtomicReference<>("");
|
|
|
+ List<DictTenantDataVo> customerSource = DictUtils.getDictList("customer_status");
|
|
|
+ customerSource.forEach(tag ->{
|
|
|
+ if (tag.getDictValue().equals(vo.getTrailStatus())){
|
|
|
+ status.set(tag.getDictKey());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ customer.setStatus(String.valueOf(status));
|
|
|
+ }
|
|
|
+
|
|
|
+ //公司网址
|
|
|
+ customer.setHomepage(vo.getHomepage());
|
|
|
+ //小满传真
|
|
|
+ customer.setFax(vo.getFax());
|
|
|
+ //小满电话区号
|
|
|
+ customer.setTelAreaCode(vo.getTelAreaCode());
|
|
|
+ //小满电话
|
|
|
+ customer.setTel(vo.getTel());
|
|
|
+ //小满备注
|
|
|
+ customer.setRemark(vo.getRemark());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void initAllList() {
|
|
|
xiaomanApiService.initAllList();
|