Эх сурвалжийг харах

fix: 纷享销客派单根据userId获取用户信息

caozixuan 1 жил өмнө
parent
commit
16c58a21f3

+ 9 - 4
sop-api/src/main/java/com/qmth/sop/server/api/FxxkAsyncController.java

@@ -11,10 +11,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 
@@ -55,6 +52,14 @@ public class FxxkAsyncController {
         return ResultUtil.ok(fxxkApiUtils.findCurrentOpenUserId());
     }
 
+    @ApiOperation(value = "纷享销客-查询单个用户信息")
+    @ApiResponses({@ApiResponse(code = 200, message = "成功", response = Result.class)})
+    @RequestMapping(value = "/find/user_info", method = RequestMethod.POST)
+    @Aac(auth = false)
+    public Result findUserInfo(@RequestParam String userId) {
+        return ResultUtil.ok(fxxkApiUtils.findFxxkUserById(userId));
+    }
+
     @ApiOperation(value = "纷享销客-查询自定义对象列表")
     @ApiResponses({@ApiResponse(code = 200, message = "成功", response = Result.class)})
     @RequestMapping(value = "/find/custom_list", method = RequestMethod.POST)

+ 67 - 2
sop-business/src/main/java/com/qmth/sop/business/sync/FxxkApiUtils.java

@@ -1,12 +1,12 @@
 package com.qmth.sop.business.sync;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.qmth.sop.business.service.SysConfigService;
 import com.qmth.sop.business.sync.been.fxxk.FxxkAppAuthInfo;
 import com.qmth.sop.business.sync.been.fxxk.FxxkAppAuthResult;
 import com.qmth.sop.business.sync.been.fxxk.FxxkCrm;
+import com.qmth.sop.business.sync.been.fxxk.FxxkUser;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.ProductTypeEnum;
@@ -117,6 +117,72 @@ public class FxxkApiUtils {
         }
     }
 
+    /**
+     * 根据id获取纷享销客用户信息
+     *
+     * @param userId userId
+     * @return 纷享销客用户信息
+     */
+    public FxxkUser findFxxkUserById(String userId) {
+        final String apiName = "PersonnelObj";
+        String postUrl = sysConfigService.findByConfigKey(SystemConstant.FXXK_USER_QUERY_URL).getConfigValue();
+        try {
+            FxxkAppAuthInfo fxxkAppAuthInfo = this.findFxxkAppAuthInfo();
+            String corpAccessToken = fxxkAppAuthInfo.getCorpAccessToken();
+            String corpId = fxxkAppAuthInfo.getCorpId();
+
+            Map<String, Object> map = new HashMap<>();
+            map.put("corpAccessToken", commonUtils.validParam(corpAccessToken, null, true, "企业应用访问公司合法性凭证"));
+            map.put("corpId", commonUtils.validParam(corpId, null, true, "开放平台公司帐号"));
+            map.put("currentOpenUserId", commonUtils.validParam(fxxkCurrenOpenUserId, null, true, "当前操作人OpenUserID"));
+
+            Map<String, Object> dataMap = new HashMap<>();
+            dataMap.put("dataObjectApiName", apiName);
+
+            Map<String, Object> queryMap = new HashMap<>();
+            queryMap.put("offset", 0.0);
+            queryMap.put("limit", 1);
+
+            // 查询
+            List<Map<String, Object>> filterMapList = new ArrayList<>();
+            // 查询条件1 : 派单状态为正常的
+            Map<String, Object> filterMap1 = new HashMap<>();
+            filterMap1.put("field_name", "user_id");
+            List<String> fieldValues = new ArrayList<>();
+            fieldValues.add(userId);
+            filterMap1.put("field_values", fieldValues);
+            filterMap1.put("operator", "EQ");
+            filterMapList.add(filterMap1);
+            queryMap.put("filters", filterMapList);
+            dataMap.put("search_query_info", queryMap);
+            map.put("data", dataMap);
+
+            String requestJson = JacksonUtil.parseJson(map);
+
+            String result = HttpUtil.postJson(postUrl, requestJson, null, null, false);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            Long errorCode = jsonObject.getLong("errorCode");
+            String errorMessage = jsonObject.getString("errorMessage");
+            if (errorCode != 0) {
+                throw ExceptionResultEnum.ERROR.exception("获取自定义对象列表失败 : " + errorMessage);
+            }
+            JSONObject data = jsonObject.getJSONObject("data");
+            JSONArray dataList = data.getJSONArray("dataList");
+            JSONObject cell = dataList.getJSONObject(0);
+            String fullName = cell.getString("full_name");
+            String phone = cell.getString("phone");
+            String id = cell.getString("user_id");
+
+            FxxkUser fxxkUser = new FxxkUser();
+            fxxkUser.setId(id);
+            fxxkUser.setFullName(fullName);
+            fxxkUser.setPhone(phone);
+            return fxxkUser;
+        } catch (Exception e) {
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
+        }
+    }
+
     /**
      * 查询自定义对象列表
      */
@@ -193,7 +259,6 @@ public class FxxkApiUtils {
             }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONArray dataList = data.getJSONArray("dataList");
-            System.out.println(JSON.toJSONString(dataList));
 
             List<FxxkCrm> fxxkCrmList = new ArrayList<>();
             for (int i = 0; i < dataList.size(); i++) {

+ 44 - 0
sop-business/src/main/java/com/qmth/sop/business/sync/been/fxxk/FxxkUser.java

@@ -0,0 +1,44 @@
+package com.qmth.sop.business.sync.been.fxxk;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 分享逍客用户信息
+ * @Author: CaoZixuan
+ * @Date: 2023-11-28
+ */
+public class FxxkUser {
+
+    @ApiModelProperty("id")
+    private String id;
+
+    @ApiModelProperty("全名")
+    private String fullName;
+
+    @ApiModelProperty("电话")
+    private String phone;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getFullName() {
+        return fullName;
+    }
+
+    public void setFullName(String fullName) {
+        this.fullName = fullName;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+}

+ 4 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -421,4 +421,7 @@ ALTER TABLE t_b_user_archives_allocation
 ;
 ALTER TABLE t_b_user_archives_supplier
     ADD UNIQUE INDEX t_b_user_archives_supplier_un (user_archives_id, supplier_id);
-;
+;
+
+-- 2023-11-28
+INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('37', 'fxxk.user.query.url', '纷享销客查询人员对象的列表', 'https://open.fxiaoke.com/cgi/crm/v2/data/query', '1', '1', '1');

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -210,6 +210,7 @@ public class SystemConstant {
     public static final String FXXK_APP_AUTH_URL = "fxxk.app.auth.url";
     public static final String FXXK_USER_BY_MOBILE_URL = "fxxk.user.by.mobile.url";
     public static final String FXXK_CUSTOM_QUERY_URL = "fxxk.custom.query.url";
+    public static final String FXXK_USER_QUERY_URL = "fxxk.user.query.url";
     public static final String RTZF_OSS_LOGIN_URL = "rtzf.oss.login.url";
 
     /**