6
0
Fork 0

调整砍价bug

release
vine_liutk 2022-04-11 09:51:19 +08:00
parent 0d3e62305d
commit d77c7394bc
7 changed files with 11 additions and 5 deletions

View File

@ -130,7 +130,7 @@ class BargainActivityController extends AdminController
$form->block(6, function (Form\BlockForm $form) { $form->block(6, function (Form\BlockForm $form) {
$form->text('name')->required(); $form->text('name')->required();
$form->switch('is_enable'); $form->switch('is_enable');
$form->dateRange('start_at', 'end_at', '活动时间')->required(); $form->datetimeRange('start_at', 'end_at', '活动时间')->required();
$form->multipleSelectTable('skus') $form->multipleSelectTable('skus')
->from(ProductSkuSimpleTable::make()) ->from(ProductSkuSimpleTable::make())
->model(ProductSku::class, 'id', 'name') ->model(ProductSku::class, 'id', 'name')

View File

@ -281,6 +281,9 @@ class OrderController extends AdminController
$show->field('reduced_amount')->as(function ($v) { $show->field('reduced_amount')->as(function ($v) {
return bcdiv($v, 100, 2); return bcdiv($v, 100, 2);
})->prepend('- ¥'); })->prepend('- ¥');
$show->field('bargain_amount')->as(function ($v) {
return bcdiv($v, 100, 2);
})->prepend('- ¥');
$show->field('total_amount')->as(function ($v) { $show->field('total_amount')->as(function ($v) {
return bcdiv($v, 100, 2); return bcdiv($v, 100, 2);
})->prepend('¥'); })->prepend('¥');

View File

@ -130,6 +130,7 @@ class BargainController extends Controller
'user_id'=> $request->user()->id, 'user_id'=> $request->user()->id,
])->where('status', '>', 0) ])->where('status', '>', 0)
->where('expire_at', '>', now()) ->where('expire_at', '>', now())
->whereNull('order_id')
->orderBy('created_at', 'desc')->first(); ->orderBy('created_at', 'desc')->first();
if (!$order) { if (!$order) {
@ -207,7 +208,7 @@ class BargainController extends Controller
} }
//砍价超时 //砍价超时
if ($bargainOrder->expire_at > now()) { if ($bargainOrder->expire_at < now()) {
throw new BizException('当前砍价已结束,无法下单'); throw new BizException('当前砍价已结束,无法下单');
} }

View File

@ -27,6 +27,7 @@ class OrderResource extends JsonResource
'coupon_discount_amount' => $this->coupon_discount_amount_format, 'coupon_discount_amount' => $this->coupon_discount_amount_format,
'vip_discount_amount' => $this->vip_discount_amount_format, 'vip_discount_amount' => $this->vip_discount_amount_format,
'reduced_amount' => $this->reduced_amount_format, 'reduced_amount' => $this->reduced_amount_format,
'bargain_amount' => $this->bargain_amount_format,
'shipping_fee' => $this->shipping_fee_format, 'shipping_fee' => $this->shipping_fee_format,
'products_total_amount' => $this->products_total_amount_format, 'products_total_amount' => $this->products_total_amount_format,
'total_amount' => $this->total_amount_format, 'total_amount' => $this->total_amount_format,

View File

@ -13,7 +13,7 @@ use Illuminate\Support\Arr;
class BargainService class BargainService
{ {
/** /**
* 创建砍价单-todo * 创建砍价单
* *
* @param User $user * @param User $user
* @param ProductSku $productSku * @param ProductSku $productSku
@ -68,7 +68,7 @@ class BargainService
} }
//砍价超时 //砍价超时
if ($order->expire_at > now()) { if ($order->expire_at < now()) {
throw new BizException('当前砍价已结束,无法再砍'); throw new BizException('当前砍价已结束,无法再砍');
} }

View File

@ -193,7 +193,7 @@ class OrderService
?UserCoupon $coupon = null, ?UserCoupon $coupon = null,
?BargainOrder $bargainOrder = null, ?BargainOrder $bargainOrder = null,
): Order { ): Order {
// 订单支付金额=商品总额-券折扣金额-会员折扣金额+邮费 // 订单支付金额=商品总额-券折扣金额-会员折扣金额+邮费-砍价金额
$totalAmount = $productsTotalAmount - $couponDiscountAmount - $vipDiscountAmount; $totalAmount = $productsTotalAmount - $couponDiscountAmount - $vipDiscountAmount;
//如果有砍价优惠 //如果有砍价优惠

View File

@ -20,6 +20,7 @@ return [
'coupon_discount_amount' => '优惠券金额', 'coupon_discount_amount' => '优惠券金额',
'vip_discount_amount' => '会员优惠', 'vip_discount_amount' => '会员优惠',
'reduced_amount' => '减免金额', 'reduced_amount' => '减免金额',
'bargain_amount' => '砍价金额',
'shipping_fee' => '运费', 'shipping_fee' => '运费',
'products_total_amount' => '商品总额', 'products_total_amount' => '商品总额',
'total_amount' => '订单总额', 'total_amount' => '订单总额',