Bladeren bron

fix: 同步nofeeds

hidewnd 1 maand geleden
bovenliggende
commit
7eda847f7b

+ 9 - 0
yt-nofeeds/nofeeds-feign/src/main/java/com/ytpm/nofeeds/feign/NofeedsFeign.java

@@ -1,5 +1,6 @@
 package com.ytpm.nofeeds.feign;
 
+import com.ytpm.agent.param.AdRecordListParam;
 import com.ytpm.agent.param.AuditCheckParam;
 import com.ytpm.agent.view.AgentAdGroupStaticsVO;
 import com.ytpm.agent.view.AgentTopCountView;
@@ -51,6 +52,14 @@ public interface NofeedsFeign {
     @GetMapping("/user/adRecords")
     ResultTable<YtDyzAdRecord> adRecords(@RequestParam(name = "userId",required = true) String userId,@RequestParam(name = "adsourceType",required = false)Integer adsourceType);
 
+    @PostMapping("/user/adRecords/page")
+    ResultTable<YtDyzAdRecord> adRecordsPage(@RequestBody AdRecordListParam param);
+
+    @GetMapping("/user/adRecords/count/month")
+    Result<Integer> queryRecordMonthCount(@RequestParam(name = "userId") String userId,
+                                          @RequestParam(name = "adSourceType", required = false) Integer adSourceType,
+                                          @RequestParam(name = "startTime", required = false) String startTime);
+
     @PostMapping("/user/queryUserByTime")
     List<YtDyzUser> queryUserByTime(@RequestBody AppUserQueryParam appUserQueryParam);
 

+ 32 - 0
yt-nofeeds/nofeeds-service/src/main/java/com/ytpm/nofeeds/controller/UserController.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.advertise.enums.AdSourceTypeEnum;
 import com.ytpm.agent.enums.UserStatusEnum;
+import com.ytpm.agent.param.AdRecordListParam;
 import com.ytpm.agent.param.AuditCheckParam;
 import com.ytpm.agent.param.AuditUserParam;
 import com.ytpm.agent.view.AgentAuditCheckVO;
@@ -47,6 +48,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -194,6 +196,36 @@ public class UserController {
         return ResultTable.resultTableOk(new PageInfo<YtDyzAdRecord>(adRecordMapper.getByUserId(userId, adsourceType)));
     }
 
+    @PostMapping("/adRecords/page")
+    public ResultTable<YtDyzAdRecord> adRecordsPage(@RequestBody AdRecordListParam param) {
+        PageHelper.startPage(param.getPage(), param.getLimit());
+        List<YtDyzAdRecord> adrecords = adRecordMapper.getByUserByParam(param);
+        return ResultTable.resultTableOk(new PageInfo<>(adrecords));
+    }
+
+    /**
+     * 查询广告记录统计数
+     */
+    @GetMapping("/adRecords/count/month")
+    public Result<Integer> queryRecordMonthCount(@RequestParam(name = "userId") String userId,
+                                                 @RequestParam(name = "adSourceType", required = false) Integer adSourceType,
+                                                 @RequestParam(name = "startTime", required = false) String startTime) {
+        Date time;
+        // 统计起始时间为空,则默认查询当月信息
+        if (StrUtil.isEmpty(startTime)) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date());
+            calendar.set(Calendar.DAY_OF_MONTH, 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+            calendar.set(Calendar.MINUTE, 0);
+            calendar.set(Calendar.SECOND, 0);
+            time = calendar.getTime();
+        } else {
+            time = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
+        }
+        return Result.resultObjOk(adRecordMapper.getRecordMonthCount(userId, adSourceType, time));
+    }
+
     @PostMapping("/queryUserByTime")
     public List<YtDyzUser> queryUserByTime(@RequestBody AppUserQueryParam appUserQueryParam) {
         List<YtDyzUser> ytDyzUsers = appUserMapper.queryAllByTime(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime(),appUserQueryParam.getAppIdList());

+ 11 - 0
yt-nofeeds/nofeeds-service/src/main/java/com/ytpm/nofeeds/dao/AdRecordMapper.java

@@ -1,5 +1,6 @@
 package com.ytpm.nofeeds.dao;
 
+import com.ytpm.agent.param.AdRecordListParam;
 import com.ytpm.app.model.YtDyzAdRecord;
 import com.ytpm.app.param.YtAppUserListParam;
 import com.ytpm.middle.view.AppRevenueHourVO;
@@ -7,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 @Mapper
@@ -26,6 +28,15 @@ public interface AdRecordMapper {
      */
     List<YtDyzAdRecord> getByUserId(@Param("userId") String userId, @Param("adsourceType") Integer adsourceType);
 
+    List<YtDyzAdRecord> getByUserByParam(AdRecordListParam param);
+
+    /**
+     * 查询用户广告记录统计数
+     */
+    Integer getRecordMonthCount(@Param("userId") String userId,
+                                @Param("adSourceType") Integer adSourceType,
+                                @Param("startTime") Date startTime);
+
     /**
      * 查询激励视频记录
      */

+ 28 - 0
yt-nofeeds/nofeeds-service/src/main/resources/mapper/AdRecordMapper.xml

@@ -191,4 +191,32 @@
         </if>
         where record_id in <foreach collection="ids" item="id" open="(" close=")" separator=",">#{id}</foreach>
     </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,
+        network_placement_id, finish_time, begin_time,result_json,ad_source_type,ad_source_index,ecpm,
+        ifnull(#{loginStatus}, 2) as loginStatus
+        <if test="loginStatus != null and loginStatus == 1">
+            from yt_dyz_ad_record_visitor
+        </if>
+        <if test="loginStatus == null or loginStatus != 1">
+            from yt_dyz_ad_record
+        </if>
+        where user_id = #{userId}
+        <if test="adsourceType != null and adsourceType!=888">
+            and ad_source_type = #{adsourceType}
+        </if>
+        order by finish_time desc
+    </select>
+    <select id="getRecordMonthCount" resultType="java.lang.Integer">
+        SELECT count(record_id) as counts
+        FROM yt_dyz_ad_record
+        where user_id= #{userId} and revenue > 0
+        <if test="adSourceType != null and adSourceType!=888">
+            and ad_source_type = #{adSourceType}
+        </if>
+        <if test="startTime != null">
+            and finish_time > #{startTime}
+        </if>
+    </select>
 </mapper>