瀏覽代碼

发送红包限制

wjj 5 天之前
父節點
當前提交
ae1182454c

+ 3 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseRedPacketLogMapper.java

@@ -168,4 +168,7 @@ public interface FsCourseRedPacketLogMapper
 
     @Select("SELECT * FROM fs_course_red_packet_log WHERE status = 0 and create_time > DATE_SUB(NOW(), INTERVAL 2 day) and company_user_id =#{userId}")
     List<FsCourseRedPacketLog> selectFail(@Param("userId") Long userId);
+
+    @Select("select * from fs_course_red_packet_log where user_id = #{userId} AND DATE(create_time) = CURDATE() LIMIT 1")
+    FsCourseRedPacketLog selectRedPacketLogByUserIdToday(@Param("userId") Long userId);
 }

+ 12 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1042,6 +1042,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
     @Transactional
     public R sendReward(FsCourseSendRewardUParam param) {
 
+        //查询今日领取红包记录
+        FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectRedPacketLogByUserIdToday(param.getUserId());
+        if (fsCourseRedPacketLog != null) {
+            if (fsCourseRedPacketLog.getStatus() == 1) {
+                return R.error("今日已领取过红包了!");
+            }
+            if (fsCourseRedPacketLog.getStatus() == 0) {
+                if (!Objects.equals(param.getVideoId(), fsCourseRedPacketLog.getVideoId())) {
+                    return R.error("已在其它课程领取过!");
+                }
+            }
+        }
         // 获取用户信息
         FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
 //        if (StringUtils.isEmpty(user.getMpOpenId())){