对接优惠券

main
yanzai 1 year ago
parent 72dbdd0125
commit 5695d6bf70

@ -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(isset($coupon_id) and !empty($coupon_id)){
if($true_price==0) return \Yz::echoError1("无需使用代金券"); if($true_price==0) return \Yz::echoError1("无需使用代金券");
$quanInfo=false; $quanInfo=false;
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境 if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController(); $AspNet=new AspNetZhuanController();

@ -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) {

@ -16,7 +16,7 @@ class TestController extends Controller
// dd($order->DepartmentItemCount(33)); // dd($order->DepartmentItemCount(33));
// $aspnet=new AspNetZhuanController(); $aspnet=new AspNetZhuanController();
// $temp_list=[]; // $temp_list=[];
// $nmr=$aspnet::GetNmrList(['yyid'=>6,'data'=>['2024-10-25']],uniqid()); // $nmr=$aspnet::GetNmrList(['yyid'=>6,'data'=>['2024-10-25']],uniqid());
// //
@ -28,8 +28,16 @@ class TestController extends Controller
// ]; // ];
// } // }
$peis = new PEISApiController(); // $peis = new PEISApiController();
dd($peis::Get($peis::Api('报告时间计算',"2403020020"),"111111","报告时间计算")); // dd($peis::Get($peis::Api('报告时间计算',"2403020020"),"111111","报告时间计算"));
$data=[
'action'=>4,
'ghzid'=>'5a798c097bc64bd79c22050175e6236a',
'dzjid'=>'994924890348203254993',
'hxbz'=>"H5撤销核销",
'yyid'=>6
];
$aspnet::YouHuiQuan($data);
} }

@ -103,6 +103,17 @@ class OrderService
DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_yucunkuan'=>1]); 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([ DB::table('orders')->where(['id' => $orderInfo->id,'status'=>1])->update([

@ -288,7 +288,6 @@ const comfrimyy = async () => {
wj: buyInfo.value.wj, wj: buyInfo.value.wj,
}; };
console.log(obj); console.log(obj);
return false;
const response = await $api("OrderCreate", obj); const response = await $api("OrderCreate", obj);
$response(response, () => { $response(response, () => {
if (response.status) { if (response.status) {

Loading…
Cancel
Save