|
@@ -3,9 +3,10 @@ package cn.newfeifan.mall.module.distri.service.usersigninlog;
|
|
|
import cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo.OrderPercentageRedisVO;
|
|
|
import cn.newfeifan.mall.module.distri.controller.app.usersigninlog.vo.UserSignInLogPageReqVO;
|
|
|
import cn.newfeifan.mall.module.distri.controller.app.usersigninlog.vo.UserSignInLogSaveReqVO;
|
|
|
-import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
|
|
|
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
|
|
|
import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
|
|
|
import cn.newfeifan.mall.module.distri.service.duser.DuserService;
|
|
|
+import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
|
|
|
import cn.newfeifan.mall.module.distri.service.socialstatus.SocialStatusService;
|
|
|
import cn.newfeifan.mall.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO;
|
|
|
import cn.newfeifan.mall.module.member.convert.signin.MemberSignInRecordConvert;
|
|
@@ -36,6 +37,7 @@ import static cn.newfeifan.mall.framework.common.exception.util.ServiceException
|
|
|
import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
import static cn.newfeifan.mall.module.distri.constant.DistriConstants.*;
|
|
|
import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
|
+import static cn.newfeifan.mall.module.member.enums.DictTypeConstants.DISTRI_ORDER_PERCENTAGE;
|
|
|
|
|
|
/**
|
|
|
* 用户签到日志 Service 实现类
|
|
@@ -61,6 +63,9 @@ public class UserSignInLogServiceImpl implements UserSignInLogService {
|
|
|
@Resource
|
|
|
private SocialStatusService socialStatusService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OrderPercentageService orderPercentageService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public AppMemberSignInRecordRespVO createUserSignInLog() {
|
|
@@ -95,38 +100,45 @@ public class UserSignInLogServiceImpl implements UserSignInLogService {
|
|
|
OrderPercentageRedisVO orderPercentageRedisVO = getOrderPercentageRedisVO();
|
|
|
long social = Long.parseLong(orderPercentageRedisVO.getSignInSocialStatus());
|
|
|
|
|
|
- if(userSignInLogDO.getRunningDays() >= Integer.parseInt(orderPercentageRedisVO.getSignInSocialStatusMax())){
|
|
|
+ if (userSignInLogDO.getRunningDays() >= Integer.parseInt(orderPercentageRedisVO.getSignInSocialStatusMax())) {
|
|
|
social = social + Long.parseLong(orderPercentageRedisVO.getSignInSocialStatusMax());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
social = social + userSignInLogDO.getRunningDays();
|
|
|
}
|
|
|
|
|
|
//更新前用户身价等级
|
|
|
- DuserDO duserByUserNow = duserService.getDuserByUser(loginUserId);
|
|
|
+ Long socialStatusIdNow = duserService.getDuserByUser(loginUserId).getSocialStatusId();
|
|
|
//更新用户身价
|
|
|
duserService.updateDuserSocial(loginUserId, social, SocialStatusEnum.SIGN_IN_SOCIAL.getStatus());
|
|
|
|
|
|
//更新后用户身价等级
|
|
|
- DuserDO duserByUserAfter = duserService.getDuserByUser(loginUserId);
|
|
|
+ Long socialStatusIdAfter = duserService.getDuserByUser(loginUserId).getSocialStatusId();
|
|
|
|
|
|
//判断是否升级
|
|
|
- boolean upgradeOrNot = !duserByUserNow.getSocialStatusId().equals(duserByUserAfter.getSocialStatusId());
|
|
|
+ boolean upgradeOrNot = !socialStatusIdNow.equals(socialStatusIdAfter);
|
|
|
String socialStatusName = null;
|
|
|
- if(upgradeOrNot){
|
|
|
- socialStatusName = socialStatusService.getSocialStatusName(duserByUserAfter.getSocialStatusId());
|
|
|
+ if (upgradeOrNot) {
|
|
|
+ socialStatusName = socialStatusService.getSocialStatusName(socialStatusIdAfter);
|
|
|
}
|
|
|
// 返回
|
|
|
- return MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO,upgradeOrNot,social,socialStatusName);
|
|
|
+ return MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO, upgradeOrNot, social, socialStatusName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取身价固定值
|
|
|
+ *
|
|
|
* @return 签到身价固定值
|
|
|
*/
|
|
|
private OrderPercentageRedisVO getOrderPercentageRedisVO() {
|
|
|
String s = stringRedisTemplate.opsForValue().get(DISTRI_ORDER_PERCENTAGE);
|
|
|
if (StringUtils.isEmpty(s)) {
|
|
|
- throw exception(REDIS_ORDER_PERCENTAGE_NOT_EXISTS);
|
|
|
+ OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
|
+ OrderPercentageRedisVO signSocial = OrderPercentageRedisVO.builder()
|
|
|
+ .signInSocialStatus(orderPercentageDO.getSignInSocialStatus())
|
|
|
+ .signInSocialStatusMax(orderPercentageDO.getSignInSocialStatusMax())
|
|
|
+ .build();
|
|
|
+ stringRedisTemplate.opsForValue().set(DISTRI_ORDER_PERCENTAGE, JSONObject.toJSONString(signSocial));
|
|
|
+ s = JSONObject.toJSONString(signSocial);
|
|
|
}
|
|
|
return JSONObject.parseObject(s, OrderPercentageRedisVO.class);
|
|
|
}
|
|
@@ -186,4 +198,4 @@ public class UserSignInLogServiceImpl implements UserSignInLogService {
|
|
|
return userSignInLogMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|