会员积分代码提交
This commit is contained in:
parent
e5d6bd058d
commit
a0bc070395
|
|
@ -87,8 +87,8 @@ public class MemberPointsController {
|
|||
*/
|
||||
@PostMapping("payedDeductPoints")
|
||||
public CzgResult<Boolean> deductPoints(@RequestBody PayedDeductPointsParam param) {
|
||||
boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success(ret);
|
||||
//boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,7 +96,7 @@ public class MemberPointsController {
|
|||
*/
|
||||
@PostMapping("consumeAwardPoints")
|
||||
public CzgResult<Void> consumeAwardPoints(@RequestBody ConsumeAwardPointsParam param) {
|
||||
memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
//memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,9 +79,10 @@ public class UMemberPointsController {
|
|||
|
||||
/**
|
||||
* 003-根据积分计算可抵扣金额
|
||||
* @param userId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param points 使用积分
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param points 使用积分
|
||||
*/
|
||||
@GetMapping("calcDeductionAmount")
|
||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||
|
|
@ -94,8 +95,8 @@ public class UMemberPointsController {
|
|||
*/
|
||||
@PostMapping("payedDeductPoints")
|
||||
public CzgResult<Boolean> deductPoints(@RequestBody PayedDeductPointsParam param) {
|
||||
boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success(ret);
|
||||
//boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +104,7 @@ public class UMemberPointsController {
|
|||
*/
|
||||
@PostMapping("consumeAwardPoints")
|
||||
public CzgResult<Void> consumeAwardPoints(@RequestBody ConsumeAwardPointsParam param) {
|
||||
memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
//memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.account.service;
|
|||
import com.czg.account.dto.points.OrderDeductionPointsDTO;
|
||||
import com.czg.account.entity.MemberPoints;
|
||||
import com.czg.account.param.MemberPointsParam;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
|
|
@ -73,9 +74,9 @@ public interface MemberPointsService extends IService<MemberPoints> {
|
|||
* @param userId 用户id
|
||||
* @param points 积分
|
||||
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
||||
* @param orderId 订单id,可以为空
|
||||
* @param orderInfo 订单信息,可以为空
|
||||
*/
|
||||
boolean deductPoints(Long userId, int points, String content, Long orderId);
|
||||
boolean deductPoints(Long userId, int points, String content, OrderInfo orderInfo);
|
||||
|
||||
/**
|
||||
* 追加积分
|
||||
|
|
@ -83,17 +84,17 @@ public interface MemberPointsService extends IService<MemberPoints> {
|
|||
* @param userId 用户id
|
||||
* @param points 积分
|
||||
* @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
|
||||
* @param orderId 订单id,可以为空
|
||||
* @param orderInfo 订单信息,可以为空
|
||||
* @return 成功/失败
|
||||
*/
|
||||
boolean addPoints(Long userId, int points, String content, Long orderId);
|
||||
boolean addPoints(Long userId, int points, String content, OrderInfo orderInfo);
|
||||
|
||||
/**
|
||||
* 消费赠送积分
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orderId 订单id
|
||||
* @param orderInfo 订单信息,可以为空
|
||||
*/
|
||||
void consumeAwardPoints(Long userId, Long orderId);
|
||||
void consumeAwardPoints(Long userId, OrderInfo orderInfo);
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@ import com.czg.account.service.MemberPointsService;
|
|||
import com.czg.enums.YesNoEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.MemberPointsLogMapper;
|
||||
import com.czg.service.account.mapper.MemberPointsMapper;
|
||||
|
|
@ -23,7 +22,6 @@ import com.mybatisflex.core.paginate.Page;
|
|||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -44,8 +42,6 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
private PointsBasicSettingMapper pointsBasicSettingMapper;
|
||||
@Resource
|
||||
private MemberPointsLogMapper memberPointsLogMapper;
|
||||
@DubboReference
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(MemberPointsParam param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
|
|
@ -190,7 +186,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean deductPoints(Long userId, int points, String content, Long orderId) {
|
||||
public boolean deductPoints(Long userId, int points, String content, OrderInfo orderInfo) {
|
||||
MemberPoints entity = initMemberPoints(userId);
|
||||
// 扣除账户积分
|
||||
entity.setAccountPoints(entity.getAccountPoints() - points);
|
||||
|
|
@ -205,12 +201,9 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
log.setFloatType("subtract");
|
||||
log.setFloatPoints(-points);
|
||||
// 有关联订单的需要回置订单表的相关积分使用字段
|
||||
if (orderId != null) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
if (orderInfo != null) {
|
||||
log.setOrderNo(orderInfo.getOrderNo());
|
||||
// TODO 是否需要回执“使用的积分数量(points_num)”和“积分抵扣金额(points_discount_amount)”,目前不清楚是创建订单的时候置入还是支付完成后回调时置入需要商议后决定
|
||||
}
|
||||
if (orderInfo != null) {
|
||||
log.setOrderNo(orderInfo.getOrderNo());
|
||||
// TODO 是否需要回执“使用的积分数量(points_num)”和“积分抵扣金额(points_discount_amount)”,目前不清楚是创建订单的时候置入还是支付完成后回调时置入需要商议后决定
|
||||
}
|
||||
super.updateById(entity);
|
||||
memberPointsLogMapper.insert(log);
|
||||
|
|
@ -219,7 +212,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addPoints(Long userId, int points, String content, Long orderId) {
|
||||
public boolean addPoints(Long userId, int points, String content, OrderInfo orderInfo) {
|
||||
MemberPoints entity = initMemberPoints(userId);
|
||||
// 增加账户积分
|
||||
entity.setAccountPoints(entity.getAccountPoints() + points);
|
||||
|
|
@ -233,11 +226,8 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
log.setFloatType("add");
|
||||
log.setFloatPoints(points);
|
||||
// 有关联订单的需要回置订单表的相关积分使用字段
|
||||
if (orderId != null) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
if (orderInfo != null) {
|
||||
log.setOrderNo(orderInfo.getOrderNo());
|
||||
}
|
||||
if (orderInfo != null) {
|
||||
log.setOrderNo(orderInfo.getOrderNo());
|
||||
}
|
||||
super.updateById(entity);
|
||||
memberPointsLogMapper.insert(log);
|
||||
|
|
@ -246,8 +236,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void consumeAwardPoints(Long userId, Long orderId) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
public void consumeAwardPoints(Long userId, OrderInfo orderInfo) {
|
||||
if (orderInfo == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
}
|
||||
|
|
@ -282,6 +271,6 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
|||
return;
|
||||
}
|
||||
BigDecimal awardPoints = NumberUtil.roundDown(NumberUtil.div(payAmount, consumeAmount), 0);
|
||||
addPoints(userId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderId);
|
||||
addPoints(userId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderInfo);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue