|
@@ -6,7 +6,18 @@ use Log;
|
|
|
|
|
|
class card_query
|
|
|
{
|
|
|
- //[$validate,$card_type,$region_no,$isTransfer,$status]
|
|
|
+ private function validate_checker($status)
|
|
|
+ {
|
|
|
+ // "status": 1 //状态 0:空号;1:实号;2:停机;3:库无;4:沉默号;5:风险号 6: 未知 7: 流量卡
|
|
|
+ Log::record("status={$status}",Log::DEBUG);
|
|
|
+ if (in_array($status, [0, 5, 7])) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //[success,$card_type,$region_no,$isTransfer,$status]
|
|
|
private function tencent_query($card_no)
|
|
|
{
|
|
|
$type_checker = function ($channel)
|
|
@@ -43,17 +54,6 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $validate_checker = function ($code)
|
|
|
- {
|
|
|
- // "status": 1 //状态 0:空号;1:实号;2:停机;3:库无;4:沉默号;5:风险号 6: 未知 7: 流量卡
|
|
|
- Log::record("status={$code}",Log::DEBUG);
|
|
|
- if (in_array($code, [0,5,7])) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
$regin_checker = function ($province)
|
|
|
{
|
|
|
if(empty($province)) return -1;
|
|
@@ -75,7 +75,7 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $api_function = function ($card_no, &$card_type, &$validate, &$region_no, &$status) use ($type_checker, $validate_checker, $regin_checker, $status_converter)
|
|
|
+ $query_fun = function ($card_no, &$card_type, &$region_no, &$status) use ($type_checker, $regin_checker, $status_converter)
|
|
|
{
|
|
|
$secretId = 'AKIDkd6sT6C4765LtYN1W2fN2WC2Ynr42acemjQW';
|
|
|
$secretKey = 'dupQeU838dhuQ8uDP2bi81nQNb5wt9KW1qLP7eWu';
|
|
@@ -109,7 +109,6 @@ class card_query
|
|
|
|
|
|
$status = $status_converter($code);
|
|
|
$card_type = $type_checker($extend['isp']);
|
|
|
- $validate = $validate_checker($code);
|
|
|
$region_no = $regin_checker($extend['prov']);
|
|
|
return true;
|
|
|
} else {
|
|
@@ -118,21 +117,23 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $validate = true;
|
|
|
- $card_type = card_type($card_no,$region_no);
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ $org_type = card_type($card_no,$region_no);
|
|
|
$region_no = -1;
|
|
|
$status = 6;
|
|
|
|
|
|
- //[$validate,$card_type,$region_no,$isTransfer,$status]
|
|
|
- $ret = $api_function($card_no, $card_type, $validate, $region_no, $status);
|
|
|
- if($ret)
|
|
|
- {
|
|
|
- return [$validate,$card_type,$region_no,$status];
|
|
|
+ //[succ,$card_type,$region_no,$isTransfer,$status]
|
|
|
+ $ret = $query_fun($card_no, $card_type, $region_no, $status);
|
|
|
+ if ($ret) {
|
|
|
+ $isTransfer = $org_type != $card_type;
|
|
|
+ return [true, $card_type, $region_no, $isTransfer, $status];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [false, $card_type, -1, false, $status];
|
|
|
}
|
|
|
- return [$validate,$card_type,-1,$status];
|
|
|
}
|
|
|
|
|
|
- //[$validate,$card_type,$region_no,$isTransfer,$status]
|
|
|
+ //[succ,$card_type,$region_no,$isTransfer,$status]
|
|
|
public function tianyan_query($card_no)
|
|
|
{
|
|
|
$type_checker = function ($channel)
|
|
@@ -151,17 +152,6 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $validate_checker = function ($status)
|
|
|
- {
|
|
|
- // "status": 1 //状态 0:空号;1:实号;2:停机;3:库无;4:沉默号;5:风险号
|
|
|
- Log::record("status={$status}",Log::DEBUG);
|
|
|
- if (in_array($status, [0,5])) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
$regin_checker = function ($area)
|
|
|
{
|
|
|
if(empty($area)) return -1;
|
|
@@ -188,7 +178,7 @@ class card_query
|
|
|
return -1;
|
|
|
};
|
|
|
|
|
|
- $ali = function ($card_no, &$validate, &$region_no,&$status) use ($validate_checker, $regin_checker): bool
|
|
|
+ $ali = function ($card_no, &$region_no, &$status) use ($regin_checker): bool
|
|
|
{
|
|
|
$url = 'https://mobileempty.shumaidata.com/mobileempty';
|
|
|
$params['mobile'] = $card_no;
|
|
@@ -205,7 +195,6 @@ class card_query
|
|
|
{
|
|
|
$data = $resp['data'];
|
|
|
$status = intval($data['status']);
|
|
|
- $validate = $validate_checker(intval($data['status']));
|
|
|
$region_no = $regin_checker($data['area']);
|
|
|
return true;
|
|
|
} else {
|
|
@@ -214,7 +203,7 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- $tianyan = function ($card_no, &$validate, &$region_no,&$status) use ($validate_checker, $regin_checker): bool
|
|
|
+ $tianyan = function ($card_no, &$region_no, &$status) use ($regin_checker): bool
|
|
|
{
|
|
|
$url = 'https://api.shumaidata.com/v4/mobile_empty/check';
|
|
|
$appid = '2Xfa6IFIPv0sVUjy';
|
|
@@ -238,7 +227,6 @@ class card_query
|
|
|
{
|
|
|
$data = $resp['data'];
|
|
|
$status = intval($data['status']);
|
|
|
- $validate = $validate_checker(intval($data['status']));
|
|
|
$region_no = $regin_checker($data['area']);
|
|
|
return true;
|
|
|
} else {
|
|
@@ -285,6 +273,7 @@ class card_query
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
[$succ,$_card_type,$_org_type,$_isTransfer] = $tianyan_cardtyper($card_no);
|
|
|
if($succ) {
|
|
|
$card_type = $_card_type;
|
|
@@ -296,36 +285,23 @@ class card_query
|
|
|
}
|
|
|
|
|
|
$status = 6;
|
|
|
- $ret = $tianyan($card_no,$validate,$region_no,$status);
|
|
|
- if($ret)
|
|
|
- {
|
|
|
- return [$validate,$card_type,$region_no,$isTransfer,$status];
|
|
|
+ $ret = $tianyan($card_no, $region_no, $status);
|
|
|
+ if ($ret) {
|
|
|
+ return [true, $card_type, $region_no, $isTransfer, $status];
|
|
|
}
|
|
|
|
|
|
- $ret = $ali($card_no,$validate,$region_no,$status);
|
|
|
- if($ret)
|
|
|
- {
|
|
|
- return [$validate,$card_type,$region_no,$isTransfer,$status];
|
|
|
+ $ret = $ali($card_no, $region_no, $status);
|
|
|
+ if ($ret) {
|
|
|
+ return [true, $card_type, $region_no, $isTransfer, $status];
|
|
|
}
|
|
|
|
|
|
- return [true,$card_type,-1,false,$status];
|
|
|
+ return [false, $card_type, -1, false, $status];
|
|
|
}
|
|
|
|
|
|
|
|
|
//[$validate,$card_type,$region_no,$isTransfer,$status,$black]
|
|
|
public function validate($card_no)
|
|
|
{
|
|
|
- $validate_checker = function ($status)
|
|
|
- {
|
|
|
- // "status": 1 //状态 0:空号;1:实号;2:停机;3:库无;4:沉默号;5:风险号
|
|
|
- Log::record("status={$status}",Log::DEBUG);
|
|
|
- if (in_array($status, [0,5])) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
$time_checker = function ($update_time)
|
|
|
{
|
|
|
//90 天以内数据有效
|
|
@@ -333,7 +309,7 @@ class card_query
|
|
|
return $delta < 360 * 86400 && $delta >= 0;
|
|
|
};
|
|
|
|
|
|
- $pinfo_getter = function ($card_no) use ($validate_checker,$time_checker)
|
|
|
+ $pinfo_getter = function ($card_no) use ($time_checker)
|
|
|
{
|
|
|
$mod_card = Model('card_info');
|
|
|
$info = $mod_card->getCardInfo($card_no);
|
|
@@ -346,11 +322,10 @@ class card_query
|
|
|
|
|
|
$card_type = intval($info['card_type']);
|
|
|
$region_no = intval($info['regin']);
|
|
|
- $isTransfer = intval($info['transfer']) == 0 ? false : true;
|
|
|
+ $isTransfer = !(intval($info['transfer']) == 0);
|
|
|
$status = intval($info['card_state']);
|
|
|
$black = intval($info['black']);
|
|
|
- $validate = $validate_checker($status);
|
|
|
-
|
|
|
+ $validate = $this->validate_checker($status);
|
|
|
$result = [$validate,$card_type,$region_no,$isTransfer,$status,$black];
|
|
|
return [true,$result];
|
|
|
}
|
|
@@ -369,22 +344,32 @@ class card_query
|
|
|
$validate = true;
|
|
|
$black = 0;
|
|
|
|
|
|
- $card_type = card_type($card_no,$region_no);
|
|
|
+ $org_type = card_type($card_no,$region_no);
|
|
|
$region_no = -1;
|
|
|
|
|
|
- if($card_type == PetroChinaCard || $card_type == SinopecCard) {
|
|
|
- return [$validate,$card_type,$region_no,false,1,$black];
|
|
|
+ if($org_type === UnknownCard) {
|
|
|
+ return [false, $org_type, $region_no, false, 1, $black];
|
|
|
}
|
|
|
|
|
|
-// [$succ,$result] = $pinfo_getter($card_no);
|
|
|
-// if($succ) return $result;
|
|
|
-
|
|
|
- $this->tencent_query($card_no);
|
|
|
-
|
|
|
+ if($org_type == PetroChinaCard || $org_type == SinopecCard) {
|
|
|
+ return [$validate, $org_type, $region_no, false, 1, $black];
|
|
|
+ }
|
|
|
|
|
|
+ [$succ,$result] = $pinfo_getter($card_no);
|
|
|
+ if($succ) return $result;
|
|
|
|
|
|
+ [$succ,$card_type,$region_no,$isTransfer,$status] = $this->tencent_query($card_no);
|
|
|
+ if($succ === false)
|
|
|
+ {
|
|
|
+ [$succ,$card_type,$region_no,$isTransfer,$status] = $this->tianyan_query($card_no);
|
|
|
+ if($succ === false) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-// if($succ) $pinfo_updator($card_no,$card_type,$org_type,$region_no,$isTransfer,$status);
|
|
|
+ $validate = $this->validate_checker($status);
|
|
|
+ $pinfo_updator($card_no,$card_type,$org_type,$region_no,$isTransfer,$status);
|
|
|
|
|
|
+ return [$validate,$card_type,$region_no,$isTransfer,$status,$black];
|
|
|
}
|
|
|
}
|