|
@@ -1,7 +1,7 @@
|
|
|
package com.xynet.marketing.utils;
|
|
|
|
|
|
-import com.xynet.marketing.service.ProviderService;
|
|
|
-import com.xynet.marketing.utils.collections.map.JHashMap;
|
|
|
+import com.cow.support.dto.UserSessionModel;
|
|
|
+import com.xynet.marketing.service.MercService;
|
|
|
import com.xynet.marketing.utils.redis.utils.RedisService;
|
|
|
|
|
|
import java.util.Map;
|
|
@@ -11,14 +11,15 @@ import java.util.Map;
|
|
|
* @date 2025/2/12
|
|
|
*/
|
|
|
public class MercAuthUtils {
|
|
|
- private static String redisPrefix = "marketing:token:merc:";
|
|
|
+
|
|
|
|
|
|
+ private static String redisPrefix = "userSession-";
|
|
|
|
|
|
public static Integer getMercId(Map<String, String> headers) {
|
|
|
|
|
|
String token = headers.get("token");
|
|
|
String providerId = headers.get("provider_id");
|
|
|
- RedisService<Integer> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
+ RedisService<UserSessionModel> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
if (!Emptys.check(token)) {
|
|
|
throw new RuntimeException("token不能为空");
|
|
|
}
|
|
@@ -26,24 +27,45 @@ public class MercAuthUtils {
|
|
|
throw new RuntimeException("服务商ID不能为空");
|
|
|
}
|
|
|
|
|
|
- Integer mercId = redisService.get(redisPrefix + providerId + ":" + token);
|
|
|
- if (!Emptys.check(mercId)) {
|
|
|
-
|
|
|
- mercId = getMercIdByProvider(token, providerId);
|
|
|
-
|
|
|
- redisService.set(redisPrefix + providerId + ":" + token, mercId, 7200);
|
|
|
+ UserSessionModel userSession = redisService.get(redisPrefix + token);
|
|
|
+ if (!Emptys.check(userSession)) {
|
|
|
+ throw new RuntimeException("token已过期");
|
|
|
}
|
|
|
- return mercId;
|
|
|
+ String thirdMercId = userSession.getUserInfo().getShbh();
|
|
|
+ MercService mercService = SpringBeanUtils.getBean(MercService.class);
|
|
|
+ return mercService.thirdMercIdToMercId(providerId, thirdMercId);
|
|
|
}
|
|
|
|
|
|
- private static Integer getMercIdByProvider(String token, String providerId) {
|
|
|
- ProviderService providerService = SpringBeanUtils.getBean(ProviderService.class);
|
|
|
- JHashMap<String, Object> param = new JHashMap<>();
|
|
|
- param.set("id", providerId);
|
|
|
- Map<String, Object> provider = providerService.obj(param);
|
|
|
-
|
|
|
-
|
|
|
- return 1;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|