Ver código fonte

fix 推广分销id不展示真实id

zoujiajian 3 anos atrás
pai
commit
6941bb54e2

+ 2 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -83,4 +83,6 @@ public interface Constant {
 	List<Long> CHAT_GPT_SKU_IDS = List.of(161l, 178l);
 
 	List<Long> MIDJOURNEY_SKU_IDS = List.of(175l, 185l, 186l);
+
+	Long HEX_NUMBER = 1718769l;
 }

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

@@ -23,6 +23,11 @@ public class AuthRedirect {
      */
     private Long sharedId;
 
+    /**
+     * 分销16进制码
+     */
+    private String sCode;
+
     /**
      * corpId
      */

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/GzhBodyDto.java

@@ -19,6 +19,11 @@ public class GzhBodyDto {
 	 */
 	private Long sharedId;
 
+	/**
+	 * 分销16进制码
+	 */
+	private String sCode;
+
 	/**
 	 * 推广id
 	 */

+ 4 - 2
netflix-dao/src/main/java/com/cyksj/model/dto/UserWhoami.java

@@ -5,7 +5,6 @@ import lombok.Setter;
 import lombok.experimental.Accessors;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 
 /**
  *
@@ -29,5 +28,8 @@ public class UserWhoami implements Serializable {
      */
     private String headimgurl;
 
-
+    /**
+     * 分销16进制码
+     */
+    private String sCode;
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/request/LoginPhoneReq.java

@@ -29,6 +29,11 @@ public class LoginPhoneReq {
 	 */
 	private Long sharedId;
 
+	/**
+	 * 分销16进制code
+	 */
+	private String sCode;
+
 	/**
 	 * 1短信登录、2邮箱登录
 	 */

+ 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, Integer dsType, Long pid);
+    User saveAuth(GzhOAuth2UserInfo userinfo, Long sharedId, String sCode, Integer dsType, Long pid);
 
     UserWhoami whoami(long userId);
 

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

@@ -63,7 +63,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 	private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
 	@Override
-    public User saveAuth(GzhOAuth2UserInfo info, Long sharedId, Integer dsType, Long pid) {
+	public User saveAuth(GzhOAuth2UserInfo info, Long sharedId, String sCode, Integer dsType, Long pid) {
         final String unionid = info.getUnionid();
         if (StrUtil.isEmpty(unionid)) {
             throw BusinessRuntimeException.getInstance("授权操作异常,请刷新页面");
@@ -110,6 +110,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		} else {
 			this.updateById(user);
 		}
+		if (sharedId == null && StrUtil.isNotBlank(sCode)) {
+			try {
+				sharedId = Long.parseLong(sCode, 16) - Constant.HEX_NUMBER;
+			} catch (NumberFormatException e) {
+				log.error("用户userId:{},进制sCode:{}转化错误", user.getId(), sCode);
+			}
+		}
 		if (sharedId != null && isNewUser) {
 			if (dsType == null || dsType == 1) {
 				distributeService.saveDistributionInvitation(sharedId, user.getId());
@@ -135,7 +142,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         UserWhoami userWhoami = new UserWhoami();
 
         BeanUtil.copyProperties(user, userWhoami);
-
+	    String sCode = Long.toHexString(user.getId() + Constant.HEX_NUMBER);
+	    userWhoami.setSCode(sCode);
         return userWhoami;
     }
 

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/wechat/WeChatService.java

@@ -77,7 +77,7 @@ public interface WeChatService {
      * 获取公众号带参数的临时二维码
      * @return
      */
-    WxGzhQrCodeTicketRep getWxGzhQrCode(Long sharedId, Integer dsType, Long popularizeId) throws Exception;
+    WxGzhQrCodeTicketRep getWxGzhQrCode(Long sharedId, String sCode, Integer dsType, Long popularizeId) throws Exception;
 
     /**
      * 获取公众号带参数的永久二维码

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/wechat/impl/WeChatServiceImpl.java

@@ -476,7 +476,7 @@ public class WeChatServiceImpl implements WeChatService {
     }
 
     @Override
-    public WxGzhQrCodeTicketRep getWxGzhQrCode(Long sharedId, Integer dsType, Long popularizeId) throws Exception {
+    public WxGzhQrCodeTicketRep getWxGzhQrCode(Long sharedId, String sCode, Integer dsType, Long popularizeId) throws Exception {
         String gzhQrCodeUrl = String.format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s", this.getAccessToken());
         //scene_str:场景值ID(字符串形式的ID),字符串类型,长度限制为1到64
         String scene_str = RandomUtil.randomString(16);
@@ -496,6 +496,7 @@ public class WeChatServiceImpl implements WeChatService {
         if (sharedId != null || popularizeId != null) {
             GzhBodyDto gzhBodyDto = new GzhBodyDto()
                     .setSharedId(sharedId)
+                    .setSCode(sCode)
                     .setPopularizeId(popularizeId)
                     .setDsType(dsType);
             String state = Codec.DoBase64.custom().setData(Jsons.toJson(gzhBodyDto)).encodeAsText();

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

@@ -94,7 +94,7 @@ public class AuthorizationController {
     private final EquipmentDistributeService equipDistributeService;
 
     @GetMapping(value = "/weChat")
-    public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, HttpServletResponse response) throws Exception {
+    public void base(String url, Long sharedId, String sCode, Integer dsType, Long popularizeId, String authType, HttpServletResponse response) throws Exception {
 
         log.info("微信授权转跳. url: {},authType:{}",url,authType);
 
@@ -104,7 +104,7 @@ public class AuthorizationController {
 
         Long mappingId = SEQUENCE.nextId();
         redisService.set(mappingId.toString(),url,60*60*24L);
-        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId);
+        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setSCode(sCode).setDsType(dsType).setPid(popularizeId);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 
         response.sendRedirect(authorizationService.createUrl(state,authType));
@@ -130,7 +130,7 @@ public class AuthorizationController {
         GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
 
         //保存用户信息
-        User user = userService.saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid());
+        User user = userService.saveAuth(userinfo, re.getSharedId(), re.getSCode(), re.getDsType(), re.getPid());
         if (user == null) {
             throw BusinessRuntimeException.getInstance("系统错误,请重新授权");
         }
@@ -253,9 +253,9 @@ public class AuthorizationController {
      * 网页扫描微信公众号二维码 临时凭证ticket  关注后登录
      */
     @GetMapping("/wx/gzh/login/qrCode")
-    public Result<WxGzhQrCodeTicketRep> getWxGzhQrCode(Long sharedId, Integer dsType, Long popularizeId) throws Exception {
+    public Result<WxGzhQrCodeTicketRep> getWxGzhQrCode(Long sharedId, String sCode, Integer dsType, Long popularizeId) throws Exception {
         //获取gzh带参数的二维码
-        WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode(sharedId, dsType, popularizeId);
+        WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode(sharedId, sCode, dsType, popularizeId);
         return GatewayResponse.SUCCESS.newBuilder().toResult(result);
     }
 
@@ -406,6 +406,9 @@ public class AuthorizationController {
             //默认头像
             user.setHeadimgurl(Constant.DEFAULT_HEAD_IMG);
             userService.save(user);
+            if (sharedId == null && StrUtil.isNotBlank(loginPhoneReq.getSCode())) {
+                sharedId = Long.parseLong(loginPhoneReq.getSCode(), 16) - Constant.HEX_NUMBER;
+            }
             //新用户分销
             if (sharedId != null) {
                 distributeService.saveDistributionInvitation(sharedId, user.getId());

+ 4 - 6
netflix-web/src/main/java/com/cyksj/web/controller/user/DistributePopularizeController.java

@@ -10,6 +10,7 @@ import com.alipay.api.AlipayResponse;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.EnvCommonService;
 import com.cyksj.common.annotation.NoSubmit;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
@@ -24,12 +25,8 @@ import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.ApplyMoneyReq;
 import com.cyksj.model.request.TransferAccountsReq;
-import com.cyksj.model.views.DistributeMoneyApplyView;
-import com.cyksj.model.views.DistributePopularizeOrdersView;
-import com.cyksj.model.views.DistributePopularizeView;
-import com.cyksj.model.views.UserDistributeView;
-import com.cyksj.service.order.OrderDonService;
 import com.cyksj.model.views.*;
+import com.cyksj.service.order.OrderDonService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -123,11 +120,12 @@ public class DistributePopularizeController {
 	@GetMapping("/get/detail")
 	public Result<DistributePopularizeView> getDetail() {
 		Long userId = StpUserUtil.getLoginIdAsLong();
+		String hexUserId = Long.toHexString(userId + Constant.HEX_NUMBER);
 		DistributePopularizeView distributePopularizeView = new DistributePopularizeView();
 		String domain = envCommonService.getHost();
 		String domainSub = domain.substring(0, domain.indexOf("8081"));
 //		distributePopularizeView.setUrl(String.format("https://%s/8081/api/auth/weChat?url=https://%s/yinhe/web&sharedId=%s", domain, domain, userId));
-		distributePopularizeView.setUrl(String.format("%syinhe/web?sharedId=%s", domainSub, userId));
+		distributePopularizeView.setUrl(String.format("%syinhe/web?sharedId=%s", domainSub, hexUserId));
 		distributePopularizeView.setUrlCode(QrCodeUtil.generateAsBase64(distributePopularizeView.getUrl(), QrConfig.create(), "png"));
 		User user = userMapper.selectById(userId);
 		distributePopularizeView.setGotPoints(user.getPoints());