Selaa lähdekoodia

add 统一网页微信登录

zoujiajian 2 vuotta sitten
vanhempi
sitoutus
e5cbcfc837
20 muutettua tiedostoa jossa 228 lisäystä ja 66 poistoa
  1. 10 0
      netflix-dao/src/main/java/com/cyksj/model/dto/AuthRedirect.java
  2. 4 4
      netflix-dao/src/main/java/com/cyksj/model/entity/YhShopUserPlatDistributeRate.java
  3. 2 2
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserBusinessDefaultRateConfigView.java
  4. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeBusinessRateRecordView.java
  5. 43 0
      netflix-service/src/main/java/com/cyksj/config/wxlogin/BaseWxOpenPlatConfig.java
  6. 24 0
      netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatEnum.java
  7. 38 0
      netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatFactory.java
  8. 7 29
      netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatYHLXLoginConfig.java
  9. 26 0
      netflix-service/src/main/java/com/cyksj/config/wxlogin/WxShopOpenPlatConfig.java
  10. 1 1
      netflix-service/src/main/java/com/cyksj/service/authorization/AuthorizationService.java
  11. 2 2
      netflix-service/src/main/java/com/cyksj/service/authorization/impl/AuthorizationServiceImpl.java
  12. 1 1
      netflix-service/src/main/java/com/cyksj/service/market/task/impl/BindTaskServiceImpl.java
  13. 1 7
      netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopServiceImpl.java
  14. 1 1
      netflix-service/src/main/java/com/cyksj/service/user/UserService.java
  15. 6 2
      netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java
  16. 1 1
      netflix-web/src/main/java/com/cyksj/web/controller/cps/CpsBackLoginController.java
  17. 4 4
      netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java
  18. 1 1
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/CmsYhShopGoodsController.java
  19. 1 1
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopLoginController.java
  20. 54 9
      netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

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

@@ -62,4 +62,14 @@ public class AuthRedirect {
      * 绑定邮箱
      */
     private String le;
+
+    /**
+     * appid
+     */
+    private String ap;
+
+    /**
+     * 店铺自定义id
+     */
+    private String cd;
 }

+ 4 - 4
netflix-dao/src/main/java/com/cyksj/model/entity/YhShopUserPlatDistributeRate.java

@@ -19,10 +19,10 @@ import java.util.Date;
  */
 @Getter
 @Setter
-@SearchBean(tables = "yh_shop_user_plat_distribute_rate ydr left join goods_don g on g.id = ydr.goods_id",
-		where = "g.status is true and g.deleted is true")
-public class YhShopUserPlatDistributeRate{
-	@TableId(value = "id",type = IdType.AUTO)
+@SearchBean(tables = "goods_don g left join yh_shop_user_plat_distribute_rate ydr on g.id = ydr.goods_id :uid:",
+		where = "g.type = 1 and g.status is true and g.deleted is true")
+public class YhShopUserPlatDistributeRate {
+	@TableId(value = "id", type = IdType.AUTO)
 	@DbField("ydr.id")
 	private Long id;
 

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserBusinessDefaultRateConfigView.java

@@ -13,8 +13,8 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "yh_shop_user_business_default_rate_config uc left join goods_don g on g.id = uc.goods_id"
-		, where = "g.deleted is true and g.status is true")
+@SearchBean(tables = "goods_don g left yh_shop_user_business_default_rate_config uc on g.id = uc.goods_id"
+		, where = "g.type = 1 and g.deleted is true and g.status is true")
 public class YhShopUserBusinessDefaultRateConfigView {
 	@DbField("uc.id")
 	private Long id;

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeBusinessRateRecordView.java

@@ -15,7 +15,7 @@ import lombok.Setter;
 @Setter
 @SearchBean(tables = "goods_don g left join goods_don_sku gdk on gdk.goods_id = g.id" +
 		" left join yh_shop_user_distribute_business_rate ur on ur.sku_id = gdk.id :business_id:",
-		where = "g.deleted is true and g.status is true")
+		where = "g.type = 1 and g.deleted is true and g.status is true")
 public class YhShopUserDistributeBusinessRateRecordView {
 	@DbField("ur.id")
 	private Long id;

+ 43 - 0
netflix-service/src/main/java/com/cyksj/config/wxlogin/BaseWxOpenPlatConfig.java

@@ -0,0 +1,43 @@
+package com.cyksj.config.wxlogin;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: BaseWxOpenPlatConfig
+ * 创建者: JavaZou
+ * 创建时间:2023/9/27 18:34
+ */
+@Getter
+@Setter
+public class BaseWxOpenPlatConfig {
+	/**
+	 * 应用唯一标识
+	 */
+	private String appId;
+
+	private String secret;
+
+	/**
+	 * 请使用 urlEncode 对链接进行处理
+	 */
+	private String redirectUri;
+
+	private String loginUrl;
+
+	private String cpsRedirectUri;
+
+	private String cpsLoginUrl;
+
+	private String yhShopRedirectUri;
+
+	private String yhShopLoginUrl;
+
+	/**
+	 * 绑定账号回调接口地址
+	 */
+	private String baRedirectUrl;
+
+	private String remark;
+}

+ 24 - 0
netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatEnum.java

@@ -0,0 +1,24 @@
+package com.cyksj.config.wxlogin;
+
+import lombok.Getter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: WxOpenPlatEnum
+ * 创建者: JavaZou
+ * 创建时间:2023/9/27 18:59
+ */
+@Getter
+public enum WxOpenPlatEnum {
+	shop("xx", "小店店铺"),
+	yh("wx7c5494c38c6a78bd", "银河官网"),
+	;
+	String appId;
+
+	String desc;
+
+	WxOpenPlatEnum(String appId, String desc) {
+		this.appId = appId;
+		this.desc = desc;
+	}
+}

+ 38 - 0
netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatFactory.java

@@ -0,0 +1,38 @@
+package com.cyksj.config.wxlogin;
+
+import com.cyksj.common.exception.BusinessRuntimeException;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: WxOpenPlatFactory
+ * 创建者: JavaZou
+ * 创建时间:2023/9/27 18:33
+ */
+public class WxOpenPlatFactory {
+
+	private static Map<String, BaseWxOpenPlatConfig> strategyBean = new ConcurrentHashMap<>();
+
+	/**
+	 * 初始化
+	 *
+	 * @param appId
+	 * @return
+	 */
+	public static BaseWxOpenPlatConfig getWeChatConfigStrategy(String appId) {
+		if (StringUtils.isEmpty(appId)) {
+			throw BusinessRuntimeException.getInstance("appid错误");
+		}
+		BaseWxOpenPlatConfig baseWeChatConfig = strategyBean.get(appId);
+		Objects.requireNonNull(baseWeChatConfig, "appid错误");
+		return baseWeChatConfig;
+	}
+
+	public static void add(BaseWxOpenPlatConfig baseWeChatConfig) {
+		strategyBean.put(baseWeChatConfig.getAppId(), baseWeChatConfig);
+	}
+}

+ 7 - 29
netflix-service/src/main/java/com/cyksj/config/wxlogin/WxOpenPlatYHLXLoginConfig.java

@@ -5,6 +5,8 @@ import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 
+import javax.annotation.PostConstruct;
+
 /*
  *项目名: netflix
  *文件名: WxOpenPlatYHLXLogin
@@ -16,33 +18,9 @@ import org.springframework.context.annotation.Configuration;
 @ConfigurationProperties(prefix = "wx-login")
 @Getter
 @Setter
-public class WxOpenPlatYHLXLoginConfig {
-	/**
-	 * 应用唯一标识
-	 */
-	private String appId;
-
-	private String secret;
-
-	/**
-	 * 请使用 urlEncode 对链接进行处理
-	 */
-	private String redirectUri;
-
-	private String loginUrl;
-
-	private String cpsRedirectUri;
-
-	private String cpsLoginUrl;
-
-	private String yhShopRedirectUri;
-
-	private String yhShopLoginUrl;
-
-	/**
-	 * 绑定账号回调接口地址
-	 */
-	private String baRedirectUrl;
-
-	private String remark;
+public class WxOpenPlatYHLXLoginConfig extends BaseWxOpenPlatConfig {
+	@PostConstruct
+	public void add() {
+		WxOpenPlatFactory.add(this);
+	}
 }

+ 26 - 0
netflix-service/src/main/java/com/cyksj/config/wxlogin/WxShopOpenPlatConfig.java

@@ -0,0 +1,26 @@
+package com.cyksj.config.wxlogin;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: WxShopOpenPlatConfig
+ * 创建者: JavaZou
+ * 创建时间:2023/9/27 18:36
+ */
+@Configuration
+@ConfigurationProperties(prefix = "wx-shop-login")
+@Getter
+@Setter
+public class WxShopOpenPlatConfig extends BaseWxOpenPlatConfig {
+
+	@PostConstruct
+	public void add() {
+		WxOpenPlatFactory.add(this);
+	}
+}

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/authorization/AuthorizationService.java

@@ -20,5 +20,5 @@ public interface AuthorizationService {
 
     JsSdkTicket getJsTicket(String appId, String url) throws Exception;
 
-    String createWxAuthLoginUrl(String state, String redirectUrl);
+    String createWxAuthLoginUrl(String state,String appId, String redirectUrl);
 }

+ 2 - 2
netflix-service/src/main/java/com/cyksj/service/authorization/impl/AuthorizationServiceImpl.java

@@ -62,8 +62,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
     }
 
     @Override
-    public String createWxAuthLoginUrl(String state, String redirectUrl) {
-        return weChatService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), URLEncoder.encode(redirectUrl, StandardCharsets.UTF_8));
+    public String createWxAuthLoginUrl(String state, String appId, String redirectUrl) {
+        return weChatService.createWxAuthLoginUrl(state, appId, URLEncoder.encode(redirectUrl, StandardCharsets.UTF_8));
     }
 
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/market/task/impl/BindTaskServiceImpl.java

@@ -337,7 +337,7 @@ public class BindTaskServiceImpl implements BindTaskService {
 			redisService.set(mappingId.toString(), returnUrl, 60 * 60 * 24L);
 			String redirectUrl = wxOpenPlatYHLXLoginConfig.getBaRedirectUrl();
 			String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
-			String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, redirectUrl);
+			String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), redirectUrl);
 			return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();

+ 1 - 7
netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopServiceImpl.java

@@ -118,15 +118,9 @@ public class YhShopServiceImpl implements YhShopFrontService {
 				throw BusinessRuntimeException.getInstance("该店铺id已存在");
 			}
 		}
-		//重置更新申请信息
-		yhShopMapper.update(null, Wrappers.lambdaUpdate(YhShop.class)
-				.set(YhShop::getVerifyStatus, YhShop.Status.verify)
-				.set(YhShop::getReason, null)
-				.set(YhShop::getName, name)
-				.set(YhShop::getCustomId, customId)
-				.eq(YhShop::getId, is_open.getId()));
 
 		try {
+			//重置更新申请信息
 			int update = yhShopMapper.update(null, Wrappers.lambdaUpdate(YhShop.class)
 					.eq(YhShop::getId, is_open.getId())
 					.eq(YhShop::getVerifyStatus, YhShop.Status.fail)

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

@@ -15,7 +15,7 @@ import java.util.List;
  */
 public interface UserService extends IService<User> {
 
-	User saveAuth(GzhOAuth2UserInfo userinfo, Long sharedId, Integer dsType, Long pid, User.RegisterEnv registerEnv, String dsCode, String callback, String callbackType) throws Exception;
+	User saveAuth(GzhOAuth2UserInfo userinfo, Long sharedId, Integer dsType, Long pid, User.RegisterEnv registerEnv, String dsCode, String callback, String callbackType, String customId) throws Exception;
 
     UserWhoami whoami(long userId);
 

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

@@ -82,7 +82,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, User.RegisterEnv registerEnv, String dsCode, String callback, String callbackType) throws Exception {
+	public User saveAuth(GzhOAuth2UserInfo info, Long sharedId, Integer dsType, Long pid, User.RegisterEnv registerEnv, String dsCode, String callback, String callbackType, String customId) throws Exception {
 		final String unionid = info.getUnionid();
 		if (StrUtil.isEmpty(unionid)) {
 			throw BusinessRuntimeException.getInstance("授权操作异常,请刷新页面");
@@ -159,6 +159,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 				distributeService.saveDistributionInvitation(sharedId, user.getId(), dsPopularizeId);
 			}
 		}
+		//店铺注册用户 关联
+		if (isNewUser && StrUtil.isNotBlank(customId)) {
+			yhShopDistributeService.saveDistributionInvitation(customId, user.getId());
+		}
 		Long userId = user.getId();
 		if (isNewUser && pid != null) {
 			TASK_POOL.execute(() -> {
@@ -495,7 +499,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		String json = Codec.DoBase64.custom().setData(state).decodeAsText();
 		AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
 		//保存用户信息
-		User user = saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid(), User.RegisterEnv.pc, re.getDsCode(), re.getCk(), re.getCt());
+		User user = saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid(), User.RegisterEnv.pc, re.getDsCode(), re.getCk(), re.getCt(), re.getCd());
 		if (user == null) {
 			throw BusinessRuntimeException.getInstance("系统错误,请重新授权");
 		}

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/cps/CpsBackLoginController.java

@@ -117,7 +117,7 @@ public class CpsBackLoginController {
 		redisService.set(authState, authState, 60 * 60 * 24L);
 		AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
 		String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
-		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getCpsRedirectUri());
+		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getCpsRedirectUri());
 		cpsAuthDto.setAuthUrl(wxAuthUrl);
 		cpsAuthDto.setAuthState(authState);
 		redisService.set(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("cps", wxOpenPlatYHLXLoginConfig.getAppId()), Jsons.toJson(cpsAuthDto), RedisService.key.WX_LOGIN_AUTH_URI.getTimeout());

+ 4 - 4
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -162,10 +162,10 @@ public class GoodsDonController {
      * 官网首页 平台列表
      */
     @GetMapping("/get/list")
-    public Result<Object> getGoodsList(String customId) {
+    public Result<? extends Object> getGoodsList(String customId) {
         if (StrUtil.isNotBlank(customId)) {
             Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
-            return GatewayResponse.SUCCESS.newBuilder().toResult(shopGoods);
+            return shopGoods;
         }
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
@@ -216,10 +216,10 @@ public class GoodsDonController {
      */
     @GetMapping("/get/homePage")
     @Deprecated
-    public Result<Object> getGoodsHomePage(String customId) {
+    public Result<? extends Object> getGoodsHomePage(String customId) {
         if (StrUtil.isNotBlank(customId)) {
             Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
-            return GatewayResponse.SUCCESS.newBuilder().toResult(shopGoods);
+            return shopGoods;
         }
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/CmsYhShopGoodsController.java

@@ -258,7 +258,7 @@ public class CmsYhShopGoodsController {
     @GetMapping("/get/detail/{userId}")
     public Result<List<YhShopUserPlatDistributeRate>> getDetailById(@PathVariable Long userId) {
         return GatewayResponse.SUCCESS.newBuilder().toResult(beanSearcher.searchAll(YhShopUserPlatDistributeRate.class, MapUtils.builder()
-                .field(YhShopUserPlatDistributeRate::getUserId, userId).op(Operator.Equal)
+                .put("uid", String.format("and ydr.user_id = %s", userId))
                 .orderBy(YhShopUserPlatDistributeRate::getGoodsId).asc()
                 .build()));
     }

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopLoginController.java

@@ -115,7 +115,7 @@ public class YhShopLoginController {
 		redisService.set(authState, authState, 60 * 60 * 24L);
 		AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
 		String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
-		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getYhShopRedirectUri());
+		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getYhShopRedirectUri());
 		cpsAuthDto.setAuthUrl(wxAuthUrl);
 		cpsAuthDto.setAuthState(authState);
 		redisService.set(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("yhShop", wxOpenPlatYHLXLoginConfig.getAppId()), Jsons.toJson(cpsAuthDto), RedisService.key.WX_LOGIN_AUTH_URI.getTimeout());

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

@@ -12,6 +12,9 @@ import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.snowflake.Sequence;
 import com.cyksj.common.util.*;
 import com.cyksj.config.WeChatConfig;
+import com.cyksj.config.wxlogin.BaseWxOpenPlatConfig;
+import com.cyksj.config.wxlogin.WxOpenPlatEnum;
+import com.cyksj.config.wxlogin.WxOpenPlatFactory;
 import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
@@ -117,9 +120,11 @@ public class AuthorizationController {
      */
     @GetMapping(value = "/weChat/baseRedirect")
     public void redirect(String code, String state, HttpServletResponse response) throws Exception {
+        String json = Codec.DoBase64.custom().setData(state).decodeAsText();
+        AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
         AuthToken token = weChatService.getAuthToken(code, weChatConfig.getAppid());
 
-        baseRedirect(token, state, User.RegisterEnv.wx, response);
+        baseRedirect(token, re, User.RegisterEnv.wx, response);
     }
 
     /**
@@ -214,19 +219,62 @@ public class AuthorizationController {
                 .setCk(callback)
                 .setCt(callbackType);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
-        String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getRedirectUri());
+        String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getRedirectUri());
         return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
     }
 
+    /**
+     * 微信网页统一授权登录
+     */
+    @GetMapping("/wx/unified/login")
+    public Result<String> wxUnifiedLogin(Long sharedId, Integer dsType, Long popularizeId, String dsCode, String type, String callbackType, String callback, String wt, String customId) throws Exception {
+        if (StrUtil.isEmpty(wt)) {
+            return GatewayResponse.SUCCESS.newBuilder().toResult();
+        }
+        WxOpenPlatEnum wxOpenPlatEnum = WxOpenPlatEnum.valueOf(wt);
+        if (wxOpenPlatEnum == null) {
+            return GatewayResponse.SUCCESS.newBuilder().toResult();
+        }
+        BaseWxOpenPlatConfig wxApp = WxOpenPlatFactory.getWeChatConfigStrategy(wxOpenPlatEnum.getAppId());
+
+        Long mappingId = SEQUENCE.nextId();
+        String loginUrl = wxApp.getLoginUrl();
+        redisService.set(mappingId.toString(), loginUrl, 60 * 60 * 24L);
+        if (StrUtil.isNotBlank(dsCode)) {
+            dsCode = dsCode.trim();
+        }
+        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setDsCode(dsCode)
+                .setCk(callback)
+                .setCd(customId)
+                .setCt(callbackType);
+        String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
+        String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxApp.getAppId(), wxApp.getRedirectUri());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
+    }
+
+    /**
+     * 网页微信授权后统一跳转
+     */
+    @GetMapping("/wx/unified/baseRedirect")
+    public void wxUnifiedRedirect(String code, String state, HttpServletResponse response) throws Exception {
+        // 转跳参数
+        String json = Codec.DoBase64.custom().setData(state).decodeAsText();
+        AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
+        AuthToken token = weChatService.getAuthToken(code, re.getAp());
+        //重定向
+        baseRedirect(token, re, User.RegisterEnv.pc, response);
+    }
+
     /**
      * 网页微信授权后跳转
      */
     @GetMapping("/wx/authLogin/baseRedirect")
     public void wxAuthLoginRedirect(String code, String state, HttpServletResponse response) throws Exception {
-
+        String json = Codec.DoBase64.custom().setData(state).decodeAsText();
+        AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
         AuthToken token = weChatService.getAuthToken(code, wxOpenPlatYHLXLoginConfig.getAppId());
         //重定向
-        baseRedirect(token, state, User.RegisterEnv.pc, response);
+        baseRedirect(token, re, User.RegisterEnv.pc, response);
     }
 
     /**
@@ -397,15 +445,12 @@ public class AuthorizationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
     }
 
-    public void baseRedirect(AuthToken token, String state, User.RegisterEnv registerEnv, HttpServletResponse response) throws Exception {
+    public void baseRedirect(AuthToken token, AuthRedirect re, User.RegisterEnv registerEnv, HttpServletResponse response) throws Exception {
         // 根据openid 与 access_token 获取用户信息
         GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
 
-        // 转跳参数
-        String json = Codec.DoBase64.custom().setData(state).decodeAsText();
-        AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
         //保存用户信息
-        User user = userService.saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid(), registerEnv, re.getDsCode(), re.getCk(), re.getCt());
+        User user = userService.saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid(), registerEnv, re.getDsCode(), re.getCk(), re.getCt(), re.getCd());
         if (user == null) {
             throw BusinessRuntimeException.getInstance("系统错误,请重新授权");
         }