|
@@ -125,11 +125,14 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
public void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList, Set<Long> allCustomer,boolean flag) {
|
|
|
List<XiaomanCustomer> xiaomanCustomerList = new ArrayList<>(customerApiVoList);
|
|
|
for (XiaomanCustomer customer : xiaomanCustomerList) {
|
|
|
+ if (customer.getCompanyId() == 18906983782932L){
|
|
|
if (allCustomer.contains(customer.getCompanyId())) {
|
|
|
processCustomer(customer, true,flag);
|
|
|
} else {
|
|
|
processCustomer(customer, false,flag);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -182,7 +185,7 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
|
|
|
//联系人
|
|
|
if (!vo.getCustomers().isEmpty()){
|
|
|
- List<CustomerInfoVo.Customer> newCistomer = new ArrayList<>();
|
|
|
+ List<CustomerInfoVo.Customer> newCistomer = new ArrayList<>();
|
|
|
vo.getCustomers().stream().collect(Collectors.groupingBy(CustomerInfoVo.Customer::getEmail)).forEach((k,v)->{
|
|
|
CustomerInfoVo.Customer customer1 = v.get(v.size() - 1);
|
|
|
newCistomer.add(customer1);
|
|
@@ -218,7 +221,7 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
|
|
|
|
|
|
}
|
|
|
- customer.setCountryName(vo.getCountryName());
|
|
|
+ customer.setXmCountryName(vo.getCountryName());
|
|
|
customerService.save(customer);
|
|
|
|
|
|
|
|
@@ -251,66 +254,109 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
extracted(vo, customer);
|
|
|
//联系人
|
|
|
if (!vo.getCustomers().isEmpty()){
|
|
|
- Map<String, CustomerUser> collect = customerUserService.lambdaQuery()
|
|
|
- .eq(CustomerUser::getCustomerId, customer.getId())
|
|
|
- .list().stream().collect(Collectors.toMap(CustomerUser::getEmail, Function.identity()));
|
|
|
- //1、小满客户的联系人email为空,不做同步
|
|
|
- //2、小满客户的联系人email与客户表联系人相匹配,以小满为主修改联系人信息
|
|
|
- //3、小满客户的联系人email与客户表联系人不匹配,以小满为主新增联系人信息
|
|
|
- for (CustomerInfoVo.Customer cus :vo.getCustomers()){
|
|
|
- if (StringUtils.isNotEmpty(cus.getEmail())){
|
|
|
- //如果email匹配成功新增 ,以小满为主修改客户信息
|
|
|
- if (collect.containsKey(cus.getEmail()) ){
|
|
|
- CustomerUser customerUser = collect.get(cus.getEmail());
|
|
|
- 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.updateById(customerUser);
|
|
|
- }else {
|
|
|
- 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{
|
|
|
+
|
|
|
+ //删除原有邮箱
|
|
|
+ customerUserService.lambdaUpdate()
|
|
|
+ .eq(CustomerUser::getCustomerId,customer.getId()).remove();
|
|
|
+
|
|
|
+ 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", "");
|
|
|
- map1.put("contactNo", "");
|
|
|
+ map1.put("type", contact.getType());
|
|
|
+ map1.put("contactNo", contact.getValue());
|
|
|
maps.add(map1);
|
|
|
}
|
|
|
- customerUser.setPhone(cus.getTel());
|
|
|
- customerUser.setContactJson(JSON.toJSONString(maps));
|
|
|
- customerUserService.save(customerUser);
|
|
|
-
|
|
|
- //新增后添加至map中
|
|
|
- collect.put(customerUser.getEmail(),customerUser);
|
|
|
+ } 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);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// Map<String, CustomerUser> collect = customerUserService.lambdaQuery()
|
|
|
+// .eq(CustomerUser::getCustomerId, customer.getId())
|
|
|
+// .list().stream().collect(Collectors.toMap(CustomerUser::getEmail, Function.identity()));
|
|
|
+// //用于匹配原有联系人是否存在
|
|
|
+// Set<String> stringSet = customerUserService.lambdaQuery()
|
|
|
+// .eq(CustomerUser::getCustomerId, customer.getId())
|
|
|
+// .list().stream().map(CustomerUser::getEmail).collect(Collectors.toSet());
|
|
|
+ //1、小满客户的联系人email为空,不做同步
|
|
|
+ //2、小满客户的联系人email与客户表联系人相匹配,以小满为主修改联系人信息
|
|
|
+ //3、小满客户的联系人email与客户表联系人不匹配,以小满为主新增联系人信息
|
|
|
+
|
|
|
+// for (CustomerInfoVo.Customer cus :vo.getCustomers()){
|
|
|
+// if (StringUtils.isNotEmpty(cus.getEmail())){
|
|
|
+// //如果email匹配成功新增 ,以小满为主修改客户信息
|
|
|
+// if (collect.containsKey(cus.getEmail()) ){
|
|
|
+// CustomerUser customerUser = collect.get(cus.getEmail());
|
|
|
+// 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.updateById(customerUser);
|
|
|
+//
|
|
|
+// stringSet.remove(cus.getEmail());
|
|
|
+// }else {
|
|
|
+// 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);
|
|
|
+//
|
|
|
+// //新增后添加至map中
|
|
|
+// collect.put(customerUser.getEmail(),customerUser);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //如果原有数据未匹配删除数据
|
|
|
+// if (!stringSet.isEmpty()){
|
|
|
+// customerUserService.lambdaUpdate().in(CustomerUser::getEmail,stringSet)
|
|
|
+// .eq(CustomerUser::getCustomerId,customer.getId()).remove();
|
|
|
+// }
|
|
|
}
|
|
|
- customer.setCountryName(vo.getCountryName());
|
|
|
+ customer.setXmCountryName(vo.getCountryName());
|
|
|
customerService.updateById(customer);
|
|
|
}
|
|
|
}
|