Quellcode durchsuchen

feat:同步origin/lih分支修改

hidewnd vor 1 Monat
Ursprung
Commit
a0efb2f4ee

+ 1 - 1
yt-agent/agent-service/src/main/java/com/ytpm/dao/AppMapper.java

@@ -20,7 +20,7 @@ public interface AppMapper {
      */
     YtApp selectPrimary(@Param("appId") String appId);
 
-    List<YtApp> selectByDitchId(@Param("ditchId") Long ditchId);
+    YtApp selectByDitchId(@Param("ditchId") Long ditchId);
 
     /**
      * 保存应用

+ 8 - 11
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java

@@ -1,6 +1,5 @@
 package com.ytpm.service.impl;
 
-import cn.hutool.core.collection.CollUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.agent.model.YtApp;
@@ -18,9 +17,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 @Service
 public class AgentDitchServiceImpl implements AgentDitchService {
@@ -59,12 +58,10 @@ public class AgentDitchServiceImpl implements AgentDitchService {
         agentDitchMapper.update(param);
         //同时修改app中的渠道类型名称
         Long ditchId = param.getDitchId();
-        List<YtApp> ytApps = appMapper.selectByDitchId(ditchId);
-        if(CollUtil.isNotEmpty(ytApps)){
-            for (YtApp ytApp : ytApps) {
-                ytApp.setDitchName(param.getDitchName());
-                appMapper.updateOne(ytApp);
-            }
+        YtApp ytApp = appMapper.selectByDitchId(ditchId);
+        if (ytApp != null) {
+            ytApp.setDitchName(param.getDitchName());
+            appMapper.updateOne(ytApp);
         }
         return Result.resultOk(RepMessage.MODIFY_SUCCESS);
     }
@@ -76,9 +73,9 @@ public class AgentDitchServiceImpl implements AgentDitchService {
         ytDitch.setDitchId(ditchId);
         agentDitchMapper.update(ytDitch);
         // 20250917 删除渠道后 同步删除渠道下应用(假删除)及应用风控配置(真删除)
-        List<YtApp> ytApps = appMapper.selectByDitchId(ditchId);
-        if(CollUtil.isNotEmpty(ytApps)){
-            List<String> ids = ytApps.stream().map(YtApp::getAppId).collect(Collectors.toList());
+        YtApp ytApp = appMapper.selectByDitchId(ditchId);
+        if(ytApp != null){
+            List<String> ids = Collections.singletonList(ytApp.getAppId());
             appMapper.deleteAppIds(ids);
             appMapper.deleteRisks(ids);
         }

+ 1 - 1
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -166,7 +166,7 @@
         select
             app_id, ditch_id, ditch_name, app_key, app_name,user_id, app_type, apk_url, qr_code, version_code, update_tips, enabled,ditch_name,ditch_id
         from yt_app
-        where ditch_id = #{ditchId}
+        where ditch_id = #{ditchId} and enabled = 1
     </select>
     <select id="getAppList" resultType="com.ytpm.middle.view.AppListVO">
         select

+ 2 - 2
yt-question/yt-question-service/src/main/java/com/ytpm/question/service/impl/AdServiceImpl.java

@@ -76,8 +76,8 @@ public class AdServiceImpl implements AdService {
     @Transactional(rollbackFor = Exception.class)
     public Result<?> saveRecord(DyzAdRecordParam param) {
         YtDyzUser user = appUserMapper.selectPrimaryKey(param.getUserId());
-        log.info(StrUtil.format("[saveRecord]:{} ", param.getBeginTime()));
-        if (Objects.isNull(user)) {
+        log.warn(StrUtil.format("[saveRecord] userId:{} revenue:{} ", param.getUserId(), param.getRevenue()));
+        if(Objects.isNull(user)){
             return Result.resultOk(RepMessage.SAVE_SUCCESS);
         }
         if (!UserStatusEnum.NORMAL.getCode().equals(user.getUserStatus())) {

+ 5 - 1
yt-question/yt-question-service/src/main/java/com/ytpm/question/service/impl/VisitorLoginServiceImpl.java

@@ -184,6 +184,7 @@ public class VisitorLoginServiceImpl extends AbstractLoginService {
         List<DyzAdRecordParam> preAdList = visitorLoginParam.getPreAdList();
         List<String> adRecordIds = new ArrayList<>();
         if (CollUtil.isNotEmpty(preAdList)) {
+            BigDecimal totalRevenue = BigDecimal.ZERO;
             for (DyzAdRecordParam adRecordParam : preAdList) {
                 if (adRecordParam == null) {
                     continue;
@@ -194,9 +195,12 @@ public class VisitorLoginServiceImpl extends AbstractLoginService {
                 adRecordParam.setLoginStatus(AdRecordEnum.LOGIN_BEFORE.getCode());
                 String recordId = adService.saveRecordAndChangeUser(adRecordParam, ytDyzUser);
                 adRecordIds.add(recordId);
+                totalRevenue = adRecordParam.getRevenue() == null ? totalRevenue : totalRevenue.add(adRecordParam.getRevenue());
             }
+            log.info(StrUtil.format("[visitor adRecords] userId:{} recordCount:{} revenue:{} ",
+                    ytDyzUser.getUserId(), adRecordIds.size(), totalRevenue));
         }
-        if (CollUtil.isEmpty(adRecordIds)) {
+        if(CollUtil.isEmpty(adRecordIds)) {
             throw new CustomerException(StrUtil.emptyToDefault(defaultConfig.getLowValueTip(), RepMessage.RISK_VISITOR_LOWER_VALUE));
         }
         ytDyzUser.setPreAdRecordList(adService.queryRecordByIds(adRecordIds));

+ 61 - 28
yt-question/yt-question-service/src/main/resources/mapper/AppUserMapper.xml

@@ -12,6 +12,7 @@
          login_days,
          total_video,
          total_income,
+         nearly_income,
          red_packet_balance,
          red_packet_amount,
          points_balance,
@@ -37,6 +38,7 @@
                 #{loginDays},
                 #{totalVideo},
                 #{totalIncome},
+                #{nearlyIncome},
                 #{redPacketBalance},
                 #{redPacketAmount},
                 #{pointsBalance},
@@ -162,7 +164,10 @@
                 start_wait_time = #{startWaitTime},
             </if>
             <if test="canCacheVideo != null">
-                can_cache_video = #{canCacheVideo}
+                can_cache_video = #{canCacheVideo},
+            </if>
+            <if test="canAllowAutoRefresh != null">
+                can_allow_auto_refresh = #{canAllowAutoRefresh}
             </if>
         </set>
         where app_id = #{appId}
@@ -206,6 +211,9 @@
             <if test="totalIncome != null">
                 total_income = #{totalIncome},
             </if>
+            <if test="nearlyIncome != null">
+                nearly_income = #{nearlyIncome},
+            </if>
             <if test="redPacketBalance != null">
                 red_packet_balance = #{redPacketBalance},
             </if>
@@ -247,14 +255,20 @@
     </delete>
     <select id="getYtAppUser" resultType="com.ytpm.app.model.YtDyzUser">
         select
-            user_id, app_id,phone,device_id, ditch_id, nick_name,head_img, power, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id
+            user_id, app_id,phone,device_id, ditch_id, nick_name,head_img, power,
+            registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, nearly_income,
+            red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total,
+            sign_days, user_status, risk_reason, wx_open_id, platform_id
         from yt_dyz_user
         where wx_open_id = #{openid}
           and ditch_id = #{ditchId}
     </select>
     <select id="queryAll" resultType="com.ytpm.app.view.YtAppUserListView">
         select
-        user_id,app_id,phone,device_id, ditch_id, nick_name,head_img, power, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id
+        user_id,app_id,phone,device_id, ditch_id, nick_name,head_img, power,
+        registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, nearly_income,
+        red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total,
+        sign_days, user_status, risk_reason, wx_open_id, platform_id
         from yt_dyz_user
         where 1 = 1
         <if test="userId != null and userId !=''">
@@ -291,7 +305,9 @@
     </select>
     <select id="selectPrimaryKey" resultType="com.ytpm.app.model.YtDyzUser">
         select
-            user_id,app_id,phone,device_id, ditch_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id, power
+            user_id,app_id,phone,device_id, ditch_id, head_img, nick_name, registry_time, last_login_time, last_login_ip,
+            login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total,
+            withdraw_total, sign_days, user_status, risk_reason, wx_open_id, platform_id, power, nearly_income
         from yt_dyz_user
         where user_id = #{userId}
     </select>
@@ -307,6 +323,7 @@
         <result column="login_days" property="loginDays" />
         <result column="total_video" property="totalVideo" />
         <result column="total_income" property="totalIncome" />
+        <result column="nearly_income" property="nearlyIncome" />
         <result column="red_packet_balance" property="redPacketBalance" />
         <result column="red_packet_amount" property="redPacketAmount" />
         <result column="points_balance" property="pointsBalance" />
@@ -344,6 +361,7 @@
         du.login_days,
         du.total_video,
         du.total_income,
+        du.nearly_income,
         du.red_packet_balance,
         du.red_packet_amount,
         du.points_balance,
@@ -385,11 +403,10 @@
 
     <select id="queryAllByTime" resultType="com.ytpm.app.model.YtDyzUser">
         SELECT
-        user_id,app_id,phone,device_id, nick_name, head_img, power, registry_time,
-        last_login_time, last_login_ip, login_days, total_video,
-        total_income, red_packet_balance, red_packet_amount,
-        points_balance, points_total, withdraw_total, sign_days,
-        user_status, risk_reason, wx_open_id, platform_id
+        user_id,app_id,phone,device_id, nick_name, head_img, power,
+        registry_time,last_login_time, last_login_ip, login_days, total_video, total_income, nearly_income,
+        red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total,
+        sign_days, user_status, risk_reason, wx_open_id, platform_id
         FROM yt_dyz_user
         <where>
             <if test="startTime != null">
@@ -448,7 +465,8 @@
             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,
             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
+            low_value_tip, brush_tip,flow_interval_time,task_limit_tip,start_wait_time,
+            can_cache_video,can_allow_auto_refresh
         from yt_app_default_config
         where app_type = #{appType}
     </select>
@@ -458,7 +476,8 @@
             answer_path,power_path,can_simulator, 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,
             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
+            low_value_tip, brush_tip,flow_interval_time,task_limit_tip,start_wait_time,
+            can_cache_video,can_allow_auto_refresh
         from yt_app_default_config
         where app_id = #{appId}
     </select>
@@ -468,22 +487,23 @@
             answer_path,power_path,can_simulator, 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,
             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
+            low_value_tip, brush_tip, flow_interval_time,task_limit_tip,start_wait_time,
+            can_cache_video,can_allow_auto_refresh
         from yt_app_default_config
         where app_id = #{appId}
     </select>
     <select id="queryByOpenid" resultType="com.ytpm.app.model.YtDyzUser">
         select
-            user_id,phone,device_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power
+            user_id,phone,device_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days,
+            total_video, total_income, nearly_income, red_packet_balance, red_packet_amount, points_balance, points_total,
+            withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power
         from yt_dyz_user
         where wx_open_id = #{openid}
     </select>
     <select id="getByDeviceId" resultType="java.lang.String">
-        select
-            platform_id
+        select platform_id
         from yt_dyz_user
-        where device_id = #{deviceId}
-          and wx_open_id = #{openid}
+        where device_id = #{deviceId} and wx_open_id = #{openid}
         limit 1
     </select>
     <select id="getConfigByIds" resultType="com.ytpm.app.view.WxDefaultConfig">
@@ -500,8 +520,7 @@
         </foreach>
     </select>
     <select id="getAdCount" resultType="java.lang.Integer">
-        select
-        sum(total_video)
+        select sum(total_video)
         from yt_dyz_user
         where app_id in
         <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
@@ -509,8 +528,7 @@
         </foreach>
     </select>
     <select id="getRevenueCount" resultType="java.math.BigDecimal">
-        select
-        sum(total_income)
+        select sum(total_income)
         from yt_dyz_user
         where app_id in
         <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
@@ -721,7 +739,10 @@
     </select>
     <select id="getMonthRegistryUser" resultType="com.ytpm.app.model.YtDyzUser">
         select
-        user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power, phone, device_id
+        user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days,
+        total_video, total_income, nearly_income, red_packet_balance, red_packet_amount, points_balance, points_total,
+        withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id,
+        power, phone, device_id
         from yt_dyz_user
         where app_id in
         <foreach collection="appIds.split(',')" separator="," item="item" open="(" close=")">
@@ -750,20 +771,25 @@
     </select>
     <select id="getLastRegistryUser" resultType="com.ytpm.app.model.YtDyzUser">
         select
-            user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power, phone, device_id, phone_json
+            user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days,
+            total_video, total_income, nearly_income, red_packet_balance, red_packet_amount, points_balance, points_total,
+            withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id,
+            power, phone, device_id, phone_json
         from yt_dyz_user
         where device_id = #{deviceId}
     </select>
 
     <select id="getByDeviceAndDitch" resultType="com.ytpm.app.model.YtDyzUser">
         select
-            user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id, power, phone, device_id, phone_json
+            user_id, head_img, nick_name, registry_time, last_login_time, last_login_ip, login_days,
+            total_video, total_income, nearly_income, red_packet_balance, red_packet_amount, points_balance, points_total,
+            withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ditch_id, app_id, platform_id,
+            power, phone, device_id, phone_json
         from yt_dyz_user
         where device_id = #{deviceId} and ditch_id = #{ditchId} limit 1
     </select>
     <select id="getPlatformByDeviceId" resultType="java.lang.String">
-        select
-            platform_id
+        select platform_id
         from yt_dyz_user
         where device_id = #{deviceId}
         limit 1
@@ -779,8 +805,15 @@
     </update>
     <update id="updateTotal">
         UPDATE yt_dyz_user
-        SET total_video = COALESCE(total_video, 0) + #{videoCount},
-            total_income = COALESCE(total_income, 0) + #{revenue}
+        SET nearly_income = 0, nearly_begin_time = NOW()
         WHERE user_id = #{userId}
+          AND last_login_time <![CDATA[ < ]]>  DATE_SUB(NOW(), INTERVAL 3 DAY)
+          AND IFNULL(nearly_begin_time, NOW()) <![CDATA[ < ]]> DATE_SUB(NOW(), INTERVAL 3 DAY);
+        UPDATE yt_dyz_user SET nearly_begin_time = NOW() WHERE user_id = #{userId} AND nearly_begin_time IS NULL;
+        UPDATE yt_dyz_user
+        SET total_video = COALESCE(total_video, 0) + #{videoCount},
+            total_income = COALESCE(total_income, 0) + #{revenue},
+            nearly_income = COALESCE(nearly_income, 0) + #{revenue}
+        WHERE user_id = #{userId};
     </update>
 </mapper>