mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
trade:优化下单逻辑的实现
This commit is contained in:
@ -21,6 +21,13 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.member.api.point;
|
||||
|
||||
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
/**
|
||||
* 用户积分的 API 接口
|
||||
*
|
||||
@ -17,6 +19,18 @@ public interface MemberPointApi {
|
||||
* @param bizType 业务类型 {@link MemberPointBizTypeEnum}
|
||||
* @param bizId 业务编号
|
||||
*/
|
||||
void addPoint(Long userId, Integer point, Integer bizType, String bizId);
|
||||
void addPoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point,
|
||||
Integer bizType, String bizId);
|
||||
|
||||
/**
|
||||
* 减少用户积分
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param point 积分
|
||||
* @param bizType 业务类型 {@link MemberPointBizTypeEnum}
|
||||
* @param bizId 业务编号
|
||||
*/
|
||||
void reducePoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point,
|
||||
Integer bizType, String bizId);
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,10 @@ import java.util.Objects;
|
||||
public enum MemberPointBizTypeEnum implements IntArrayValuable {
|
||||
|
||||
SIGN(1, "签到", "签到获得 {} 积分", true),
|
||||
ORDER_BUY(10, "订单消费", "下单获得 {} 积分", true),
|
||||
ORDER_CANCEL(11, "订单取消", "退单获得 {} 积分", false); // 退回积分
|
||||
ORDER_REWARD(10, "订单奖励", "下单获得 {} 积分", true),
|
||||
ORDER_CANCEL(11, "订单取消", "退单获得 {} 积分", false), // 退回积分
|
||||
ORDER_USE(12, "订单使用", "下单使用 {} 积分", false), // 扣减积分
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
@ -31,4 +31,13 @@ public class MemberPointApiImpl implements MemberPointApi {
|
||||
memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reducePoint(Long userId, Integer point, Integer bizType, String bizId) {
|
||||
MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
throw exception(POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user