完成医院和站点设置、套餐缓存
parent
f8a887dabc
commit
472e0fc47b
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API\Admin\YeWu;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ComboController extends Controller
|
||||
{
|
||||
//获取套餐列表
|
||||
public function UpdateCombo()
|
||||
{
|
||||
$hospital_id =request('hospital');
|
||||
date_default_timezone_set('PRC');
|
||||
$data=[
|
||||
"价格下限"=>"0","价格上限"=>"999999","性别"=>null,"妇检"=>false,"请求来源"=>"小程序"
|
||||
];
|
||||
$peis=new PEISApiController();
|
||||
$info= $peis::Post('套餐查询',$hospital_id,$data,false);
|
||||
$successCount=0;//成功的数量
|
||||
|
||||
if(count($info['data'])>0){
|
||||
$combos=$info['data'];
|
||||
foreach ($combos as $c_key=>$combo){
|
||||
|
||||
$item=[];
|
||||
$comboDetail= $peis::Post('套餐详情查询',$hospital_id,['套餐Id'=>$combo['Id']],false);
|
||||
if($comboDetail['code']!=0) return \Yz::echoError1("套餐详情查询失败");
|
||||
|
||||
$comboDetail_list=$comboDetail['data'][0]['包含项目'];
|
||||
foreach ($comboDetail_list as $key=>$v){
|
||||
$item[]=[
|
||||
'id'=>$v['Id'],
|
||||
'name'=>$v['名称'],
|
||||
'desc'=>$v['简介'],
|
||||
];
|
||||
}
|
||||
|
||||
$item=json_encode($item,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
|
||||
$db_combo=DB::table('combos')->where(['combo_id'=>$combo['Id']])->first();
|
||||
$comboData=[
|
||||
'hospital_id'=>$hospital_id,
|
||||
'combo_id'=>$combo['Id'],
|
||||
'name'=>$combo['名称'],
|
||||
'original_price'=>$combo['原价'],
|
||||
'price'=>$combo['价格'],
|
||||
'items'=>$item,
|
||||
'updated_at'=>date('Y-m-d H:i:s'),
|
||||
];
|
||||
if(!!$db_combo){
|
||||
//如果存在套餐
|
||||
$u=DB::table('combos')->where(['combo_id'=>$combo['Id']])->update($comboData);
|
||||
}else{
|
||||
//如果不存在套餐
|
||||
$u= DB::table('combos')->insert($comboData);
|
||||
}
|
||||
if($u){
|
||||
$successCount++;
|
||||
}else{
|
||||
return \Yz::echoError1('更新失败');
|
||||
}
|
||||
|
||||
}
|
||||
$hospital=DB::table('hospital')->where(['id'=>$hospital_id])->first();
|
||||
if(!!$hospital->frequency){
|
||||
$date = new DateTime();
|
||||
$date->modify('+'.$hospital->frequency.' minutes');
|
||||
$formatted_time = $date->format('Y-m-d H:i:s');
|
||||
DB::table("hospital")->where(['id'=>$hospital_id])->update([
|
||||
'next_time'=>$formatted_time
|
||||
]);
|
||||
}
|
||||
return \Yz::Return(true,'操作完成',['success_count'=>$successCount,'combos_count'=>count($combos)]);
|
||||
|
||||
}else{
|
||||
return \Yz::echoError1('未查询到套餐');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API\Admin\YeWu;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PEISApiController extends Controller
|
||||
{
|
||||
public static function Api($url_code, $code)
|
||||
{
|
||||
$url = 'https://dqgatjzx-wx.sixinyun.com';
|
||||
$api['套餐详情查询'] = "{$url}/PEISCommon/QueryComboDetail/{$code}";
|
||||
$api['自选项目查询'] = "{$url}/PEISCommon/QueryGroups/{$code}";
|
||||
$api['套餐查询'] = "{$url}/PEISCommon/QueryCombos/{$code}";
|
||||
return $api["{$url_code}"] ?? $url_code;
|
||||
}
|
||||
public static function Post($url_code, $hospital_id, $data, $print = false)
|
||||
{
|
||||
|
||||
$hospital = DB::table('hospital')->where(['id'=>$hospital_id,'status'=>1,'is_del'=>0])->first();
|
||||
if (!$hospital) return \Yz::echoError1('医院不存在');
|
||||
$code = $hospital->code;
|
||||
$url = self::Api($url_code, $code);
|
||||
// self::RequestLog($url, $data, $code, $url_code);
|
||||
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json; charset=utf-8',
|
||||
'Content-Length: ' . strlen($data_string)
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
|
||||
$res_string = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
if (!json_decode($res_string, true)) {
|
||||
return \Yz::Return(false,'获取失败', [
|
||||
'url' => $url,
|
||||
'data' => $data,
|
||||
'res' => $res_string
|
||||
]);
|
||||
}
|
||||
$res = json_decode($res_string, true);
|
||||
|
||||
|
||||
return [
|
||||
'code' => $res['ResultCode'],
|
||||
'message' => $res['ResultContent'],
|
||||
'data' => $res['Records']
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
ENV = 'development'
|
||||
VITE_APP_API = '/api/'
|
||||
VITE_APP_FILE = 'http://tijian-composite'
|
||||
VITE_APP_FILE = 'http://tjweb.pi.sa0.online:88'
|
||||
Loading…
Reference in New Issue