会员积分问题修复
This commit is contained in:
@@ -43,33 +43,33 @@ public class MemberPointsController {
|
|||||||
* 001-会员积分账户信息
|
* 001-会员积分账户信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("userPoints")
|
@GetMapping("userPoints")
|
||||||
public CzgResult<MemberPoints> getMemberPoints(@RequestParam Long userId) {
|
public CzgResult<MemberPoints> getMemberPoints(@RequestParam Long shopUserId) {
|
||||||
MemberPoints data = memberPointsService.getMemberPoints(userId);
|
MemberPoints data = memberPointsService.getMemberPoints(shopUserId);
|
||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcUsablePoints")
|
@GetMapping("calcUsablePoints")
|
||||||
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount) {
|
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount) {
|
||||||
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(userId, orderAmount);
|
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount);
|
||||||
return CzgResult.success(usablePoints);
|
return CzgResult.success(usablePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 004-根据抵扣金额计算所需积分
|
* 004-根据抵扣金额计算所需积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @param deductionAmount 抵扣金额
|
* @param deductionAmount 抵扣金额
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcUsedPoints")
|
@GetMapping("calcUsedPoints")
|
||||||
public CzgResult<Integer> calcUsedPoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
public CzgResult<Integer> calcUsedPoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
||||||
int points = memberPointsService.calcUsedPoints(userId, orderAmount, deductionAmount);
|
int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount);
|
||||||
return CzgResult.success(points);
|
return CzgResult.success(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ public class MemberPointsController {
|
|||||||
* 003-根据积分计算可抵扣金额
|
* 003-根据积分计算可抵扣金额
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcDeductionAmount")
|
@GetMapping("calcDeductionAmount")
|
||||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||||
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(userId, orderAmount, points);
|
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points);
|
||||||
return CzgResult.success(deductionAmount);
|
return CzgResult.success(deductionAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,38 +55,38 @@ public class UMemberPointsController {
|
|||||||
/**
|
/**
|
||||||
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcUsablePoints")
|
@GetMapping("calcUsablePoints")
|
||||||
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount) {
|
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount) {
|
||||||
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(userId, orderAmount);
|
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount);
|
||||||
return CzgResult.success(usablePoints);
|
return CzgResult.success(usablePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 004-根据抵扣金额计算所需积分
|
* 004-根据抵扣金额计算所需积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @param deductionAmount 抵扣金额
|
* @param deductionAmount 抵扣金额
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcUsedPoints")
|
@GetMapping("calcUsedPoints")
|
||||||
public CzgResult<Integer> calcUsedPoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
public CzgResult<Integer> calcUsedPoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
||||||
int points = memberPointsService.calcUsedPoints(userId, orderAmount, deductionAmount);
|
int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount);
|
||||||
return CzgResult.success(points);
|
return CzgResult.success(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 003-根据积分计算可抵扣金额
|
* 003-根据积分计算可抵扣金额
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @param points 使用积分
|
* @param points 使用积分
|
||||||
*/
|
*/
|
||||||
@GetMapping("calcDeductionAmount")
|
@GetMapping("calcDeductionAmount")
|
||||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||||
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(userId, orderAmount, points);
|
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points);
|
||||||
return CzgResult.success(deductionAmount);
|
return CzgResult.success(deductionAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class MemberPointsLogDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
/**
|
/**
|
||||||
* 用户id
|
* 用户id(shopUserId)
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,19 +25,15 @@ public class MemberPoints implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* id
|
* 会员id
|
||||||
*/
|
*/
|
||||||
@Id(keyType = KeyType.Auto)
|
@Id(keyType = KeyType.Auto)
|
||||||
private Long id;
|
@Column(value = "id")
|
||||||
|
private Long shopUserId;
|
||||||
/**
|
/**
|
||||||
* 店铺id
|
* 店铺id
|
||||||
*/
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
/**
|
|
||||||
* 会员id
|
|
||||||
*/
|
|
||||||
@Column(value = "id")
|
|
||||||
private Long userId;
|
|
||||||
/**
|
/**
|
||||||
* 会员名称
|
* 会员名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ConsumeAwardPointsParam implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID(shopUserId)
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class PayedDeductPointsParam implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID(shopUserId)
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,73 +28,73 @@ public interface MemberPointsService extends IService<MemberPoints> {
|
|||||||
/**
|
/**
|
||||||
* 初始化会员积分
|
* 初始化会员积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @return 会员积分等信息
|
* @return 会员积分等信息
|
||||||
*/
|
*/
|
||||||
MemberPoints initMemberPoints(Long userId);
|
MemberPoints initMemberPoints(Long shopUserId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会员积分等信息
|
* 获取会员积分等信息
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @return 会员积分等信息
|
* @return 会员积分等信息
|
||||||
*/
|
*/
|
||||||
MemberPoints getMemberPoints(Long userId);
|
MemberPoints getMemberPoints(Long shopUserId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户id及订单金额计算可抵扣积分及可抵扣金额
|
* 根据用户id及订单金额计算可抵扣积分及可抵扣金额
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @return 积分及金额
|
* @return 积分及金额
|
||||||
*/
|
*/
|
||||||
OrderDeductionPointsDTO getMemberUsablePoints(Long userId, BigDecimal orderAmount);
|
OrderDeductionPointsDTO getMemberUsablePoints(Long shopUserId, BigDecimal orderAmount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据抵扣金额计算抵扣积分
|
* 根据抵扣金额计算抵扣积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @param deductionAmount 抵扣金额
|
* @param deductionAmount 抵扣金额
|
||||||
*/
|
*/
|
||||||
int calcUsedPoints(Long userId, BigDecimal orderAmount, BigDecimal deductionAmount);
|
int calcUsedPoints(Long shopUserId, BigDecimal orderAmount, BigDecimal deductionAmount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据抵扣积分计算抵扣金额
|
* 根据抵扣积分计算抵扣金额
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderAmount 订单金额
|
* @param orderAmount 订单金额
|
||||||
* @param points 抵扣积分
|
* @param points 抵扣积分
|
||||||
*/
|
*/
|
||||||
BigDecimal calcDeductionAmount(Long userId, BigDecimal orderAmount, int points);
|
BigDecimal calcDeductionAmount(Long shopUserId, BigDecimal orderAmount, int points);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扣除积分
|
* 扣除积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param points 积分
|
* @param points 积分
|
||||||
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
||||||
* @param orderInfo 订单信息,可以为空
|
* @param orderInfo 订单信息,可以为空
|
||||||
*/
|
*/
|
||||||
boolean deductPoints(Long userId, int points, String content, OrderInfo orderInfo);
|
boolean deductPoints(Long shopUserId, int points, String content, OrderInfo orderInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 追加积分
|
* 追加积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param points 积分
|
* @param points 积分
|
||||||
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
||||||
* @param orderInfo 订单信息,可以为空
|
* @param orderInfo 订单信息,可以为空
|
||||||
* @return 成功/失败
|
* @return 成功/失败
|
||||||
*/
|
*/
|
||||||
boolean addPoints(Long userId, int points, String content, OrderInfo orderInfo);
|
boolean addPoints(Long shopUserId, int points, String content, OrderInfo orderInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费赠送积分
|
* 消费赠送积分
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param shopUserId 用户id
|
||||||
* @param orderInfo 订单信息,可以为空
|
* @param orderInfo 订单信息,可以为空
|
||||||
*/
|
*/
|
||||||
void consumeAwardPoints(Long userId, OrderInfo orderInfo);
|
void consumeAwardPoints(Long shopUserId, OrderInfo orderInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMappe
|
|||||||
queryWrapper.select(MEMBER_POINTS.DEFAULT_COLUMNS)
|
queryWrapper.select(MEMBER_POINTS.DEFAULT_COLUMNS)
|
||||||
.select(SHOP_USER.NICK_NAME.as(MemberPointsLogDTO::getNickName), SHOP_USER.HEAD_IMG.as(MemberPointsLogDTO::getHeadImg), SHOP_USER.PHONE.as(MemberPointsLogDTO::getPhone))
|
.select(SHOP_USER.NICK_NAME.as(MemberPointsLogDTO::getNickName), SHOP_USER.HEAD_IMG.as(MemberPointsLogDTO::getHeadImg), SHOP_USER.PHONE.as(MemberPointsLogDTO::getPhone))
|
||||||
.from(MEMBER_POINTS_LOG)
|
.from(MEMBER_POINTS_LOG)
|
||||||
.leftJoin(SHOP_USER).on(SHOP_USER.ID.eq(MEMBER_POINTS.USER_ID));
|
.leftJoin(SHOP_USER).on(SHOP_USER.ID.eq(MEMBER_POINTS.SHOP_USER_ID));
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
|
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
queryWrapper.eq(MemberPoints::getShopId, shopId);
|
queryWrapper.eq(MemberPoints::getShopId, shopId);
|
||||||
queryWrapper.orderBy(MemberPoints::getId, false);
|
queryWrapper.orderBy(MemberPoints::getShopUserId, false);
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemberPoints initMemberPoints(Long userId) {
|
public MemberPoints initMemberPoints(Long shopUserId) {
|
||||||
MemberPoints entity = super.getOne(query().eq(MemberPoints::getUserId, userId));
|
MemberPoints entity = super.getOne(query().eq(MemberPoints::getShopUserId, shopUserId));
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new CzgException("会员信息不存在");
|
throw new CzgException("会员信息不存在");
|
||||||
}
|
}
|
||||||
@@ -79,13 +79,13 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemberPoints getMemberPoints(Long userId) {
|
public MemberPoints getMemberPoints(Long shopUserId) {
|
||||||
return initMemberPoints(userId);
|
return initMemberPoints(shopUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderDeductionPointsDTO getMemberUsablePoints(Long userId, BigDecimal orderAmount) {
|
public OrderDeductionPointsDTO getMemberUsablePoints(Long shopUserId, BigDecimal orderAmount) {
|
||||||
MemberPoints entity = initMemberPoints(userId);
|
MemberPoints entity = initMemberPoints(shopUserId);
|
||||||
Long shopId = entity.getShopId();
|
Long shopId = entity.getShopId();
|
||||||
Integer accountPoints = entity.getAccountPoints();
|
Integer accountPoints = entity.getAccountPoints();
|
||||||
OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO();
|
OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO();
|
||||||
@@ -148,8 +148,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calcUsedPoints(Long userId, BigDecimal orderAmount, BigDecimal deductionAmount) {
|
public int calcUsedPoints(Long shopUserId, BigDecimal orderAmount, BigDecimal deductionAmount) {
|
||||||
OrderDeductionPointsDTO core = getMemberUsablePoints(userId, orderAmount);
|
OrderDeductionPointsDTO core = getMemberUsablePoints(shopUserId, orderAmount);
|
||||||
if (!core.getUsable()) {
|
if (!core.getUsable()) {
|
||||||
throw new CzgException(core.getUnusableReason());
|
throw new CzgException(core.getUnusableReason());
|
||||||
}
|
}
|
||||||
@@ -166,8 +166,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal calcDeductionAmount(Long userId, BigDecimal orderAmount, int points) {
|
public BigDecimal calcDeductionAmount(Long shopUserId, BigDecimal orderAmount, int points) {
|
||||||
OrderDeductionPointsDTO core = getMemberUsablePoints(userId, orderAmount);
|
OrderDeductionPointsDTO core = getMemberUsablePoints(shopUserId, orderAmount);
|
||||||
if (!core.getUsable()) {
|
if (!core.getUsable()) {
|
||||||
throw new CzgException(core.getUnusableReason());
|
throw new CzgException(core.getUnusableReason());
|
||||||
}
|
}
|
||||||
@@ -186,8 +186,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deductPoints(Long userId, int points, String content, OrderInfo orderInfo) {
|
public boolean deductPoints(Long shopUserId, int points, String content, OrderInfo orderInfo) {
|
||||||
MemberPoints entity = initMemberPoints(userId);
|
MemberPoints entity = initMemberPoints(shopUserId);
|
||||||
// 扣除账户积分
|
// 扣除账户积分
|
||||||
entity.setAccountPoints(entity.getAccountPoints() - points);
|
entity.setAccountPoints(entity.getAccountPoints() - points);
|
||||||
entity.setLastPointsChangeTime(LocalDateTime.now());
|
entity.setLastPointsChangeTime(LocalDateTime.now());
|
||||||
@@ -196,7 +196,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
// 记录积分变动记录
|
// 记录积分变动记录
|
||||||
MemberPointsLog log = new MemberPointsLog();
|
MemberPointsLog log = new MemberPointsLog();
|
||||||
log.setShopId(entity.getShopId());
|
log.setShopId(entity.getShopId());
|
||||||
log.setUserId(entity.getUserId());
|
log.setUserId(entity.getShopUserId());
|
||||||
log.setContent(content);
|
log.setContent(content);
|
||||||
log.setFloatType("subtract");
|
log.setFloatType("subtract");
|
||||||
log.setFloatPoints(-points);
|
log.setFloatPoints(-points);
|
||||||
@@ -212,8 +212,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean addPoints(Long userId, int points, String content, OrderInfo orderInfo) {
|
public boolean addPoints(Long shopUserId, int points, String content, OrderInfo orderInfo) {
|
||||||
MemberPoints entity = initMemberPoints(userId);
|
MemberPoints entity = initMemberPoints(shopUserId);
|
||||||
// 增加账户积分
|
// 增加账户积分
|
||||||
entity.setAccountPoints(entity.getAccountPoints() + points);
|
entity.setAccountPoints(entity.getAccountPoints() + points);
|
||||||
entity.setLastPointsChangeTime(LocalDateTime.now());
|
entity.setLastPointsChangeTime(LocalDateTime.now());
|
||||||
@@ -221,7 +221,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
// 记录积分变动记录
|
// 记录积分变动记录
|
||||||
MemberPointsLog log = new MemberPointsLog();
|
MemberPointsLog log = new MemberPointsLog();
|
||||||
log.setShopId(entity.getShopId());
|
log.setShopId(entity.getShopId());
|
||||||
log.setUserId(entity.getUserId());
|
log.setUserId(entity.getShopUserId());
|
||||||
log.setContent(content);
|
log.setContent(content);
|
||||||
log.setFloatType("add");
|
log.setFloatType("add");
|
||||||
log.setFloatPoints(points);
|
log.setFloatPoints(points);
|
||||||
@@ -236,7 +236,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void consumeAwardPoints(Long userId, OrderInfo orderInfo) {
|
public void consumeAwardPoints(Long shopUserId, OrderInfo orderInfo) {
|
||||||
if (orderInfo == null) {
|
if (orderInfo == null) {
|
||||||
throw new CzgException("订单不存在");
|
throw new CzgException("订单不存在");
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
String rewardsGroup = basicSetting.getRewardsGroup();
|
String rewardsGroup = basicSetting.getRewardsGroup();
|
||||||
MemberPoints entity;
|
MemberPoints entity;
|
||||||
try {
|
try {
|
||||||
entity = initMemberPoints(userId);
|
entity = initMemberPoints(shopUserId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -271,6 +271,6 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BigDecimal awardPoints = NumberUtil.roundDown(NumberUtil.div(payAmount, consumeAmount), 0);
|
BigDecimal awardPoints = NumberUtil.roundDown(NumberUtil.div(payAmount, consumeAmount), 0);
|
||||||
addPoints(userId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderInfo);
|
addPoints(shopUserId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||||||
if (quantity <= 0) {
|
if (quantity <= 0) {
|
||||||
throw new CzgException("兑换的商品库存不足");
|
throw new CzgException("兑换的商品库存不足");
|
||||||
}
|
}
|
||||||
MemberPoints memberPoints = memberPointsMapper.selectOneByQuery(query().eq(MemberPoints::getUserId, param.getUserId()));
|
MemberPoints memberPoints = memberPointsMapper.selectOneByQuery(query().eq(MemberPoints::getShopUserId, param.getUserId()));
|
||||||
if (memberPoints == null) {
|
if (memberPoints == null) {
|
||||||
throw new CzgException("会员积分不足无法兑换此商品");
|
throw new CzgException("会员积分不足无法兑换此商品");
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||||||
entity.setCancelOrRefundReason(param.getCancelOrRefundReason());
|
entity.setCancelOrRefundReason(param.getCancelOrRefundReason());
|
||||||
entity.setCancelOrRefundTime(LocalDateTime.now());
|
entity.setCancelOrRefundTime(LocalDateTime.now());
|
||||||
super.updateById(entity);
|
super.updateById(entity);
|
||||||
MemberPoints memberPoints = memberPointsMapper.selectOneByQuery(query().eq(MemberPoints::getUserId, entity.getUserId()));
|
MemberPoints memberPoints = memberPointsMapper.selectOneByQuery(query().eq(MemberPoints::getShopUserId, entity.getUserId()));
|
||||||
if (memberPoints == null) {
|
if (memberPoints == null) {
|
||||||
throw new CzgException("会员信息不存在");
|
throw new CzgException("会员信息不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.czg.service.order.service.impl;
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.core.exceptions.ValidateException;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
@@ -695,9 +694,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
updateChain.set(OrderInfo::getPayType, payType.getValue());
|
updateChain.set(OrderInfo::getPayType, payType.getValue());
|
||||||
}
|
}
|
||||||
updateChain.update();
|
updateChain.update();
|
||||||
|
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||||
//积分使用
|
//积分使用
|
||||||
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
|
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
|
||||||
pointsService.deductPoints(orderInfo.getUserId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo);
|
pointsService.deductPoints(shopUser.getId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo);
|
||||||
}
|
}
|
||||||
//更新优惠券信息
|
//更新优惠券信息
|
||||||
if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList())) {
|
if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList())) {
|
||||||
@@ -707,7 +707,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
if (orderInfo.getUserId() == null) {
|
if (orderInfo.getUserId() == null) {
|
||||||
log.info("订单:{}优惠券使用失败,用户Id为空", orderInfo.getId());
|
log.info("订单:{}优惠券使用失败,用户Id为空", orderInfo.getId());
|
||||||
} else {
|
} else {
|
||||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
log.info("订单:{}优惠券使用失败,店铺用户不存在", orderInfo.getId());
|
log.info("订单:{}优惠券使用失败,店铺用户不存在", orderInfo.getId());
|
||||||
} else {
|
} else {
|
||||||
@@ -717,7 +716,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//下单赠送积分
|
//下单赠送积分
|
||||||
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo);
|
pointsService.consumeAwardPoints(shopUser.getId(), orderInfo);
|
||||||
|
|
||||||
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
|
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
|
||||||
// if (!"after-pay".equals(orderInfo.getPayMode())) {
|
// if (!"after-pay".equals(orderInfo.getPayMode())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user