Quellcode durchsuchen

益寿缘app-完善App创建商城订单接口

cgp vor 4 Tagen
Ursprung
Commit
ea9f6eb832

+ 17 - 18
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -3009,9 +3009,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         if (StringUtils.isBlank(user.getAppOpenId())){
             return R.error("请绑定微信!");
         }
-        FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
+        FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
         if (log == null) {
-            return R.error("无记录");
+            return R.error("无看课记录");
         }
         FsCourseAnswerLogs rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
 
@@ -3019,24 +3019,23 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             logger.error("未答题:{}",param.getUserId());
             return R.error("未答题");
         }
-        if (log.getRewardType() != null ) {
-            if (log.getRewardType() == 1){
-                FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
-                if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
-                    return R.error("已领取该课程奖励,不可重复领取!");
-                }
-                if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 0) {
-                    if(StringUtils.isNotEmpty(fsCourseRedPacketLog.getResult())){
-                        R r = JSON.parseObject(fsCourseRedPacketLog.getResult(), R.class);
-                        return r;
-                    } else {
-                        return R.error("操作频繁,请稍后再试!");
-                    }
-                }
-            }else if (log.getRewardType() == 2){
+        if (log.getRewardType() != null) {
+            FsCourseRedPacketLog packetLog = redPacketLogMapper.selectFsCourseRedPacketLogByTemporary(param.getVideoId(), param.getUserId());
+            if(packetLog != null && packetLog.getStatus() == 1) {
                 return R.error("已领取该课程奖励,不可重复领取!");
             }
-
+            if(packetLog != null && packetLog.getStatus() == 0) {
+                if(StringUtils.isNotEmpty(packetLog.getResult())){
+                    R r = JSON.parseObject(packetLog.getResult(), R.class);
+                    return r;
+                } else {
+                    return R.error("操作频繁,请稍后再试!");
+                }
+            }
+            if(packetLog != null && packetLog.getStatus() == 2) {
+                return R.error("请联系客服补发");
+            }
+            return R.error("奖励已发放");
         }
         // 获取视频信息
         FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());

+ 86 - 12
fs-service/src/main/java/com/fs/his/service/impl/AppUserRewardServiceImpl.java

@@ -3,6 +3,10 @@ package com.fs.his.service.impl;
 import com.fs.common.core.domain.R;
 import com.fs.course.domain.FsCourseRedPacketLog;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
+import com.fs.his.domain.FsPackage;
+import com.fs.his.mapper.FsPackageMapper;
+import com.fs.hisStore.domain.FsStoreProductScrm;
+import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 import me.chanjar.weixin.common.util.locks.RedisTemplateSimpleDistributedLock;
 import com.fs.app.domain.FsAppRole;
 import com.fs.app.mapper.FsAppRoleMapper;
@@ -23,6 +27,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.data.redis.core.StringRedisTemplate;
@@ -64,6 +69,12 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
     @Autowired
     private FsCourseRedPacketLogMapper redPacketLogMapper;
 
+    @Autowired
+    private FsPackageMapper fsPackageMapper;
+    
+    @Autowired
+    private FsStoreProductScrmMapper fsStoreProductMapper;
+
     private static final String APP_WATCH_COURSE_DAY_KEY = "app:watch:course:day:";
 
     private static final String LOCK_WATCH_REWARD_KEY = "lock:watch:reward:";
@@ -135,7 +146,7 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
     public void addUserFirstLoginRewards(Long fsUserId) {
         String activityType = ActivityTypeEnum.FIRST_LOGIN.getCode();
 
-        FsAppRole appRoleConfig = getAppRoleConfig(fsUserId);
+        FsAppRole appRoleConfig = getAppRoleConfigFirstRegister(fsUserId);
         if (appRoleConfig == null) {
             log.info("登录注册奖励-当前用户未匹配到App奖励角色");
             return;
@@ -206,7 +217,7 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
             String activityType = ActivityTypeEnum.WATCH_COURSE.getCode();
 
             // 根据配置获取奖品类型、金额等
-            FsAppRole appRoleConfig = getAppRoleConfig(fsUserId);
+            FsAppRole appRoleConfig = getAppRoleConfigWatchCourse(fsUserId);
             if (appRoleConfig == null) {
                 log.info("看课奖励-当前用户未匹配到App角色");
                 return;
@@ -418,7 +429,7 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
         FsUserRewards queryReward = rewardsMapper.selectByUserIdAndFirstLoginType(fsUserId);
         if (queryReward == null) {
             //查询当前用户对应的角色配置返回红包、积分、商品弹窗信息
-            fsAppRole = getAppRoleConfig(fsUserId);
+            fsAppRole = getAppRoleConfigFirstRegister(fsUserId);
             return fsAppRole;
         }
         return fsAppRole;
@@ -428,10 +439,13 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
     public FsAppRole showWatchCourseRewardWindows(Long fsUserId) {
         String watchCourseKey = APP_WATCH_COURSE_DAY_KEY + fsUserId;
         FsAppRole noShowWindow = new FsAppRole();
-
+        Object cacheObject = redisCache.getCacheObject(watchCourseKey);
+        if (cacheObject == null) {
+            return noShowWindow;
+        }
         // 获取用户和配置
         FsUser fsUser = fsUserMapper.selectFsUserById(fsUserId);
-        FsAppRole defaultConfig = getAppRoleConfig(fsUserId);
+        FsAppRole defaultConfig = getAppRoleConfigWatchCourse(fsUserId);
         if (defaultConfig == null) {
             return noShowWindow;
         }
@@ -471,10 +485,6 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
         }
 
         // 5. 积分/红包逻辑
-        Object cacheObject = redisCache.getCacheObject(watchCourseKey);
-        if (cacheObject == null) {
-            return noShowWindow;
-        }
         if (CollectionUtils.isNotEmpty(todayRewards)) {
             return noShowWindow;
         }
@@ -564,19 +574,83 @@ public class AppUserRewardServiceImpl implements IAppUserRewardService {
             log.error("用户不存在, userId: {}", fsUserId);
         }
     }
-
     //根据用户id、角色id获取配置的奖品信息(实物商品包含商品名称和图片)
-    private FsAppRole getAppRoleConfig(Long fsUserId) {
+    private FsAppRole getAppRoleConfigFirstRegister(Long fsUserId) {
+        //获取当前用户最高权重角色, "false"表示查询等级数字最大的权重角色
+        FsAppRole fsAppRole = appRoleMapper.selectHighestLevelAppRoleByUserId(fsUserId, "false");
+        if (fsAppRole == null) {
+            log.info("未找到用户:{}对应的角色首次注册配置", fsUserId);
+            return null;
+        }
+        fsAppRole.setShow(true);//显示弹窗
+        //补充实物商品名称以及商品图片
+        if (fsAppRole.getRegisterRewardType()!=null&&fsAppRole.getRegisterRewardType()==3){
+            if (fsAppRole.getRegisterProductType()!=null&&fsAppRole.getRegisterProductType()==1){
+                FsPackage fsPackage = fsPackageMapper.selectFsPackageByPackageId(fsAppRole.getRegisterProductId());
+                if (fsPackage != null){
+                    fsAppRole.setGoodsName(fsPackage.getPackageName());
+                    fsAppRole.setGoodsUrl(fsPackage.getImgUrl());
+                    return fsAppRole;
+                }
+            } else if (fsAppRole.getRegisterProductType()!=null&&fsAppRole.getRegisterProductType()==2){
+                FsStoreProductScrm storeProductScrm = getProductInfo(fsAppRole.getRegisterProductId());
+                if (storeProductScrm != null){
+                    fsAppRole.setGoodsName(storeProductScrm.getProductName());
+                    fsAppRole.setGoodsUrl(storeProductScrm.getImgUrl());
+                    return fsAppRole;
+                }
+            }
+        }
+        return fsAppRole;
+    }
+    //根据用户id、角色id获取配置的奖品信息(实物商品包含商品名称和图片)
+    private FsAppRole getAppRoleConfigWatchCourse(Long fsUserId) {
         //获取当前用户最高权重角色, "false"表示查询等级数字最大的权重角色
         FsAppRole fsAppRole = appRoleMapper.selectHighestLevelAppRoleByUserId(fsUserId, "false");
         if (fsAppRole == null) {
-            log.info("未找到用户:{}对应的角色配置", fsUserId);
+            log.info("未找到用户:{}对应的角色看课奖励配置", fsUserId);
             return null;
         }
         fsAppRole.setShow(true);//显示弹窗
+        //补充实物商品名称以及商品图片
+        if (fsAppRole.getCourseRewardType()!=null&&fsAppRole.getCourseRewardType()==3){
+            if (fsAppRole.getCourseProductType()!=null&&fsAppRole.getCourseProductType()==1){
+                FsPackage fsPackage = fsPackageMapper.selectFsPackageByPackageId(fsAppRole.getCourseProductId());
+                if (fsPackage != null){
+                    fsAppRole.setGoodsName(fsPackage.getPackageName());
+                    fsAppRole.setGoodsUrl(fsPackage.getImgUrl());
+                    return fsAppRole;
+                }
+            } else if ( fsAppRole.getCourseProductType()!=null&&fsAppRole.getCourseProductType()==2){
+                FsStoreProductScrm storeProductScrm = getProductInfo(fsAppRole.getCourseProductId());
+                if (storeProductScrm != null){
+                    fsAppRole.setGoodsName(storeProductScrm.getProductName());
+                    fsAppRole.setGoodsUrl(storeProductScrm.getImgUrl());
+                    return fsAppRole;
+                }
+            }
+        }
         return fsAppRole;
     }
 
+    /**
+     * 查询套餐包信息
+     * @param goodsId 商品id
+     * @return 返回 FsPackage对象
+     */
+    private FsPackage getPackageInfo(Long goodsId) {
+        return fsPackageMapper.selectFsPackageByPackageId(goodsId);
+    }
+
+    /**
+     * 查询商城商品信息
+     * @param goodsId 商品id
+     * @return 返回FsStoreProductScrm 对象
+     */
+    private FsStoreProductScrm getProductInfo(Long goodsId) {
+        return fsStoreProductMapper.selectFsStoreProductById(goodsId);
+    }
+
     /**
      * 获取到今晚23:59:59的剩余秒数
      */