|
|
@ -402,10 +402,11 @@ class OrderController extends Controller |
|
|
'id' => 'required|integer', |
|
|
'id' => 'required|integer', |
|
|
'num' => 'required|integer', |
|
|
'num' => 'required|integer', |
|
|
'pay_type' => 'required|integer', |
|
|
'pay_type' => 'required|integer', |
|
|
'spec_id' => 'required|integer', |
|
|
|
|
|
|
|
|
'spec_id' => 'required|array', |
|
|
], [ |
|
|
], [ |
|
|
'*.required' => '参数缺失', |
|
|
'*.required' => '参数缺失', |
|
|
'*.integer' => '参数类型错误', |
|
|
'*.integer' => '参数类型错误', |
|
|
|
|
|
'spec_id.array' => '产品规格必须是数组', |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
if (!$formData['num'] || $formData['num'] < 1) { |
|
|
if (!$formData['num'] || $formData['num'] < 1) { |
|
|
@ -425,19 +426,26 @@ class OrderController extends Controller |
|
|
|
|
|
|
|
|
//如果是线下支付,显示的价格跟在线全款支付价格一样
|
|
|
//如果是线下支付,显示的价格跟在线全款支付价格一样
|
|
|
|
|
|
|
|
|
//订金支付
|
|
|
|
|
|
if ($formData['pay_type'] == PayType::DEPOSIT_PAY) { |
|
|
|
|
|
$ap->final_price = $ap->deposit * $formData['num']; |
|
|
|
|
|
|
|
|
$spec = AgentProductSpec::where('agent_product_id', $formData['id']) |
|
|
|
|
|
->whereIn('id', $formData['spec_id']) |
|
|
|
|
|
->get(); |
|
|
|
|
|
if ($spec->isEmpty()) { |
|
|
|
|
|
return $this->error('你选择的产品规格不存在'); |
|
|
|
|
|
} |
|
|
|
|
|
$spec = $spec->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
if ($formData['pay_type'] == PayType::DEPOSIT_PAY) { //订金支付
|
|
|
|
|
|
$single_price = $ap->deposit; |
|
|
} |
|
|
} |
|
|
//定金支付
|
|
|
|
|
|
else if($formData['pay_type'] == PayType::EARNEST_PAY) { |
|
|
|
|
|
$ap->final_price = $ap->earnest * $formData['num']; |
|
|
|
|
|
|
|
|
else if($formData['pay_type'] == PayType::EARNEST_PAY) { //定金支付
|
|
|
|
|
|
$single_price = $ap->earnes; |
|
|
} else { |
|
|
} else { |
|
|
$spec = AgentProductSpec::where('agent_product_id', $formData['id'])->find($formData['spec_id']); |
|
|
|
|
|
if (!$spec) { |
|
|
|
|
|
return $this->error('你选择的产品规格不存在'); |
|
|
|
|
|
} |
|
|
|
|
|
$ap->final_price = $spec->price * $formData['num']; |
|
|
|
|
|
|
|
|
$single_price = $ap->price; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$ap->final_price = 0; |
|
|
|
|
|
foreach ($spec as $v) { |
|
|
|
|
|
$ap->final_price += $single_price * $formData['num']; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$ap->num = $formData['num']; |
|
|
$ap->num = $formData['num']; |
|
|
|