parent
f8797b0e79
commit
f7ca147e49
|
|
@ -4,6 +4,8 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CreateOrderDTO {
|
public class CreateOrderDTO {
|
||||||
|
|
@ -18,4 +20,8 @@ public class CreateOrderDTO {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String useType;
|
private String useType;
|
||||||
private String vipUserId;
|
private String vipUserId;
|
||||||
|
// 使用的优惠券
|
||||||
|
private List<Integer> userCouponIds = new ArrayList<>();
|
||||||
|
// 使用的积分抵扣数量
|
||||||
|
private Integer pointsNum ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.ysk.cashier.mybatis.service;
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.cons.TableConstant;
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
|
import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
@ -55,5 +56,13 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
*/
|
*/
|
||||||
boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId);
|
boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据店就餐模式查询购物车
|
||||||
|
* @param shopEatTypeInfoDTO 就餐模式
|
||||||
|
* @return 购物车信息
|
||||||
|
*/
|
||||||
|
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,13 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||||
*/
|
*/
|
||||||
List<TbOrderDetail> selectByOrderId(Integer orderId);
|
List<TbOrderDetail> selectByOrderId(Integer orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据购物车id和订单id查询订单详情
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param cartIdList 购物车id
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @return 详情信息
|
||||||
|
*/
|
||||||
|
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, ArrayList<Integer> cartIdList, Integer orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@ package cn.ysk.cashier.mybatis.service.impl;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.ysk.cashier.cons.TableConstant;
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO;
|
||||||
import cn.ysk.cashier.enums.OrderUseTypeEnum;
|
import cn.ysk.cashier.enums.*;
|
||||||
import cn.ysk.cashier.enums.ShopInfoEatModelEnum;
|
|
||||||
import cn.ysk.cashier.enums.ShopInfoRegisterlEnum;
|
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
|
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper;
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||||
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -32,8 +32,11 @@ import java.util.List;
|
||||||
public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, TbCashierCart> implements MpCashierCartService {
|
public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, TbCashierCart> implements MpCashierCartService {
|
||||||
private final MpShopInfoMapper mpShopInfoMapper;
|
private final MpShopInfoMapper mpShopInfoMapper;
|
||||||
|
|
||||||
public MpCashierCartServiceImpl(MpShopInfoMapper mpShopInfoMapper) {
|
private final MpShopTableMapper shopTableMapper;
|
||||||
|
|
||||||
|
public MpCashierCartServiceImpl(MpShopInfoMapper mpShopInfoMapper, MpShopTableMapper shopTableMapper) {
|
||||||
this.mpShopInfoMapper = mpShopInfoMapper;
|
this.mpShopInfoMapper = mpShopInfoMapper;
|
||||||
|
this.shopTableMapper = shopTableMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -93,5 +96,31 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
||||||
.eq(TbCashierCart::getOrderId, orderId)
|
.eq(TbCashierCart::getOrderId, orderId)
|
||||||
.set(TbCashierCart::getStatus, status.getValue()));
|
.set(TbCashierCart::getStatus, status.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId) {
|
||||||
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
|
||||||
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
||||||
|
.in(TbCashierCart::getStatus, "create", "return")
|
||||||
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
|
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
|
||||||
|
|
||||||
|
// 非堂食校验台桌状态
|
||||||
|
TbShopTable tbShopTable;
|
||||||
|
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||||
|
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||||
|
} else {
|
||||||
|
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
|
||||||
|
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
|
||||||
|
} else {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,12 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
|
||||||
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
||||||
.eq(TbOrderDetail::getOrderId, orderId));
|
.eq(TbOrderDetail::getOrderId, orderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, ArrayList<Integer> cartIdList, Integer orderId) {
|
||||||
|
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
||||||
|
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId))
|
||||||
|
.eq(TbOrderDetail::getShopId, shopId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,16 @@ public class TbOrderInfo implements Serializable {
|
||||||
|
|
||||||
@Column(name = "`refund_remark`")
|
@Column(name = "`refund_remark`")
|
||||||
private String refundRemark;
|
private String refundRemark;
|
||||||
|
|
||||||
|
// 积分折扣金额
|
||||||
|
private BigDecimal pointsDiscountAmount;
|
||||||
|
// 使用的积分数量
|
||||||
|
private Integer pointsNum;
|
||||||
|
// 用户优惠券id
|
||||||
|
private String activateInInfoList;
|
||||||
|
// 优惠券折扣金额
|
||||||
|
private BigDecimal activateInDiscountAmount;
|
||||||
|
|
||||||
public void copy(TbOrderInfo source){
|
public void copy(TbOrderInfo source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||||
import cn.ysk.cashier.cons.RedisConstant;
|
import cn.ysk.cashier.cons.RedisConstant;
|
||||||
import cn.ysk.cashier.cons.TableConstant;
|
import cn.ysk.cashier.cons.TableConstant;
|
||||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||||
|
import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO;
|
||||||
import cn.ysk.cashier.dto.shop.TbShopTableDto;
|
import cn.ysk.cashier.dto.shop.TbShopTableDto;
|
||||||
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
|
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
|
||||||
import cn.ysk.cashier.dto.shoptable.*;
|
import cn.ysk.cashier.dto.shoptable.*;
|
||||||
|
|
@ -18,10 +19,7 @@ import cn.ysk.cashier.enums.*;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
||||||
import cn.ysk.cashier.mybatis.mapper.*;
|
import cn.ysk.cashier.mybatis.mapper.*;
|
||||||
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
import cn.ysk.cashier.mybatis.service.*;
|
||||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
|
||||||
import cn.ysk.cashier.mybatis.service.MpOrderInfoService;
|
|
||||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
|
||||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
|
|
@ -98,6 +96,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
private final MpShopTableService mpShopTableService;
|
private final MpShopTableService mpShopTableService;
|
||||||
private final MpShopUnitMapper mpShopUnitMapper;
|
private final MpShopUnitMapper mpShopUnitMapper;
|
||||||
private final MpProductStockDetailMapper mpProductStockDetailMapper;
|
private final MpProductStockDetailMapper mpProductStockDetailMapper;
|
||||||
|
private final TbMemberPointsService memberPointsService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1107,50 +1106,30 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null);
|
TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null);
|
||||||
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
|
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
|
||||||
|
|
||||||
// 就餐模式信息
|
|
||||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(createOrderDTO.getShopId(), createOrderDTO.getTableId(), createOrderDTO.getUseType());
|
|
||||||
|
|
||||||
// 传递orderId直接取否则取当前缓存id
|
|
||||||
Integer orderId = shopEatTypeInfoDTO.isDineInAfter() ?
|
|
||||||
getCurrentOrderId(shopEatTypeInfoDTO) : null;
|
|
||||||
|
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
|
||||||
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
|
||||||
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
|
||||||
.in(TbCashierCart::getStatus, "create", "return")
|
|
||||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
|
||||||
.and(q -> q.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId()).or().isNull(TbCashierCart::getMasterId));
|
|
||||||
|
|
||||||
// 非堂食校验台桌状态
|
// 非堂食校验台桌状态
|
||||||
TbShopTable tbShopTable = null;
|
TbShopTable tbShopTable = null;
|
||||||
if (shopEatTypeInfoDTO.isTakeout()) {
|
|
||||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
|
||||||
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
|
||||||
} else {
|
|
||||||
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
|
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
|
||||||
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||||
.in(TbShopTable::getStatus, "idle", "using"));
|
.in(TbShopTable::getStatus, "idle", "using"));
|
||||||
|
}
|
||||||
if (tbShopTable == null) {
|
if (tbShopTable == null) {
|
||||||
throw new BadRequestException("台桌未开台或不存在");
|
throw new BadRequestException("台桌未开台或不存在");
|
||||||
}
|
}
|
||||||
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
|
|
||||||
} else {
|
|
||||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// 就餐模式信息
|
||||||
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(createOrderDTO.getShopId(), createOrderDTO.getTableId(), createOrderDTO.getUseType());
|
||||||
List<TbCashierCart> allCashierCarts = cashierCartMapper
|
// 传递orderId直接取否则取当前缓存id
|
||||||
.selectList(queryWrapper);
|
Integer orderId = shopEatTypeInfoDTO.isDineInAfter() ?
|
||||||
|
getCurrentOrderId(shopEatTypeInfoDTO) : null;
|
||||||
|
|
||||||
|
List<TbCashierCart> allCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, createOrderDTO.getMasterId());
|
||||||
List<TbCashierCart> cashierCarts = new ArrayList<>();
|
List<TbCashierCart> cashierCarts = new ArrayList<>();
|
||||||
TbCashierCart seatCart = null;
|
TbCashierCart seatCart = null;
|
||||||
for (TbCashierCart allCashierCart : allCashierCarts) {
|
for (TbCashierCart allCashierCart : allCashierCarts) {
|
||||||
if (TableConstant.CART_SEAT_ID.equals(allCashierCart.getProductId())) {
|
if (TableConstant.CART_SEAT_ID.equals(allCashierCart.getProductId())) {
|
||||||
seatCart = allCashierCart;
|
seatCart = allCashierCart;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (OrderStatusEnums.CREATE.getValue().equals(allCashierCart.getStatus())) {
|
// if (OrderStatusEnums.CREATE.getValue().equals(allCashierCart.getStatus())) {
|
||||||
// cashierCarts.add(allCashierCart);
|
// cashierCarts.add(allCashierCart);
|
||||||
// }
|
// }
|
||||||
|
|
@ -1176,12 +1155,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
cartIdList.add(tbCashierCart.getId());
|
cartIdList.add(tbCashierCart.getId());
|
||||||
}
|
}
|
||||||
// 查询历史orderDetail
|
// 查询历史orderDetail
|
||||||
Integer finalOrderId = orderId;
|
List<TbOrderDetail> oldOrderDetailList = mpOrderDetailService.selectByCartIdOrOrderId(createOrderDTO.getShopId(), cartIdList, orderId);
|
||||||
LambdaQueryWrapper<TbOrderDetail> query = new LambdaQueryWrapper<TbOrderDetail>()
|
|
||||||
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, finalOrderId))
|
|
||||||
.eq(TbOrderDetail::getShopId, createOrderDTO.getShopId());
|
|
||||||
|
|
||||||
List<TbOrderDetail> oldOrderDetailList = orderDetailMapper.selectList(query);
|
|
||||||
ArrayList<Integer> removeOrderDetailIds = new ArrayList<>();
|
ArrayList<Integer> removeOrderDetailIds = new ArrayList<>();
|
||||||
ArrayList<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
ArrayList<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
||||||
HashMap<String, TbOrderDetail> oldOrderDetailMap = new HashMap<>();
|
HashMap<String, TbOrderDetail> oldOrderDetailMap = new HashMap<>();
|
||||||
|
|
@ -1203,7 +1178,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
||||||
List<TbOrderDetail> addOrderDetails = new ArrayList<>();
|
List<TbOrderDetail> addOrderDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
boolean hasNewInfo = false;
|
boolean hasNewInfo = false;
|
||||||
for (TbCashierCart cashierCart : cashierCarts) {
|
for (TbCashierCart cashierCart : cashierCarts) {
|
||||||
if (!"return".equals(cashierCart.getStatus())) {
|
if (!"return".equals(cashierCart.getStatus())) {
|
||||||
|
|
@ -1239,7 +1213,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
orderDetail.setProductName(cashierCart.getName());
|
orderDetail.setProductName(cashierCart.getName());
|
||||||
orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId()));
|
orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId()));
|
||||||
orderDetail.setPackAmount(cashierCart.getPackFee());
|
orderDetail.setPackAmount(cashierCart.getPackFee());
|
||||||
orderDetail.setStatus("unpaid");
|
orderDetail.setStatus(TableConstant.CashierCart.Status.RETURN.equalsVals(cashierCart.getStatus()) ? cashierCart.getStatus() : "unpaid");
|
||||||
orderDetail.setUseType(shopEatTypeInfoDTO.getUseType());
|
orderDetail.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||||
orderDetail.setCartId(cashierCart.getId());
|
orderDetail.setCartId(cashierCart.getId());
|
||||||
|
|
@ -1250,7 +1224,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
orderDetails.add(orderDetail);
|
orderDetails.add(orderDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 查询订单
|
// 查询订单
|
||||||
TbOrderInfo orderInfo = null;
|
TbOrderInfo orderInfo = null;
|
||||||
if (orderId != null) {
|
if (orderId != null) {
|
||||||
|
|
@ -1275,7 +1248,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
orderInfo.setSettlementAmount(totalAmount);
|
orderInfo.setSettlementAmount(totalAmount);
|
||||||
orderInfo.setAmount(totalAmount);
|
orderInfo.setAmount(totalAmount);
|
||||||
orderInfo.setOriginAmount(totalAmount);
|
orderInfo.setOriginAmount(totalAmount);
|
||||||
// orderInfo.setStatus("unpaid");
|
|
||||||
orderInfo.setOrderAmount(totalAmount);
|
orderInfo.setOrderAmount(totalAmount);
|
||||||
orderInfo.setRemark(createOrderDTO.getNote());
|
orderInfo.setRemark(createOrderDTO.getNote());
|
||||||
orderInfo.setFreightAmount(feeAmount);
|
orderInfo.setFreightAmount(feeAmount);
|
||||||
|
|
@ -1449,6 +1421,26 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void calculateOrderCouponAndPoints(TbOrderInfo orderInfo, List<Integer> userCouponList, Integer pointsNum) {
|
||||||
|
BigDecimal shouldPayAmount = BigDecimal.ZERO;
|
||||||
|
if (pointsNum != null) {
|
||||||
|
Long memberId = Long.valueOf(orderInfo.getMemberId());
|
||||||
|
OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(memberId, orderInfo.getOrderAmount());
|
||||||
|
if (!memberUsablePoints.getUsable()) {
|
||||||
|
throw new BadRequestException(memberUsablePoints.getUnusableReason());
|
||||||
|
}
|
||||||
|
if (pointsNum < memberUsablePoints.getMinDeductionPoints() || pointsNum > memberUsablePoints.getMaxUsablePoints()) {
|
||||||
|
throw new BadRequestException("可抵扣积分区间为: [" + memberUsablePoints.getMinDeductionPoints() + "-" + memberUsablePoints.getMaxUsablePoints() + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal discountAmount = memberPointsService.calcDeductionAmount(memberId, orderInfo.getOrderAmount(), pointsNum);
|
||||||
|
orderInfo.setPointsNum(pointsNum);
|
||||||
|
orderInfo.setPointsDiscountAmount(discountAmount);
|
||||||
|
shouldPayAmount = shouldPayAmount.subtract(discountAmount);
|
||||||
|
memberPointsService.deductPoints(memberId, pointsNum, "霸王餐充值抵扣", Long.valueOf(orderInfo.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object pending(PendingDTO pendingDTO) {
|
public Object pending(PendingDTO pendingDTO) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue