|
|
|
@ -81,7 +81,7 @@ class OrderController extends Controller
|
|
|
|
$plan_id = request('plan_id');//号源id
|
|
|
|
$plan_id = request('plan_id');//号源id
|
|
|
|
$plan_nmr_id = request('plan_nmr_id');//核磁号源id
|
|
|
|
$plan_nmr_id = request('plan_nmr_id');//核磁号源id
|
|
|
|
$doctor = request('doctor');//预约的医生名字
|
|
|
|
$doctor = request('doctor');//预约的医生名字
|
|
|
|
|
|
|
|
$coupon_id=request('coupon_id');//优惠券
|
|
|
|
$jifen = request('jifen', 0); //使用的积分数量
|
|
|
|
$jifen = request('jifen', 0); //使用的积分数量
|
|
|
|
$yucunkuan = request('yucunkuan', 0);//使用的预存款数量
|
|
|
|
$yucunkuan = request('yucunkuan', 0);//使用的预存款数量
|
|
|
|
|
|
|
|
|
|
|
|
@ -333,11 +333,59 @@ class OrderController extends Controller
|
|
|
|
$true_price = $true_price - ($jifen + $yucunkuan);
|
|
|
|
$true_price = $true_price - ($jifen + $yucunkuan);
|
|
|
|
if ($true_price < -1) return \Yz::echoError1("预抵扣金额超过订单金额,操作失败");
|
|
|
|
if ($true_price < -1) return \Yz::echoError1("预抵扣金额超过订单金额,操作失败");
|
|
|
|
if ($true_price < 0) $true_price = 0;
|
|
|
|
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');
|
|
|
|
$now_datetime = date('Y-m-d H:i:s');
|
|
|
|
//构建订单号
|
|
|
|
//构建订单号
|
|
|
|
$order_num = $this->generateOrderNumber();
|
|
|
|
$order_num = $this->generateOrderNumber();
|
|
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
$data = [
|
|
|
|
'title' => $title,
|
|
|
|
'title' => $title,
|
|
|
|
'type' => $type,
|
|
|
|
'type' => $type,
|
|
|
|
@ -365,8 +413,10 @@ class OrderController extends Controller
|
|
|
|
'birthday' => $person->birthday,
|
|
|
|
'birthday' => $person->birthday,
|
|
|
|
'married' => $person->married,
|
|
|
|
'married' => $person->married,
|
|
|
|
'wj_flag' => $wj_flag,
|
|
|
|
'wj_flag' => $wj_flag,
|
|
|
|
|
|
|
|
'youhuiquan'=>$quanInfo===false?'':json_encode(['id'=>$quanInfo['DZJID'],'name'=>$quanInfo['DZJLBMC']],JSON_UNESCAPED_UNICODE),
|
|
|
|
'created_at' => $now_datetime,
|
|
|
|
'created_at' => $now_datetime,
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
DB::beginTransaction();
|
|
|
|
$insert = DB::table('orders')->insertGetId($data);
|
|
|
|
$insert = DB::table('orders')->insertGetId($data);
|
|
|
|
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
|
|
|
|
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
|
|
|
|
@ -377,11 +427,17 @@ class OrderController extends Controller
|
|
|
|
'order_id' => $insert,
|
|
|
|
'order_id' => $insert,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
//调用接口扣除积分和预存款
|
|
|
|
//调用接口扣除积分和预存款、优惠券
|
|
|
|
$jifen_dikou_status = true;
|
|
|
|
$jifen_dikou_status = true;
|
|
|
|
$yucunkuan_dikou_status = true;
|
|
|
|
$yucunkuan_dikou_status = true;
|
|
|
|
$yyid = $hospital_id;
|
|
|
|
$youhuiquan_dikou_status = true;
|
|
|
|
if ($yyid == 1) $yyid = 6;
|
|
|
|
$r_yyid = $hospital_id;
|
|
|
|
|
|
|
|
if($r_yyid==1){
|
|
|
|
|
|
|
|
$yyid=6;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($r_yyid==4){
|
|
|
|
|
|
|
|
$yyid=2;
|
|
|
|
|
|
|
|
}
|
|
|
|
if ($env == 'pro') { //如果是正式环境
|
|
|
|
if ($env == 'pro') { //如果是正式环境
|
|
|
|
if ($jifen > 0) {
|
|
|
|
if ($jifen > 0) {
|
|
|
|
$jifen_dikou_status = false;
|
|
|
|
$jifen_dikou_status = false;
|
|
|
|
@ -391,9 +447,23 @@ class OrderController extends Controller
|
|
|
|
$yucunkuan_dikou_status = false;
|
|
|
|
$yucunkuan_dikou_status = false;
|
|
|
|
$yucunkuan_dikou_status = $AspNet::UseYuCunKuan($person->ghzid, -$yucunkuan, $yyid, 0, $insert, 'tj_h5', '抵扣体检H5订单', $now_datetime);
|
|
|
|
$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();
|
|
|
|
DB::commit();
|
|
|
|
$action = false;
|
|
|
|
$action = false;
|
|
|
|
if ($true_price == 0) {
|
|
|
|
if ($true_price == 0) {
|
|
|
|
|