|
@@ -4,12 +4,12 @@ package com.care.keeper.service;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.care.common.cache.RedisKeyConstant;
|
|
|
import com.care.common.cache.RedisUtil;
|
|
|
+import com.care.common.entity.CareSysUser;
|
|
|
+import com.care.common.service.CareSysUserService;
|
|
|
import com.care.common.util.HttpUtil;
|
|
|
-import com.care.common.util.Result;
|
|
|
import com.care.keeper.config.KeeperWxConfig;
|
|
|
import com.care.keeper.config.PlatformPinanshouhuConfig;
|
|
|
import com.care.keeper.vo.KeeperInitParams;
|
|
|
-import com.google.gson.Gson;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -25,10 +25,11 @@ public class WxKeeperPassportService extends AbstractKeeperPassportService {
|
|
|
|
|
|
@Resource
|
|
|
private PlatformPinanshouhuConfig platformPinanshouhuConfig;
|
|
|
+ @Resource
|
|
|
+ private CareSysUserService careSysUserService;
|
|
|
|
|
|
- Gson gson = new Gson();
|
|
|
|
|
|
- public Result<Object> login(KeeperInitParams params) {
|
|
|
+ public CareSysUser login(KeeperInitParams params) {
|
|
|
KeeperWxConfig wxConfig = platformPinanshouhuConfig.keeperWxConfig();
|
|
|
// 解析codeUrl
|
|
|
String codeUrl = MessageFormat.format(wxConfig.getCodeUrl(), wxConfig.getAppId(), wxConfig.getSecret(), params.getCode());
|
|
@@ -37,15 +38,20 @@ public class WxKeeperPassportService extends AbstractKeeperPassportService {
|
|
|
log.warn("-----jsonObject:[{}]", jsonObject);
|
|
|
|
|
|
String openid = jsonObject.getStr("openid");
|
|
|
- String sessionKey = jsonObject.getStr("session_key");
|
|
|
- log.warn("-----openid:[{}], session_key:[{}]", openid, sessionKey);
|
|
|
+ CareSysUser careSysUser = careSysUserService.detailByOpenid4Keeper(openid);
|
|
|
+ if(careSysUser != null) {
|
|
|
+ return careSysUser;
|
|
|
+ } else { //没有注册,走第二步
|
|
|
+ String sessionKey = jsonObject.getStr("session_key");
|
|
|
+ log.warn("-----openid:[{}], session_key:[{}]", openid, sessionKey);
|
|
|
|
|
|
- KeeperInitParams keeperInitParams = new KeeperInitParams();
|
|
|
- keeperInitParams.setLoginType("wx");
|
|
|
- keeperInitParams.setOpenid(openid);
|
|
|
- keeperInitParams.setSessionKey(sessionKey);
|
|
|
- redisUtil.hset(RedisKeyConstant.PINANSHOUHU_WX_LOGIN_INFO, params.getCode(), keeperInitParams, RedisKeyConstant.PINANSHOUHU_WX_LOGIN_INFO_TIME);
|
|
|
- return Result.success();
|
|
|
+ KeeperInitParams keeperInitParams = new KeeperInitParams();
|
|
|
+ keeperInitParams.setLoginType("wx");
|
|
|
+ keeperInitParams.setOpenid(openid);
|
|
|
+ keeperInitParams.setSessionKey(sessionKey);
|
|
|
+ redisUtil.hset(RedisKeyConstant.PINANSHOUHU_WX_LOGIN_INFO, params.getCode(), keeperInitParams, RedisKeyConstant.PINANSHOUHU_WX_LOGIN_INFO_TIME);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|