瀏覽代碼

Merge remote-tracking branch 'origin/master'

marxjaw 1 月之前
父節點
當前提交
f431721b1c

+ 326 - 0
ReadMe.md

@@ -0,0 +1,326 @@
+# 易推广告平台
+
+> **本地调试请切换配置文件至local模式!!!!**
+
+> **本地调试请切换配置文件至local模式!!!!**
+
+> **本地调试请切换配置文件至local模式!!!!**
+
+> **数据库当前为主从部署,数据操作及DDL操作请在master节点使用SQL语句处理**
+
+> **数据库当前为主从部署,数据操作及DDL操作请在master节点使用SQL语句处理**
+
+## 项目信息
+
+> 版本依赖
+
+|         依赖         |      版本       |
+|:------------------:|:-------------:|
+|        jdk         |      1.8      |
+|     SpringBoot     | 2.1.9.RELEASE |
+| SpringCloudAlibaba | 0.9.0.RELEASE |
+|       mysql        |  5.7.44-log   |
+|       nacos        |     2.4.3     |
+
+
+
+> 项目结构
+
+```text
+
+-- yt-platform 
+----yt-common  公共包
+----yt-gateway 网关
+----yt-oauth   授权中心
+----yt-agent   易推平台代理商系统
+----yt-middle  易推中台
+----yt-risk    风控中心
+
+# 剩余为子包服务
+
+
+```
+
+
+
+## 服务部署
+
+
+
+```shell
+# 1.进入部署目录
+cd /data/www/app
+# 2.检查服务是否已部署
+ps -ef|grep -s [service]
+# 前往nacos下线当前实例
+
+# 查询实例日志
+tail -fn 100 [service].log
+
+# risk-manageer
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1ReservePercent=10 \
+-XX:MaxGCPauseMillis=300 risk-manage.jar > risk.log 2>&1 &
+
+# yt-middle
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 yt-middle.jar > middle.log 2>&1 &
+
+# agent-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1ReservePercent=10 \
+-XX:MaxGCPauseMillis=300 agent-service.jar > agent.log 2>&1 &
+
+
+#####################
+
+# nofeeds-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/nofeeds.hprof \
+nofeeds-service.jar > nofeeds.log 2>&1 &
+
+
+# 青柠记账 lime-service
+nohup java -jar -Xms3072m -Xmx3072m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/lime.hprof \
+lime-service.jar > lime.log 2>&1 &
+
+#######################
+
+# 典故问答王 allusion-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/allusion.hprof \
+allusion-service.jar > allusion.log 2>&1 &
+
+
+# 计数计算器 calculator-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/calculator.hprof \
+calculator-service.jar > calculator.log 2>&1 &
+
+
+# 斗图表情大师 emoticons-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/emoticons.hprof \
+emoticons-service.jar > emoticons.log 2>&1 &
+
+# algebraic-service.jar
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/algebraic.hprof \
+algebraic-service.jar > algebraic.log 2>&1 &
+
+
+# 算术小达人 arithmetic-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/arithmetic.hprof \
+arithmetic-service.jar > arithmetic.log 2>&1 &
+
+
+# 计步趣健身 countstep-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/countstep.hprof \
+countstep-service.jar > countstep.log 2>&1 &
+
+
+# 元气算术能手 vitality-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/vitality.hprof \
+vitality-service.jar > vitality.log 2>&1 &
+
+
+# 小锦鲤 carp-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/carp.hprof \
+carp-service.jar > carp.log 2>&1 &
+
+
+# 谚语知识赛 proverb-service.
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/proverb.hprof \
+proverb-service.jar > proverb.log 2>&1 &
+
+
+# 谚语变形记 adage-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/adage.hprof \
+adage-service.jar > adage.log 2>&1 &
+
+
+# 好运答题王 dtw-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/dtw.hprof \
+dtw-service.jar > dtw.log 2>&1 &
+
+
+# 咕噜日记 diary-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/diary.hprof \
+diary-service.jar > diary.log 2>&1 &
+
+
+# 答题达人 answer-service
+nohup java -jar -Xms3072m -Xmx3072m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/answer.hprof \
+answer-service.jar > answer.log 2>&1 &
+
+
+# 代数式能手 algebraic-service
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/algebraic.hprof \
+algebraic-service.jar > algebraic.log 2>&1 &
+
+# 歇后语擂台 arena-service
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/arena.hprof \
+arena-service.jar > arena.log 2>&1 &
+
+
+# 天天趣算术 funarith
+nohup java -jar -Xms3072m -Xmx3072m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/funarith.hprof \
+funarith-service.jar > funarith.log 2>&1 &
+
+
+# 成语趣解释 idiom
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/idiom.hprof \
+idiom-service.jar > idiom.log 2>&1 &
+
+
+# 每天爱跑步 irun
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/irun.hprof \
+irun-service.jar > irun.log 2>&1 &
+
+
+# 宠物里程表 mileage
+nohup java -jar -Xms4096m -Xmx4096m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/mileage.hprof \
+mileage-service.jar > mileage.log 2>&1 &
+
+
+# 全民养猪 raisepig
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/raisepig.hprof \
+raisepig-service.jar > raisepig.log 2>&1 &
+
+
+# 找茬挑战王 picking
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/picking.hprof \
+picking-service.jar > picking.log 2>&1 &
+
+
+# 归物迹 summary
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/summary.hprof \
+summary-service.jar > summary.log 2>&1 &
+
+
+  # 打字训练营 typing
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/typing.hprof \
+typing-service.jar > typing.log 2>&1 &
+
+
+# 青柠檬记账 lemon
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/lemon.hprof \
+lemon-service.jar > lemon.log 2>&1 &
+
+
+# 走路趣计步 walk
+nohup java -jar -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/walk.hprof \
+walk-service.jar > walk.log 2>&1 &
+
+
+# 全民爱走路 walking
+nohup java -jar -Xms2048m -Xmx2048m -XX:MaxMetaspaceSize=256M -XX:+UseCompressedOops \
+-XX:+UseG1GC -XX:ConcGCThreads=2 -XX:InitiatingHeapOccupancyPercent=35 \
+-XX:G1ReservePercent=10 -XX:MaxGCPauseMillis=300 \
+-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/www/app/walking.hprof \
+walking-service.jar > walking.log 2>&1 &
+
+
+
+```
+
+
+## 数据处理
+
+> 删除指定appid风控规则
+
+
+```sql
+delete from yt_risk_config
+where config_id in (
+select config_id from yt_risk_template_config
+where template_id in (SELECT template_id from yt_risk_template where template_code like '[appid]%')
+);
+
+delete from yt_risk_template_config
+where template_id in (SELECT template_id from yt_risk_template where template_code like '[appid]%');
+
+delete from yt_risk_template where template_code like '[appid]%';
+```
+
+
+## 更新日志
+
+...

+ 0 - 1
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/DitchController.java

@@ -33,7 +33,6 @@ public class DitchController {
     @ApiOperation("获取渠道类型列表")
     @PostMapping("/list")
     public Result<List<AgentDitchView>> list(@RequestBody DitchListForIosParam param) {
-        param.setAppId(param.getAppId());
         DitchListParam ditchListParam = new DitchListParam();
         return Result.resultOk(RepMessage.QUERY_SUCCESS, agentDitchService.ditchList(ditchListParam));
     }

+ 14 - 2
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/UserController.java

@@ -175,8 +175,20 @@ public class UserController {
     @PostMapping("/adRecords/page")
     public ResultTable<YtDyzAdRecord> adRecordsPage(@RequestBody AdRecordListParam param, Errors errors) {
         PageHelper.startPage(param.getPage(), param.getLimit());
-        log.error("=================================",param.getLoginStatus());
-        List<YtDyzAdRecord> adrecords = adRecordMapper.getByUserByParam(param);
+        YtDyzUser user = appUserMapper.selectById(param.getUserId());
+        List<YtDyzAdRecord> adrecords;
+        if (param.getLoginStatus() == 1){
+            adrecords = adRecordMapper.getByIosIdBeforeLogin(user.getIosId());
+            for (YtDyzAdRecord adrecord: adrecords){
+                if (adrecord.getUserId() == null){
+                    adrecord.setUserId(user.getUserId());
+                    adRecordMapper.updateOneVisitor(adrecord);
+                }
+                adrecord.setLoginStatus(1);
+            }
+        } else {
+            adrecords = adRecordMapper.getByUserByParam(param);
+        }
         return ResultTable.resultTableOk(new PageInfo<>(adrecords));
     }
 

+ 18 - 14
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/WxController.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
+import com.ytpm.agent.enums.UserStatusEnum;
 import com.ytpm.agent.model.YtDitch;
 import com.ytpm.app.enums.AppTypeEnums;
 import com.ytpm.app.enums.LoginType;
@@ -14,15 +15,12 @@ import com.ytpm.app.model.YtDyzPowerRecord;
 import com.ytpm.app.model.YtDyzUser;
 import com.ytpm.app.param.IosLoginParam;
 import com.ytpm.app.param.WxLoginParam;
-import com.ytpm.app.view.IosPowerResView;
-import com.ytpm.app.view.IosUserInfo;
-import com.ytpm.app.view.WxDefaultConfig;
-import com.ytpm.app.view.WxLoginResult;
-import com.ytpm.app.view.WxUserInfo;
+import com.ytpm.app.view.*;
 import com.ytpm.feign.RiskFeign;
 import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
 import com.ytpm.general.StatusCode;
+import com.ytpm.handle.CommonException;
 import com.ytpm.lemonios.dao.AdRecordMapper;
 import com.ytpm.lemonios.dao.AppUserMapper;
 import com.ytpm.lemonios.dao.DitchMapper;
@@ -30,15 +28,9 @@ import com.ytpm.lemonios.service.AppUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
@@ -141,11 +133,23 @@ public class WxController {
             IosUserInfo userInfo = setIosUserInfo(param);
             user = appUserService.crudForNewTransIos(param, userInfo);
         }
-        List<YtDyzAdRecord> adRecordList = recordMapper.getByIosId(param.getIosId());
+        List<YtDyzAdRecord> adRecordList = recordMapper.getByIosIdBeforeLogin(param.getIosId());
         user.setPreAdRecordList(adRecordList);
         user.setLoginType(LoginType.VISITOR);
         user.setAppId("a689ab630d3e62");
-        riskFeign.checkLoginRisk(user);
+        Result<?> result = riskFeign.checkLoginRisk(user);
+        if (result.getCode() != 200) {
+            String errorMessage = result.getMessage();
+            if (user.getLoginType() == LoginType.VISITOR && RepMessage.RISK_VISITOR_LOWER_VALUE.equals(errorMessage)) {
+                WxDefaultConfig defaultConfig = appUserMapper.getLastDefaultConfig();
+                throw new CommonException(StrUtil.emptyToDefault(defaultConfig.getLowValueTip(), errorMessage));
+            }
+            throw new CommonException(errorMessage);
+        }
+        YtDyzUser newUser = new YtDyzUser();
+        newUser.setUserId(user.getUserId());
+        newUser.setUserStatus(UserStatusEnum.NORMAL.getCode());
+        appUserMapper.updateUser(newUser);
         return Result.resultObjOk(user);
     }
 

+ 10 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/AdRecordMapper.java

@@ -31,6 +31,11 @@ public interface AdRecordMapper {
      */
     List<YtDyzAdRecord> getByIosId(@Param("iosId") String iosId);
 
+    /**
+     * 查询激励视频记录
+     */
+    List<YtDyzAdRecord> getByIosIdBeforeLogin(@Param("iosId") String iosId);
+
     List<YtDyzAdRecord> getByUserByParam(AdRecordListParam param);
 
     /**
@@ -57,4 +62,9 @@ public interface AdRecordMapper {
      * 保存游客广告记录
      */
     void addOneVisitor(YtDyzAdRecord adRecord);
+
+    /**
+     * 保存游客广告记录
+     */
+    void updateOneVisitor(YtDyzAdRecord adRecord);
 }

+ 5 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/AppUserMapper.java

@@ -122,6 +122,11 @@ public interface AppUserMapper {
      */
     WxDefaultConfig getLastOne(@Param("appId") String appId);
 
+    /**
+     * 获取最近一条默认配置
+     */
+    WxDefaultConfig getLastDefaultConfig();
+
     /**
      * 根据微信openid查询用户
      */

+ 16 - 17
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/AdServiceImpl.java

@@ -58,9 +58,7 @@ public class AdServiceImpl implements AdService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Result<?> saveRecord(DyzAdRecordParam param) {
-        YtDyzUser user;
         if (StrUtil.isEmpty(param.getUserId())) {
-            user = appUserMapper.selectByIosId((param.getIosId()));
             YtDyzAdRecord adRecord = new YtDyzAdRecord();
             if(Objects.isNull(param.getBeginTime()) || "null".equals(param.getBeginTime())){
                 if ("null".equals(param.getBeginTime())) {
@@ -69,25 +67,26 @@ public class AdServiceImpl implements AdService {
                 param.setBeginTime(param.getFinishTime());
             }
             BeanUtils.copyProperties(param, adRecord);
-            adRecord.setUserId(user.getUserId());
+            adRecord.setIosId(param.getIosId());
+            adRecord.setAppId("251be4dff0fd408fbc1fe2c47bf515eb");
             adRecord.setRecordId(IdUtil.fastSimpleUUID());
             adRecord.setNetworkName(AdPlatformTypeEnum.getDesc(Integer.parseInt(param.getNetworkFormId())));
             adRecordMapper.addOneVisitor(adRecord);
         } else {
-            user = appUserMapper.selectPrimaryKey(param.getUserId());
-        }
-        if(Objects.isNull(user)){
-            return Result.resultOk(RepMessage.SAVE_SUCCESS);
-        }
-        if(!UserStatusEnum.NORMAL.getCode().equals(user.getUserStatus())){
-            return new Result<>(StatusCode.ACCESS_ERR,getTipsMsg());
-        }
-        saveRecordAndChangeUser(param, user);
-        //调用风控广告校验
-        if(AdSourceTypeEnum.rewarded_video.getAdSourceType() == param.getAdSourceType()){
-            Result<?> result = riskFeign.checkAdRisk(user);
-            if(result.getCode()!=200){
-                return new Result<>(StatusCode.ACCESS_ERR, getTipsMsg());
+            YtDyzUser user = appUserMapper.selectPrimaryKey(param.getUserId());
+            if(!UserStatusEnum.NORMAL.getCode().equals(user.getUserStatus())){
+                return new Result<>(StatusCode.ACCESS_ERR,getTipsMsg());
+            }
+            if(Objects.isNull(user)){
+                return Result.resultOk(RepMessage.SAVE_SUCCESS);
+            }
+            saveRecordAndChangeUser(param, user);
+            //调用风控广告校验
+            if(AdSourceTypeEnum.rewarded_video.getAdSourceType() == param.getAdSourceType()){
+                Result<?> result = riskFeign.checkAdRisk(user);
+                if(result.getCode()!=200){
+                    return new Result<>(StatusCode.ACCESS_ERR, getTipsMsg());
+                }
             }
         }
         return Result.resultOk(RepMessage.SAVE_SUCCESS);

+ 9 - 1
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/AppUserServiceImpl.java

@@ -231,9 +231,15 @@ public class AppUserServiceImpl implements AppUserService {
         YtDyzUser newUser = new YtDyzUser();
         if (old.getDitchId() == null) {
             newUser.setDitchId(param.getDitchId());
-            YtDitch ditch =  ditchMapper.selectById(param.getDitchId());
+            YtDitch ditch = ditchMapper.selectById(param.getDitchId());
             newUser.setAppId(ditch.getAppId());
         }
+        if (param.getDitchId() != null){
+            newUser.setDitchId(param.getDitchId());
+            YtDitch ditch = ditchMapper.selectById(param.getDitchId());
+            newUser.setAppId(ditch.getAppId());
+        }
+
         newUser.setUserId(old.getUserId());
         newUser.setNickName(userInfo.getNickname());
         newUser.setHeadImg(userInfo.getHeadimgurl());
@@ -243,6 +249,8 @@ public class AppUserServiceImpl implements AppUserService {
         newUser.setDeviceId(param.getDeviceId());
         newUser.setLoginDays(old.getLoginDays()+1);
         appUserMapper.updateUser(newUser);
+        YtDyzUser oldUser = appUserMapper.selectById(newUser.getUserId());
+        System.out.println(oldUser);
     }
 
     /**

+ 30 - 0
yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/AdRecordMapper.xml

@@ -50,6 +50,7 @@
             record_id,
             user_id,
             nick_name,
+            ios_id,
             placement_id,
             ad_source_id,
             revenue,
@@ -69,6 +70,7 @@
                 #{recordId},
                 #{userId},
                 #{nickName},
+                #{iosId},
                 #{placementId},
                 #{adSourceId},
                 #{revenue},
@@ -84,6 +86,28 @@
                 #{appId}
             )
     </insert>
+    <update id="updateOneVisitor" parameterType="com.ytpm.app.model.YtDyzAdRecord">
+        update yt_dyz_ad_record_visitor
+        <set>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="nickName != null">nick_name = #{nickName},</if>
+            <if test="iosId != null">ios_id = #{iosId},</if>
+            <if test="placementId != null">placement_id = #{placementId},</if>
+            <if test="adSourceId != null">ad_source_id = #{adSourceId},</if>
+            <if test="revenue != null">revenue = #{revenue},</if>
+            <if test="networkFormId != null">network_form_id = #{networkFormId},</if>
+            <if test="networkName != null">network_name = #{networkName},</if>
+            <if test="networkPlacementId != null">network_placement_id = #{networkPlacementId},</if>
+            <if test="beginTime != null">begin_time = #{beginTime},</if>
+            <if test="finishTime != null">finish_time = #{finishTime},</if>
+            <if test="resultJson != null">result_json = #{resultJson},</if>
+            <if test="adSourceIndex != null">ad_source_index = #{adSourceIndex},</if>
+            <if test="adSourceType != null">ad_source_type = #{adSourceType},</if>
+            <if test="ecpm != null">ecpm = #{ecpm},</if>
+            <if test="appId != null">app_id = #{appId},</if>
+        </set>
+        where record_id = #{recordId}  <!-- 假设record_id是主键 -->
+    </update>
     <select id="countByAppIds" resultType="java.lang.Integer">
         select
             count(record_id)
@@ -109,6 +133,12 @@
         from yt_dyz_ad_record
         where ios_id = #{iosId}
     </select>
+    <select id="getByIosIdBeforeLogin" resultType="com.ytpm.app.model.YtDyzAdRecord">
+        select
+            record_id, user_id,app_id,ios_id, nick_name, placement_id, ad_source_id, revenue, network_form_id, network_name, network_placement_id, finish_time, begin_time,result_json,ad_source_type,ad_source_index,ecpm
+        from yt_dyz_ad_record_visitor
+        where ios_id = #{iosId}
+    </select>
     <select id="getByUserByParam" resultType="com.ytpm.app.model.YtDyzAdRecord">
         select
         record_id, user_id,app_id, nick_name, placement_id, ad_source_id, revenue, network_form_id, network_name,

+ 172 - 8
yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/AppUserMapper.xml

@@ -225,6 +225,12 @@
             <if test="iosId != null">
                 ios_id = #{iosId},
             </if>
+            <if test="appId != null">
+                app_id = #{appId},
+            </if>
+            <if test="ditchId != null">
+                ditch_id = #{ditchId},
+            </if>
             <if test="phoneJson != null">
                 phone_json = #{phoneJson},
             </if>
@@ -456,33 +462,191 @@
     </select>
     <select id="getByAppId" resultType="com.ytpm.app.view.WxDefaultConfig">
         select
-            config_id, config_name, open_id appId, secret, app_id platformAppId, app_key platformAppSecret, app_type,user_path,login_path,ad_path,answer_path,power_path
-             ,can_simulator,taku_app_id,taku_key,taku_banner_pid,taku_interstitial_pid,taku_reward_pid,taku_native_pid,can_use_adb,can_accumulation,can_use_float,can_use_root,ditch_id,power_wait_time,interstitial_interval_time
+            config_id,
+            config_name,
+            open_id,
+            secret,
+            app_id,
+            app_key,
+            app_type,
+            user_path,
+            login_path,
+            ad_path,
+            answer_path,
+            power_path,
+            taku_app_id,
+            taku_key,
+            taku_banner_pid,
+            taku_native_pid,
+            taku_reward_pid,
+            taku_interstitial_pid,
+            can_use_root,
+            can_use_adb,
+            can_use_float,
+            can_accumulation,
+            can_simulator,
+            ditch_id,
+            power_wait_time,
+            interstitial_interval_time,
+            low_value_tip,
+            brush_tip,
+            flow_interval_time,
+            task_limit_tip,
+            start_wait_time,
+            can_cache_video
         from yt_app_default_config
         where app_id = #{appId}
     </select>
     <select id="getDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
         select
-            config_id, config_name, open_id appId, secret, app_id platformAppId, app_key platformAppSecret, app_type,user_path,login_path,ad_path,answer_path,power_path
-                     ,can_simulator,taku_app_id,taku_key,taku_banner_pid,taku_interstitial_pid,taku_reward_pid,taku_native_pid,can_use_adb,can_accumulation,can_use_float,can_use_root,ditch_id,power_wait_time,interstitial_interval_time
+            config_id,
+            config_name,
+            open_id,
+            secret,
+            app_id,
+            app_key,
+            app_type,
+            user_path,
+            login_path,
+            ad_path,
+            answer_path,
+            power_path,
+            taku_app_id,
+            taku_key,
+            taku_banner_pid,
+            taku_native_pid,
+            taku_reward_pid,
+            taku_interstitial_pid,
+            can_use_root,
+            can_use_adb,
+            can_use_float,
+            can_accumulation,
+            can_simulator,
+            ditch_id,
+            power_wait_time,
+            interstitial_interval_time,
+            low_value_tip,
+            brush_tip,
+            flow_interval_time,
+            task_limit_tip,
+            start_wait_time,
+            can_cache_video
         from yt_app_default_config
         where app_type = #{appType}
     </select>
     <select id="getDefaultConfigByDitchId" resultType="com.ytpm.app.view.WxDefaultConfig">
         select
-            config_id, config_name, open_id, secret, app_id, app_key, app_type,user_path,login_path,ad_path,answer_path,power_path
-             ,can_simulator,taku_app_id,taku_key,taku_banner_pid,taku_interstitial_pid,taku_reward_pid,taku_native_pid,can_use_adb,can_accumulation,can_use_float,can_use_root,ditch_id,power_wait_time,interstitial_interval_time
+            config_id,
+            config_name,
+            open_id,
+            secret,
+            app_id,
+            app_key,
+            app_type,
+            user_path,
+            login_path,
+            ad_path,
+            answer_path,
+            power_path,
+            taku_app_id,
+            taku_key,
+            taku_banner_pid,
+            taku_native_pid,
+            taku_reward_pid,
+            taku_interstitial_pid,
+            can_use_root,
+            can_use_adb,
+            can_use_float,
+            can_accumulation,
+            can_simulator,
+            ditch_id,
+            power_wait_time,
+            interstitial_interval_time,
+            low_value_tip,
+            brush_tip,
+            flow_interval_time,
+            task_limit_tip,
+            start_wait_time,
+            can_cache_video
         from yt_app_default_config
         where ditch_id = #{ditchId}
     </select>
     <select id="getLastOne" resultType="com.ytpm.app.view.WxDefaultConfig">
         select
-            config_id, config_name, open_id, secret, app_id, app_key, app_type,user_path,login_path,ad_path,answer_path,power_path
-             ,can_simulator,taku_app_id,taku_key,taku_banner_pid,taku_interstitial_pid,taku_reward_pid,taku_native_pid,can_use_adb,can_accumulation,can_use_float,can_use_root,ditch_id,power_wait_time,interstitial_interval_time
+            config_id,
+            config_name,
+            open_id,
+            secret,
+            app_id,
+            app_key,
+            app_type,
+            user_path,
+            login_path,
+            ad_path,
+            answer_path,
+            power_path,
+            taku_app_id,
+            taku_key,
+            taku_banner_pid,
+            taku_native_pid,
+            taku_reward_pid,
+            taku_interstitial_pid,
+            can_use_root,
+            can_use_adb,
+            can_use_float,
+            can_accumulation,
+            can_simulator,
+            ditch_id,
+            power_wait_time,
+            interstitial_interval_time,
+            low_value_tip,
+            brush_tip,
+            flow_interval_time,
+            task_limit_tip,
+            start_wait_time,
+            can_cache_video
         from yt_app_default_config
         where app_id =  #{appId}
         limit 1
     </select>
+    <select id="getLastDefaultConfig" resultType="com.ytpm.app.view.WxDefaultConfig">
+        SELECT
+            config_id,
+            config_name,
+            open_id,
+            secret,
+            app_id,
+            app_key,
+            app_type,
+            user_path,
+            login_path,
+            ad_path,
+            answer_path,
+            power_path,
+            taku_app_id,
+            taku_key,
+            taku_banner_pid,
+            taku_native_pid,
+            taku_reward_pid,
+            taku_interstitial_pid,
+            can_use_root,
+            can_use_adb,
+            can_use_float,
+            can_accumulation,
+            can_simulator,
+            ditch_id,
+            power_wait_time,
+            interstitial_interval_time,
+            low_value_tip,
+            brush_tip,
+            flow_interval_time,
+            task_limit_tip,
+            start_wait_time,
+            can_cache_video
+        FROM yt_app_default_config
+        ORDER BY config_id DESC
+            LIMIT 1
+    </select>
     <select id="getSecretByAppId" resultType="java.lang.String">
         select
            secret

+ 19 - 2
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -113,6 +113,11 @@ public class RiskServiceImpl implements RiskService {
     private RedisService redisService;
     @Resource
     private AppMapper appMapper;
+
+    @Value("${risk.visitor.validity-period:48}")
+    private Integer loginCheckValidityPeriod;
+
+
     /**
      * 查询配置字段选项
      */
@@ -1010,6 +1015,12 @@ public class RiskServiceImpl implements RiskService {
         }
         // 游客用户总收益校验
         if(dyzUser.getLoginType() != null && LoginType.VISITOR == dyzUser.getLoginType()){
+            // 已通过用户 不再进行校验
+            String cacheKey = StrUtil.format("visitor:login_validity_{}_{}", dyzUser.getAppId(), dyzUser.getUserId());
+            if (redisService.hasKey(cacheKey)) {
+                log.info("visitor[{}] last check success time < {} h", dyzUser.getUserId(), loginCheckValidityPeriod);
+                return Result.resultOk(RepMessage.RISK_SUCCESS);
+            }
             boolean checkResult = checkVisitorRisk(dyzUser);
             if (!checkResult) {
                // 20250911 需求调整 锁定用户
@@ -1024,8 +1035,13 @@ public class RiskServiceImpl implements RiskService {
                 param.setOperatorName("系统风控");
                 param.setAgentId(configMapper.getApplicationOwner(dyzUser.getAppId()));
                 addBannedRecord(Collections.singletonList(dyzUser.getUserId()),param);
-                YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
-                YtPlatformUserApp userApp =  appMapper.selectParentApp(ytApp.getSuperiorId());
+                YtPlatformUserApp userApp;
+                if (dyzUser.getIosId() != null) {
+                    userApp = appMapper.selectParentApp(dyzUser.getAppId());
+                } else {
+                    YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
+                    userApp =  appMapper.selectParentApp(ytApp.getSuperiorId());
+                }
                 ScheduledExecutorService scheduled  = Executors.newSingleThreadScheduledExecutor();
                 scheduled.schedule(()->{
                     YtDyzUser next = new YtDyzUser();
@@ -1040,6 +1056,7 @@ public class RiskServiceImpl implements RiskService {
                 return Result.resultErr(RepMessage.RISK_VISITOR_LOWER_VALUE);
             }
 //            return checkResult ? Result.resultOk(RepMessage.RISK_SUCCESS) : Result.resultErr(RepMessage.RISK_VISITOR_LOWER_VALUE);
+            redisService.setTimeOutHoursStr(cacheKey, "ok", loginCheckValidityPeriod);
         }
         return Result.resultOk(RepMessage.RISK_SUCCESS);
     }