You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.2 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class IntegralSaveMoneyCouponController extends Controller
{
//获取用户基本信息和积分、优惠券、预存款信息
public function GetInfo()
{
$openid =request('openid');
$person_id =request('person_id');
$combo_id =request('combo_id');
$user=DB::table('web_users')->where(['openid'=>$openid,'status'=>1,'is_del'=>0])->first();
if(!$user) return \Yz::echoError1('openid对应用户不存在');
$person=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0,'id'=>$person_id])->first();
if(!$person) return \Yz::echoError1('就诊人信息查询失败');
$quan_ids=false;
if(isset($combo_id)){
$quan_ids=DB::table('coupons_combos')->where(['combo_id'=>$combo_id])->pluck('coupon_hisid')->toArray();
}
$jifen=0;
$yucunkuan=0;
$YouHuiQuanType_ids=[];
$coupon_list=[];
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$jifen= $AspNet::GetJiFen_YuCunKuan(1,$person->ghzid);
$yucunkuan= $AspNet::GetJiFen_YuCunKuan(2,$person->ghzid);
$YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]);
foreach ($YouHuiQuanType as $key=>$type){
if($type['TJXCXHX']==1){
$YouHuiQuanType_ids[]=$type['DZJLBID'];
}
}
if(count($YouHuiQuanType_ids)>0 and isset($combo_id)){ //如果没有选择套餐,则不显示优惠券
$data=[
'ghzid'=>$person->ghzid,
'action'=>1,
];
$YouHuiQuanList=$AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key=>$quan){
if(in_array($quan['DZJLBID'],$YouHuiQuanType_ids) and $quan['是否在有效内']===true and $quan['TimeNuZTTextm']=="有效" and $quan['ZT']==1){
if(isset($combo_id) and !in_array($quan['DZJLBID'],$quan_ids)){continue;} //如果设置了套餐id,则比对券id是否绑定套餐只有绑定的才能显示
$coupon_list[]=[
'id'=>$quan['DZJID'],
"title"=>$quan['DZJLBMC'],
"date_range"=>[substr($quan['YSQKSSJ'],0,10),substr($quan['YSQJSSJ'],0,10)],
'price'=>$quan['JE'],
"desc"=>$quan['DZJLBMC']
];
}
}
}
}
if($env=='dev') {//如果是开发环境
$jifen=50;
$yucunkuan=20;
$coupon_list=[
[
'id'=>1,
"title"=>"新人专属",
"date_range"=>['2024-05-01','2024-12-31'],
'price'=>'12',
"desc"=>"满299可用"
],
[
'id'=>2,
"title"=>"新人专属2",
"date_range"=>['2024-08-01','2024-11-10'],
'price'=>'60',
"desc"=>"满500可用"
]
];
}
return \Yz::Return(true,"查询完成",[
'person'=>$person,
'integral'=>$jifen,
'save_money'=>$yucunkuan,
'coupon_list'=>$coupon_list,
]);
}
//获取本单可用积分
public function UsableIntegralSaveMoney(){
$ysje =request('ysje');
$ssje =request('ssje');
$type =request('type'); //1积分2预存款预存款暂时不用此接口查
$openid =request('openid');
$person_id =request('person_id');
if(!isset($type)) return \Yz::echoError1("type不能为空");
$user=DB::table('web_users')->where(['openid'=>$openid,'status'=>1,'is_del'=>0])->first();
if(!$user) return \Yz::echoError1('openid对应用户不存在');
$person=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0,'id'=>$person_id])->first();
if(!$person) return \Yz::echoError1('就诊人信息查询失败');
$count=0;
$env=config('app.globals.Env');
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$count= $AspNet::GetEnableCount($person->ghzid,$ysje,$ssje);
}
if($env=='dev') {//如果是开发环境
$count=30;
}
if($type==1){
return \Yz::Return(true,"查询完成",['keyong_jifen'=>$count]);
}
return \Yz::echoError1("查询失败");
}
}