|
|
@@ -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的剩余秒数
|
|
|
*/
|