diff --git a/app/Admin/Controllers/BargainActivityController.php b/app/Admin/Controllers/BargainActivityController.php index f59eddd1..a11f2bd8 100644 --- a/app/Admin/Controllers/BargainActivityController.php +++ b/app/Admin/Controllers/BargainActivityController.php @@ -130,7 +130,7 @@ class BargainActivityController extends AdminController $form->block(6, function (Form\BlockForm $form) { $form->text('name')->required(); $form->switch('is_enable'); - $form->dateRange('start_at', 'end_at', '活动时间')->required(); + $form->datetimeRange('start_at', 'end_at', '活动时间')->required(); $form->multipleSelectTable('skus') ->from(ProductSkuSimpleTable::make()) ->model(ProductSku::class, 'id', 'name') diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 477bbcd9..118ffd03 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -281,6 +281,9 @@ class OrderController extends AdminController $show->field('reduced_amount')->as(function ($v) { return bcdiv($v, 100, 2); })->prepend('- ¥'); + $show->field('bargain_amount')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('- ¥'); $show->field('total_amount')->as(function ($v) { return bcdiv($v, 100, 2); })->prepend('¥'); diff --git a/app/Endpoint/Api/Http/Controllers/BargainController.php b/app/Endpoint/Api/Http/Controllers/BargainController.php index bb84b9cb..19e5e74d 100644 --- a/app/Endpoint/Api/Http/Controllers/BargainController.php +++ b/app/Endpoint/Api/Http/Controllers/BargainController.php @@ -130,6 +130,7 @@ class BargainController extends Controller 'user_id'=> $request->user()->id, ])->where('status', '>', 0) ->where('expire_at', '>', now()) + ->whereNull('order_id') ->orderBy('created_at', 'desc')->first(); if (!$order) { @@ -207,7 +208,7 @@ class BargainController extends Controller } //砍价超时 - if ($bargainOrder->expire_at > now()) { + if ($bargainOrder->expire_at < now()) { throw new BizException('当前砍价已结束,无法下单'); } diff --git a/app/Endpoint/Api/Http/Resources/OrderResource.php b/app/Endpoint/Api/Http/Resources/OrderResource.php index 8f18d737..42da778e 100644 --- a/app/Endpoint/Api/Http/Resources/OrderResource.php +++ b/app/Endpoint/Api/Http/Resources/OrderResource.php @@ -27,6 +27,7 @@ class OrderResource extends JsonResource 'coupon_discount_amount' => $this->coupon_discount_amount_format, 'vip_discount_amount' => $this->vip_discount_amount_format, 'reduced_amount' => $this->reduced_amount_format, + 'bargain_amount' => $this->bargain_amount_format, 'shipping_fee' => $this->shipping_fee_format, 'products_total_amount' => $this->products_total_amount_format, 'total_amount' => $this->total_amount_format, diff --git a/app/Services/BargainService.php b/app/Services/BargainService.php index 19ba02fe..4dbcc562 100644 --- a/app/Services/BargainService.php +++ b/app/Services/BargainService.php @@ -13,7 +13,7 @@ use Illuminate\Support\Arr; class BargainService { /** - * 创建砍价单-todo + * 创建砍价单 * * @param User $user * @param ProductSku $productSku @@ -68,7 +68,7 @@ class BargainService } //砍价超时 - if ($order->expire_at > now()) { + if ($order->expire_at < now()) { throw new BizException('当前砍价已结束,无法再砍'); } diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 7edea3a3..1ea130cb 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -193,7 +193,7 @@ class OrderService ?UserCoupon $coupon = null, ?BargainOrder $bargainOrder = null, ): Order { - // 订单支付金额=商品总额-券折扣金额-会员折扣金额+邮费 + // 订单支付金额=商品总额-券折扣金额-会员折扣金额+邮费-砍价金额 $totalAmount = $productsTotalAmount - $couponDiscountAmount - $vipDiscountAmount; //如果有砍价优惠 diff --git a/resources/lang/zh_CN/order.php b/resources/lang/zh_CN/order.php index ed1374ac..d1da761c 100644 --- a/resources/lang/zh_CN/order.php +++ b/resources/lang/zh_CN/order.php @@ -20,6 +20,7 @@ return [ 'coupon_discount_amount' => '优惠券金额', 'vip_discount_amount' => '会员优惠', 'reduced_amount' => '减免金额', + 'bargain_amount' => '砍价金额', 'shipping_fee' => '运费', 'products_total_amount' => '商品总额', 'total_amount' => '订单总额',