Browse Source

订单超时时间

master
lemon 4 years ago
parent
commit
3991591679
  1. 12
      app/Http/Controllers/Api/OrderController.php
  2. 6
      app/Http/Controllers/Api/SharePayController.php
  3. 6
      app/Http/Controllers/Api/WxpayController.php
  4. 35
      database/migrations/2021_09_15_154853_update_order_table.php

12
app/Http/Controllers/Api/OrderController.php

@ -175,6 +175,16 @@ class OrderController extends Controller
$order_timeout = AgentSetting::val($this->agent_id, 'order_timeout') ?? 60; //默认60分钟
$timeout = date('Y-m-d H:i:s', time() + $order_timeout * 60); //60 * 分钟转为秒
//处理预付金额
if ($formData['pay_type'] == PayType::DEPOSIT_PAY) {
//订金支付
$prepayPrice = $ap->deposit;
$prepayTimeout = $ap->deposit_timeout;
} else if($formData['pay_type'] == PayType::EARNEST_PAY) {
//定金支付
$prepayPrice = $ap->earnest;
$prepayTimeout = $ap->earnest_timeout;
}
// 存入订单表
$order = Order::query()->create([
'user_id' => $this->user_id,
@ -197,6 +207,8 @@ class OrderController extends Controller
'timeout' => $timeout,
'agent_cloud_pid' => $ap->agent_cloud_pid,
'agent_cloud_price' => $ap->agentCloudProduct->price ?? 0,
'prepay_price ' => $prepayPrice ?? 0,
'prepay_timeout' => $prepayTimeout ?? 0,
]);
//存入订单产品表

6
app/Http/Controllers/Api/SharePayController.php

@ -52,9 +52,11 @@ class SharePayController extends Controller
//如果已经付定金或首付款,则仅支付尾款
if ($order->status == Status::PAY_EARNEST) {
$price = $order->price - $order->paid_money;
$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 = $this->calc($order->price, $order->num, $order->pay_type, $order->agentProduct);
$price = bcmul($order->price,$order->num,2);
}
$setting = AdminSetting::val(['payee_appid', 'payee_mchid', 'payee_mchkey']);

6
app/Http/Controllers/Api/WxpayController.php

@ -97,10 +97,8 @@ class WxpayController
$order->paid_money = DB::raw('`paid_money` + ' . $money);
//如果是已付定金,重新设置超时时间,否则清除超时时间
if ($order->status == OrderStatus::PAY_EARNEST) {
if ($pay_type == PayType::DEPOSIT_PAY) { //订金超时
$time = $agent_product->deposit_timeout * 60;
} else if ($pay_type == PayType::EARNEST_PAY) { //定金超时
$time = $agent_product->earnest_timeout * 60;
if ($pay_type == PayType::DEPOSIT_PAY || $pay_type == PayType::EARNEST_PAY) { //订金超时
$time = $order->prepay_timeout * 60;
}
if (empty($time)) { //默认订单超时
$time = (AgentSetting::val($agent_id, 'order_timeout') ?? 60) * 60;

35
database/migrations/2021_09_15_154853_update_order_table.php

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateOrderTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('orders', function (Blueprint $table) {
$table->decimal('prepay_price')
->default(0)
->comment('下单时产品的订金/定金');
$table->integer('prepay_timeout')
->default(0)
->comment('订金/定金支付超时时间,单位:分钟');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Loading…
Cancel
Save