From 47b2ca9540704e0cc3ed24e7be150cccff0fbf92 Mon Sep 17 00:00:00 2001 From: mzeros Date: Mon, 23 Dec 2024 13:50:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(channel):=20=E6=96=B0=E5=A2=9E=E8=BF=88?= =?UTF-8?q?=E8=BF=9C=E7=A7=91=E6=8A=80=20=E6=90=BA=E5=8F=B7=E8=BD=AC?= =?UTF-8?q?=E7=BD=91API=20=E6=8E=A5=E5=8F=A3=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=A0=81=E6=90=BA=E5=B8=A6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 Mykjapi 类实现迈远科技 携号转网API 接口 - 修改 Baidumnpapi 类以适应新的 携号转网API 查询逻辑 - 更新 Core 控制器以支持新的 携号转网API 查询结果处理 -调整 Order 控制器以接收新的 携号转网API 查询数组 --- app/channel/service/system/Baidumnpapi.php | 17 +-- app/channel/service/system/Mykjapi.php | 118 ++++++++++++++++++ app/gateway/controller/v4/Core.php | 46 ++++--- .../controller/merchantApi/Order.php | 44 ++++--- 4 files changed, 182 insertions(+), 43 deletions(-) create mode 100644 app/channel/service/system/Mykjapi.php diff --git a/app/channel/service/system/Baidumnpapi.php b/app/channel/service/system/Baidumnpapi.php index 10e4c7c..b1f48b2 100644 --- a/app/channel/service/system/Baidumnpapi.php +++ b/app/channel/service/system/Baidumnpapi.php @@ -16,8 +16,9 @@ class Baidumnpapi extends Core protected $method = ''; #通用充值 - public function phone_mnp($mobile) + public function phone_mnp($param) { + $mobile = $param['mobile']; $url = $this->host .'?mobile='.$mobile; $headers = [ 'Content-Type'=>'application/json', @@ -28,18 +29,18 @@ class Baidumnpapi extends Core $response = $this->curl('post', $url, [] ,true,$headers); +// var_dump($response);die; $response = $this->response($response); //$response['data'] = '{}'; //$response['msg'] = 'ok'; + $isp_array = [ + '移动' =>1, + '联通'=>2, + '电信'=>3]; if($response['msg'] == 'ok'){ if(isset($response['array']['result']['Now_isp'])){ - if($response['array']['result']['Now_isp'] == '移动'){ - return 1; - }elseif ($response['array']['result']['Now_isp'] == '联通'){ - return 2; - }else{ - return 3; - } + return ['mobile'=>$response['array']['result']['Mobile'],'old_isp'=>$isp_array[$response['array']['result']['Init_isp']],'new_isp'=>$isp_array[$response['array']['result']['Now_isp']] ]; + } } diff --git a/app/channel/service/system/Mykjapi.php b/app/channel/service/system/Mykjapi.php new file mode 100644 index 0000000..c2e36f4 --- /dev/null +++ b/app/channel/service/system/Mykjapi.php @@ -0,0 +1,118 @@ +host .'HrmApi/numberPortingCheck'; + $request = [ + 'hashcode'=>$this->mid, + 'mobile'=>$mobile, + ]; + + $request['sign'] = md5($this->mid.$mobile.$this->token.date('Ymd',time())); + + + + + + $response = $this->curl('post', $url, $request ,true); + + $response = $this->response($response); + + //$response['data'] = '{}'; + //$response['msg'] = 'ok'; + if($response['msg'] == 'ok'){ + if(isset($response['array']['mobileresult']['res'])){ + if($response['array']['mobileresult']['res'] == '1'){ + return ['mobile'=>$response['array']['mobileresult']['mobile'],'old_isp'=>$response['array']['mobileresult']['initIsp'],'new_isp'=>$response['array']['mobileresult']['isp'] ]; + } + } + } + + + return $response['msg']; + + } + + + + + + + + + # 数据响应格式处理 + public function response($data) + { + $log['type'] = 'response'; + $log['data'] = $data; + $log['config'] = $this->data; + $this->log($log); + + $array = $this->json_decode($data); + if (!$array) { + $msg = 'error'; + } elseif (isset($array['errorRes']['err_code']) && $array['errorRes']['err_code'] == 200) { + # 正确 + $msg = 'ok'; + + } else { + # 错误 + $msg = $array['errorRes']['err_content'] ?? 'error'; + } + + + + return array + ( + 'msg' => $msg, + 'data' => $data, + 'array' => $array, + ); + } + + + + # 查询余额接口 + public function account($day) + { +// $request['day'] = $day; +// $request['appid'] = $this->mid; +// $request['version'] = 'v4'; +// $request['product'] = 'query'; +// list($msec, $sec) = explode(' ', microtime()); +// $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); +// $request['time'] = $msectime; +// $request['nonce'] = substr(sha1(microtime()), rand(10, 15)); +// $request['sign'] = $this->_sign($request); +// $url = $this->host . 'handle/accountByDay'; +// $response = $this->curl('post', $url, $request,true); +// $response = $this->response($response); +// +// return $response['array']['data']; + } + + # 提交数据 + private function submit($param, $check) + { + + } + + +} \ No newline at end of file diff --git a/app/gateway/controller/v4/Core.php b/app/gateway/controller/v4/Core.php index b688698..3c8d504 100644 --- a/app/gateway/controller/v4/Core.php +++ b/app/gateway/controller/v4/Core.php @@ -150,9 +150,12 @@ class Core extends Controller $this->getMerchant(); if($this->product == 'dhcz_mnp'){ $this->getMnp_isp($this->input['mobile']); + $this->input['product'] =$this->product; + } + #验证安全进价是否匹配 if($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])){ $safe_price = $this->input['safe_price']; @@ -242,35 +245,44 @@ class Core extends Controller public function getMnp_isp($mobile) { $settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus'); + $this->input['old_product'] = $this->product; if ($settingPhoneMNPStatus == 1) { $mnp_cid = sysconf('PhoneMnp_cid'); + $param = [ + 'mobile' => $mobile, + ]; if($mnp_cid){ - $mnp_isp = ChannelService::instance()->call('phone_mnp', $mnp_cid, $mobile); - if($mnp_isp == 1){ - $this->product = 'ydcz'; - $this->input['mnp_isp'] = '移动'; - $this->Kou_Mnp($mobile); - return $this->product ; + $mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param); - }elseif($mnp_isp == 2){ - $this->product = 'ltcz'; - $this->input['mnp_isp'] = '联通'; - $this->Kou_Mnp($mobile); - return $this->product ; - }elseif($mnp_isp == 3){ - $this->product = 'dxcz'; - $this->input['mnp_isp'] = '电信'; - $this->Kou_Mnp($mobile); - return $this->product ; + if(is_array($mnp_array) && isset($mnp_array['new_isp'])){ + $mnp_isp = $mnp_array['new_isp']; + if($mnp_isp == 1){ + $this->product = 'ydcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; + + }elseif($mnp_isp == 2){ + $this->product = 'ltcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; + }elseif($mnp_isp == 3){ + $this->product = 'dxcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; + } } + } } $isp = Service::instance()->isp($this->input['mobile']); - $this->input['old_product'] = $this->product; + if ($isp == 1) { $this->product = 'ydcz'; } elseif ($isp == 2) { diff --git a/app/private_api/controller/merchantApi/Order.php b/app/private_api/controller/merchantApi/Order.php index 8fdfb10..bd09475 100644 --- a/app/private_api/controller/merchantApi/Order.php +++ b/app/private_api/controller/merchantApi/Order.php @@ -36,11 +36,13 @@ class Order extends Core $param['mobile'] = $this->input['account']; if($this->product == 'dhcz_mnp'){ + $param['old_product'] = $this->input['old_product'] = $this->product; $this->getMnp_isp($this->input['account']); - if(isset($this->input['mnp_isp'])){ - $param['mnp_isp'] = $this->input['mnp_isp']; + if(isset($this->input['mnp_isp_array'])){ + $param['mnp_isp_array'] = $this->input['mnp_isp_array']; } + } $param['product'] =$this->product; @@ -57,25 +59,31 @@ class Order extends Core { $settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus'); if ($settingPhoneMNPStatus == 1) { + $param = [ + 'mobile' => $mobile, + ]; $mnp_cid = sysconf('PhoneMnp_cid'); if($mnp_cid){ - $mnp_isp = ChannelService::instance()->call('phone_mnp', $mnp_cid, $mobile); - if($mnp_isp == 1){ - $this->product = 'ydcz'; - $this->input['mnp_isp'] = '移动'; - $this->Kou_Mnp($mobile); - return $this->product ; + $mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param); + if(is_array($mnp_array) && isset($mnp_array['new_isp'])){ + $mnp_isp = $mnp_array['new_isp']; + if($mnp_isp == 1){ + $this->product = 'ydcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; - }elseif($mnp_isp == 2){ - $this->product = 'ltcz'; - $this->input['mnp_isp'] = '联通'; - $this->Kou_Mnp($mobile); - return $this->product ; - }elseif($mnp_isp == 3){ - $this->product = 'dxcz'; - $this->input['mnp_isp'] = '电信'; - $this->Kou_Mnp($mobile); - return $this->product ; + }elseif($mnp_isp == 2){ + $this->product = 'ltcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; + }elseif($mnp_isp == 3){ + $this->product = 'dxcz'; + $this->input['mnp_isp_array'] = $mnp_array; + $this->Kou_Mnp($mobile); + return $this->product ; + } }