|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API\H5;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\API\AspNetZhuanController;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Controllers\API\PEISApiController;
|
|
|
|
|
use App\Lib\Tools;
|
|
|
|
|
@ -75,6 +76,9 @@ class OrderController extends Controller
|
|
|
|
|
$plan_nmr_id = request('plan_nmr_id');//核磁号源id
|
|
|
|
|
$doctor = request('doctor');//预约的医生名字
|
|
|
|
|
|
|
|
|
|
$jifen = request('jifen',0); //使用的积分数量
|
|
|
|
|
$yucunkuan = request('yucunkuan',0);//使用的预存款数量
|
|
|
|
|
|
|
|
|
|
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
|
|
|
|
|
if (!isset($openid)) return \Yz::echoError1('openid不能为空');
|
|
|
|
|
if (!isset($person_id)) return \Yz::echoError1('person_id不能为空');
|
|
|
|
|
@ -296,7 +300,25 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验积分和预存款
|
|
|
|
|
$env=config('app.globals.Env');
|
|
|
|
|
$AspNet=new AspNetZhuanController();
|
|
|
|
|
if($env=='pro') { //如果是正式环境, 测试环境不抵扣
|
|
|
|
|
if($jifen>0) {
|
|
|
|
|
$all_jifen= $AspNet::GetJiFen_YuCunKuan(1,$person->ghzid);
|
|
|
|
|
if($jifen>$all_jifen) return \Yz::echoError1("用户剩余积分不足");
|
|
|
|
|
}
|
|
|
|
|
if($yucunkuan>0) {
|
|
|
|
|
return \Yz::echoError1("暂不支持预存款");
|
|
|
|
|
$all_yucunkuan= $AspNet::GetJiFen_YuCunKuan(2,$person->ghzid);
|
|
|
|
|
if($yucunkuan>$all_yucunkuan) return \Yz::echoError1("用户剩余预存款不足");
|
|
|
|
|
}
|
|
|
|
|
$true_price=$true_price-($jifen+$yucunkuan);
|
|
|
|
|
if($true_price<-1) return \Yz::echoError1("预抵扣金额超过订单金额,操作失败");
|
|
|
|
|
if($true_price<0) $true_price=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$now_datetime=date('Y-m-d H:i:s');
|
|
|
|
|
//构建订单号
|
|
|
|
|
$order_num = $this->generateOrderNumber();
|
|
|
|
|
$data = [
|
|
|
|
|
@ -309,7 +331,9 @@ class OrderController extends Controller
|
|
|
|
|
'id_number' => $person->id_number,
|
|
|
|
|
'buy_info' => json_encode($buy_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
'price' => $price,
|
|
|
|
|
'true_price' => $true_price,
|
|
|
|
|
'true_price' =>number_format($true_price, 2, '.', ''),
|
|
|
|
|
'jifen'=>$jifen,
|
|
|
|
|
'yucunkuan'=>$yucunkuan,
|
|
|
|
|
'order_number' => $order_num,
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'appointment_date' => $plan->date,
|
|
|
|
|
@ -323,13 +347,35 @@ class OrderController extends Controller
|
|
|
|
|
'sex' => $person->sex,
|
|
|
|
|
'birthday' => $person->birthday,
|
|
|
|
|
'married' => $person->married,
|
|
|
|
|
'created_at' =>$now_datetime,
|
|
|
|
|
];
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
$insert = DB::table('orders')->insertGetId($data);
|
|
|
|
|
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
|
|
|
|
|
'status' => 2
|
|
|
|
|
]);
|
|
|
|
|
if ($insert and $up_plan) {
|
|
|
|
|
//更新问卷log表
|
|
|
|
|
DB::table('questionnaires_logs')->where(['person_id'=>$person->id,'order_id'=>0])->update([
|
|
|
|
|
'order_id' => $insert,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//调用接口扣除积分和预存款
|
|
|
|
|
$jifen_dikou_status=true;
|
|
|
|
|
$yucunkuan_dikou_status=true;
|
|
|
|
|
$yyid=$hospital_id;
|
|
|
|
|
if($yyid==1) $yyid=6;
|
|
|
|
|
if($env=='pro') { //如果是正式环境
|
|
|
|
|
if($jifen>0) {
|
|
|
|
|
$jifen_dikou_status=false;
|
|
|
|
|
$jifen_dikou_status= $AspNet::UseJiFen($person->ghzid,-$jifen,$yyid,$insert,'tj_h5','抵扣体检H5订单',$now_datetime);
|
|
|
|
|
}
|
|
|
|
|
if($yucunkuan>0) {
|
|
|
|
|
$yucunkuan_dikou_status=false;
|
|
|
|
|
// $yucunkuan_dikou_status= $AspNet::UseYuCunKuan();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($insert and $up_plan and $jifen_dikou_status and $yucunkuan_dikou_status) {
|
|
|
|
|
DB::commit();
|
|
|
|
|
$action = false;
|
|
|
|
|
if ($true_price === 0) {
|
|
|
|
|
|