|
@@ -66,7 +66,7 @@ class OrderService
|
|
// 批量查询商品信息
|
|
// 批量查询商品信息
|
|
$goodsData = [];
|
|
$goodsData = [];
|
|
if (!empty($goodsIds)) {
|
|
if (!empty($goodsIds)) {
|
|
- $goodsCollection = Goods::with(['category', 'brand'])
|
|
|
|
|
|
+ $goodsCollection = Goods::with(['brand'])
|
|
->where('id', 'in', $goodsIds)
|
|
->where('id', 'in', $goodsIds)
|
|
->where('status', GoodsEnum::STATUS_ON_SALE)
|
|
->where('status', GoodsEnum::STATUS_ON_SALE)
|
|
->select();
|
|
->select();
|
|
@@ -201,7 +201,7 @@ class OrderService
|
|
'comment_status' => 0, // 评论状态:0=未评论
|
|
'comment_status' => 0, // 评论状态:0=未评论
|
|
'status' => 1, // 状态
|
|
'status' => 1, // 状态
|
|
// 添加分类和品牌信息用于优惠券计算 (临时字段,不会保存到数据库)
|
|
// 添加分类和品牌信息用于优惠券计算 (临时字段,不会保存到数据库)
|
|
- 'category_id' => $item->goods->category_id,
|
|
|
|
|
|
+ // 'category_id' => $item->goods->category_ids,
|
|
'brand_id' => $item->goods->brand_id,
|
|
'brand_id' => $item->goods->brand_id,
|
|
];
|
|
];
|
|
|
|
|
|
@@ -219,26 +219,26 @@ class OrderService
|
|
// 订单应付金额(暂时等于订单金额,后续会减去优惠)
|
|
// 订单应付金额(暂时等于订单金额,后续会减去优惠)
|
|
$orderInfo['amount'] = $orderInfo['order_amount'];
|
|
$orderInfo['amount'] = $orderInfo['order_amount'];
|
|
|
|
|
|
- if (!empty($userCoupon)) {
|
|
|
|
- // 校验优惠券
|
|
|
|
- $goods_ids = array_column($orderItem, 'goods_id');
|
|
|
|
- $category_ids = array_column($orderItem, 'category_id');
|
|
|
|
- $brand_ids = array_column($orderItem, 'brand_id');
|
|
|
|
- $couponModel = new Coupon();
|
|
|
|
- $coupon = $couponModel->getCoupon($userCoupon['coupon_id'])
|
|
|
|
- ->checkCoupon()
|
|
|
|
- ->checkOpen()
|
|
|
|
- ->checkUseTime($userCoupon['createtime'])
|
|
|
|
- ->checkConditionGoods($goods_ids, $userId, $category_ids, $brand_ids);
|
|
|
|
-
|
|
|
|
- // 计算折扣金额,判断是使用不含运费,还是含运费的金额
|
|
|
|
- $amount = !isset($config['shippingfeecoupon']) || $config['shippingfeecoupon'] == 0 ? $orderInfo['goods_price'] : $orderInfo['order_amount'];
|
|
|
|
- list($new_money, $coupon_money) = $coupon->doBuy($amount);
|
|
|
|
-
|
|
|
|
- // 判断优惠金额是否超出总价,超出则直接设定优惠金额为总价
|
|
|
|
- $orderInfo['coupon_discount_fee'] = $coupon_money > $amount ? $amount : $coupon_money;
|
|
|
|
- $orderInfo['discount_fee'] = $orderInfo['coupon_discount_fee'];
|
|
|
|
- }
|
|
|
|
|
|
+ // if (!empty($userCoupon)) {
|
|
|
|
+ // // 校验优惠券
|
|
|
|
+ // $goods_ids = array_column($orderItem, 'goods_id');
|
|
|
|
+ // $category_ids = array_column($orderItem, 'category_id');
|
|
|
|
+ // $brand_ids = array_column($orderItem, 'brand_id');
|
|
|
|
+ // $couponModel = new Coupon();
|
|
|
|
+ // $coupon = $couponModel->getCoupon($userCoupon['coupon_id'])
|
|
|
|
+ // ->checkCoupon()
|
|
|
|
+ // ->checkOpen()
|
|
|
|
+ // ->checkUseTime($userCoupon['createtime'])
|
|
|
|
+ // ->checkConditionGoods($goods_ids, $userId, $category_ids, $brand_ids);
|
|
|
|
+
|
|
|
|
+ // // 计算折扣金额,判断是使用不含运费,还是含运费的金额
|
|
|
|
+ // $amount = !isset($config['shippingfeecoupon']) || $config['shippingfeecoupon'] == 0 ? $orderInfo['goods_price'] : $orderInfo['order_amount'];
|
|
|
|
+ // list($new_money, $coupon_money) = $coupon->doBuy($amount);
|
|
|
|
+
|
|
|
|
+ // // 判断优惠金额是否超出总价,超出则直接设定优惠金额为总价
|
|
|
|
+ // $orderInfo['coupon_discount_fee'] = $coupon_money > $amount ? $amount : $coupon_money;
|
|
|
|
+ // $orderInfo['discount_fee'] = $orderInfo['coupon_discount_fee'];
|
|
|
|
+ // }
|
|
|
|
|
|
// 计算最终应付金额【订单金额减去折扣】
|
|
// 计算最终应付金额【订单金额减去折扣】
|
|
$orderInfo['amount'] = max(0, bcsub($orderInfo['order_amount'], $orderInfo['discount_fee'], 2));
|
|
$orderInfo['amount'] = max(0, bcsub($orderInfo['order_amount'], $orderInfo['discount_fee'], 2));
|