Browse Source

Merge branch 'develop' of ssh://8.134.10.79:222/Leadfyy.co/hainan into develop

develop
lemon 4 years ago
parent
commit
ddee0666c3
  1. 17
      app/Http/Controllers/Api/OrderController.php
  2. 34
      app/Http/Controllers/Api/WxpayController.php
  3. 2
      config/admin.php

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

@ -80,8 +80,10 @@ class OrderController extends Controller
if ($v['timeout'] !== null) {
$second = strtotime($v['timeout']) - $time;
if ($second > 0) {
$v['status_text'] = '请在' . ceil($second / 60) . '分钟内付款';
if ($second > 0 && $v['status'] == Status::UNPAID) {
$v['status_text'] = '请在' . ceil($second / 60) . "分钟内付款";
} else if ($second > 0 && $v['status'] == Status::OFFLINE_UNPAID) {
$v['status_text'] = '请在' . ceil($second / 60) . "分钟内线下付款";
} else if ($second < 0 && $v['status'] == Status::PAY_EARNEST) {
$v['status_text'] = '尾款支付已超时';
} /*else { //此部分由定时处理
@ -169,14 +171,9 @@ class OrderController extends Controller
throw new \Exception('商户产品库存不足');
}
if ($formData['pay_type'] == PayType::DEPOSIT_PAY && $ap->deposit_timeout > 0) {
$timeout = date('Y-m-d H:i:s', time() + $ap->deposit_timeout * 60);
} else if ($formData['pay_type'] == PayType::EARNEST_PAY && $ap->earnest_timeout > 0) {
$timeout = date('Y-m-d H:i:s', time() + $ap->earnest_timeout * 60);
} else {
$order_timeout = AgentSetting::val($this->agent_id, 'order_timeout') ?? 60; //默认60分钟
$timeout = date('Y-m-d H:i:s', time() + 60 * $order_timeout); //60 * 分钟转为秒
}
//未付款时定金/订金的超时时间依然使用默认的订单超时时间,付定金/订金之后才使用定金超时时间
$order_timeout = AgentSetting::val($this->agent_id, 'order_timeout') ?? 60; //默认60分钟
$timeout = date('Y-m-d H:i:s', time() + $order_timeout * 60); //60 * 分钟转为秒
// 存入订单表
$order = Order::query()->create([

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

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Common\PayType;
use App\Models\Agent;
use App\Models\AgentProduct;
use App\Models\AgentSetting;
use App\Models\Order;
use App\Models\Product;
use App\Models\UserMoneyLog;
@ -62,6 +63,14 @@ class WxpayController
if ($message['result_code'] === 'SUCCESS') {
DB::beginTransaction();
try {
//增加销量,库存在拍下时已经减了
$agent_product = AgentProduct::find($order->agent_product_id);
$agent_product->increment('sale', $order->num);
Product::query()
->where('id', $order->product_id)
->increment('sale', $order->num);
$status = $order->status;
$pay_type = $order->pay_type;
$money = $message['total_fee'] / 100;
@ -73,24 +82,29 @@ class WxpayController
$order->status = OrderStatus::PAID_RETAINAGE;
$order->verify_code = uniqid(); //生成核销码
}
} else if ($pay_type == 0) {
} else if ($pay_type == PayType::ONLINE) {
$order->status = OrderStatus::PAID;
$order->verify_code = uniqid(); //生成核销码
}
$order->paid_at = now();
$order->paid_money = DB::raw('`paid_money` + ' . $money);
$order->timeout = null; //清除超时时间
//如果是已付定金,重新设置超时时间,否则清除超时时间
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 (empty($time)) { //默认订单超时
$time = (AgentSetting::val($agent_id, 'order_timeout') ?? 60) * 60;
}
$order->timeout = date('Y-m-d H:i:s', time() + $time);
} else {
$order->timeout = null;
}
$order->save();
//增加销量,库存在拍下时已经减了
AgentProduct::query()
->where('id', $order->agent_product_id)
->increment('sale', $order->num);
Product::query()
->where('id', $order->product_id)
->increment('sale', $order->num);
//资金流水
UserMoneyLog::query()->create([
'user_id' => $order->user_id,

2
config/admin.php

@ -29,7 +29,7 @@ return [
| `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo' => '<img src="/vendor/dcat-admin/images/logo.png" width="35"> &nbsp;Dcat Admin',
'logo' => '<img src="/vendor/dcat-admin/images/logo.png" width="35"> &nbsp;旅游SAAS系统',
/*
|--------------------------------------------------------------------------

Loading…
Cancel
Save