批量取消

main
yanzai 1 year ago
parent 4b72da2da6
commit 8c1d6d3864

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\API\PEISApiController;
use App\Lib\Tools;
use App\Services\ConfigService;
use App\Services\OrderService;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -600,6 +601,30 @@ class OrderController extends Controller
return ['status' => true, 'msg' => "完成"];
}
//未支付取消订单
public function Cancel()
{
}
//批量取消订单
public function BatchCancel()
{
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
$orderInfos = DB::table('orders')->where(['status' => 1])->get();
foreach ($orderInfos as $k => $orderInfo) {
$person=DB::table('web_user_person')->where(['id' => $orderInfo->person_id])->first();
$datetime = new DateTime($orderInfo->created_at);
$timestamp = $datetime->getTimestamp();
$orderInfo->end_time = $timestamp + (60 * $WaitingPaymentTime);
if (time() > $orderInfo->end_time) {
$do=new OrderService();
$do->Cancel($orderInfo);
}
}
return \Yz::Return(true, "批量处理完成", []);
}
public function create_appointment($hospital, $data)
{
$peis = new PEISApiController();

@ -144,13 +144,19 @@ class PayController extends Controller
$yyid=$orderInfo->hospital_id;
if($yyid==1) $yyid=6;
if($env=='pro') { //如果是正式环境
if($orderInfo->jifen>0) {
if($orderInfo->jifen>0 and $orderInfo->is_refund_jifen==0) {
$jifen_huifu_status=false;
$jifen_huifu_status= $AspNet::UseJiFen($person->ghzid,$orderInfo->jifen,$yyid,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime);
if( $jifen_huifu_status===true){
DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_jifen'=>1]);
}
if($orderInfo->yucunkuan>0) {
}
if($orderInfo->yucunkuan>0 and $orderInfo->is_refund_yucunkuan==0) {
$yucunkuan_huifu_status=false;
$yucunkuan_huifu_status= $AspNet::UseYuCunKuan($person->ghzid,$orderInfo->yucunkuan,$yyid,0,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime);
if($yucunkuan_huifu_status===true){
DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_yucunkuan'=>1]);
}
}
}

@ -1,6 +1,7 @@
<?php
namespace App\Services;
use App\Http\Controllers\API\AspNetZhuanController;
use Illuminate\Support\Facades\DB;
class OrderService
@ -71,4 +72,41 @@ class OrderService
return ['department_list'=>$de_list,'wait_day'=>"10"];
}
public function Cancel($orderInfo)
{
$person=DB::table('web_user_person')->where(['id' => $orderInfo->person_id])->first();
$now_datetime=date('Y-m-d H:i:s');
//调用接口恢复积分和预存款
$env=config('app.globals.Env');
$AspNet=new AspNetZhuanController();
$jifen_huifu_status=true;
$yucunkuan_huifu_status=true;
$yyid=$orderInfo->hospital_id;
if($yyid==1) $yyid=6;
if($env=='pro') { //如果是正式环境
if($orderInfo->jifen>0 and $orderInfo->is_refund_jifen==0) {
$jifen_huifu_status=false;
$jifen_huifu_status= $AspNet::UseJiFen($person->ghzid,$orderInfo->jifen,$yyid,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime);
if( $jifen_huifu_status===true){
DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_jifen'=>1]);
}
}
if($orderInfo->yucunkuan>0 and $orderInfo->is_refund_yucunkuan==0) {
$yucunkuan_huifu_status=false;
$yucunkuan_huifu_status= $AspNet::UseYuCunKuan($person->ghzid,$orderInfo->yucunkuan,$yyid,0,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime);
if($yucunkuan_huifu_status===true){
DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_yucunkuan'=>1]);
}
}
}
DB::table('orders')->where(['id' => $orderInfo->id,'status'=>1])->update([
'status' => 3
]);
//恢复号源
$up_plan = DB::table('plans')->where(['id' => $orderInfo->plan_id, 'status' => 2])->update([
'status' => 1
]);
return true;
}
}

@ -91,3 +91,5 @@ Route::group(['prefix' => 'api/Web'], function () {
//对外------
Route::any('/TJPushInfo', 'App\Http\Controllers\API\Internal\SiXinPushController@PushInfo');//接收思信推送
Route::any('/TJCheck', 'App\Http\Controllers\API\Internal\OrderController@TJCheck');//到检
Route::any('/OrderBatchCancel', 'App\Http\Controllers\API\H5\OrderController@BatchCancel');//批量取消

Loading…
Cancel
Save