|
@@ -210,65 +210,69 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
|
|
|
.eq(CustomerUser::getCustomerId, customer.getId())
|
|
|
.list().stream().collect(Collectors.toMap(CustomerUser::getEmail, Function.identity()));
|
|
|
|
|
|
-
|
|
|
+ Set<String > str = new HashSet<>();
|
|
|
for (CustomerInfoVo.Customer cus :vo.getCustomers()){
|
|
|
-
|
|
|
- if (collect.containsKey(cus.getEmail())){
|
|
|
- List<Map> maps = new ArrayList<>();
|
|
|
- CustomerUser customerUser = collect.get(cus.getEmail());
|
|
|
- for (CustomerInfoVo.Contact contact: cus.getContact()){
|
|
|
- if (StringUtils.isNotEmpty(customerUser.getContactJson())){
|
|
|
+ if ( !str.contains(customer.getId()+"_"+ cus.getEmail())){
|
|
|
+
|
|
|
+ if (collect.containsKey(cus.getEmail()) ){
|
|
|
+ List<Map> maps = new ArrayList<>();
|
|
|
+ CustomerUser customerUser = collect.get(cus.getEmail());
|
|
|
+ if (StringUtils.isNotEmpty(customerUser.getContactJson())) {
|
|
|
maps = JSON.parseArray(customerUser.getContactJson(), Map.class);
|
|
|
- for (Map map:maps){
|
|
|
- if (!contact.getValue().equals(map.get("contactNo")) && !contact.getType().equals(map.get("type"))){
|
|
|
- Map map1 = new HashMap();
|
|
|
- map1.put("type",contact.getType());
|
|
|
- map1.put("contactNo",contact.getValue());
|
|
|
- maps.add(map1);
|
|
|
- }else {
|
|
|
- System.out.println();
|
|
|
+ }
|
|
|
+ for (CustomerInfoVo.Contact contact: cus.getContact()){
|
|
|
+ if (StringUtils.isNotEmpty(customerUser.getContactJson())){
|
|
|
+ for (Map map:maps){
|
|
|
+ if (!contact.getValue().equals(map.get("contactNo")) && !contact.getType().equals(map.get("type"))){
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("type",contact.getType());
|
|
|
+ map1.put("contactNo",contact.getValue());
|
|
|
+ maps.add(map1);
|
|
|
+ }else {
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ }else {
|
|
|
+ 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",contact.getType());
|
|
|
- map1.put("contactNo",contact.getValue());
|
|
|
- maps.add(map1);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- customerUser.setEmail(cus.getEmail());
|
|
|
- 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()) {
|
|
|
+ customerUser.setEmail(cus.getEmail());
|
|
|
+ customerUser.setContactJson(JSON.toJSONString(maps));
|
|
|
+ str.add(customer.getId()+"_"+ cus.getEmail());
|
|
|
+ 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{
|
|
|
Map map1 = new HashMap();
|
|
|
- map1.put("type", contact.getType());
|
|
|
- map1.put("contactNo", contact.getValue());
|
|
|
+ map1.put("type", "");
|
|
|
+ map1.put("contactNo", "");
|
|
|
maps.add(map1);
|
|
|
}
|
|
|
- }else{
|
|
|
- Map map1 = new HashMap();
|
|
|
- map1.put("type", "");
|
|
|
- map1.put("contactNo", "");
|
|
|
- maps.add(map1);
|
|
|
- }
|
|
|
|
|
|
- customerUser.setContactJson(JSON.toJSONString(maps));
|
|
|
- customerUserService.save(customerUser);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ customerUser.setContactJson(JSON.toJSONString(maps));
|
|
|
|
|
|
+ str.add(customer.getId()+"_"+ cus.getEmail());
|
|
|
+ customerUserService.save(customerUser);
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|