dcs преди 1 месец
родител
ревизия
c619ced24c

+ 14 - 4
virgo.core/src/main/java/com/bosshand/virgo/core/controller/CustomerController.java

@@ -1,5 +1,6 @@
 package com.bosshand.virgo.core.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.core.model.Customer;
 import com.bosshand.virgo.core.response.Response;
 import com.bosshand.virgo.core.service.CustomerService;
@@ -54,11 +55,20 @@ public class CustomerController {
     @ApiOperation("更新")
     @RequestMapping(value = "", method = RequestMethod.PUT)
     public Response update(@RequestBody Customer customer) {
-        Customer c = customerService.getOrganizationId(customer.getOrganizationId(), customer.getUserId());
-        if(c != null){
-            return Response.fail(20000, "组织下已经指定过该用户为客服了");
+        JSONObject js = new JSONObject();
+        if (customer.getNickName() != null) {
+            js.put("nickname", customer.getNickName());
         }
-        customerService.update(customer);
+        if (customer.getAvatarUrl() != null) {
+            js.put("avatarUrl", customer.getAvatarUrl());
+        }
+        if (js.size() == 0) {
+            Customer c = customerService.getOrganizationId(customer.getOrganizationId(), customer.getUserId());
+            if (c != null) {
+                return Response.fail(20000, "组织下已经指定过该用户为客服了");
+            }
+        }
+        customerService.update(customer, js);
         return Response.ok();
     }
 

+ 1 - 8
virgo.core/src/main/java/com/bosshand/virgo/core/service/CustomerService.java

@@ -54,15 +54,8 @@ public class CustomerService {
     /**
      * 指定用户为客服
      */
-    public int update(Customer customer) {
+    public int update(Customer customer, JSONObject js) {
         Customer c = customerDao.get(customer.getId());
-        JSONObject js = new JSONObject();
-        if (customer.getNickName() != null) {
-            js.put("nickname", customer.getNickName());
-        }
-        if (customer.getAvatarUrl() != null) {
-            js.put("avatarUrl", customer.getAvatarUrl());
-        }
         if (js.size() != 0) {
             String str = WeChatUtil.httpPost("https://www.waywish.com/im/user/update", js, getToken(c.getCustomerId()));
             log.info("updateCustomerChatUser=" + str);