取消订单,恢复积分
This commit is contained in:
parent
02f3bde2b4
commit
1b60079481
@ -1,14 +1,16 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.event.AfterSaleStatusChangeEvent;
|
||||
import cn.lili.event.GoodsCommentCompleteEvent;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.event.OrderStatusChangeEvent;
|
||||
import cn.lili.event.*;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
import cn.lili.modules.order.cart.entity.vo.CartVO;
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
@ -31,7 +33,7 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2020-07-03 11:20
|
||||
*/
|
||||
@Service
|
||||
public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent, AfterSaleStatusChangeEvent {
|
||||
public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent, AfterSaleStatusChangeEvent, TradeEvent {
|
||||
|
||||
/**
|
||||
* 配置
|
||||
@ -86,7 +88,7 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
|
||||
//根据订单编号获取订单数据,如果为积分订单则跳回
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())) {
|
||||
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) {
|
||||
return;
|
||||
}
|
||||
//获取积分设置
|
||||
@ -95,7 +97,13 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0);
|
||||
//赠送会员积分
|
||||
memberService.updateMemberPoint(point.longValue(), true, order.getMemberId(), "会员下单,赠送积分" + point + "分");
|
||||
|
||||
//取消订单恢复积分
|
||||
} else if (orderMessage.getNewStatus().equals(OrderStatusEnum.CANCELLED)) {
|
||||
//根据订单编号获取订单数据,如果为积分订单则跳回
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name()) && order.getPriceDetailDTO().getPayPoint() != null) {
|
||||
memberService.updateMemberPoint(Convert.toLong(order.getPriceDetailDTO().getPayPoint()), true, order.getMemberId(), "订单取消,恢复积分:" + order.getPriceDetailDTO().getPayPoint() + "分");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,4 +134,25 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
Setting setting = settingService.get(SettingEnum.POINT_SETTING.name());
|
||||
return new Gson().fromJson(setting.getSettingValue(), PointSetting.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分订单 扣除用户积分
|
||||
*
|
||||
* @param tradeDTO 交易
|
||||
*/
|
||||
@Override
|
||||
public void orderCreate(TradeDTO tradeDTO) {
|
||||
if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) {
|
||||
StringBuilder orderSns = new StringBuilder();
|
||||
for (CartVO item : tradeDTO.getCartList()) {
|
||||
orderSns.append(item.getSn());
|
||||
}
|
||||
boolean result = memberService.updateMemberPoint((0 - tradeDTO.getPriceDetailDTO().getPayPoint().longValue()), false, tradeDTO.getMemberId(),
|
||||
"订单【" + orderSns + "】创建,积分扣减");
|
||||
|
||||
if (!result) {
|
||||
throw new ServiceException(ResultCode.PAY_POINT_ENOUGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,9 @@ import cn.lili.modules.order.cart.render.CartRenderStep;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.promotion.entity.dos.Pintuan;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsVO;
|
||||
import cn.lili.modules.promotion.service.PintuanService;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -54,6 +56,9 @@ public class CheckDataRender implements CartRenderStep {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private PointsGoodsService pointsGoodsService;
|
||||
|
||||
@Override
|
||||
public void render(TradeDTO tradeDTO) {
|
||||
//预校验
|
||||
@ -143,7 +148,7 @@ public class CheckDataRender implements CartRenderStep {
|
||||
private void preCalibration(TradeDTO tradeDTO) {
|
||||
|
||||
//拼团订单预校验
|
||||
if(tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)){
|
||||
if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) {
|
||||
//拼团判定,不能参与自己创建的拼团
|
||||
if (tradeDTO.getParentOrderSn() != null) {
|
||||
//订单接受
|
||||
@ -164,10 +169,16 @@ public class CheckDataRender implements CartRenderStep {
|
||||
}
|
||||
}
|
||||
}
|
||||
//积分商品,判断用户积分是否满足
|
||||
}else if(tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS)){
|
||||
Member member=memberService.getUserInfo();
|
||||
if(member.getPoint()<tradeDTO.getSkuList().get(0).getPoint()){
|
||||
//积分商品,判断用户积分是否满足
|
||||
} else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS)) {
|
||||
String skuId = tradeDTO.getSkuList().get(0).getGoodsSku().getId();
|
||||
//获取积分商品VO
|
||||
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsVOByMongo(skuId);
|
||||
if(pointsGoodsVO==null){
|
||||
throw new ServiceException(ResultCode.POINT_GOODS_ERROR);
|
||||
}
|
||||
Member member = memberService.getUserInfo();
|
||||
if (member.getPoint() < pointsGoodsVO.getPoints()) {
|
||||
throw new ServiceException(ResultCode.USER_POINTS_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public enum OrderPromotionTypeEnum {
|
||||
/**
|
||||
* 积分订单
|
||||
*/
|
||||
POINT,
|
||||
POINTS,
|
||||
/**
|
||||
* 砍价订单
|
||||
*/
|
||||
|
File diff suppressed because one or more lines are too long
@ -29,7 +29,7 @@ public interface KanjiaActivityGoodsService extends IService<KanjiaActivityGoods
|
||||
* @param kanJiaActivityGoodsDTOS 砍价商品
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
boolean add(KanjiaActivityGoodsOperationDTO kanJiaActivityGoodsDTOS);
|
||||
Boolean add(KanjiaActivityGoodsOperationDTO kanJiaActivityGoodsDTOS);
|
||||
|
||||
/**
|
||||
* 查询砍价活动商品分页信息
|
||||
|
@ -70,7 +70,7 @@ public class KanjiaActivityGoodsServiceImpl extends ServiceImpl<KanJiaActivityGo
|
||||
|
||||
|
||||
@Override
|
||||
public boolean add(KanjiaActivityGoodsOperationDTO kanJiaActivityGoodsOperationDTO) {
|
||||
public Boolean add(KanjiaActivityGoodsOperationDTO kanJiaActivityGoodsOperationDTO) {
|
||||
List<KanjiaActivityGoods> kanjiaActivityGoodsList = new ArrayList<>();
|
||||
for (KanjiaActivityGoodsDTO kanJiaActivityGoodsDTO : kanJiaActivityGoodsOperationDTO.getPromotionGoodsList()) {
|
||||
//根据skuId查询商品信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user