Browse Source

fix : 客服系统功能提交08

bilingfeng 1 year ago
parent
commit
f451e61498

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <客服系统07> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <客服系统08> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 3 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/KfMsgController.java

@@ -31,12 +31,12 @@ public class KfMsgController {
     @Autowired
     private IKfMsgContentService kfMsgContentService;
 
-    @ApiOperation(value = "图片上传")
+    @ApiOperation(value = "发送图片消息 (参数按照发送消息的参数给, 外加图片文件)")
     @PostMapping(value = "/upload/msg")
     @PreAuthorize(permissionKey = "manage:kf:uploadMsg")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = String.class)})
-    public ResultVO<String> uploadMsg(MultipartFile files) {
-        return ResultVO.ok(kfMsgContentService.uploadMsg(files));
+    public ResultVO<String> uploadMsg(@Validated @RequestBody KfApiParam param, MultipartFile files) {
+        return ResultVO.ok(kfMsgContentService.uploadMsg(param, files));
     }
 
     @ApiOperation(value = "小游戏列表查询")

+ 3 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IKfMsgContentService.java

@@ -18,10 +18,11 @@ public interface IKfMsgContentService extends IService<KfMsgContent> {
     /**
      * 消息上传
      *
+     * @param param : 接口参数
      * @param files : 文件
-     * @return
+     * @return : 返回发送结果
      */
-    String uploadMsg(MultipartFile files);
+    String uploadMsg(KfApiParam param, MultipartFile files);
 
     /**
      * 获取游戏列表

+ 17 - 4
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/KfMsgContentServiceImpl.java

@@ -61,16 +61,30 @@ public class KfMsgContentServiceImpl extends ServiceImpl<KfMsgContentMapper, KfM
     private IGameAppletService gameAppletService;
 
     @Override
-    public String uploadMsg(MultipartFile files) {
+    public String uploadMsg(KfApiParam param, MultipartFile files) {
+        log.error("发送图片消息参数, param : {}", JsonUtil.toString(param));
+        //查询用户授权信息
+        KfUser kfUser = kfUserService.getKfUser(SecurityUtil.getUserId(), param.getAppId());
+        //图片上传腾讯
+        String uploadResult = this.imgUploadApi(kfUser, files);
+        //发送客服消息
+        Map<String, Object> paramMap = param.getParam();
+        paramMap.put("msg_content", uploadResult);
+        //腾讯api
+        return this.commKfApi(kfUser, param.getAction().getValue(), KfApiEnum.getApiUrl(param.getAction()), paramMap);
+    }
+
+    private String imgUploadApi(KfUser kfUser, MultipartFile files) {
+        //请求地址
         URI uri = UriComponentsBuilder.fromHttpUrl(KfApiEnum.UPLOAD_MSG.getApiUrl())
                 .queryParam("action", KfActionEnum.UPLOAD_PIC_MSG.getValue())
-                .queryParam("token", 1825310116)
+                .queryParam("token", kfUser.getToken())
                 .queryParam("lang", "zh_CN")
                 .build().toUri();
         //最外层请求头
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
-        httpHeaders.add("cookie", "pgv_pvid=7470066620; source=2; sid=d1lubV9fQ3VTdDl6cWVUVkMzZkhydWpzTTIzWVVDSkFybzJ6eFNNMTlmXzV3VW5iMmtXQ3VTbzdWVEhMSDdRNjhXTDVYbGRubFAxdzRMdFpJcFBYaHNqQXdOSmJ2bGRIWllwZW93bkdGTXgyRUlTZDlhWXNrTE4wV3pXM09ONHBXQ1ZLNUNtdDE0M2RDbU85; openid=osgl56837eGXb_-MOIxsZwHANIjI; randInfo=CAESIBpschlnORBlE1gRjg+3dTdv3FP6VJR/H6BxqeN33eiA; account=3950578098; sessionType=10; clientIp=61.174.155.242; userAgent=; scene=2; SL_G_WPT_TO=zh; SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; _clck=14m1amj|1|fh5|0; mm_lang=zh_CN");
+        httpHeaders.add("cookie", kfUser.getCookie());
         LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
         //文件内容请求头
         HttpHeaders formHeader = new HttpHeaders();
@@ -121,7 +135,6 @@ public class KfMsgContentServiceImpl extends ServiceImpl<KfMsgContentMapper, KfM
 
     @Override
     public String kfApi(KfApiParam param) {
-        log.error("请求参数, param : {}", JsonUtil.toString(param));
         //查询用户授权信息
         KfUser kfUser = kfUserService.getKfUser(SecurityUtil.getUserId(), param.getAppId());
         //请求调用腾讯接口