瀏覽代碼

fix 微信内打开推广链接记录新用户人数

zoujiajian 3 年之前
父節點
當前提交
be903ec1de

+ 10 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/AuthRedirect.java

@@ -26,4 +26,14 @@ public class AuthRedirect {
      */
     private String corpId;
 
+    /**
+     * 1、虚物,2、实物
+     */
+    private Integer dsType;
+
+    /**
+     * 推广id
+     */
+    private Long pid;
+
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/user/UserService.java

@@ -12,7 +12,7 @@ import com.cyksj.model.entity.WxSyncLog;
  */
 public interface UserService extends IService<User> {
 
-    User saveAuth(GzhOAuth2UserInfo userinfo, Long sharedId);
+    User saveAuth(GzhOAuth2UserInfo userinfo, Long sharedId, Integer dsType, Long pid);
 
     UserWhoami whoami(long userId);
 

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java

@@ -41,7 +41,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     private final DistributeService distributeService;
 
     @Override
-    public User saveAuth(GzhOAuth2UserInfo info, Long sharedId) {
+    public User saveAuth(GzhOAuth2UserInfo info, Long sharedId, Integer dsType, Long pid) {
         final String unionid = info.getUnionid();
         if (StrUtil.isEmpty(unionid)) {
             throw BusinessRuntimeException.getInstance("授权操作异常,请刷新页面");
@@ -80,6 +80,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         Boolean isNewUser = false;
         if (user.getId() == null) {
             isNewUser = true;
+            user.setPopularizeId(pid);
         }
         this.saveOrUpdate(user);
         if (sharedId != null && isNewUser) {

+ 3 - 3
netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

@@ -91,7 +91,7 @@ public class AuthorizationController {
     private final DistributeService distributeService;
 
     @GetMapping(value = "/weChat")
-    public void base(String url,Long sharedId, String authType, HttpServletResponse response) throws Exception {
+    public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, HttpServletResponse response) throws Exception {
 
         log.info("微信授权转跳. url: {},authType:{}",url,authType);
 
@@ -101,7 +101,7 @@ public class AuthorizationController {
 
         Long mappingId = SEQUENCE.nextId();
         redisService.set(mappingId.toString(),url,60*60*24L);
-        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId);
+        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 
         response.sendRedirect(authorizationService.createUrl(state,authType));
@@ -127,7 +127,7 @@ public class AuthorizationController {
         GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
 
         //保存用户信息
-        User user = userService.saveAuth(userinfo, re.getSharedId());
+        User user = userService.saveAuth(userinfo, re.getSharedId(),re.getDsType(), re.getPid());
 
         //写回登陆信息
         StpUserUtil.login(user.getId());