refactor(app): 重构代码以支持移动网络提供商特定逻辑
- 移动网络提供商相关代码从 Core 控制器中提取并重新组织 - 在 Feihan 和 Jiyu 服务中添加新的充值方法 - 修改 Meicheng服务以支持新的移动网络提供商逻辑 - 优化 Port 控制器中的渠道余额检查逻辑 - 优化修复在签名前加字段导致异常报错,提炼到校验签名后判断
This commit is contained in:
parent
99caf318c4
commit
82277cad87
@ -24,6 +24,12 @@ class Feihan extends Core
|
|||||||
$this->api='onlineorder.do';
|
$this->api='onlineorder.do';
|
||||||
return $this->submit( $param, $check);
|
return $this->submit( $param, $check);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dxcz_lt_mnp($param)
|
||||||
|
{
|
||||||
|
$param['paytype'] = 'dx';
|
||||||
|
return $this->dxcz($param);
|
||||||
|
}
|
||||||
public function ydcz($param)
|
public function ydcz($param)
|
||||||
{
|
{
|
||||||
$check = array
|
$check = array
|
||||||
|
@ -13,18 +13,31 @@ class Jiyu extends Core
|
|||||||
$check = array
|
$check = array
|
||||||
(
|
(
|
||||||
'mobile' => 'recharge_account',
|
'mobile' => 'recharge_account',
|
||||||
'cash'=>'cash'
|
'cash'=>'quantity'
|
||||||
);
|
);
|
||||||
$this->api='api/buy';
|
$this->api='api/buy';
|
||||||
return $this->submit($param, $check);
|
return $this->submit($param, $check);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ydcz($param)
|
||||||
|
{
|
||||||
|
return $this->dhcz($param);
|
||||||
|
}
|
||||||
|
public function dxcz($param)
|
||||||
|
{
|
||||||
|
return $this->dhcz($param);
|
||||||
|
}
|
||||||
|
public function ltcz($param)
|
||||||
|
{
|
||||||
|
return $this->dhcz($param);
|
||||||
|
}
|
||||||
# 通用卡密购买
|
# 通用卡密购买
|
||||||
public function cardbuy($param)
|
public function cardbuy($param)
|
||||||
{
|
{
|
||||||
$check = array
|
$check = array
|
||||||
(
|
(
|
||||||
'account' => 'recharge_account',
|
'account' => 'recharge_account',
|
||||||
'cash'=>'cash'
|
'cash'=>'quantity'
|
||||||
);
|
);
|
||||||
$this->api='api/buy';
|
$this->api='api/buy';
|
||||||
return $this->submit($param, $check);
|
return $this->submit($param, $check);
|
||||||
@ -138,7 +151,7 @@ class Jiyu extends Core
|
|||||||
$array = $this->json_decode($data);
|
$array = $this->json_decode($data);
|
||||||
if (!$array) {
|
if (!$array) {
|
||||||
$msg = 'error';
|
$msg = 'error';
|
||||||
} elseif ($array['code']=='ok') {
|
} elseif (isset($array['code']) && $array['code']=='ok') {
|
||||||
# 正确
|
# 正确
|
||||||
$msg = 'ok';
|
$msg = 'ok';
|
||||||
if(isset($array['cards'])){
|
if(isset($array['cards'])){
|
||||||
@ -152,7 +165,7 @@ class Jiyu extends Core
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# 错误
|
# 错误
|
||||||
$msg = isset($array['message']) ? $array['message'] : 'error';
|
$msg = $array['message'] ?? 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
return array
|
return array
|
||||||
@ -163,6 +176,24 @@ class Jiyu extends Core
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 查询余额接口
|
||||||
|
public function account($day)
|
||||||
|
{
|
||||||
|
$request['customer_id'] = $this->mid;
|
||||||
|
$request['timestamp']=time();
|
||||||
|
$request['sign'] = $this->_sign($request);
|
||||||
|
$url = $this->host . 'api/customer';
|
||||||
|
$response = $this->curl('post', $url, $request);
|
||||||
|
$response = $this->response($response);
|
||||||
|
|
||||||
|
$datas = $response['array']['data'];
|
||||||
|
if(is_array($datas) && isset($datas['balance']) && $datas['balance'] ){
|
||||||
|
$datas['account'] = $datas['balance'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# 提交数据
|
# 提交数据
|
||||||
private function submit($param, $check)
|
private function submit($param, $check)
|
||||||
@ -173,12 +204,15 @@ class Jiyu extends Core
|
|||||||
}
|
}
|
||||||
$request = $param['detail'];
|
$request = $param['detail'];
|
||||||
$request['customer_id']=$this->mid;
|
$request['customer_id']=$this->mid;
|
||||||
$request['quantity']=1;
|
if(!isset($request['quantity'])){
|
||||||
|
$request['quantity']=$param['cash'] ?? 1;
|
||||||
|
}
|
||||||
|
|
||||||
$request['notify_url']=$this->getNotify($param['order'], 1);
|
$request['notify_url']=$this->getNotify($param['order'], 1);
|
||||||
$request['outer_order_id']=$param['order'];
|
$request['outer_order_id']=$param['order'];
|
||||||
$request['product_id']=$this->getGid($param['cash']);
|
$request['product_id']=$this->getGid($param['cash']);
|
||||||
$request['timestamp']=time();
|
$request['timestamp']=time();
|
||||||
unset($request['cash']);
|
// unset($request['cash']);
|
||||||
$request['sign'] = $this->_sign($request);
|
$request['sign'] = $this->_sign($request);
|
||||||
$url = $this->host . $this->api;
|
$url = $this->host . $this->api;
|
||||||
|
|
||||||
@ -192,7 +226,7 @@ class Jiyu extends Core
|
|||||||
|
|
||||||
private function _sign($request)
|
private function _sign($request)
|
||||||
{
|
{
|
||||||
unset($request['cash']);
|
// unset($request['cash']);
|
||||||
ksort($request);
|
ksort($request);
|
||||||
$str=$this->token;
|
$str=$this->token;
|
||||||
foreach($request as $k=>$v){
|
foreach($request as $k=>$v){
|
||||||
|
@ -62,6 +62,12 @@ class Meicheng extends Core
|
|||||||
return $this->hf_submit($param);
|
return $this->hf_submit($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dxcz_lt_mnp($param)
|
||||||
|
{
|
||||||
|
$param['paytype'] = 'dx';
|
||||||
|
return $this->hf_submit($param);
|
||||||
|
}
|
||||||
|
|
||||||
public function hf_submit($param)
|
public function hf_submit($param)
|
||||||
{
|
{
|
||||||
$check = array
|
$check = array
|
||||||
|
@ -149,12 +149,8 @@ class Core extends Controller
|
|||||||
|
|
||||||
# 从数据库中或者缓存中取出商户的信息,并验证是否有效
|
# 从数据库中或者缓存中取出商户的信息,并验证是否有效
|
||||||
$this->getMerchant();
|
$this->getMerchant();
|
||||||
if($this->product == 'dhcz_mnp'){
|
|
||||||
$this->getMnp_isp($this->input['mobile']);
|
|
||||||
$this->input['product'] =$this->product;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#验证安全进价是否匹配
|
#验证安全进价是否匹配
|
||||||
@ -217,6 +213,38 @@ class Core extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $this->mid==1 &&isset($this->merchant['other_param']) && str_contains($this->merchant['other_param'],'mnp_SProduct_isp')){
|
||||||
|
$other_param = json_decode($this->merchant['other_param'],true);
|
||||||
|
if(is_array($other_param) && isset($other_param['mnp_SProduct_isp'])){
|
||||||
|
|
||||||
|
if (strlen($this->product) >= 2) {
|
||||||
|
$pp_isp = '_' . substr($this->product, 0, 2).'_mnp';
|
||||||
|
|
||||||
|
if(str_contains($other_param['mnp_SProduct_isp'], $pp_isp) && isset($this->input['cash'])){
|
||||||
|
$this->getMnp_isp($this->input['mobile']);
|
||||||
|
|
||||||
|
if(isset($this->input['mnp_isp_array'] ) && isset($other_param['mnp_SPISP_'.$this->product.$pp_isp]) && str_contains($other_param['mnp_SPISP_'.$this->product.$pp_isp],$this->input['cash'])){
|
||||||
|
$this->input['product'] =$this->product.$pp_isp;
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->product =$this->input['product'] ;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// var_dump($this->product);die;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->product == 'dhcz_mnp'){
|
||||||
|
$this->getMnp_isp($this->input['mobile']);
|
||||||
|
$this->input['product'] =$this->product;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unset($this->input['sign']);
|
unset($this->input['sign']);
|
||||||
@ -255,6 +283,7 @@ class Core extends Controller
|
|||||||
if($mnp_cid){
|
if($mnp_cid){
|
||||||
$mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param);
|
$mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param);
|
||||||
|
|
||||||
|
|
||||||
if(is_array($mnp_array) && isset($mnp_array['new_isp'])){
|
if(is_array($mnp_array) && isset($mnp_array['new_isp'])){
|
||||||
$mnp_isp = $mnp_array['new_isp'];
|
$mnp_isp = $mnp_array['new_isp'];
|
||||||
if($mnp_isp == 1){
|
if($mnp_isp == 1){
|
||||||
@ -279,6 +308,7 @@ class Core extends Controller
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ class Port extends Core
|
|||||||
|
|
||||||
public function check_channel_balance()
|
public function check_channel_balance()
|
||||||
{
|
{
|
||||||
$channel = DB::name('channel_list')->field("id,name,key")->where('status',1)->select();
|
$cid = [17];
|
||||||
|
$channel = DB::name('channel_list')->field("id,name,key")->where('status',1)->whereNotIn('id', $cid)->select();
|
||||||
if($channel->isEmpty()){
|
if($channel->isEmpty()){
|
||||||
$this->yes('ok','暂无可用渠道');
|
$this->yes('ok','暂无可用渠道');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user