Forráskód Böngészése

feat: 离线广告保存 增加重复广告过滤处;平台枚举型补充

hidewnd 3 hete
szülő
commit
60c3399560

+ 1 - 1
yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java

@@ -125,7 +125,7 @@ public class TakuApiServiceImpl implements TakuApiService {
         AuthContent authContent = new AuthContent();
         authContent.setAccount_id(channelParam.getChannelAccount());
         authContent.setSecret_key(channelParam.getApiSecret());
-        if (channelParam.getAdPlatformType().equals(AdPlatformTypeEnum.KUAISHOU.getCode())) {
+        if (channelParam.getAdPlatformType().equals(AdPlatformTypeEnum.KUAI_SHOU.getCode())) {
             authContent.setAccess_key(channelParam.getApiKey());
         }
         network.setAuth_content(authContent);

+ 6 - 4
yt-common/src/main/java/com/ytpm/advertise/enums/AdPlatformTypeEnum.java

@@ -7,11 +7,13 @@ public enum AdPlatformTypeEnum {
     CSJ(15,"穿山甲"),
     TENCENT(8,"腾讯广告"),
     BAIDU(22,"百度联盟"),
-    KUAISHOU(28,"快手"),
-    Sigmob(29,"Sigmob"),
+    KUAI_SHOU(28,"快手"),
+    SIGMOB(29,"Sigmob"),
+    AD_MATE_X(93, "美数AdMateX"),
+    BEI_ZI(95, "倍孜"),
     ;
-    private int code;
-    private String desc;
+    private final int code;
+    private final String desc;
 
     AdPlatformTypeEnum(int code, String desc) {
         this.code = code;

+ 3 - 1
yt-common/src/main/java/com/ytpm/agent/param/AppParam.java

@@ -1,6 +1,5 @@
 package com.ytpm.agent.param;
 
-import com.ytpm.advertise.param.AddAppParam;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -94,4 +93,7 @@ public class AppParam {
 
     @ApiModelProperty("小说解锁定时(秒)")
     private Integer unlockTimer;
+
+    @ApiModelProperty("是否展示真实小说名称")
+    private Integer canShowRealNovelName;
 }

+ 3 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentAppView.java

@@ -189,4 +189,7 @@ public class AgentAppView {
     @ApiModelProperty("小说解锁定时(秒)")
     private Integer unlockTimer;
 
+    @ApiModelProperty("是否展示真实小说名称")
+    private Integer canShowRealNovelName;
+
 }

+ 3 - 0
yt-common/src/main/java/com/ytpm/app/model/YtAppDefaultConfig.java

@@ -86,6 +86,9 @@ public class YtAppDefaultConfig {
     @ApiModelProperty("小说解锁定时(秒)")
     private Integer unlockTimer;
 
+    @ApiModelProperty("是否展示真实小说名称")
+    private Integer canShowRealNovelName;
+
     public YtAppDefaultConfig(Object o, String appName, String wxAppId, String wxSecret, String appId, String appKey, int appType,String ditchId) {
         this.configId = Objects.isNull(o)?null: Integer.parseInt(o.toString());
         this.configName = appName;

+ 3 - 0
yt-common/src/main/java/com/ytpm/app/view/WxDefaultConfig.java

@@ -81,4 +81,7 @@ public class WxDefaultConfig {
 
     @ApiModelProperty("小说解锁定时(秒)")
     private Integer unlockTimer;
+
+    @ApiModelProperty("是否展示真实小说名称")
+    private Integer canShowRealNovelName;
 }

+ 31 - 0
yt-middle/middle-platform/src/main/java/com/ytpm/middle/config/JacksonConfig.java

@@ -0,0 +1,31 @@
+package com.ytpm.middle.config;
+
+
+import com.ytpm.handle.CustomDateSerializer;
+import com.ytpm.handle.MultiFormatDateDeserializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Date;
+
+/**
+ * @author lih
+ * @date 2025-10-14 11:06
+ */
+@Configuration
+public class JacksonConfig {
+
+    @Value("${spring.jackson.time-zone:Asia/Shanghai}")
+    private String timeZone;
+
+    @Bean
+    public Jackson2ObjectMapperBuilderCustomizer customJacksonConfig() {
+        return builder -> {
+            // 注册Date类型的序列化器和反序列化器
+            builder.serializerByType(Date.class, new CustomDateSerializer(timeZone));
+            builder.deserializerByType(Date.class, new MultiFormatDateDeserializer(timeZone));
+        };
+    }
+}

+ 1 - 0
yt-middle/middle-platform/src/main/java/com/ytpm/middle/service/impl/ApkServiceImpl.java

@@ -214,6 +214,7 @@ public class ApkServiceImpl implements ApkService {
         config.setCanCacheVideo(param.getCanCacheVideo());
         config.setStartWaitTime(param.getStartWaitTime());
         config.setCanAllowAutoRefresh(param.getCanAllowAutoRefresh());
+        config.setCanShowRealNovelName(param.getCanShowRealNovelName());
         feignInvoker.invoke(app.getServiceName(), "updateAppConfig",config);
     }
 

+ 0 - 1
yt-novel/yt-novel-service/src/main/java/com/ytpm/novel/controller/NovelController.java

@@ -1,7 +1,6 @@
 package com.ytpm.novel.controller;
 
 
-import com.ytpm.app.model.YtNovelChapter;
 import com.ytpm.novel.model.dto.YtNovelCategoryDto;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;

+ 20 - 3
yt-novel/yt-novel-service/src/main/java/com/ytpm/novel/service/impl/NovelServiceImpl.java

@@ -22,7 +22,6 @@ import com.ytpm.novel.model.dto.YtNovelDto;
 import com.ytpm.novel.model.param.NovelPageParam;
 import com.ytpm.novel.model.param.NovelRecordParam;
 import com.ytpm.novel.model.param.NovelShelfParam;
-import com.ytpm.novel.redis.RedisService;
 import com.ytpm.novel.service.NovelService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -40,8 +39,6 @@ import java.util.List;
 @Service("novelService")
 public class NovelServiceImpl implements NovelService {
 
-    @Resource
-    private RedisService redisService;
     @Resource
     private NovelMapper novelMapper;
     @Resource
@@ -51,9 +48,28 @@ public class NovelServiceImpl implements NovelService {
     public PageInfo<YtNovelDto> selectNovelPage(NovelPageParam param) {
         PageHelper.startPage(param.getPage(), param.getLimit());
         List<YtNovelDto> list = novelMapper.selectNovelPage(param);
+        for (YtNovelDto dto : list) {
+            dto.setNovelTemporaryName(dto.getNovelName());
+        }
         return new PageInfo<>(list);
     }
 
+    /**
+     * 获取小说临时名称
+     */
+    private String getTemporaryName(String novelName){
+        String novelTemporaryName = novelName;
+        if (StrUtil.isNotEmpty(novelName)) {
+            if (novelName.length() > 10) {
+                novelTemporaryName = novelName.substring(0, 6);
+            }
+            else if (novelName.length() > 2) {
+                novelTemporaryName = novelName.substring(0,2) + "**" + novelName.charAt(novelName.length() - 1);
+            }
+        }
+        return novelTemporaryName;
+    }
+
     @Override
     public PageInfo<YtNovelChapterDto> selectNovelChapterPage(NovelPageParam param) {
         PageHelper.startPage(param.getPage(), param.getLimit());
@@ -75,6 +91,7 @@ public class NovelServiceImpl implements NovelService {
             return dto;
         }
         BeanUtil.copyProperties(novel, dto);
+        dto.setNovelTemporaryName(dto.getNovelName());
         // 查询最后阅读章节
         if (StrUtil.isNotEmpty(userId)) {
             YtNovelReadRecord lastReadRecord = novelMapper.selectLastRecord(userId, novelId);

+ 7 - 15
yt-novel/yt-novel-service/src/main/resources/mapper/AppUserMapper.xml

@@ -172,8 +172,11 @@
             <if test="unlockTimer != null">
                 unlock_timer = #{unlockTimer},
             </if>
+            <if test="canShowRealNovelName != null">
+                can_show_real_novle_name = #{canShowRealNovelName},
+            </if>
             <if test="revenueDisplayRate != null">
-                revenue_display_rate = #{revenueDisplayRate}
+                can_show_real_novle_name = #{revenueDisplayRate}
             </if>
         </set>
         where app_id = #{appId}
@@ -463,7 +466,7 @@
             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,can_allow_auto_refresh,revenue_display_rate,unlock_timer
+            can_cache_video,can_allow_auto_refresh,revenue_display_rate,unlock_timer,can_show_real_novle_name
         from yt_app_default_config
         where app_type = #{appType}
     </select>
@@ -474,18 +477,7 @@
             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,can_allow_auto_refresh,revenue_display_rate,unlock_timer
-        from yt_app_default_config
-        where app_id = #{appId}
-    </select>
-    <select id="getSecretByAppId" resultType="java.lang.String">
-        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_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,can_allow_auto_refresh,revenue_display_rate,unlock_timer
+            can_cache_video,can_allow_auto_refresh,revenue_display_rate,unlock_timer,can_show_real_novle_name
         from yt_app_default_config
         where app_id = #{appId}
     </select>
@@ -510,7 +502,7 @@
         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,can_allow_auto_refresh,
-        revenue_display_rate,unlock_timer
+        revenue_display_rate,unlock_timer,can_show_real_novle_name
         from yt_app_default_config
         where app_id in
         <foreach collection="appIds.split(',')" item="item" separator="," open="(" close=")">

+ 1 - 1
yt-question/yt-question-service/src/main/java/com/ytpm/question/controller/AdController.java

@@ -44,7 +44,7 @@ public class AdController {
     }
 
     /**
-     * 保存广告记录
+     * 保存因离线而暂存的广告记录
      */
     @ApiOperation("延迟保存广告记录")
     @PostMapping("/saveRecord/delay")

+ 2 - 0
yt-question/yt-question-service/src/main/java/com/ytpm/question/dao/AdRecordMapper.java

@@ -26,6 +26,8 @@ public interface AdRecordMapper {
      */
     void addOneVisitor(YtDyzAdRecord adRecord);
 
+    YtDyzAdRecord getByTakuAdId(@Param("userId") String userId, @Param("id") String id);
+
     void batchAddVisitor(@Param("adRecords") List<YtDyzAdRecord> adRecords);
 
     /**

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

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.ytpm.advertise.enums.AdPlatformTypeEnum;
 import com.ytpm.advertise.enums.AdSourceTypeEnum;
 import com.ytpm.agent.enums.AdRecordEnum;
@@ -124,10 +125,27 @@ public class AdServiceImpl implements AdService {
         log.info("[delaySaveRecord] userId:{}", param.getUserId());
         if (CollectionUtil.isNotEmpty(param.getAdRecords())) {
             YtDyzAdRecord insertEntity;
+            List<String> filter = new ArrayList<>();
             List<YtDyzAdRecord> saveList = new ArrayList<>();
             BigDecimal totalRevenue = BigDecimal.ZERO;
             for (DyzAdRecordParam adParam : param.getAdRecords()) {
                 handleTimeNull(adParam);
+                String takuAdId = null;
+                if (StrUtil.isNotEmpty(adParam.getResultJson())) {
+                    JSONObject json = JSONObject.parseObject(adParam.getResultJson());
+                    takuAdId = json.getString("id");
+                }
+                // 广告数据校验 重复数据过滤
+                if (StrUtil.isNotEmpty(takuAdId)) {
+                    if (filter.contains(takuAdId)) {
+                        continue;
+                    }
+                    YtDyzAdRecord record = adRecordMapper.getByTakuAdId(user.getUserId(), takuAdId);
+                    if (record != null) {
+                        continue;
+                    }
+                    filter.add(takuAdId);
+                }
                 insertEntity = new YtDyzAdRecord();
                 BeanUtils.copyProperties(adParam, insertEntity);
                 insertEntity.setRecordId(IdUtil.fastSimpleUUID());
@@ -143,13 +161,14 @@ public class AdServiceImpl implements AdService {
                 }
             }
             if (CollUtil.isNotEmpty(saveList)) {
+                log.info("[delaySaveRecord] saveCount:{}, {}", saveList.size(), saveList.stream().map(YtDyzAdRecord::getRecordId).collect(Collectors.joining(",")));
                 if (param.getLoginStatus() != null && AdRecordEnum.LOGIN_BEFORE.getCode().equals(param.getLoginStatus())) {
                     adRecordMapper.batchAddVisitor(saveList);
                 } else {
                     adRecordMapper.batchAdd(saveList);
                 }
+                appUserMapper.updateTotal(user.getUserId(), saveList.size(), totalRevenue);
             }
-            appUserMapper.updateTotal(user.getUserId(), saveList.size(), totalRevenue);
         }
         return Result.resultOk(RepMessage.SAVE_SUCCESS);
     }

+ 9 - 0
yt-question/yt-question-service/src/main/resources/mapper/AdRecordMapper.xml

@@ -371,5 +371,14 @@
             AND DATE(finish_time) = DATE(NOW())
         </if>
     </select>
+    <select id="getByTakuAdId" 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, network_placement_id, finish_time, begin_time,
+            result_json,ad_source_type,ad_source_index,ecpm
+        from yt_dyz_ad_record
+        where user_id = #{userId} and JSON_EXTRACT(result_json, '$.id') = #{id}
+        limit 1
+    </select>
 
 </mapper>