|
|
<?php
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
class AspNetZhuanController extends Controller
|
|
|
{
|
|
|
public static $request;
|
|
|
public static $BaseUrl = "http://220.174.210.111:82";//url
|
|
|
public static $JF_BaseUrl = "http://220.174.210.111:82/jifen.aspx";//积分预存款Url
|
|
|
|
|
|
//获取用户积分和预存款
|
|
|
public static function GetJiFen_YuCunKuan($type, $ghzid)
|
|
|
{
|
|
|
$res = self::Get(self::$JF_BaseUrl . '?type=' . $type . '&ghzid=' . $ghzid,"查询剩余积分/预存款");
|
|
|
if ($type == 1) return $res['剩余积分'];
|
|
|
if ($type == 2) return $res['剩余预存款'];
|
|
|
}
|
|
|
//获取本次账单可使用的积分
|
|
|
public static function GetEnableCount($ghzid,$ysje,$ssje)
|
|
|
{
|
|
|
$res = self::Get(self::$JF_BaseUrl . '?type=3' . '&ghzid=' . $ghzid. '&ysje=' . $ysje. '&ssje=' . $ssje,"查询本单积分");
|
|
|
return $res['本次账单可抵扣积分'];
|
|
|
}
|
|
|
//使用积分
|
|
|
public static function UseJiFen($ghzid,$jifen,$yyid,$caozuorenid,$caozuorenmigncheng,$beizhu,$dingdanshijian){
|
|
|
$res = self::Get(self::$JF_BaseUrl . '?type=4' . '&ghzid=' . $ghzid. '&jifen=' . $jifen.'&yyid='.$yyid.'&caozuorenid='.$caozuorenid.'&caozuorenmigncheng='.urlencode($caozuorenmigncheng).'&beizhu='.urlencode($beizhu).'&dingdanshijian='.urlencode($dingdanshijian),"积分变更");
|
|
|
return true;
|
|
|
}
|
|
|
//使用预存款
|
|
|
public static function UseYuCunKuan($ghzid,$yucunkuan,$yyid,$yucunkuanleixing,$caozuorenid,$caozuorenmigncheng,$beizhu,$dingdanshijian)
|
|
|
{
|
|
|
$res = self::Get(self::$JF_BaseUrl . '?type=5' . '&ghzid=' . $ghzid. '&yucunkuan=' . $yucunkuan.'&yyid='.$yyid.'&yucunkuanleixing='.$yucunkuanleixing.'&caozuorenid='.$caozuorenid.'&caozuorenmigncheng='.urlencode($caozuorenmigncheng).'&beizhu='.urlencode($beizhu).'&dingdanshijian='.urlencode($dingdanshijian),"预存款变更");
|
|
|
return true;
|
|
|
}
|
|
|
//二线预约
|
|
|
public static function ErXian($data,$nonce)
|
|
|
{
|
|
|
//$res= self::Post(self::$BaseUrl . '/test.aspx?str='.$nonce,$data,'二线号源');
|
|
|
$res= self::Post(self::$BaseUrl . '/erxian.aspx?str='.$nonce,$data,'二线号源');
|
|
|
if($data['action']==2) return $res['gid']??false;
|
|
|
return $res['data']??true;
|
|
|
}
|
|
|
|
|
|
//发送短信
|
|
|
public static function SendMsg($r_yyid,$tel,$name,$time,$sex){
|
|
|
$yy_name='';
|
|
|
if($r_yyid==1){
|
|
|
$yyid=6;
|
|
|
$yy_name="现代妇儿秀英院区";
|
|
|
}
|
|
|
if($r_yyid==4){
|
|
|
$yyid=2;
|
|
|
$yy_name="现代妇儿府城院区";
|
|
|
}
|
|
|
$keshi="健康管理中心1区";
|
|
|
if($sex==1) $keshi="健康管理中心(1楼男宾区)";
|
|
|
if($sex==2) $keshi="健康管理中心(2楼女宾区)";
|
|
|
$sex_zh='';
|
|
|
if($sex==1) $sex_zh="先生";
|
|
|
if($sex==2) $sex_zh="女士";
|
|
|
//$content="时间:".$time.";科室:".$keshi."。温馨提醒:您的预约已成功,请在预约时间前 30 分钟达到科室,凭身份证原件开单。建议您体检前3天清淡饮食、禁烟酒";
|
|
|
$content=$time." 健康体检。请提前10分钟凭身份证到".$yy_name.$keshi."自助机取号。建议体检前3天清淡饮食、禁烟酒。体检当天禁食禁水,空腹6小时以上";
|
|
|
$url=self::$BaseUrl."/tuisong.aspx?yyid=".$yyid."&type=8&mobile=".$tel."&msg1=".urlencode($name)."&msg2=".urlencode($content);
|
|
|
self::get($url,"短信发送");
|
|
|
}
|
|
|
//发送验证码
|
|
|
public static function SendYanZhengMaCode($r_yyid,$tel,$code){
|
|
|
if($r_yyid==1){
|
|
|
$yyid=6;
|
|
|
$yy_name="现代妇儿秀英院区";
|
|
|
}
|
|
|
if($r_yyid==4){
|
|
|
$yyid=2;
|
|
|
$yy_name="现代妇儿府城院区";
|
|
|
}
|
|
|
$url=self::$BaseUrl."/tuisong.aspx?yyid=".$yyid."&type=13&mobile=".$tel."&msg1=".urlencode($code);
|
|
|
self::get($url,"短信发送");
|
|
|
}
|
|
|
//通用短信发送
|
|
|
public static function PublicSendMsg($type,$r_yyid,$tel,$name,$msg)
|
|
|
{
|
|
|
if($r_yyid==1){
|
|
|
$yyid=6;
|
|
|
$yy_name="现代妇儿秀英院区";
|
|
|
}
|
|
|
if($r_yyid==4){
|
|
|
$yyid=2;
|
|
|
$yy_name="现代妇儿府城院区";
|
|
|
}
|
|
|
$url=self::$BaseUrl."/tuisong.aspx?yyid=".$yyid."&type=".$type."&mobile=".$tel."&msg1=".urlencode($name)."&msg2=".urlencode($msg);
|
|
|
self::get($url,"短信发送");
|
|
|
}
|
|
|
//获取优惠卷类型
|
|
|
public static function YouHuiQuan($data)
|
|
|
{
|
|
|
$nonce=uniqid();
|
|
|
//$res= self::Post(self::$BaseUrl . '/zhongzhuan.aspx?str='.$nonce,$data,'获取优惠卷类型');
|
|
|
$res= self::Post(self::$BaseUrl . '/youhuijuan.aspx?str='.$nonce,$data,'获取优惠卷类型');
|
|
|
|
|
|
return $res['data']??true;
|
|
|
}
|
|
|
//获取人员档案
|
|
|
public static function GetPersonInfo($data)
|
|
|
{
|
|
|
$res= self::Post(self::$BaseUrl . '/renyuan.aspx',$data,'获取人员档案');
|
|
|
if($data['action']==2) return $res;
|
|
|
return $res['data'] ?? false;
|
|
|
}
|
|
|
public static function GetPersonInfo2($data)
|
|
|
{
|
|
|
$res= self::Post(self::$BaseUrl . '/renyuan.aspx',$data,'获取人员档案');
|
|
|
return $res['data'] ?? false;
|
|
|
}
|
|
|
//获取报告解读日期和状态
|
|
|
public static function GetReportAnalysis($data)
|
|
|
{
|
|
|
$res= self::Post2(self::$BaseUrl . '/baogaojiedu.aspx',$data,'报告解读');
|
|
|
return $res;
|
|
|
}
|
|
|
//获取指定日期医生排班
|
|
|
public static function GetDoctorDateList($data)
|
|
|
{
|
|
|
$res= self::Post2(self::$BaseUrl . '/yisheng.aspx',$data,'医生排班');
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//微信推送
|
|
|
public static function WeiXinSend($data)
|
|
|
{
|
|
|
$nonce=uniqid();
|
|
|
$res= self::Post(self::$BaseUrl . '/sendwx.aspx?str='.$nonce,$data,'微信推送');
|
|
|
return $res;
|
|
|
}
|
|
|
//获取hzid
|
|
|
public static function GetHzid($data){
|
|
|
$nonce=uniqid();
|
|
|
$res= self::Post(self::$BaseUrl . '/test.aspx?str='.$nonce,$data,'获取hzid');
|
|
|
return $res;
|
|
|
}
|
|
|
//婚检插入his
|
|
|
public static function HunjianHis($data){
|
|
|
$nonce=uniqid();
|
|
|
$res= self::Post(self::$BaseUrl . '/hunjian.aspx?r='.$nonce,$data,'His信息Handle');
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
public static function Get($url,$mark)
|
|
|
{
|
|
|
self::RequestLog($url, [], $mark, '.Net转发');
|
|
|
$response = Http::get($url);
|
|
|
if($mark=="短信发送"){
|
|
|
Log::info( $response->body());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if ($response->successful()) {
|
|
|
$res = $response->json();
|
|
|
|
|
|
self::$request->response_data = json_encode($res, JSON_UNESCAPED_UNICODE);
|
|
|
self::$request->save();
|
|
|
|
|
|
if ($res['code'] == "200") {
|
|
|
return $res;
|
|
|
} else {
|
|
|
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $res['msg']));
|
|
|
}
|
|
|
} else {
|
|
|
$status = $response->status();
|
|
|
// 获取响应体作为字符串
|
|
|
$body = $response->body();
|
|
|
|
|
|
self::$request->response_data = $body;
|
|
|
self::$request->save();
|
|
|
|
|
|
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
|
|
|
}
|
|
|
}
|
|
|
public static function Post($url,$data,$mark)
|
|
|
{
|
|
|
self::RequestLog($url, $data, $mark, '.Net转发');
|
|
|
$response = Http::post($url,$data);
|
|
|
if ($response->successful()) {
|
|
|
$res = $response->json();
|
|
|
$res_string=json_encode($res, JSON_UNESCAPED_UNICODE);
|
|
|
$str_len = mb_strlen($res_string, 'utf-8');
|
|
|
$str_size = $str_len / 1024;
|
|
|
$save_res = $res_string;
|
|
|
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
|
|
|
self::$request->response_data = $save_res;
|
|
|
self::$request->save();
|
|
|
if (strpos($url, "renyuan.aspx") !== false and $data['action']==2) {
|
|
|
return $res;
|
|
|
}
|
|
|
if ($res['code'] == "200") {
|
|
|
return $res;
|
|
|
} else {
|
|
|
|
|
|
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $res['msg']));
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
$status = $response->status();
|
|
|
// 获取响应体作为字符串
|
|
|
$body = $response->body();
|
|
|
|
|
|
self::$request->response_data = $body;
|
|
|
self::$request->save();
|
|
|
|
|
|
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
|
|
|
}
|
|
|
}
|
|
|
public static function Post2($url,$data,$mark)
|
|
|
{
|
|
|
self::RequestLog($url, $data, $mark, '.Net转发');
|
|
|
$response = Http::post($url,$data);
|
|
|
if ($response->successful()) {
|
|
|
$res = $response->json();
|
|
|
$res_string=json_encode($res, JSON_UNESCAPED_UNICODE);
|
|
|
$str_len = mb_strlen($res_string, 'utf-8');
|
|
|
$str_size = $str_len / 1024;
|
|
|
$save_res = $res_string;
|
|
|
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
|
|
|
self::$request->response_data = $save_res;
|
|
|
self::$request->save();
|
|
|
return $res;
|
|
|
|
|
|
} else {
|
|
|
$status = $response->status();
|
|
|
// 获取响应体作为字符串
|
|
|
$body = $response->body();
|
|
|
|
|
|
self::$request->response_data = $body;
|
|
|
self::$request->save();
|
|
|
|
|
|
throw new HttpResponseException(\Yz::echoError1("调用".$mark."接口失败:" . $status . "body:" . $body));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static function RequestLog($url, $post_data, $mark, $code = 0)
|
|
|
{
|
|
|
self::CheckTableName();
|
|
|
foreach ($post_data as $key => $post_datum) {
|
|
|
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE), 'utf-8');
|
|
|
$str_size = $str_len / 1024;
|
|
|
if ($str_size > 10) {
|
|
|
$post_data["$key"] = 'Row size too large';
|
|
|
}
|
|
|
}
|
|
|
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
|
|
|
self::$request->code = $code;
|
|
|
self::$request->mark = $mark;
|
|
|
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
|
|
|
self::$request->request_url = $url;
|
|
|
self::$request->save();
|
|
|
}
|
|
|
|
|
|
public static function CheckTableName()
|
|
|
{
|
|
|
$table_name = 'zz_peis_log_' . date('ym');
|
|
|
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
|
|
|
if ($table_count->c === 0) {
|
|
|
Schema::create($table_name, function (Blueprint $table) {
|
|
|
$table->id();
|
|
|
$table->string('code', 50)->index();
|
|
|
$table->string('mark', 50)->index();
|
|
|
$table->text('post_data');
|
|
|
$table->text('response_data')->nullable();
|
|
|
$table->string('request_url', 2000);
|
|
|
$table->timestamps();
|
|
|
});
|
|
|
}
|
|
|
self::$request = new \App\Models\PEISLog();
|
|
|
self::$request->setTable($table_name);
|
|
|
}
|
|
|
|
|
|
}
|