订单明细 最终单价
This commit is contained in:
parent
a9900821bb
commit
763dc0c634
|
|
@ -21,8 +21,7 @@ public interface CashierCartService extends IService<CashierCart> {
|
|||
*
|
||||
* @param shopId 桌码
|
||||
* @param tableCode 桌码
|
||||
* @param isUseVip 是否使用会员价
|
||||
* @param placeNum 第几次下单
|
||||
*/
|
||||
List<OrderDetail> getCartByTableCode(@NotBlank Long shopId,@NotBlank String tableCode, @NotNull Integer isUseVip,@NotNull Integer placeNum);
|
||||
List<OrderDetail> getCartByTableCode(@NotBlank Long shopId,@NotBlank String tableCode, @NotNull Integer placeNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ public interface CashierCartMapper extends BaseMapper<CashierCart> {
|
|||
/**
|
||||
*
|
||||
* @param tableCode 桌码
|
||||
* @param isUseVip 是否使用会员价
|
||||
* @param placeNum 第几次下单
|
||||
*/
|
||||
List<OrderDetail> getCartByTableCode(Long shopId,String tableCode,Integer isUseVip,Integer placeNum);
|
||||
List<OrderDetail> getCartByTableCode(Long shopId,String tableCode,Integer placeNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
public class CashierCartServiceImpl extends ServiceImpl<CashierCartMapper, CashierCart> implements CashierCartService {
|
||||
|
||||
@Override
|
||||
public List<OrderDetail> getCartByTableCode(Long shopId, String tableCode, Integer isUseVip, Integer placeNum) {
|
||||
return getMapper().getCartByTableCode(shopId, tableCode, isUseVip, placeNum);
|
||||
public List<OrderDetail> getCartByTableCode(Long shopId, String tableCode, Integer placeNum) {
|
||||
return getMapper().getCartByTableCode(shopId, tableCode, placeNum);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,12 +191,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
}
|
||||
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
||||
List<OrderDetail> orderDetails = cartService.getCartByTableCode(shopInfo.getId(), param.getTableCode(), param.isVipPrice() ? 1 : 0, param.getPlaceNum());
|
||||
List<OrderDetail> orderDetails = cartService.getCartByTableCode(shopInfo.getId(), param.getTableCode(), param.getPlaceNum());
|
||||
log.info("下单1 {}", JSONObject.toJSONString(orderDetails));
|
||||
//总打包费
|
||||
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
BigDecimal totalAmount = processOrderDetails(orderDetails, packAmount);
|
||||
BigDecimal totalAmount = processOrderDetails(orderDetails, packAmount, param.isVipPrice());
|
||||
log.info("下单2 总金额{} {}", totalAmount, JSONObject.toJSONString(orderDetails));
|
||||
if (packAmount.getPrice().compareTo(param.getPackFee()) != 0) {
|
||||
throw new ValidateException("生成订单失败,打包费不正确");
|
||||
|
|
@ -334,13 +334,22 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
* @param orderDetails 订单详情 需要回填
|
||||
* @param packAmount 打包费
|
||||
*/
|
||||
private BigDecimal processOrderDetails(List<OrderDetail> orderDetails, BigDecimalDTO packAmount) {
|
||||
private BigDecimal processOrderDetails(List<OrderDetail> orderDetails, BigDecimalDTO packAmount, boolean isVipPrice) {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
if (detail.getDiscountSaleAmount() != null && detail.getDiscountSaleAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
detail.setUnitPrice(detail.getDiscountSaleAmount());
|
||||
}else {
|
||||
if (isVipPrice) {
|
||||
detail.setUnitPrice(detail.getMemberPrice());
|
||||
}else {
|
||||
detail.setUnitPrice(detail.getPrice());
|
||||
}
|
||||
}
|
||||
if (detail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && detail.getPackAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
packAmount.setPrice(packAmount.getPrice().add(detail.getPackAmount().multiply(detail.getPackNumber())));
|
||||
}
|
||||
detail.setPayAmount(detail.getNum().multiply(detail.getPrice()));
|
||||
detail.setPayAmount(detail.getNum().multiply(detail.getUnitPrice()));
|
||||
totalAmount = totalAmount.add(detail.getPayAmount());
|
||||
}
|
||||
return totalAmount;
|
||||
|
|
@ -374,10 +383,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
for (OrderDetail orderDetail : value) {
|
||||
if (orderDetail.getDiscountSaleAmount() != null && orderDetail.getDiscountSaleAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setUnitPrice(orderDetail.getDiscountSaleAmount());
|
||||
}else {
|
||||
} else {
|
||||
if (isVipPrice) {
|
||||
orderDetail.setUnitPrice(orderDetail.getMemberPrice());
|
||||
}else {
|
||||
} else {
|
||||
orderDetail.setUnitPrice(orderDetail.getPrice());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
<insert id="createOrderDetails">
|
||||
INSERT INTO tb_order_detail(order_id, shop_id, product_id, product_img, product_name, product_type, sku_id,
|
||||
sku_name, price, discount_amount, pack_amount, pay_amount, return_amount, num, pack_number, coupon_num,
|
||||
sku_name, price,member_price,discount_sale_amount,unit_price, discount_amount, pack_amount, pay_amount,
|
||||
return_amount, num, pack_number, coupon_num,
|
||||
return_num, refund_num, refund_no, discount_sale_note, status, place_num, is_temporary, is_print, is_wait_call,
|
||||
pro_group_info, remark, refund_remark, create_time, update_time)
|
||||
VALUES
|
||||
<foreach collection="orderDetails" item="entity" separator=",">
|
||||
(#{orderId}, #{entity.shopId}, #{entity.productId}, #{entity.productImg}, #{entity.productName},
|
||||
#{entity.productType}, #{entity.skuId}, #{entity.skuName}, #{entity.price}, #{entity.discountAmount},
|
||||
#{entity.productType}, #{entity.skuId}, #{entity.skuName}, #{entity.price},#{entity.memberPrice},
|
||||
#{entity.discountSaleAmount}, #{entity.unitPrice}, #{entity.discountAmount},
|
||||
#{entity.packAmount}, #{entity.payAmount}, #{entity.returnAmount}, #{entity.num}, #{entity.packNumber},
|
||||
#{entity.couponNum}, #{entity.returnNum}, #{entity.refundNum}, #{entity.refundNo},
|
||||
#{entity.discountSaleNote}, #{entity.status}, #{entity.placeNum}, #{entity.isTemporary}, #{entity.isPrint},
|
||||
|
|
|
|||
Loading…
Reference in New Issue