member: 根据积分配置的比例,换算积分
This commit is contained in:
parent
d4acacec60
commit
fd126ba2f7
@ -8,11 +8,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.point.MemberPointRecordMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -30,12 +32,15 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
*
|
||||
* @author QingX
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Validated
|
||||
public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
||||
|
||||
@Resource
|
||||
private MemberPointRecordMapper recordMapper;
|
||||
@Resource
|
||||
private MemberPointConfigService memberPointConfigService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
@ -65,6 +70,15 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
||||
|
||||
@Override
|
||||
public void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId) {
|
||||
MemberPointConfigDO pointConfig = memberPointConfigService.getPointConfig();
|
||||
if (pointConfig == null || pointConfig.getTradeGivePoint() == null) {
|
||||
log.warn("增加积分失败:积分配置”1 元赠送多少分“未设置, userId={}, point={}, bizType={}, bizId={}",
|
||||
userId, point, bizType.getType(), bizId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据配置的比例,换算实际的积分
|
||||
point = point * pointConfig.getTradeGivePoint();
|
||||
if (bizType.isReduce() && point > 0) {
|
||||
point = -point;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user