Commit c0def4f6 by 朱继来

添加自营预售订单改预付款

parent 01f7a739
......@@ -7,12 +7,14 @@ use App\Http\Controllers\Controller;
use App\Model\UserMainModel;
use App\Model\UserCompanyModel;
use App\Model\OrderModel;
use App\Model\OrderPriceModel;
use App\Model\OrderInvoiceModel;
use App\Model\OrderActionLogModel;
use App\Model\PayLogModel;
use DB;
use Excel;
use Log;
use Exception;
class SpecialController extends Controller
{
......@@ -255,4 +257,65 @@ class SpecialController extends Controller
dd($data);
}
// 自营预售订单改预付款
public function changeOrderPayType(Request $request)
{
$order_id = $request->input('order_id', 0);
if (!$order_id) return '订单ID不存在';
DB::connection('order')->transaction(function() use ($order_id) {
$OrderModel = new OrderModel();
$OrderPriceModel = new OrderPriceModel();
$PayLogModel = new PayLogModel();
$OrderActionLogModel = new OrderActionLogModel();
// 查询订单信息
$order_info = $OrderModel->find($order_id);
if (!$order_info) throw new Exception("修改失败,订单不存在", 1);
if ($order_info['status'] > 2) throw new Exception("修改失败,订单已支付", 1);
$advance_amount = number_format($order_info['order_amount'] * 0.3, 2);
// 订单表
$order = array();
$order['order_pay_type'] = 2;
$order['advance_amount'] = $advance_amount;
$order['status'] = 3;
$order['advance_pay_time'] = time();
$OrderModel->where('order_id', $order_id)->update($order);
// 支付记录表
$pay_log = array();
$pay_log['order_id'] = $order_id;
$pay_log['pay_id'] = 0; // 支付方式ID
$pay_log['pay_name'] = '交通银行'; // 支付方式名
$pay_log['pay_type'] = 2;
$pay_log['pay_amount'] = $advance_amount;
$pay_log['is_paid'] = 1;
$pay_log['create_time'] = time();
$pay_log['pay_time'] = time();
$PayLogModel->insert($pay_log);
// 价格表
$price = array();
$price['order_id'] = $order_id;
$price['order_sn'] = '12019101531990';
$price['price_type'] = -2;
$price['price'] = '-'.$advance_amount;
$price['currency'] = $order_info['currency'];
$price['create_time'] = time();
$OrderPriceModel->insert($price);
// 操作日志
$OrderActionLogModel->addLog($order_id, 1000, 2, '手动调整订单支付类型');
});
return '调整成功';
}
}
\ No newline at end of file
......@@ -151,5 +151,6 @@ Route::group(['middleware' => 'api'], function () {
Route::get('/act/clear', 'CronController@clearData'); // 清除活动统计用户表和缓存
Route::get ('/handle/paylog', 'SpecialController@handlePayLog'); // 处理支付记录
Route::get('/act/sendactmsg', 'CronController@sendActMsg'); // 推送活动短信
Route::get ('/handle/paytype', 'SpecialController@changeOrderPayType'); // 自营更改预付款支付方式
});
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderPriceModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_price';
protected $primaryKey = 'price_id';
public $timestamps = false;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment