diff --git a/Laravel/app/Http/Controllers/API/H5/ComboController.php b/Laravel/app/Http/Controllers/API/H5/ComboController.php index 0ebdaa2..55eecb8 100644 --- a/Laravel/app/Http/Controllers/API/H5/ComboController.php +++ b/Laravel/app/Http/Controllers/API/H5/ComboController.php @@ -458,12 +458,12 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4) ]; } - + $env=config('app.globals.Env'); //如果使用了代金券 if(isset($coupon_id) and !empty($coupon_id)){ if($true_price==0) return \Yz::echoError1("无需使用代金券"); $quanInfo=false; - $env=config('app.globals.Env'); + if($env=='pro') { //如果是正式环境 $AspNet=new AspNetZhuanController(); diff --git a/Laravel/app/Http/Controllers/API/H5/OrderController.php b/Laravel/app/Http/Controllers/API/H5/OrderController.php index 8ddbb81..140eccb 100644 --- a/Laravel/app/Http/Controllers/API/H5/OrderController.php +++ b/Laravel/app/Http/Controllers/API/H5/OrderController.php @@ -81,7 +81,7 @@ class OrderController extends Controller $plan_id = request('plan_id');//号源id $plan_nmr_id = request('plan_nmr_id');//核磁号源id $doctor = request('doctor');//预约的医生名字 - + $coupon_id=request('coupon_id');//优惠券 $jifen = request('jifen', 0); //使用的积分数量 $yucunkuan = request('yucunkuan', 0);//使用的预存款数量 @@ -333,11 +333,59 @@ class OrderController extends Controller $true_price = $true_price - ($jifen + $yucunkuan); if ($true_price < -1) return \Yz::echoError1("预抵扣金额超过订单金额,操作失败"); if ($true_price < 0) $true_price = 0; + + //如果使用了代金券 + $quanInfo=false; + if(isset($coupon_id) and !empty($coupon_id)){ + if($true_price==0) return \Yz::echoError1("无需使用代金券"); + + + if($env=='pro') { //如果是正式环境 + $AspNet=new AspNetZhuanController(); + + $data=[ + 'ghzid'=>$person->ghzid, + 'ghzid'=>"5a798c097bc64bd79c22050175e6236a", + 'action'=>1, + ]; + $YouHuiQuanList=$AspNet::YouHuiQuan($data); + foreach ($YouHuiQuanList as $key=>$quan){ + if($quan['DZJID']==$coupon_id){ + $quanInfo=$quan; + } + } + + if($quanInfo['是否在有效内']===true and $quanInfo['TimeNuZTTextm']=="有效" and $quanInfo['ZT']==1){ + + }else{ + return \Yz::echoError1("此代金券不可用"); + } + + $quanType=false; + $YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]); + foreach ($YouHuiQuanType as $key=>$qtype){ + if($quanInfo['DZJLBID']==$qtype['DZJLBID']){ + $quanType=$qtype; + } +// if($qtype['TJXCXHX']==1 and ($qtype['MKJE']===0 || $qtype['MKJE']>=$true_price)){ +// $YouHuiQuanType_ids[]=$qtype['DZJLBID']; +// } + } + if($quanType===false or $quanInfo===false) return \Yz::echoError1("此代金券不可用"); + if($quanType['TJXCXHX']!=1 ) return \Yz::echoError1("此代金券不可用"); + if($quanType['MKJE']==0 or $quanType['MKJE']>=$true_price){ + //抵扣代金券金额,折扣暂未实现 + $true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0; + } + } + + } } $now_datetime = date('Y-m-d H:i:s'); //构建订单号 $order_num = $this->generateOrderNumber(); + $data = [ 'title' => $title, 'type' => $type, @@ -365,8 +413,10 @@ class OrderController extends Controller 'birthday' => $person->birthday, 'married' => $person->married, 'wj_flag' => $wj_flag, + 'youhuiquan'=>$quanInfo===false?'':json_encode(['id'=>$quanInfo['DZJID'],'name'=>$quanInfo['DZJLBMC']],JSON_UNESCAPED_UNICODE), 'created_at' => $now_datetime, ]; + DB::beginTransaction(); $insert = DB::table('orders')->insertGetId($data); $up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([ @@ -377,11 +427,17 @@ class OrderController extends Controller 'order_id' => $insert, ]); - //调用接口扣除积分和预存款 + //调用接口扣除积分和预存款、优惠券 $jifen_dikou_status = true; $yucunkuan_dikou_status = true; - $yyid = $hospital_id; - if ($yyid == 1) $yyid = 6; + $youhuiquan_dikou_status = true; + $r_yyid = $hospital_id; + if($r_yyid==1){ + $yyid=6; + } + if($r_yyid==4){ + $yyid=2; + } if ($env == 'pro') { //如果是正式环境 if ($jifen > 0) { $jifen_dikou_status = false; @@ -391,9 +447,23 @@ class OrderController extends Controller $yucunkuan_dikou_status = false; $yucunkuan_dikou_status = $AspNet::UseYuCunKuan($person->ghzid, -$yucunkuan, $yyid, 0, $insert, 'tj_h5', '抵扣体检H5订单', $now_datetime); } + + //核销优惠券 + if(isset($coupon_id) and !empty($coupon_id)){ + $youhuiquan_dikou_status=false; + $data=[ + 'action'=>3, + 'ghzid'=>$person->ghzid, + 'dzjid'=>$coupon_id, + 'hxbz'=>"抵扣体检H5订单", + 'yyid'=>$yyid + ]; + $youhuiquan_dikou_status=$AspNet::YouHuiQuan($data); + } + } - if ($insert and $up_plan and $jifen_dikou_status and $yucunkuan_dikou_status) { + if ($insert and $up_plan and $jifen_dikou_status and $yucunkuan_dikou_status and $youhuiquan_dikou_status) { DB::commit(); $action = false; if ($true_price == 0) { diff --git a/Laravel/app/Http/Controllers/TestController.php b/Laravel/app/Http/Controllers/TestController.php index 3b5fd9c..8596a7a 100644 --- a/Laravel/app/Http/Controllers/TestController.php +++ b/Laravel/app/Http/Controllers/TestController.php @@ -16,7 +16,7 @@ class TestController extends Controller // dd($order->DepartmentItemCount(33)); -// $aspnet=new AspNetZhuanController(); + $aspnet=new AspNetZhuanController(); // $temp_list=[]; // $nmr=$aspnet::GetNmrList(['yyid'=>6,'data'=>['2024-10-25']],uniqid()); // @@ -28,8 +28,16 @@ class TestController extends Controller // ]; // } - $peis = new PEISApiController(); - dd($peis::Get($peis::Api('报告时间计算',"2403020020"),"111111","报告时间计算")); +// $peis = new PEISApiController(); +// dd($peis::Get($peis::Api('报告时间计算',"2403020020"),"111111","报告时间计算")); + $data=[ + 'action'=>4, + 'ghzid'=>'5a798c097bc64bd79c22050175e6236a', + 'dzjid'=>'994924890348203254993', + 'hxbz'=>"H5撤销核销", + 'yyid'=>6 + ]; + $aspnet::YouHuiQuan($data); } diff --git a/Laravel/app/Services/OrderService.php b/Laravel/app/Services/OrderService.php index a0800e4..b9b493b 100644 --- a/Laravel/app/Services/OrderService.php +++ b/Laravel/app/Services/OrderService.php @@ -103,6 +103,17 @@ class OrderService DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_yucunkuan'=>1]); } } + if(!empty($orderInfo->youhuiquan)){ + $youhuiquan=json_decode( $orderInfo->youhuiquan,true); + $data=[ + 'action'=>4, + 'ghzid'=>$person->ghzid, + 'dzjid'=>$youhuiquan['id'], + 'hxbz'=>"H5撤销核销", + 'yyid'=>$yyid + ]; + $AspNet::YouHuiQuan($data); + } } DB::table('orders')->where(['id' => $orderInfo->id,'status'=>1])->update([ diff --git a/h5/pages/main/tjyy/tjyy.vue b/h5/pages/main/tjyy/tjyy.vue index 10f464d..a2f4358 100755 --- a/h5/pages/main/tjyy/tjyy.vue +++ b/h5/pages/main/tjyy/tjyy.vue @@ -288,7 +288,6 @@ const comfrimyy = async () => { wj: buyInfo.value.wj, }; console.log(obj); -return false; const response = await $api("OrderCreate", obj); $response(response, () => { if (response.status) {