Jelajahi Sumber

Merge remote-tracking branch 'origin/master' into lih

hidewnd 1 bulan lalu
induk
melakukan
b9ab58b18f

+ 2 - 2
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentIndexController.java

@@ -137,11 +137,11 @@ public class AgentIndexController {
         if(CollUtil.isEmpty(appList)){
             return Result.resultErr(RepMessage.APP_EMPTY);
         }
-        //设定缓存键值 小于三分钟时更新续存
+        //设定缓存键值
         String redisKey = StrConstant.PLATFORM_AGENT_SUFFIX + appId +StrConstant.PROFIT+userInfo.getUserId();
         String appIds = appList.stream().map(YtApp::getAppId).distinct().collect(Collectors.joining(","));
         //分广告平台,分别统计用户当天、昨日、本月的数据封装并返回
-        if(Boolean.FALSE.equals(redisService.hasKey(redisKey)) || redisService.getExpire(redisKey) < 3){
+        if(Boolean.FALSE.equals(redisService.hasKey(redisKey))){
             Object o = feignInvoker.invoke(app.getServiceName(),"getAgentProfit", appIds);
             List<AgentAdGroupStaticsVO> agentProfit = JSONArray.parseArray(JSON.toJSONString(o), AgentAdGroupStaticsVO.class);
             if(CollUtil.isNotEmpty(agentProfit)){

+ 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));
     }

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

@@ -29,6 +29,7 @@ import com.ytpm.risk.view.RiskConfigView;
 import com.ytpm.risk.view.RiskTemplateView;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.Errors;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -172,9 +173,22 @@ public class UserController {
     }
 
     @PostMapping("/adRecords/page")
-    public ResultTable<YtDyzAdRecord> adRecordsPage(@RequestBody AdRecordListParam param) {
+    public ResultTable<YtDyzAdRecord> adRecordsPage(@RequestBody AdRecordListParam param, Errors errors) {
         PageHelper.startPage(param.getPage(), param.getLimit());
-        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));
     }
 

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

@@ -5,23 +5,22 @@ 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;
 import com.ytpm.app.model.YtAppDefaultConfig;
 import com.ytpm.app.model.YtDyzAdRecord;
 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;
@@ -29,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;
@@ -116,7 +109,6 @@ public class WxController {
         IosUserInfo userInfo = setIosUserInfo(param);
         param.setLoginIp(getClientIp(request));
         YtDyzUser old = appUserService.crudForNewTransIos(param, userInfo);
-        riskFeign.checkLoginRisk(old);
         //调用风控服务校验默认风控配置
         old.setRiskCode("313");
         Result<?> result = riskFeign.checkRisk(old);
@@ -139,11 +131,25 @@ public class WxController {
         YtDyzUser user = appUserMapper.selectByIosId(param.getIosId());
         if (user == null) {
             IosUserInfo userInfo = setIosUserInfo(param);
-            YtDyzUser old = appUserService.crudForNewTransIos(param, userInfo);
-            return Result.resultObjOk(old);
+            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");
+        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);

+ 16 - 5
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);
     }
 
     /**
@@ -300,11 +308,14 @@ public class AppUserServiceImpl implements AppUserService {
         old.setWithdrawTotal(BigDecimal.ZERO);
         old.setDitchId(param.getDitchId());
         old.setSignDays(0);
-        YtDitch ditch = ditchMapper.selectById(param.getDitchId());
-        if (ditch != null) {
-            old.setAppId(ditch.getAppId());
+        YtDitch ditch;
+        if (param.getDitchId() == null){
+            old.setDitchId(2025062500193L);
+            old.setAppId("251be4dff0fd408fbc1fe2c47bf515eb");
         } else {
-            old.setAppId("");
+            ditch = ditchMapper.selectById(param.getDitchId());
+            old.setDitchId(param.getDitchId());
+            old.setAppId(ditch.getAppId());
         }
         old.setUserStatus(UserStatusEnum.NORMAL.getCode());
         old.setIosId(param.getIosId());

+ 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

+ 43 - 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;
+
+
     /**
      * 查询配置字段选项
      */
@@ -496,8 +501,11 @@ public class RiskServiceImpl implements RiskService {
     @Override
     public Result<?> checkAdRisk(YtDyzUser dyzUser) {
         //查询当前用户今日有被解封则直接放行
+        long start = System.currentTimeMillis();
         List<RiskDeblockingListView> vo = riskManageMapper.queryTodayDeblock(dyzUser.getUserId());
         if(CollUtil.isNotEmpty(vo)){
+            log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
+                    dyzUser.getAppId(), System.currentTimeMillis() - start));
             return Result.resultOk(RepMessage.QUERY_SUCCESS);
         }
         YtApp ytApp = appMapper.selectRiskApp(dyzUser.getAppId());
@@ -507,6 +515,8 @@ public class RiskServiceImpl implements RiskService {
         JSONObject object = JSON.parseObject(JSON.toJSONString(o));
         List<YtDyzAdRecord> adRecords = JSONArray.parseArray(object.getString("data"), YtDyzAdRecord.class);
         if(CollUtil.isEmpty(adRecords)){
+            log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
+                    dyzUser.getAppId(), System.currentTimeMillis() - start));
             return Result.resultOk(RepMessage.QUERY_SUCCESS);
         }
         try {
@@ -527,8 +537,12 @@ public class RiskServiceImpl implements RiskService {
                 checkRisk766(dyzUser, adRecords);
             }
         } catch (CommonException e) {
+            log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
+                    dyzUser.getAppId(), System.currentTimeMillis() - start));
             return Result.resultFail(StatusCode.ACCESS_RISK_ERROR, e.getMessage());
         }
+        log.debug(StrUtil.format("[checkAdRisk] appId:{} (end - start):{}",
+                dyzUser.getAppId(), System.currentTimeMillis() - start));
         return Result.resultOk(RepMessage.QUERY_SUCCESS);
     }
 
@@ -999,6 +1013,7 @@ public class RiskServiceImpl implements RiskService {
      */
     @Override
     public Result<?> checkLoginRisk(YtDyzUser dyzUser) {
+        long start = System.currentTimeMillis();
         // 20250908 移除游客登陆校验
 //        // 游客登陆风控校验
 //        RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-323");
@@ -1010,6 +1025,14 @@ 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);
+                log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
+                        dyzUser.getAppId(), System.currentTimeMillis() - start));
+                return Result.resultOk(RepMessage.RISK_SUCCESS);
+            }
             boolean checkResult = checkVisitorRisk(dyzUser);
             if (!checkResult) {
                // 20250911 需求调整 锁定用户
@@ -1024,8 +1047,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();
@@ -1037,10 +1065,15 @@ public class RiskServiceImpl implements RiskService {
                 },300, TimeUnit.MILLISECONDS);
                 //修改为解锁用户存入redis 24小时后进行解锁
                 scheduled.shutdown();
+                log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
+                        dyzUser.getAppId(), System.currentTimeMillis() - start));
                 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);
         }
+        log.debug(StrUtil.format("[checkLoginRisk] appId:{} (end - start):{}",
+                dyzUser.getAppId(), System.currentTimeMillis() - start));
         return Result.resultOk(RepMessage.RISK_SUCCESS);
     }
 
@@ -1074,6 +1107,7 @@ public class RiskServiceImpl implements RiskService {
     private boolean checkVisitorRisk(YtDyzUser dyzUser) {
         RiskTemplateView view = configMapper.getByCode(dyzUser.getAppId() + "-344");
         RiskTemplateView view2 = configMapper.getByCode(dyzUser.getAppId() + "-345");
+
         boolean checkResult = true;
         if((view != null && view.getEnabled() == 1) || (view2 != null && view2.getEnabled() == 1)) {
             //根据用户所属应用查询该应用母包openid查询用户信息
@@ -1146,6 +1180,7 @@ public class RiskServiceImpl implements RiskService {
 
     @Override
     public Result<?> checkAdRisk766(YtDyzUser dyzUser) {
+        long start = System.currentTimeMillis();
         YtPlatformUserApp userApp;
         if (dyzUser.getIosId()!=null) {
             userApp =  appMapper.selectParentApp(dyzUser.getAppId());
@@ -1158,6 +1193,8 @@ public class RiskServiceImpl implements RiskService {
         JSONObject object = JSON.parseObject(JSON.toJSONString(o));
         List<YtDyzAdRecord> adRecords = JSONArray.parseArray(object.getString("data"), YtDyzAdRecord.class);
         if(CollUtil.isEmpty(adRecords)){
+            log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
+                    dyzUser.getAppId(), System.currentTimeMillis() - start));
             return Result.resultOk(RepMessage.QUERY_SUCCESS);
         }
         //过滤出当日的激励视频数据 按照时间正序排以便筛选每日前几条激励视频
@@ -1169,9 +1206,13 @@ public class RiskServiceImpl implements RiskService {
                 // 校验风控766规则
                 checkRisk766(dyzUser, adRecords);
             } catch (CommonException e) {
+                log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
+                        dyzUser.getAppId(), System.currentTimeMillis() - start));
                 return Result.resultFail(StatusCode.ACCESS_ERR, e.getMessage());
             }
         }
+        log.debug(StrUtil.format("[checkAdRisk766] appId:{} (end - start):{}",
+                dyzUser.getAppId(), System.currentTimeMillis() - start));
         return Result.resultOk(RepMessage.QUERY_SUCCESS);
     }