zoujiajian 1 year ago
parent
commit
54d1f182d7

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

@@ -83,4 +83,10 @@ public class AuthRedirect {
      * 1.主动 2.被邀请用户
      */
     private Integer cst;
+
+    /**
+     * 店铺类型
+     * 1.普通店铺(默认) 2.镜像店铺
+     */
+    private Integer cmt = 1;
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/shop/YhShopDistributeService.java

@@ -20,5 +20,5 @@ public interface YhShopDistributeService {
 	/**
 	 * 店铺分销 用户关系记录
 	 */
-	void saveDistributionInvitation(String customId, Long userId);
+	void saveDistributionInvitation(String customId, Long userId, Integer cmt);
 }

+ 21 - 1
netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopDistributeServiceImpl.java

@@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopUserDistributeSharedMapper;
 import com.cyksj.mapper.shop.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.service.distribute.UserBusinessFrontService;
@@ -41,6 +43,10 @@ public class YhShopDistributeServiceImpl implements YhShopDistributeService {
 	private final GoodsDonMapper goodsDonMapper;
 
 	private final UserDistributeSharedMapper userDistributeSharedMapper;
+
+	private final UserMirrorShopMapper userMirrorShopMapper;
+
+	private final UserMirrorShopUserDistributeSharedMapper userMirrorShopUserDistributeSharedMapper;
 	@Override
 	public void distributeWaitingSendPointsRecord(OrderDon order) {
 		BigDecimal orderMoney = order.getMoney();
@@ -159,8 +165,22 @@ public class YhShopDistributeServiceImpl implements YhShopDistributeService {
 	}
 
 	@Override
-	public void saveDistributionInvitation(String customId, Long userId) {
+	public void saveDistributionInvitation(String customId, Long userId, Integer cmt) {
 		customId = customId.trim();
+		if (cmt != null && cmt == 2) {
+			UserMirrorShop userMirrorShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+					.eq(UserMirrorShop::getCustomId, customId)
+					.last("limit 1"));
+			if (userMirrorShop != null && userMirrorShop.getStatus()) {
+				log.info("用户镜像店铺shopUserId:{}新用户uid:{}注册关联上下级", userMirrorShop.getUserId(), userId);
+				UserMirrorShopUserDistributeShared shopUserDistributeShared = new UserMirrorShopUserDistributeShared();
+				shopUserDistributeShared.setShopUserId(userMirrorShop.getUserId());
+				shopUserDistributeShared.setUserId(userId);
+				userMirrorShopUserDistributeSharedMapper.insert(shopUserDistributeShared);
+			}
+			return;
+		}
+
 		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class).eq(YhShop::getCustomId, customId).last("limit 1"));
 		if (yhShop.getVerifyStatus() != YhShop.Status.success) {
 			return;

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

@@ -207,7 +207,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		}
 		//店铺注册用户 关联
 		if (isNewUser && StrUtil.isNotBlank(customId)) {
-			yhShopDistributeService.saveDistributionInvitation(customId, user.getId());
+			yhShopDistributeService.saveDistributionInvitation(customId, user.getId(), re.getCmt());
 		}
 		Long userId = user.getId();
 		if (isNewUser && pid != null) {
@@ -484,7 +484,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 			}
 			//店铺注册用户 关联
 			if (StrUtil.isNotBlank(customId)) {
-				yhShopDistributeService.saveDistributionInvitation(customId, user.getId());
+				yhShopDistributeService.saveDistributionInvitation(customId, user.getId(), loginReq.getCmt());
 			}
 			//缓存用户注册 回传信息
 			String callback = loginReq.getCallback();

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

@@ -94,8 +94,7 @@ public class AuthorizationController {
     private final TemplateCommonService templateCommonService;
 
     @GetMapping(value = "/weChat")
-    public void base(String url, String dsCode, Long sharedId, Integer dsType, Long popularizeId, String authType, String callbackType, String callback, String customId, Integer cst, HttpServletResponse response) throws Exception {
-
+    public void base(String url, String dsCode, Long sharedId, Integer dsType, Long popularizeId, String authType, String callbackType, String callback, String customId, Integer cst, Integer cmt, HttpServletResponse response) throws Exception {
         log.info("微信授权转跳. url: {},authType:{}", url, authType);
         if (StrUtil.isBlank(url)) {
             url = "https://nf.video/";
@@ -114,7 +113,8 @@ public class AuthorizationController {
                 .setCd(customId)
                 .setCk(callback)
                 .setCt(callbackType)
-                .setCst(cst);
+                .setCst(cst)
+                .setCmt(cmt);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 
         response.sendRedirect(authorizationService.createUrl(url, state, authType));