فهرست منبع

修复侧边栏

cgp 1 هفته پیش
والد
کامیت
ad4d4ccb8b

+ 1 - 1
fs-service/src/main/java/com/fs/feishu/service/FeishuDocApiService.java

@@ -76,7 +76,7 @@ public class FeishuDocApiService {
                                 .index(0)
                                 .children(new Block[]{
                                         Block.newBuilder()
-                                                .blockType(3)
+                                                .blockType(2)
                                                 .text(Text.newBuilder()
                                                         .elements(new TextElement[]{
                                                                 TextElement.newBuilder()

+ 1 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/WxH5MpScrmController.java

@@ -162,4 +162,5 @@ public class WxH5MpScrmController {
         }
     }
 
+
 }

+ 107 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/WxH5NewController.java

@@ -0,0 +1,107 @@
+package com.fs.app.controller.store;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import cn.hutool.core.date.DateTime;
+import com.fs.app.annotation.UserOperationLog;
+import com.fs.app.param.FsUserLoginByCourseMpParam;
+import com.fs.app.param.FsUserLoginByMpParam;
+import com.fs.app.utils.JwtUtils;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.company.domain.Company;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyService;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.core.config.WxMaConfiguration;
+import com.fs.course.domain.FsUserCompanyUser;
+import com.fs.course.mapper.FsCourseWatchLogMapper;
+import com.fs.course.service.IFsUserCompanyUserService;
+import com.fs.his.domain.FsUser;
+import com.fs.his.domain.FsUserWx;
+import com.fs.his.enums.FsUserOperationEnum;
+import com.fs.his.service.IFsUserService;
+import com.fs.his.service.IFsUserWxService;
+import com.fs.qw.mapper.QwExternalContactMapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
+import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.mp.api.WxMpService;
+import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.C;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+@Api("会员-h5-微信相关接口")
+@RestController
+@RequestMapping("/store/app/wx/h5/mp")
+@Slf4j
+public class WxH5NewController {
+
+    @Autowired
+    private IFsUserService userService;
+
+    @Autowired
+    JwtUtils jwtUtils;
+    @Autowired
+    RedisCache redisCache;
+
+    @Autowired
+    FsCourseWatchLogMapper fsCourseWatchLogMapper;
+    @Autowired
+    QwExternalContactMapper qwExternalContactMapper;
+    @Autowired
+    ICompanyService companyService;
+    @Autowired
+    ICompanyUserService companyUserService;
+    @Autowired
+    private IFsUserWxService fsUserWxService;
+
+    @ApiOperation("处理用户与小程序的绑定")
+    @PostMapping("/handleFsUserWx")
+    public R handleFsUserWx(@RequestBody FsUserLoginByMpParam param) {
+        try {
+            final WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
+            //获取微信用户信息
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+
+            FsUser user = userService.selectFsUserById(param.getUserId());
+            handleFsUserWx(user, param, session);
+            return R.ok();
+        } catch (WxErrorException e) {
+            if (e.getError().getErrorCode() == 40163) {
+                return R.error(40163, e.getError().getErrorMsg());
+            } else {
+                return R.error("获取用户信息失败," + e.getMessage());
+            }
+        }
+    }
+    private void handleFsUserWx(FsUser user, FsUserLoginByMpParam param, WxMaJscode2SessionResult session) {
+        if (user == null) return;
+        FsUserWx fsUserWx = new FsUserWx();
+        fsUserWx.setType(1);
+        fsUserWx.setFsUserId(user.getUserId());
+        fsUserWx.setAppId(param.getAppId());
+        fsUserWx.setOpenId(session.getOpenid());
+        fsUserWx.setUnionId(session.getUnionid() != null ? session.getUnionid() : null);
+        fsUserWx.setCreateTime(new Date());
+        fsUserWx.setUpdateTime(new Date());
+        fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
+    }
+
+}