|
|
|
@ -114,6 +114,7 @@ class OrderController extends Controller
|
|
|
|
if (!$person) return \Yz::echoError1('体检人不存在');
|
|
|
|
if (!$person) return \Yz::echoError1('体检人不存在');
|
|
|
|
$title = "自选项目";
|
|
|
|
$title = "自选项目";
|
|
|
|
$price = 0;
|
|
|
|
$price = 0;
|
|
|
|
|
|
|
|
$quanInfo=false;
|
|
|
|
$true_price = 0;//订单真实支付金额
|
|
|
|
$true_price = 0;//订单真实支付金额
|
|
|
|
$buy_info = [
|
|
|
|
$buy_info = [
|
|
|
|
'combo' => [
|
|
|
|
'combo' => [
|
|
|
|
@ -208,6 +209,14 @@ class OrderController extends Controller
|
|
|
|
if (isset($wj_flag) and $wj_flag == 1) {
|
|
|
|
if (isset($wj_flag) and $wj_flag == 1) {
|
|
|
|
$item_price = $item_price * $wj_zhekou;
|
|
|
|
$item_price = $item_price * $wj_zhekou;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//使用优惠券
|
|
|
|
|
|
|
|
if (isset($coupon_id) and !empty($coupon_id)) {
|
|
|
|
|
|
|
|
if($item_price==0) return \Yz::echoError1("自选项目金额为0,无需使用优惠券");
|
|
|
|
|
|
|
|
$use_quan=$this->useYouHuiQuan($item_price,$person,$coupon_id);
|
|
|
|
|
|
|
|
$quanInfo=$use_quan['quanInfo'];
|
|
|
|
|
|
|
|
$item_price=$use_quan['price'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$price += $item_price;
|
|
|
|
$price += $item_price;
|
|
|
|
$missingIds = array_diff($item_ids, $existingIds);
|
|
|
|
$missingIds = array_diff($item_ids, $existingIds);
|
|
|
|
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用,Id:" . implode(', ', $missingIds));
|
|
|
|
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用,Id:" . implode(', ', $missingIds));
|
|
|
|
@ -341,53 +350,7 @@ class OrderController extends Controller
|
|
|
|
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("无需使用代金券");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AspNet = new AspNetZhuanController();
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'ghzid' => $person->ghzid,
|
|
|
|
|
|
|
|
'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) {
|
|
|
|
|
|
|
|
//抵扣代金券金额
|
|
|
|
|
|
|
|
if($quanType['YHLX']==1){//抵扣券
|
|
|
|
|
|
|
|
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($quanType['YHLX']==2){//抵扣券
|
|
|
|
|
|
|
|
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($plan_nmr_info) and !empty($plan_nmr_info)) {
|
|
|
|
if (isset($plan_nmr_info) and !empty($plan_nmr_info)) {
|
|
|
|
$plan_nmr_temp = [];
|
|
|
|
$plan_nmr_temp = [];
|
|
|
|
foreach ($plan_nmr_info as $key => $plan_nmr) {
|
|
|
|
foreach ($plan_nmr_info as $key => $plan_nmr) {
|
|
|
|
@ -640,6 +603,7 @@ class OrderController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果是个检
|
|
|
|
//如果是个检
|
|
|
|
if ($order_info->type == 1) {
|
|
|
|
if ($order_info->type == 1) {
|
|
|
|
|
|
|
|
$checkup_type=DB::table('checkup_type')->where(['id' => $order_info->checkup_type_id])->first();
|
|
|
|
$cad = [
|
|
|
|
$cad = [
|
|
|
|
'type' => 1,
|
|
|
|
'type' => 1,
|
|
|
|
"姓名" => $order_info->name,
|
|
|
|
"姓名" => $order_info->name,
|
|
|
|
@ -651,7 +615,7 @@ class OrderController extends Controller
|
|
|
|
"预约时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
|
|
|
|
"预约时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
|
|
|
|
"介绍人" => $order_info->referral,
|
|
|
|
"介绍人" => $order_info->referral,
|
|
|
|
'套餐Id' => $order_info->combo_id == 0 ? null : $order_info->combo_id,
|
|
|
|
'套餐Id' => $order_info->combo_id == 0 ? null : $order_info->combo_id,
|
|
|
|
|
|
|
|
'体检类型Id'=>isset($checkup_type->sx_id)?$checkup_type->sx_id:null,
|
|
|
|
"已收费" => true,
|
|
|
|
"已收费" => true,
|
|
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
];
|
|
|
|
@ -821,4 +785,54 @@ class OrderController extends Controller
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
return $info;
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function useYouHuiQuan($true_price,$person,$coupon_id){
|
|
|
|
|
|
|
|
//如果使用了代金券
|
|
|
|
|
|
|
|
$quanInfo = false;
|
|
|
|
|
|
|
|
if (isset($coupon_id) and !empty($coupon_id)) {
|
|
|
|
|
|
|
|
if ($true_price == 0) return \Yz::echoError1("无需使用代金券");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AspNet = new AspNetZhuanController();
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'ghzid' => $person->ghzid,
|
|
|
|
|
|
|
|
'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) {
|
|
|
|
|
|
|
|
//抵扣代金券金额
|
|
|
|
|
|
|
|
if($quanType['YHLX']==1){//抵扣券
|
|
|
|
|
|
|
|
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($quanType['YHLX']==2){//抵扣券
|
|
|
|
|
|
|
|
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ['price'=>$true_price,'quanInfo'=>$quanInfo];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|