|
@@ -2,6 +2,7 @@ package com.ytpm.lemonios.controller;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -10,7 +11,6 @@ import com.ytpm.agent.enums.AdRecordEnum;
|
|
|
import com.ytpm.agent.enums.UserStatusEnum;
|
|
import com.ytpm.agent.enums.UserStatusEnum;
|
|
|
import com.ytpm.agent.model.YtDitch;
|
|
import com.ytpm.agent.model.YtDitch;
|
|
|
import com.ytpm.annotation.ApiEncrypt;
|
|
import com.ytpm.annotation.ApiEncrypt;
|
|
|
-import com.ytpm.annotation.Internal;
|
|
|
|
|
import com.ytpm.app.enums.LoginType;
|
|
import com.ytpm.app.enums.LoginType;
|
|
|
import com.ytpm.app.model.YtAppDefaultConfig;
|
|
import com.ytpm.app.model.YtAppDefaultConfig;
|
|
|
import com.ytpm.app.model.YtDyzAdRecord;
|
|
import com.ytpm.app.model.YtDyzAdRecord;
|
|
@@ -54,7 +54,6 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
-import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -86,6 +85,9 @@ public class WxController {
|
|
|
@Value("${yt.ios.appid:}")
|
|
@Value("${yt.ios.appid:}")
|
|
|
private String appId;
|
|
private String appId;
|
|
|
|
|
|
|
|
|
|
+ @Value(" ${risk.config.iplimit.tips:}")
|
|
|
|
|
+ private String ipLimitTips;
|
|
|
|
|
+
|
|
|
@Value("${spring.application.name-zh:}")
|
|
@Value("${spring.application.name-zh:}")
|
|
|
private String applicationNameZh;
|
|
private String applicationNameZh;
|
|
|
|
|
|
|
@@ -99,8 +101,8 @@ public class WxController {
|
|
|
public Result<YtDyzUser> wxLogin(@RequestBody WxLoginParam param, HttpServletRequest request) {
|
|
public Result<YtDyzUser> wxLogin(@RequestBody WxLoginParam param, HttpServletRequest request) {
|
|
|
//根据应用获取配置调用微信接口登录
|
|
//根据应用获取配置调用微信接口登录
|
|
|
WxDefaultConfig defaultConfig = appUserMapper.getDefaultConfig(param.getAppType());
|
|
WxDefaultConfig defaultConfig = appUserMapper.getDefaultConfig(param.getAppType());
|
|
|
- if(Objects.isNull(defaultConfig)){
|
|
|
|
|
- return new Result<>(StatusCode.ACCESS_ERR,"微信登录失败,未找到相应配置!");
|
|
|
|
|
|
|
+ if (Objects.isNull(defaultConfig)) {
|
|
|
|
|
+ return new Result<>(StatusCode.ACCESS_ERR, "微信登录失败,未找到相应配置!");
|
|
|
}
|
|
}
|
|
|
param.setAppId(defaultConfig.getPlatformAppId());
|
|
param.setAppId(defaultConfig.getPlatformAppId());
|
|
|
WxLoginResult loginResult = getWechatLoginInfo(param.getWxCode(), param.getAppType(),
|
|
WxLoginResult loginResult = getWechatLoginInfo(param.getWxCode(), param.getAppType(),
|
|
@@ -108,17 +110,17 @@ public class WxController {
|
|
|
if (Objects.isNull(loginResult) || StrUtil.isBlank(loginResult.getOpenid())) {
|
|
if (Objects.isNull(loginResult) || StrUtil.isBlank(loginResult.getOpenid())) {
|
|
|
return new Result<>(StatusCode.ACCESS_ERR, "微信登录失败,请刷新授权码!");
|
|
return new Result<>(StatusCode.ACCESS_ERR, "微信登录失败,请刷新授权码!");
|
|
|
}
|
|
}
|
|
|
- WxUserInfo wxUserInfo = getWechatUserInfo(loginResult.getAccess_token(),loginResult.getOpenid());
|
|
|
|
|
- if(Objects.isNull(wxUserInfo)) {
|
|
|
|
|
- return new Result<>(StatusCode.ACCESS_ERR,"微信用户登录失败");
|
|
|
|
|
|
|
+ WxUserInfo wxUserInfo = getWechatUserInfo(loginResult.getAccess_token(), loginResult.getOpenid());
|
|
|
|
|
+ if (Objects.isNull(wxUserInfo)) {
|
|
|
|
|
+ return new Result<>(StatusCode.ACCESS_ERR, "微信用户登录失败");
|
|
|
}
|
|
}
|
|
|
param.setLoginIp(getClientIp(request));
|
|
param.setLoginIp(getClientIp(request));
|
|
|
- YtDyzUser old = appUserService.crudForNewTrans(param,wxUserInfo,loginResult);
|
|
|
|
|
|
|
+ YtDyzUser old = appUserService.crudForNewTrans(param, wxUserInfo, loginResult);
|
|
|
//调用风控服务校验默认风控配置
|
|
//调用风控服务校验默认风控配置
|
|
|
old.setRiskCode("313");
|
|
old.setRiskCode("313");
|
|
|
Result<?> result = riskFeign.checkRisk(old);
|
|
Result<?> result = riskFeign.checkRisk(old);
|
|
|
- if(result.getCode()!=200){
|
|
|
|
|
- return new Result<>(StatusCode.ACCESS_ERR,result.getMessage());
|
|
|
|
|
|
|
+ if (result.getCode() != 200) {
|
|
|
|
|
+ return new Result<>(StatusCode.ACCESS_ERR, result.getMessage());
|
|
|
}
|
|
}
|
|
|
return Result.resultOk(RepMessage.LOGIN_SUCCESS, old);
|
|
return Result.resultOk(RepMessage.LOGIN_SUCCESS, old);
|
|
|
}
|
|
}
|
|
@@ -133,7 +135,7 @@ public class WxController {
|
|
|
userInfoUrl = StrUtil.format(userInfoUrl, accessToken, openid);
|
|
userInfoUrl = StrUtil.format(userInfoUrl, accessToken, openid);
|
|
|
String curUser = HttpUtil.get(userInfoUrl);
|
|
String curUser = HttpUtil.get(userInfoUrl);
|
|
|
WxUserInfo wxUserInfo = JSON.parseObject(curUser, WxUserInfo.class);
|
|
WxUserInfo wxUserInfo = JSON.parseObject(curUser, WxUserInfo.class);
|
|
|
- log.error("获取的用户信息:{}",wxUserInfo);
|
|
|
|
|
|
|
+ log.error("获取的用户信息:{}", wxUserInfo);
|
|
|
return wxUserInfo;
|
|
return wxUserInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -154,7 +156,7 @@ public class WxController {
|
|
|
|
|
|
|
|
@ApiOperation("获取IOS登陆幂等Token")
|
|
@ApiOperation("获取IOS登陆幂等Token")
|
|
|
@GetMapping("/get/requestId")
|
|
@GetMapping("/get/requestId")
|
|
|
- public Result<String> getRequestId(@RequestParam("ditchId") String ditchId, @RequestParam("iosId") String iosId){
|
|
|
|
|
|
|
+ public Result<String> getRequestId(@RequestParam("ditchId") String ditchId, @RequestParam("iosId") String iosId) {
|
|
|
String redisKey = StrUtil.format("visitor:requestId:{}:{}", ditchId, iosId);
|
|
String redisKey = StrUtil.format("visitor:requestId:{}:{}", ditchId, iosId);
|
|
|
String requestId = "";
|
|
String requestId = "";
|
|
|
if (redisService.hasKey(redisKey)) {
|
|
if (redisService.hasKey(redisKey)) {
|
|
@@ -208,13 +210,13 @@ public class WxController {
|
|
|
return Result.resultOk();
|
|
return Result.resultOk();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private IosUserInfo setIosUserInfo(IosLoginParam param){
|
|
|
|
|
|
|
+ private IosUserInfo setIosUserInfo(IosLoginParam param) {
|
|
|
IosUserInfo userInfo = new IosUserInfo();
|
|
IosUserInfo userInfo = new IosUserInfo();
|
|
|
- userInfo.setOpenid(param.getIosId() == null ? "" : param.getIosId());
|
|
|
|
|
- userInfo.setHeadimgurl(param.getIconUrl() == null ? "" : param.getIconUrl());
|
|
|
|
|
- if (StrUtil.isEmpty(param.getAlias())){
|
|
|
|
|
|
|
+ userInfo.setOpenid(param.getIosId() == null ? "" : param.getIosId());
|
|
|
|
|
+ userInfo.setHeadimgurl(param.getIconUrl() == null ? "" : param.getIconUrl());
|
|
|
|
|
+ if (StrUtil.isEmpty(param.getAlias())) {
|
|
|
YtDyzUser user;
|
|
YtDyzUser user;
|
|
|
- if (param.getDitchId() == null){
|
|
|
|
|
|
|
+ if (param.getDitchId() == null) {
|
|
|
user = appUserMapper.selectByIosId(param.getIosId());
|
|
user = appUserMapper.selectByIosId(param.getIosId());
|
|
|
} else {
|
|
} else {
|
|
|
user = appUserMapper.getYtAppUserForIos(param.getIosId(), param.getDitchId());
|
|
user = appUserMapper.getYtAppUserForIos(param.getIosId(), param.getDitchId());
|
|
@@ -314,9 +316,15 @@ public class WxController {
|
|
|
Result<?> result = riskFeign.checkRisk(dyzUser);
|
|
Result<?> result = riskFeign.checkRisk(dyzUser);
|
|
|
if (result.getCode() != 200) {
|
|
if (result.getCode() != 200) {
|
|
|
String errorMessage = result.getMessage();
|
|
String errorMessage = result.getMessage();
|
|
|
|
|
+ // 自定义低价值风控提示语
|
|
|
if (RepMessage.RISK_VISITOR_LOWER_VALUE.equals(errorMessage)) {
|
|
if (RepMessage.RISK_VISITOR_LOWER_VALUE.equals(errorMessage)) {
|
|
|
errorMessage = StrUtil.emptyToDefault(defaultConfig.getLowValueTip(), errorMessage);
|
|
errorMessage = StrUtil.emptyToDefault(defaultConfig.getLowValueTip(), errorMessage);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 自定义IP风控提示语
|
|
|
|
|
+ if (RepMessage.RISK_IP_LIMIT_VALUE.equals(errorMessage) && StrUtil.isNotEmpty(ipLimitTips)) {
|
|
|
|
|
+ String[] split = ipLimitTips.split(",");
|
|
|
|
|
+ errorMessage = split[RandomUtil.randomInt(split.length)];
|
|
|
|
|
+ }
|
|
|
return new Result<>(StatusCode.ACCESS_ERR, errorMessage);
|
|
return new Result<>(StatusCode.ACCESS_ERR, errorMessage);
|
|
|
}
|
|
}
|
|
|
if (dyzUser.getLastLoginTime() != null && dyzUser.getRegistryTime() != null) {
|
|
if (dyzUser.getLastLoginTime() != null && dyzUser.getRegistryTime() != null) {
|
|
@@ -360,7 +368,7 @@ public class WxController {
|
|
|
@PostMapping("/getByDitchId")
|
|
@PostMapping("/getByDitchId")
|
|
|
@ApiOperation("获取默认配置")
|
|
@ApiOperation("获取默认配置")
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public Result<WxDefaultConfig> getByDitchId(@RequestBody IosLoginParam param){
|
|
|
|
|
|
|
+ public Result<WxDefaultConfig> getByDitchId(@RequestBody IosLoginParam param) {
|
|
|
WxDefaultConfig defaultConfig = appUserMapper.getDefaultConfigByDitchId(param.getDitchId());
|
|
WxDefaultConfig defaultConfig = appUserMapper.getDefaultConfigByDitchId(param.getDitchId());
|
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS, defaultConfig);
|
|
return Result.resultOk(RepMessage.QUERY_SUCCESS, defaultConfig);
|
|
|
}
|
|
}
|
|
@@ -368,7 +376,7 @@ public class WxController {
|
|
|
@PostMapping("/getLastOne")
|
|
@PostMapping("/getLastOne")
|
|
|
@ApiOperation("获取最近一条默认配置")
|
|
@ApiOperation("获取最近一条默认配置")
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public Result<?> getLastOne(@RequestBody YtDitch param){
|
|
|
|
|
|
|
+ public Result<?> getLastOne(@RequestBody YtDitch param) {
|
|
|
return appUserService.addDefaultConfig(param);
|
|
return appUserService.addDefaultConfig(param);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -377,7 +385,8 @@ public class WxController {
|
|
|
if (xfHeader == null) {
|
|
if (xfHeader == null) {
|
|
|
return request.getRemoteAddr();
|
|
return request.getRemoteAddr();
|
|
|
}
|
|
}
|
|
|
- return xfHeader.split(",")[0]; // 可能会有多个IP,这里取第一个逗号前的IP
|
|
|
|
|
|
|
+ // 可能会有多个IP,这里取第一个逗号前的IP
|
|
|
|
|
+ return xfHeader.split(",")[0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -387,7 +396,7 @@ public class WxController {
|
|
|
@GetMapping("/defaultConfig")
|
|
@GetMapping("/defaultConfig")
|
|
|
public Result<WxDefaultConfig> getWxDefaultConfig(int appType) {
|
|
public Result<WxDefaultConfig> getWxDefaultConfig(int appType) {
|
|
|
WxDefaultConfig config = appUserMapper.getDefaultConfig(appType);
|
|
WxDefaultConfig config = appUserMapper.getDefaultConfig(appType);
|
|
|
- if(Objects.isNull(config)){
|
|
|
|
|
|
|
+ if (Objects.isNull(config)) {
|
|
|
return Result.resultErr("应用类型有误!");
|
|
return Result.resultErr("应用类型有误!");
|
|
|
}
|
|
}
|
|
|
return Result.resultObjOk(config);
|
|
return Result.resultObjOk(config);
|
|
@@ -415,7 +424,7 @@ public class WxController {
|
|
|
|
|
|
|
|
@ApiOperation("保存应用默认配置")
|
|
@ApiOperation("保存应用默认配置")
|
|
|
@PostMapping("/saveAppConfig")
|
|
@PostMapping("/saveAppConfig")
|
|
|
- public Result<String> saveAppConfig(@RequestBody YtAppDefaultConfig defaultConfig){
|
|
|
|
|
|
|
+ public Result<String> saveAppConfig(@RequestBody YtAppDefaultConfig defaultConfig) {
|
|
|
appUserMapper.saveAppConfig(defaultConfig);
|
|
appUserMapper.saveAppConfig(defaultConfig);
|
|
|
return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
|
}
|
|
}
|
|
@@ -423,7 +432,7 @@ public class WxController {
|
|
|
|
|
|
|
|
@ApiOperation("修改应用默认配置")
|
|
@ApiOperation("修改应用默认配置")
|
|
|
@PostMapping("/updateAppConfig")
|
|
@PostMapping("/updateAppConfig")
|
|
|
- public Result<String> updateAppConfig(@RequestBody YtAppDefaultConfig defaultConfig){
|
|
|
|
|
|
|
+ public Result<String> updateAppConfig(@RequestBody YtAppDefaultConfig defaultConfig) {
|
|
|
appUserMapper.updateAppConfig(defaultConfig);
|
|
appUserMapper.updateAppConfig(defaultConfig);
|
|
|
return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
|
}
|
|
}
|
|
@@ -431,7 +440,7 @@ public class WxController {
|
|
|
|
|
|
|
|
@ApiOperation("修改应用默认配置")
|
|
@ApiOperation("修改应用默认配置")
|
|
|
@PostMapping("/updateAppsConfig")
|
|
@PostMapping("/updateAppsConfig")
|
|
|
- public void updateAppsConfig(@RequestBody AppConfigUpdateParam param){
|
|
|
|
|
|
|
+ public void updateAppsConfig(@RequestBody AppConfigUpdateParam param) {
|
|
|
if (CollUtil.isNotEmpty(param.getApps()) && param.getDefaultConfig() != null) {
|
|
if (CollUtil.isNotEmpty(param.getApps()) && param.getDefaultConfig() != null) {
|
|
|
String appIds = String.join(",", param.getApps());
|
|
String appIds = String.join(",", param.getApps());
|
|
|
List<WxDefaultConfig> configs = appUserMapper.getConfigByIds(appIds);
|
|
List<WxDefaultConfig> configs = appUserMapper.getConfigByIds(appIds);
|
|
@@ -439,22 +448,22 @@ public class WxController {
|
|
|
for (WxDefaultConfig config : configs) {
|
|
for (WxDefaultConfig config : configs) {
|
|
|
YtAppDefaultConfig appConfig = new YtAppDefaultConfig();
|
|
YtAppDefaultConfig appConfig = new YtAppDefaultConfig();
|
|
|
BeanUtils.copyProperties(config, appConfig);
|
|
BeanUtils.copyProperties(config, appConfig);
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuAppId())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuAppId())) {
|
|
|
appConfig.setTakuAppId(updateInfo.getTakuAppId());
|
|
appConfig.setTakuAppId(updateInfo.getTakuAppId());
|
|
|
}
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuKey())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuKey())) {
|
|
|
appConfig.setTakuKey(updateInfo.getTakuKey());
|
|
appConfig.setTakuKey(updateInfo.getTakuKey());
|
|
|
}
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuBannerPid())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuBannerPid())) {
|
|
|
appConfig.setTakuBannerPid(updateInfo.getTakuBannerPid());
|
|
appConfig.setTakuBannerPid(updateInfo.getTakuBannerPid());
|
|
|
}
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuNativePid())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuNativePid())) {
|
|
|
appConfig.setTakuNativePid(updateInfo.getTakuNativePid());
|
|
appConfig.setTakuNativePid(updateInfo.getTakuNativePid());
|
|
|
}
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuRewardPid())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuRewardPid())) {
|
|
|
appConfig.setTakuRewardPid(updateInfo.getTakuRewardPid());
|
|
appConfig.setTakuRewardPid(updateInfo.getTakuRewardPid());
|
|
|
}
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(updateInfo.getTakuInterstitialPid())) {
|
|
|
|
|
|
|
+ if (StrUtil.isNotEmpty(updateInfo.getTakuInterstitialPid())) {
|
|
|
appConfig.setTakuInterstitialPid(updateInfo.getTakuInterstitialPid());
|
|
appConfig.setTakuInterstitialPid(updateInfo.getTakuInterstitialPid());
|
|
|
}
|
|
}
|
|
|
appUserMapper.updateAppConfig(appConfig);
|
|
appUserMapper.updateAppConfig(appConfig);
|
|
@@ -465,19 +474,21 @@ public class WxController {
|
|
|
|
|
|
|
|
@ApiOperation("根据APP_ID获取配置")
|
|
@ApiOperation("根据APP_ID获取配置")
|
|
|
@GetMapping("/getConfigs")
|
|
@GetMapping("/getConfigs")
|
|
|
- public List<WxDefaultConfig> getConfigs(@RequestParam(name = "appIds")String appIds){
|
|
|
|
|
|
|
+ public List<WxDefaultConfig> getConfigs(@RequestParam(name = "appIds") String appIds) {
|
|
|
List<WxDefaultConfig> configs = new ArrayList<>();
|
|
List<WxDefaultConfig> configs = new ArrayList<>();
|
|
|
List<WxDefaultConfig> dyzConfigs = appUserMapper.getConfigByIds(appIds);
|
|
List<WxDefaultConfig> dyzConfigs = appUserMapper.getConfigByIds(appIds);
|
|
|
- if(CollUtil.isNotEmpty(dyzConfigs)){configs.addAll(dyzConfigs);}
|
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dyzConfigs)) {
|
|
|
|
|
+ configs.addAll(dyzConfigs);
|
|
|
|
|
+ }
|
|
|
return configs;
|
|
return configs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("删除默认配置")
|
|
@ApiOperation("删除默认配置")
|
|
|
@GetMapping("/delDefaultConfig")
|
|
@GetMapping("/delDefaultConfig")
|
|
|
- public void delDefaultConfig(@RequestParam(name = "appId")String appId){
|
|
|
|
|
|
|
+ public void delDefaultConfig(@RequestParam(name = "appId") String appId) {
|
|
|
List<WxDefaultConfig> dyzConfig = appUserMapper.getConfigByIds(appId);
|
|
List<WxDefaultConfig> dyzConfig = appUserMapper.getConfigByIds(appId);
|
|
|
- if(CollUtil.isNotEmpty(dyzConfig)){
|
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dyzConfig)) {
|
|
|
appUserMapper.delByAppId(appId);
|
|
appUserMapper.delByAppId(appId);
|
|
|
// 同步删除渠道记录
|
|
// 同步删除渠道记录
|
|
|
ditchMapper.deleteByAppId(appId);
|
|
ditchMapper.deleteByAppId(appId);
|