|
|
|
@ -52,11 +52,11 @@ class SharePayController extends Controller |
|
|
|
|
|
|
|
//如果已经付定金或首付款,则仅支付尾款
|
|
|
|
if ($order->status == Status::PAY_EARNEST) { |
|
|
|
$price = bcsub($order->price,$order->paid_money,2); |
|
|
|
$price = bcsub($order->price, $order->paid_money, 2); |
|
|
|
} elseif (in_array($order->pay_type, [PayType::DEPOSIT_PAY, PayType::EARNEST_PAY])) { |
|
|
|
$price = $order->prepay_price; |
|
|
|
} else { |
|
|
|
$price = bcmul($order->price,$order->num,2); |
|
|
|
$price = $order->price; |
|
|
|
} |
|
|
|
|
|
|
|
$setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']); |
|
|
|
@ -98,29 +98,4 @@ class SharePayController extends Controller |
|
|
|
['id' => $order->id, 'order_no' => $order->order_no, 'jump_appid' => $jump_appid]; // 返回数组
|
|
|
|
return $this->success($payConfig); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算最终价格 |
|
|
|
* @param float $price 订单价格 |
|
|
|
* @param float $num 购买数量 |
|
|
|
* @param int $pay_type 支付方式 |
|
|
|
* @param AgentProduct $agent_product 代理商产品 |
|
|
|
* @return float |
|
|
|
*/ |
|
|
|
private function calc(float $price, float $num, int $pay_type, AgentProduct $agent_product): float |
|
|
|
{ |
|
|
|
/** 修改需要同步修改Order里面的 */ |
|
|
|
//根据支付方式计算价格
|
|
|
|
if (in_array($pay_type, [PayType::DEPOSIT_PAY, PayType::EARNEST_PAY, PayType::DOWN_PAYMENT])) { |
|
|
|
if ($pay_type == PayType::DEPOSIT_PAY && $agent_product->deposit && $agent_product->deposit_timeout) { |
|
|
|
return $agent_product->deposit; |
|
|
|
} else if ($pay_type == PayType::EARNEST_PAY && $agent_product->earnest && $agent_product->earnest_timeout) { |
|
|
|
return $agent_product->earnest; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$total_price = $price * $num; |
|
|
|
|
|
|
|
return round($total_price, 2); |
|
|
|
} |
|
|
|
} |