feat(channel): 新增迈远科技 携号转网API 接口并优化手机号码携带查询功能
- 新增 Mykjapi 类实现迈远科技 携号转网API 接口 - 修改 Baidumnpapi 类以适应新的 携号转网API 查询逻辑 - 更新 Core 控制器以支持新的 携号转网API 查询结果处理 -调整 Order 控制器以接收新的 携号转网API 查询数组
This commit is contained in:
parent
13743bd078
commit
47b2ca9540
@ -16,8 +16,9 @@ class Baidumnpapi extends Core
|
|||||||
protected $method = '';
|
protected $method = '';
|
||||||
|
|
||||||
#通用充值
|
#通用充值
|
||||||
public function phone_mnp($mobile)
|
public function phone_mnp($param)
|
||||||
{
|
{
|
||||||
|
$mobile = $param['mobile'];
|
||||||
$url = $this->host .'?mobile='.$mobile;
|
$url = $this->host .'?mobile='.$mobile;
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type'=>'application/json',
|
'Content-Type'=>'application/json',
|
||||||
@ -28,18 +29,18 @@ class Baidumnpapi extends Core
|
|||||||
|
|
||||||
|
|
||||||
$response = $this->curl('post', $url, [] ,true,$headers);
|
$response = $this->curl('post', $url, [] ,true,$headers);
|
||||||
|
// var_dump($response);die;
|
||||||
$response = $this->response($response);
|
$response = $this->response($response);
|
||||||
//$response['data'] = '{}';
|
//$response['data'] = '{}';
|
||||||
//$response['msg'] = 'ok';
|
//$response['msg'] = 'ok';
|
||||||
|
$isp_array = [
|
||||||
|
'移动' =>1,
|
||||||
|
'联通'=>2,
|
||||||
|
'电信'=>3];
|
||||||
if($response['msg'] == 'ok'){
|
if($response['msg'] == 'ok'){
|
||||||
if(isset($response['array']['result']['Now_isp'])){
|
if(isset($response['array']['result']['Now_isp'])){
|
||||||
if($response['array']['result']['Now_isp'] == '移动'){
|
return ['mobile'=>$response['array']['result']['Mobile'],'old_isp'=>$isp_array[$response['array']['result']['Init_isp']],'new_isp'=>$isp_array[$response['array']['result']['Now_isp']] ];
|
||||||
return 1;
|
|
||||||
}elseif ($response['array']['result']['Now_isp'] == '联通'){
|
|
||||||
return 2;
|
|
||||||
}else{
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
118
app/channel/service/system/Mykjapi.php
Normal file
118
app/channel/service/system/Mykjapi.php
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\channel\service\system;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 迈远科技api
|
||||||
|
* Class Baidumnpapi
|
||||||
|
* @package app\channel\service
|
||||||
|
*/
|
||||||
|
class Mykjapi extends Core
|
||||||
|
{
|
||||||
|
# 这几个可以后台设置
|
||||||
|
protected $host = '';
|
||||||
|
protected $mid = '';
|
||||||
|
protected $token = '';
|
||||||
|
protected $method = '';
|
||||||
|
|
||||||
|
#通用充值
|
||||||
|
public function phone_mnp($param)
|
||||||
|
{
|
||||||
|
$mobile = $param['mobile'];
|
||||||
|
$url = $this->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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -150,9 +150,12 @@ class Core extends Controller
|
|||||||
$this->getMerchant();
|
$this->getMerchant();
|
||||||
if($this->product == 'dhcz_mnp'){
|
if($this->product == 'dhcz_mnp'){
|
||||||
$this->getMnp_isp($this->input['mobile']);
|
$this->getMnp_isp($this->input['mobile']);
|
||||||
|
$this->input['product'] =$this->product;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#验证安全进价是否匹配
|
#验证安全进价是否匹配
|
||||||
if($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])){
|
if($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])){
|
||||||
$safe_price = $this->input['safe_price'];
|
$safe_price = $this->input['safe_price'];
|
||||||
@ -242,27 +245,36 @@ class Core extends Controller
|
|||||||
public function getMnp_isp($mobile)
|
public function getMnp_isp($mobile)
|
||||||
{
|
{
|
||||||
$settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus');
|
$settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus');
|
||||||
|
$this->input['old_product'] = $this->product;
|
||||||
if ($settingPhoneMNPStatus == 1) {
|
if ($settingPhoneMNPStatus == 1) {
|
||||||
$mnp_cid = sysconf('PhoneMnp_cid');
|
$mnp_cid = sysconf('PhoneMnp_cid');
|
||||||
|
$param = [
|
||||||
|
'mobile' => $mobile,
|
||||||
|
];
|
||||||
if($mnp_cid){
|
if($mnp_cid){
|
||||||
$mnp_isp = ChannelService::instance()->call('phone_mnp', $mnp_cid, $mobile);
|
$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){
|
if($mnp_isp == 1){
|
||||||
$this->product = 'ydcz';
|
$this->product = 'ydcz';
|
||||||
$this->input['mnp_isp'] = '移动';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
|
|
||||||
}elseif($mnp_isp == 2){
|
}elseif($mnp_isp == 2){
|
||||||
$this->product = 'ltcz';
|
$this->product = 'ltcz';
|
||||||
$this->input['mnp_isp'] = '联通';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
}elseif($mnp_isp == 3){
|
}elseif($mnp_isp == 3){
|
||||||
$this->product = 'dxcz';
|
$this->product = 'dxcz';
|
||||||
$this->input['mnp_isp'] = '电信';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -270,7 +282,7 @@ class Core extends Controller
|
|||||||
|
|
||||||
|
|
||||||
$isp = Service::instance()->isp($this->input['mobile']);
|
$isp = Service::instance()->isp($this->input['mobile']);
|
||||||
$this->input['old_product'] = $this->product;
|
|
||||||
if ($isp == 1) {
|
if ($isp == 1) {
|
||||||
$this->product = 'ydcz';
|
$this->product = 'ydcz';
|
||||||
} elseif ($isp == 2) {
|
} elseif ($isp == 2) {
|
||||||
|
@ -36,11 +36,13 @@ class Order extends Core
|
|||||||
$param['mobile'] = $this->input['account'];
|
$param['mobile'] = $this->input['account'];
|
||||||
|
|
||||||
if($this->product == 'dhcz_mnp'){
|
if($this->product == 'dhcz_mnp'){
|
||||||
|
$param['old_product'] = $this->input['old_product'] = $this->product;
|
||||||
$this->getMnp_isp($this->input['account']);
|
$this->getMnp_isp($this->input['account']);
|
||||||
if(isset($this->input['mnp_isp'])){
|
if(isset($this->input['mnp_isp_array'])){
|
||||||
$param['mnp_isp'] = $this->input['mnp_isp'];
|
$param['mnp_isp_array'] = $this->input['mnp_isp_array'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$param['product'] =$this->product;
|
$param['product'] =$this->product;
|
||||||
|
|
||||||
@ -57,26 +59,32 @@ class Order extends Core
|
|||||||
{
|
{
|
||||||
$settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus');
|
$settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus');
|
||||||
if ($settingPhoneMNPStatus == 1) {
|
if ($settingPhoneMNPStatus == 1) {
|
||||||
|
$param = [
|
||||||
|
'mobile' => $mobile,
|
||||||
|
];
|
||||||
$mnp_cid = sysconf('PhoneMnp_cid');
|
$mnp_cid = sysconf('PhoneMnp_cid');
|
||||||
if($mnp_cid){
|
if($mnp_cid){
|
||||||
$mnp_isp = ChannelService::instance()->call('phone_mnp', $mnp_cid, $mobile);
|
$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){
|
if($mnp_isp == 1){
|
||||||
$this->product = 'ydcz';
|
$this->product = 'ydcz';
|
||||||
$this->input['mnp_isp'] = '移动';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
|
|
||||||
}elseif($mnp_isp == 2){
|
}elseif($mnp_isp == 2){
|
||||||
$this->product = 'ltcz';
|
$this->product = 'ltcz';
|
||||||
$this->input['mnp_isp'] = '联通';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
}elseif($mnp_isp == 3){
|
}elseif($mnp_isp == 3){
|
||||||
$this->product = 'dxcz';
|
$this->product = 'dxcz';
|
||||||
$this->input['mnp_isp'] = '电信';
|
$this->input['mnp_isp_array'] = $mnp_array;
|
||||||
$this->Kou_Mnp($mobile);
|
$this->Kou_Mnp($mobile);
|
||||||
return $this->product ;
|
return $this->product ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user