会员积分问题修复
This commit is contained in:
parent
e684ea1498
commit
732e780db4
|
|
@ -47,8 +47,8 @@ public class UMemberPointsController {
|
|||
*/
|
||||
@GetMapping("myPoints")
|
||||
public CzgResult<MemberPoints> getMemberPoints() {
|
||||
long userId = StpKit.USER.getLoginIdAsLong();
|
||||
MemberPoints data = memberPointsService.getMemberPoints(userId);
|
||||
long shopUserId = StpKit.USER.getLoginIdAsLong();
|
||||
MemberPoints data = memberPointsService.getMemberPoints(shopUserId);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ public class UMemberPointsController {
|
|||
* @param orderAmount 订单金额
|
||||
*/
|
||||
@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);
|
||||
return CzgResult.success(usablePoints);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ public class UMemberPointsController {
|
|||
* @param deductionAmount 抵扣金额
|
||||
*/
|
||||
@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);
|
||||
return CzgResult.success(points);
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ public class UMemberPointsController {
|
|||
* @param points 使用积分
|
||||
*/
|
||||
@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);
|
||||
return CzgResult.success(deductionAmount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
|||
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.entity.PointsExchangeRecord;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
|
|
@ -105,7 +104,7 @@ public class UShopUserController {
|
|||
@GetMapping("/pointsRecord")
|
||||
public CzgResult<Page<PointsExchangeRecord>> getPointsRecord() {
|
||||
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")
|
||||
public CzgResult<PointsExchangeRecord> getPointsRecordDetail(@RequestParam Long id) {
|
||||
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)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ public class MemberPointsLog implements Serializable {
|
|||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 用户id
|
||||
* 店铺用户id
|
||||
*/
|
||||
private Long userId;
|
||||
private Long shopUserId;
|
||||
/**
|
||||
* 摘要信息(如:兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ public class PointsExchangeRecord implements Serializable {
|
|||
*/
|
||||
private String pickupMethod;
|
||||
/**
|
||||
* 用户id
|
||||
* 店铺用户id
|
||||
*/
|
||||
private Long userId;
|
||||
private Long shopUserId;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class ConsumeAwardPointsParam implements Serializable {
|
|||
/**
|
||||
* 用户ID(shopUserId)
|
||||
*/
|
||||
private Long userId;
|
||||
private Long shopUserId;
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class PayedDeductPointsParam implements Serializable {
|
|||
/**
|
||||
* 用户ID(shopUserId)
|
||||
*/
|
||||
private Long userId;
|
||||
private Long shopUserId;
|
||||
/**
|
||||
* 消耗积分
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMappe
|
|||
private QueryWrapper buildQueryWrapper(MemberPointsLogDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
if (ObjUtil.isNotNull(param.getUserId())) {
|
||||
queryWrapper.eq(MemberPointsLog::getUserId, param.getUserId());
|
||||
queryWrapper.eq(MemberPointsLog::getShopUserId, param.getUserId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(param.getNickName())) {
|
||||
queryWrapper.like(ShopUser::getNickName, param.getNickName());
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
// 记录积分变动记录
|
||||
MemberPointsLog log = new MemberPointsLog();
|
||||
log.setShopId(entity.getShopId());
|
||||
log.setUserId(entity.getShopUserId());
|
||||
log.setShopUserId(entity.getShopUserId());
|
||||
log.setContent(content);
|
||||
log.setFloatType("subtract");
|
||||
log.setFloatPoints(-points);
|
||||
|
|
@ -221,7 +221,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
// 记录积分变动记录
|
||||
MemberPointsLog log = new MemberPointsLog();
|
||||
log.setShopId(entity.getShopId());
|
||||
log.setUserId(entity.getShopUserId());
|
||||
log.setShopUserId(entity.getShopUserId());
|
||||
log.setContent(content);
|
||||
log.setFloatType("add");
|
||||
log.setFloatPoints(points);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||
queryWrapper.eq(PointsExchangeRecord::getStatus, param.getStatus());
|
||||
}
|
||||
if (ObjUtil.isNotNull(param.getUserId())) {
|
||||
queryWrapper.eq(PointsExchangeRecord::getUserId, param.getUserId());
|
||||
queryWrapper.eq(PointsExchangeRecord::getShopUserId, param.getUserId());
|
||||
}
|
||||
if (StrUtil.isNotEmpty(param.getKeywords())) {
|
||||
queryWrapper.and(q -> {
|
||||
|
|
@ -309,7 +309,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||
if (goods == null) {
|
||||
throw new CzgException("积分商品不存在");
|
||||
}
|
||||
MemberPoints memberPoints = memberPointsMapper.selectOneById(entity.getUserId());
|
||||
MemberPoints memberPoints = memberPointsMapper.selectOneById(entity.getShopUserId());
|
||||
if (memberPoints == null) {
|
||||
throw new CzgException("会员积分不足无法兑换此商品");
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||
// 记录积分浮动流水
|
||||
MemberPointsLog log = new MemberPointsLog();
|
||||
log.setShopId(entity.getShopId());
|
||||
log.setUserId(entity.getUserId());
|
||||
log.setShopUserId(entity.getShopUserId());
|
||||
log.setContent(StrUtil.format("兑换商品:{} * {}", entity.getPointsGoodsName(), "1"));
|
||||
log.setFloatType("subtract");
|
||||
log.setFloatPoints(-requiredPoints);
|
||||
|
|
@ -370,7 +370,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||
entity.setCancelOrRefundReason(param.getCancelOrRefundReason());
|
||||
entity.setCancelOrRefundTime(LocalDateTime.now());
|
||||
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) {
|
||||
throw new CzgException("会员信息不存在");
|
||||
}
|
||||
|
|
@ -388,7 +388,7 @@ public class PointsExchangeRecordServiceImpl extends ServiceImpl<PointsExchangeR
|
|||
// 记录积分浮动流水
|
||||
MemberPointsLog log = new MemberPointsLog();
|
||||
log.setShopId(entity.getShopId());
|
||||
log.setUserId(entity.getUserId());
|
||||
log.setShopUserId(entity.getShopUserId());
|
||||
log.setContent(StrUtil.format("(退单)兑换商品:{} * {}", entity.getPointsGoodsName(), "1"));
|
||||
log.setFloatType("add");
|
||||
log.setFloatPoints(+entity.getSpendPoints());
|
||||
|
|
|
|||
Loading…
Reference in New Issue