|
|
@@ -17,6 +17,8 @@ import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.common.utils.sign.Md5Utils;
|
|
|
import com.fs.core.config.WxOpenProperties;
|
|
|
+import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.domain.FsUserNewTask;
|
|
|
@@ -29,6 +31,7 @@ import com.fs.his.vo.FsUserRegisterParam;
|
|
|
import com.fs.watch.domain.WatchDeviceSetup;
|
|
|
import com.fs.watch.domain.WatchUser;
|
|
|
import com.fs.watch.service.WatchUserService;
|
|
|
+import io.netty.util.internal.StringUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.Synchronized;
|
|
|
@@ -64,6 +67,9 @@ public class AppLoginController extends AppBaseController{
|
|
|
@Autowired
|
|
|
private WxOpenProperties openProperties;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
@@ -240,8 +246,23 @@ public class AppLoginController extends AppBaseController{
|
|
|
return R.error("code不存在");
|
|
|
}
|
|
|
|
|
|
- logger.info("zyp app微信登录,param:{},输出appid,{},secret:{}", param, openProperties.getAppId(), openProperties.getSecret());
|
|
|
- Map result = WxUtil.getAccessToken(param.getCode(), openProperties.getAppId(), openProperties.getSecret());
|
|
|
+ String appId=null;
|
|
|
+ String secret=null;
|
|
|
+ if (!StringUtil.isNullOrEmpty(param.getAppId())){
|
|
|
+
|
|
|
+ FsCoursePlaySourceConfig config = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ appId=config.getAppid();
|
|
|
+ secret=config.getSecret();
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ appId = openProperties.getAppId();
|
|
|
+ secret = openProperties.getSecret();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info("zyp app微信登录,param:{},输出appid,{},secret:{}", param, appId, secret);
|
|
|
+ Map result = WxUtil.getAccessToken(param.getCode(), appId, secret);
|
|
|
String accessToken = result.get("access_token").toString();
|
|
|
String unionid = result.get("unionid").toString();
|
|
|
|
|
|
@@ -267,7 +288,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
}
|
|
|
user.setUnionId(unionid);
|
|
|
// 新用户 - 添加 appId
|
|
|
- user.setAppId(openProperties.getAppId());
|
|
|
+ user.setAppId(appId);
|
|
|
user.setCreateTime(new Date());
|
|
|
user.setStatus(1);
|
|
|
if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
|
@@ -281,7 +302,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
return R.ok(map);
|
|
|
} else {
|
|
|
// 老用户 - 检查并添加appId(不重复添加)
|
|
|
- String updatedAppId = addAppIdIfNotExists(user.getAppId(), openProperties.getAppId());
|
|
|
+ String updatedAppId = addAppIdIfNotExists(user.getAppId(), appId);
|
|
|
if (!updatedAppId.equals(user.getAppId())) {
|
|
|
FsUser userMap = new FsUser();
|
|
|
userMap.setUserId(user.getUserId());
|
|
|
@@ -434,10 +455,10 @@ public class AppLoginController extends AppBaseController{
|
|
|
return R.error("验证码错误");
|
|
|
}
|
|
|
updateExistingUserJpushId(user.get(0), map.get("jpushId"));
|
|
|
-
|
|
|
+
|
|
|
// 更新登录设备信息
|
|
|
updateLoginDevice(user.get(0).getUserId(), map.get("loginDevice"), map.get("source"));
|
|
|
-
|
|
|
+
|
|
|
return generateTokenAndReturn(user.get(0));
|
|
|
}
|
|
|
|
|
|
@@ -536,8 +557,24 @@ public class AppLoginController extends AppBaseController{
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R bindWeChat(@Validated @RequestBody FsUserEditUnionidParam param) {
|
|
|
try {
|
|
|
+
|
|
|
+ String appId=null;
|
|
|
+ String secret=null;
|
|
|
+ if (!StringUtil.isNullOrEmpty(param.getAppId())){
|
|
|
+
|
|
|
+ FsCoursePlaySourceConfig config = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ appId=config.getAppid();
|
|
|
+ secret=config.getSecret();
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ appId = openProperties.getAppId();
|
|
|
+ secret = openProperties.getSecret();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
logger.info("zyp app绑定微信,param:{}", param);
|
|
|
- Map result = WxUtil.getAccessToken(param.getCode(), openProperties.getAppId(), openProperties.getSecret());
|
|
|
+ Map result = WxUtil.getAccessToken(param.getCode(), appId, secret);
|
|
|
if (!result.containsKey("access_token")) {
|
|
|
return R.error("微信授权失败");
|
|
|
}
|
|
|
@@ -702,10 +739,10 @@ public class AppLoginController extends AppBaseController{
|
|
|
if (!Md5Utils.hash(param.getPassword()).equals(user.getPassword())) {
|
|
|
return R.error("密码不正确");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 更新登录设备信息
|
|
|
updateLoginDevice(user.getUserId(), param.getLoginDevice(), param.getSource());
|
|
|
-
|
|
|
+
|
|
|
//登录成功以后写入达人表
|
|
|
//fsUserTalentService.addFsUserTalent(fsUser.getUserId());
|
|
|
return generateTokenAndReturn(user);
|
|
|
@@ -839,10 +876,10 @@ public class AppLoginController extends AppBaseController{
|
|
|
}else {
|
|
|
return R.ok().put("users",usersByPhone);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 更新登录设备信息
|
|
|
updateLoginDevice(user.getUserId(), param.getLoginDevice(), param.getSource());
|
|
|
-
|
|
|
+
|
|
|
return generateTokenAndReturn(user);
|
|
|
}
|
|
|
|
|
|
@@ -855,10 +892,10 @@ public class AppLoginController extends AppBaseController{
|
|
|
if (StringUtils.isNotEmpty(param.getJpushId())){
|
|
|
updateExistingUserJpushId(user, param.getJpushId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 更新登录设备信息
|
|
|
updateLoginDevice(user.getUserId(), param.getLoginDevice(), param.getSource());
|
|
|
-
|
|
|
+
|
|
|
return generateTokenAndReturn(user);
|
|
|
}
|
|
|
|