|
|
@ -3,6 +3,7 @@ |
|
|
namespace App\Http\Controllers\Api; |
|
|
namespace App\Http\Controllers\Api; |
|
|
|
|
|
|
|
|
use App\Common\PayType; |
|
|
use App\Common\PayType; |
|
|
|
|
|
use App\Common\ProductStatus; |
|
|
use App\Http\Controllers\Controller; |
|
|
use App\Http\Controllers\Controller; |
|
|
use App\Models\Agent; |
|
|
use App\Models\Agent; |
|
|
use App\Models\AgentProduct; |
|
|
use App\Models\AgentProduct; |
|
|
@ -127,12 +128,13 @@ class OrderController extends Controller |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
$ap = AgentProduct::query() |
|
|
$ap = AgentProduct::query() |
|
|
->where('id', $formData['id']) |
|
|
|
|
|
|
|
|
->where(['id' => $formData['id'], 'status' => ProductStatus::ON_SALE]) |
|
|
|
|
|
->where('stock', '>=', $formData['num']) |
|
|
->with(['coupon', 'product', 'agentCloudProduct:id,price']) |
|
|
->with(['coupon', 'product', 'agentCloudProduct:id,price']) |
|
|
->has('product') |
|
|
->has('product') |
|
|
->first(); |
|
|
->first(); |
|
|
if (!$ap || !$ap->product) { |
|
|
if (!$ap || !$ap->product) { |
|
|
$this->error('产品不存在或已下架'); |
|
|
|
|
|
|
|
|
return $this->error('产品已下架或库存不足'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$coupon_ids = []; |
|
|
$coupon_ids = []; |
|
|
@ -189,7 +191,7 @@ class OrderController extends Controller |
|
|
'guide_id' => $ap->guide_id, |
|
|
'guide_id' => $ap->guide_id, |
|
|
'timeout' => $timeout, |
|
|
'timeout' => $timeout, |
|
|
'agent_cloud_pid' => $ap->agent_cloud_pid, |
|
|
'agent_cloud_pid' => $ap->agent_cloud_pid, |
|
|
'agent_cloud_price' => $ap->agentCloudProduct->price, |
|
|
|
|
|
|
|
|
'agent_cloud_price' => $ap->agentCloudProduct->price ?? 0, |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
//存入订单产品表
|
|
|
//存入订单产品表
|
|
|
|