|
|
@ -52,7 +52,7 @@ class OrderController extends Controller |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$order_list = $order_list->select('id', 'agent_product_id', 'product_id', 'title', 'picture', 'price', 'num', 'status', 'created_at') |
|
|
|
|
|
|
|
|
$order_list = $order_list->select('id', 'agent_product_id', 'product_id', 'title', 'picture', 'price', 'num', 'status', 'timeout', 'created_at') |
|
|
->orderBy('id', 'DESC') |
|
|
->orderBy('id', 'DESC') |
|
|
->simplePaginate(15) |
|
|
->simplePaginate(15) |
|
|
->toArray(); |
|
|
->toArray(); |
|
|
@ -154,10 +154,23 @@ class OrderController extends Controller |
|
|
$title = $ap->title; //产品标题
|
|
|
$title = $ap->title; //产品标题
|
|
|
|
|
|
|
|
|
//供应商产品表减库存
|
|
|
//供应商产品表减库存
|
|
|
$ap->product->decrement('stock', $formData['num']); |
|
|
|
|
|
|
|
|
$product_ids = explode(',', $ap->product_ids); |
|
|
|
|
|
$affect_row = Product::query() |
|
|
|
|
|
->where('stock', '>=', $formData['num']) //乐观锁
|
|
|
|
|
|
->whereIn('id', $product_ids) |
|
|
|
|
|
->decrement('stock', $formData['num']); |
|
|
|
|
|
if ($affect_row != count($product_ids)) { |
|
|
|
|
|
throw new \Exception('供应产品库存不足'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//代理商产品表减库存
|
|
|
//代理商产品表减库存
|
|
|
$ap->decrement('stock', $formData['num']); |
|
|
|
|
|
|
|
|
$affect_row = AgentProduct::query() |
|
|
|
|
|
->where('stock', '>=', $formData['num']) //乐观锁
|
|
|
|
|
|
->where('id', $ap->id) |
|
|
|
|
|
->decrement('stock', $formData['num']); |
|
|
|
|
|
if (!$affect_row) { |
|
|
|
|
|
throw new \Exception('商户产品库存不足'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ($formData['pay_type'] == PayType::DEPOSIT_PAY && $ap->deposit_timeout > 0) { |
|
|
if ($formData['pay_type'] == PayType::DEPOSIT_PAY && $ap->deposit_timeout > 0) { |
|
|
$timeout = date('Y-m-d H:i:s', time() + $ap->deposit_timeout * 60); |
|
|
$timeout = date('Y-m-d H:i:s', time() + $ap->deposit_timeout * 60); |
|
|
@ -190,7 +203,6 @@ class OrderController extends Controller |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
//存入订单产品表
|
|
|
//存入订单产品表
|
|
|
$product_ids = explode(',', $ap->product_ids); |
|
|
|
|
|
$supplier_product_info = Product::whereIn('id', $product_ids) |
|
|
$supplier_product_info = Product::whereIn('id', $product_ids) |
|
|
->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray(); |
|
|
->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray(); |
|
|
|
|
|
|
|
|
|