Ver código fonte

客户修改

Guo1B0 11 meses atrás
pai
commit
f5c3e5d17a

+ 4 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Custom.java

@@ -110,6 +110,8 @@ public class Custom extends Model<Custom> {
      */
     @TableField("tel_phone")
     private String telPhone;
+    @TableField("contacts_name")
+    private String contactsName;
 
     /**
      * 传真
@@ -124,6 +126,8 @@ public class Custom extends Model<Custom> {
     private String countryBilling;
     @TableField(exist = false)
     private String userId;
+    @TableField(exist = false)
+    private List<Contacts> contacts;
 
     /**
      * 开单地址-省/市

+ 23 - 9
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java

@@ -126,6 +126,13 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
 //                msg.setError("电话号码重复了");
                 return msg;
             }
+
+            if (contactsMapper.selectCount(new QueryWrapper<Contacts>()
+                    .eq("contacts_name", custom.getContactsName())
+            ) == 0) {
+                msg.setError("此联系人不存在");
+                return msg;
+            }
             custom.setCreateTime(new Date());
             custom.setCreatorId(user.getId());
             custom.setIsDelete(0);
@@ -137,6 +144,11 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             actionLog.setItemId(custom.getId());
             actionLogMapper.insert(actionLog);
             customMapper.insert(custom);
+            Contacts contacts = contactsMapper.selectOne(new QueryWrapper<Contacts>().eq("name", custom.getCustomName()).eq("phone", custom.getTelPhone()));
+            if (contacts != null){
+                contacts.setCustomId(custom.getId());
+                contactsMapper.update(contacts,new UpdateWrapper<Contacts>().eq("id",contacts.getId()));
+            }
         }
         msg.setMsg("操作成功");
         return msg;
@@ -207,15 +219,17 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         custom1.setBusinessOpportunitys(businessOpportunityMapper.selectList(new QueryWrapper<BusinessOpportunity>().eq("customer_id",custom1.getId())));
         //操作记录
         custom1.setActionLogs(actionLogMapper.selectList(new QueryWrapper<ActionLog>().eq("code","custom").eq("item_id",custom1.getId())));
-        List<CustomItemContacts> contacts = customItemContactsMapper.selectList(new QueryWrapper<CustomItemContacts>().eq("contacts_id", custom1.getId()));
-        List<Integer> ids = new ArrayList<>();
-        for (CustomItemContacts contact : contacts) {
-            ids.add(contact.getCustomId());
-        }
-        if (ids.size() > 0){
-            List<Contacts> cs = contactsMapper.selectListByIds(ids);
-            custom1.setContactsList(cs);
-        }
+//        List<CustomItemContacts> contacts = customItemContactsMapper.selectList(new QueryWrapper<CustomItemContacts>().eq("contacts_id", custom1.getId()));
+//        List<Integer> ids = new ArrayList<>();
+//        for (CustomItemContacts contact : contacts) {
+//            ids.add(contact.getCustomId());
+//        }
+//        if (ids.size() > 0){
+//            List<Contacts> cs = contactsMapper.selectListByIds(ids);
+//            custom1.setContactsList(cs);
+//        }
+        //联系人
+        custom1.setContacts(contactsMapper.selectList((new QueryWrapper<Contacts>().eq("custom_id",custom1.getId()))));
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         httpRespMsg.setData(custom1);
         return httpRespMsg;