会员积分问题修复

This commit is contained in:
Tankaikai 2025-03-17 17:16:06 +08:00
parent e684ea1498
commit 732e780db4
9 changed files with 21 additions and 22 deletions

View File

@ -47,8 +47,8 @@ public class UMemberPointsController {
*/ */
@GetMapping("myPoints") @GetMapping("myPoints")
public CzgResult<MemberPoints> getMemberPoints() { public CzgResult<MemberPoints> getMemberPoints() {
long userId = StpKit.USER.getLoginIdAsLong(); long shopUserId = StpKit.USER.getLoginIdAsLong();
MemberPoints data = memberPointsService.getMemberPoints(userId); MemberPoints data = memberPointsService.getMemberPoints(shopUserId);
return CzgResult.success(data); return CzgResult.success(data);
} }
@ -59,7 +59,7 @@ public class UMemberPointsController {
* @param orderAmount 订单金额 * @param orderAmount 订单金额
*/ */
@GetMapping("calcUsablePoints") @GetMapping("calcUsablePoints")
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam("userId") Long shopUserId, @RequestParam BigDecimal orderAmount) { public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount) {
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount); OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount);
return CzgResult.success(usablePoints); return CzgResult.success(usablePoints);
} }
@ -72,7 +72,7 @@ public class UMemberPointsController {
* @param deductionAmount 抵扣金额 * @param deductionAmount 抵扣金额
*/ */
@GetMapping("calcUsedPoints") @GetMapping("calcUsedPoints")
public CzgResult<Integer> calcUsedPoints(@RequestParam("userId") Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) { public CzgResult<Integer> calcUsedPoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount); int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount);
return CzgResult.success(points); return CzgResult.success(points);
} }
@ -85,7 +85,7 @@ public class UMemberPointsController {
* @param points 使用积分 * @param points 使用积分
*/ */
@GetMapping("calcDeductionAmount") @GetMapping("calcDeductionAmount")
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam("userId") Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) { public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points); BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points);
return CzgResult.success(deductionAmount); return CzgResult.success(deductionAmount);
} }

View File

@ -4,7 +4,6 @@ import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserDetailDTO; import com.czg.account.dto.shopuser.ShopUserDetailDTO;
import com.czg.account.dto.shopuser.ShopUserVipCardDTO; import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.PointsExchangeRecord; import com.czg.account.entity.PointsExchangeRecord;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.ShopUserFlow; import com.czg.account.entity.ShopUserFlow;
import com.czg.account.service.PointsExchangeRecordService; import com.czg.account.service.PointsExchangeRecordService;
import com.czg.account.service.ShopUserFlowService; import com.czg.account.service.ShopUserFlowService;
@ -105,7 +104,7 @@ public class UShopUserController {
@GetMapping("/pointsRecord") @GetMapping("/pointsRecord")
public CzgResult<Page<PointsExchangeRecord>> getPointsRecord() { public CzgResult<Page<PointsExchangeRecord>> getPointsRecord() {
return CzgResult.success(pointsExchangeRecordService.page(PageUtil.buildPage(), new QueryWrapper().eq(PointsExchangeRecord::getShopId, StpKit.USER.getShopId()) return CzgResult.success(pointsExchangeRecordService.page(PageUtil.buildPage(), new QueryWrapper().eq(PointsExchangeRecord::getShopId, StpKit.USER.getShopId())
.eq(PointsExchangeRecord::getUserId, StpKit.USER.getLoginIdAsLong()).orderBy(PointsExchangeRecord::getId, false))); .eq(PointsExchangeRecord::getShopUserId, StpKit.USER.getLoginIdAsLong()).orderBy(PointsExchangeRecord::getId, false)));
} }
/** /**
@ -116,7 +115,7 @@ public class UShopUserController {
@GetMapping("/pointsRecord/detail") @GetMapping("/pointsRecord/detail")
public CzgResult<PointsExchangeRecord> getPointsRecordDetail(@RequestParam Long id) { public CzgResult<PointsExchangeRecord> getPointsRecordDetail(@RequestParam Long id) {
return CzgResult.success(pointsExchangeRecordService.getOne(new QueryWrapper().eq(PointsExchangeRecord::getShopId, StpKit.USER.getShopId()) return CzgResult.success(pointsExchangeRecordService.getOne(new QueryWrapper().eq(PointsExchangeRecord::getShopId, StpKit.USER.getShopId())
.eq(PointsExchangeRecord::getUserId, StpKit.USER.getLoginIdAsLong()).eq(PointsExchangeRecord::getId, id))); .eq(PointsExchangeRecord::getShopUserId, StpKit.USER.getLoginIdAsLong()).eq(PointsExchangeRecord::getId, id)));
} }

View File

@ -33,9 +33,9 @@ public class MemberPointsLog implements Serializable {
*/ */
private Long shopId; private Long shopId;
/** /**
* 用户id * 店铺用户id
*/ */
private Long userId; private Long shopUserId;
/** /**
* 摘要信息兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等 * 摘要信息兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等
*/ */

View File

@ -55,9 +55,9 @@ public class PointsExchangeRecord implements Serializable {
*/ */
private String pickupMethod; private String pickupMethod;
/** /**
* 用户id * 店铺用户id
*/ */
private Long userId; private Long shopUserId;
/** /**
* 用户昵称 * 用户昵称
*/ */

View File

@ -20,7 +20,7 @@ public class ConsumeAwardPointsParam implements Serializable {
/** /**
* 用户ID(shopUserId) * 用户ID(shopUserId)
*/ */
private Long userId; private Long shopUserId;
/** /**
* 订单ID * 订单ID
*/ */

View File

@ -20,7 +20,7 @@ public class PayedDeductPointsParam implements Serializable {
/** /**
* 用户ID(shopUserId) * 用户ID(shopUserId)
*/ */
private Long userId; private Long shopUserId;
/** /**
* 消耗积分 * 消耗积分
*/ */

View File

@ -30,7 +30,7 @@ public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMappe
private QueryWrapper buildQueryWrapper(MemberPointsLogDTO param) { private QueryWrapper buildQueryWrapper(MemberPointsLogDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper(); QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
if (ObjUtil.isNotNull(param.getUserId())) { if (ObjUtil.isNotNull(param.getUserId())) {
queryWrapper.eq(MemberPointsLog::getUserId, param.getUserId()); queryWrapper.eq(MemberPointsLog::getShopUserId, param.getUserId());
} }
if (StrUtil.isNotBlank(param.getNickName())) { if (StrUtil.isNotBlank(param.getNickName())) {
queryWrapper.like(ShopUser::getNickName, param.getNickName()); queryWrapper.like(ShopUser::getNickName, param.getNickName());

View File

@ -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.getShopUserId()); log.setShopUserId(entity.getShopUserId());
log.setContent(content); log.setContent(content);
log.setFloatType("subtract"); log.setFloatType("subtract");
log.setFloatPoints(-points); log.setFloatPoints(-points);
@ -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.getShopUserId()); log.setShopUserId(entity.getShopUserId());
log.setContent(content); log.setContent(content);
log.setFloatType("add"); log.setFloatType("add");
log.setFloatPoints(points); log.setFloatPoints(points);

View File

@ -64,7 +64,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
queryWrapper.eq(PointsExchangeRecord::getStatus, param.getStatus()); queryWrapper.eq(PointsExchangeRecord::getStatus, param.getStatus());
} }
if (ObjUtil.isNotNull(param.getUserId())) { if (ObjUtil.isNotNull(param.getUserId())) {
queryWrapper.eq(PointsExchangeRecord::getUserId, param.getUserId()); queryWrapper.eq(PointsExchangeRecord::getShopUserId, param.getUserId());
} }
if (StrUtil.isNotEmpty(param.getKeywords())) { if (StrUtil.isNotEmpty(param.getKeywords())) {
queryWrapper.and(q -> { queryWrapper.and(q -> {
@ -309,7 +309,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
if (goods == null) { if (goods == null) {
throw new CzgException("积分商品不存在"); throw new CzgException("积分商品不存在");
} }
MemberPoints memberPoints = memberPointsMapper.selectOneById(entity.getUserId()); MemberPoints memberPoints = memberPointsMapper.selectOneById(entity.getShopUserId());
if (memberPoints == null) { if (memberPoints == null) {
throw new CzgException("会员积分不足无法兑换此商品"); throw new CzgException("会员积分不足无法兑换此商品");
} }
@ -327,7 +327,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
// 记录积分浮动流水 // 记录积分浮动流水
MemberPointsLog log = new MemberPointsLog(); MemberPointsLog log = new MemberPointsLog();
log.setShopId(entity.getShopId()); log.setShopId(entity.getShopId());
log.setUserId(entity.getUserId()); log.setShopUserId(entity.getShopUserId());
log.setContent(StrUtil.format("兑换商品:{} * {}", entity.getPointsGoodsName(), "1")); log.setContent(StrUtil.format("兑换商品:{} * {}", entity.getPointsGoodsName(), "1"));
log.setFloatType("subtract"); log.setFloatType("subtract");
log.setFloatPoints(-requiredPoints); log.setFloatPoints(-requiredPoints);
@ -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::getShopUserId, entity.getUserId())); MemberPoints memberPoints = memberPointsMapper.selectOneByQuery(query().eq(MemberPoints::getShopUserId, entity.getShopUserId()));
if (memberPoints == null) { if (memberPoints == null) {
throw new CzgException("会员信息不存在"); throw new CzgException("会员信息不存在");
} }
@ -388,7 +388,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
// 记录积分浮动流水 // 记录积分浮动流水
MemberPointsLog log = new MemberPointsLog(); MemberPointsLog log = new MemberPointsLog();
log.setShopId(entity.getShopId()); log.setShopId(entity.getShopId());
log.setUserId(entity.getUserId()); log.setShopUserId(entity.getShopUserId());
log.setContent(StrUtil.format("(退单)兑换商品:{} * {}", entity.getPointsGoodsName(), "1")); log.setContent(StrUtil.format("(退单)兑换商品:{} * {}", entity.getPointsGoodsName(), "1"));
log.setFloatType("add"); log.setFloatType("add");
log.setFloatPoints(+entity.getSpendPoints()); log.setFloatPoints(+entity.getSpendPoints());