fix: 创建订单会员价计算有误修复
This commit is contained in:
parent
5dd35a9572
commit
8d5642c07a
|
|
@ -1385,18 +1385,18 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
* 根据商品优惠券
|
||||
*
|
||||
* @param fullCashierCarts
|
||||
* @param orderId
|
||||
* @param orderInfo
|
||||
* @param shopId
|
||||
* @param updateState
|
||||
* @return
|
||||
*/
|
||||
private OrderPriceDTO createOrderDetailWithCoupon(List<TbCashierCart> fullCashierCarts, Integer orderId, Integer shopId, boolean updateState) {
|
||||
private OrderPriceDTO createOrderDetailWithCoupon(List<TbCashierCart> fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, boolean updateState) {
|
||||
OrderPriceDTO priceDTO = new OrderPriceDTO();
|
||||
|
||||
List<Integer> cartIds = fullCashierCarts.stream().map(TbCashierCart::getId).collect(Collectors.toList());
|
||||
// 查询历史orderDetail
|
||||
List<TbOrderDetail> oldOrderDetailList = mpOrderDetailService
|
||||
.selectByCartIdOrOrderId(shopId, cartIds, orderId);
|
||||
.selectByCartIdOrOrderId(shopId, cartIds, orderInfo == null ? -1 : orderInfo.getId());
|
||||
HashMap<String, TbOrderDetail> oldOrderDetailMap = new HashMap<>();
|
||||
oldOrderDetailList.forEach(item -> {
|
||||
if (cartIds.contains(item.getCartId())) {
|
||||
|
|
@ -1408,6 +1408,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
});
|
||||
|
||||
for (TbCashierCart cashierCart : fullCashierCarts) {
|
||||
if (orderInfo != null) {
|
||||
cashierCart.setIsMember(orderInfo.getMemberId() == null ? 0 : 1);
|
||||
cashierCart.resetTotalAmount();
|
||||
}
|
||||
|
||||
// 已经退款和使用优惠券的商品不进行统计金额
|
||||
if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) {
|
||||
priceDTO.setTotalAmount(priceDTO.getTotalAmount().add(cashierCart.getTotalAmount()));
|
||||
|
|
@ -1418,6 +1423,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
priceDTO.setOriginAmount(priceDTO.getOriginAmount().add(cashierCart.getTotalAmount()));
|
||||
}
|
||||
|
||||
|
||||
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
||||
TbOrderDetail orderDetail = null;
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
|
|
@ -1451,10 +1457,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
orderDetail.setUseType(cashierCart.getUseType());
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
orderDetail.setCartId(cashierCart.getId());
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
}
|
||||
orderDetail.setOrderId(orderId);
|
||||
orderDetail.setOrderId(orderInfo == null ? null : orderInfo.getId());
|
||||
priceDTO.getOrderDetailList().add(orderDetail);
|
||||
}
|
||||
return priceDTO;
|
||||
|
|
|
|||
Loading…
Reference in New Issue