Commit 6c55f147 by 朱继来

设置运费为0(供测试使用)

parent 6042972e
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\OrderModel;
use App\Model\OrderActionLogModel;
use DB;
class SpecialController extends Controller
{
// 订单特殊处理,用于测试调整运费
public function changeOrderPrice(Request $request)
{
$mobile = $request->input('mobile', '');
$order_id = $request->input('order_id', '');
if (!$mobile || !$order_id) {
echo '参数缺失';die;
}
// 检查是否为测试账号
$test_mobile = Config('params.test_mobile');
if (!in_array($mobile, $test_mobile)) {
echo '非测试账号';die;
}
DB::connection('order')->beginTransaction();
$order = DB::connection('order')->table('lie_order_price')->where('order_id', $order_id)->where('price_type', 3)->first();
if (!$order) {
echo '运费不存在';die;
}
$data['price'] = 0;
$update = DB::connection('order')->table('lie_order_price')->where('order_id', $order_id)->where('price_type', 3)->update($data);
if (!$update) {
DB::connection('order')->rollback();
echo '运费更新失败';die;
}
$OrderModel = new OrderModel();
$order_info = $OrderModel->find($order_id);
$intracode = DB::table('lie_intracode')->where('user_id', $order_info['user_id'])->select('admin_id')->first();
$sale_id = $intracode ? $intracode->admin_id : 0;
// 操作记录
$OrderActionLogModel = new OrderActionLogModel();
$actionLog = $OrderActionLogModel->addLog($order_id, $sale_id, 2, '调整运费为0');
if (!$actionLog) {
DB::connection('order')->rollback();
echo '添加运费更新日志失败';die;
}
DB::connection('order')->commit();
echo '运费更新成功';
}
}
\ No newline at end of file
......@@ -126,5 +126,6 @@ Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms');
Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel');
Route::get ('/api/check/histroyorder', 'OrderController@checkHistroyOrder');
Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice');
});
......@@ -65,4 +65,9 @@
1 => '样品销售',
2 => '仓库损耗',
],
// 测试账号
'test_mobile' => [
'15989573440',
],
];
\ 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