From 82277cad87a799b1dfbf2969ec01ad2fd9f88291 Mon Sep 17 00:00:00 2001 From: mzeros Date: Thu, 26 Dec 2024 23:00:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BB=A5=E6=94=AF=E6=8C=81=E7=A7=BB=E5=8A=A8=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=8F=90=E4=BE=9B=E5=95=86=E7=89=B9=E5=AE=9A=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移动网络提供商相关代码从 Core 控制器中提取并重新组织 - 在 Feihan 和 Jiyu 服务中添加新的充值方法 - 修改 Meicheng服务以支持新的移动网络提供商逻辑 - 优化 Port 控制器中的渠道余额检查逻辑 - 优化修复在签名前加字段导致异常报错,提炼到校验签名后判断 --- app/channel/service/system/Feihan.php | 6 ++++ app/channel/service/system/Jiyu.php | 48 +++++++++++++++++++++---- app/channel/service/system/Meicheng.php | 6 ++++ app/gateway/controller/v4/Core.php | 38 +++++++++++++++++--- app/openapi/controller/Port.php | 3 +- 5 files changed, 89 insertions(+), 12 deletions(-) diff --git a/app/channel/service/system/Feihan.php b/app/channel/service/system/Feihan.php index fdafe4f..e5908f1 100644 --- a/app/channel/service/system/Feihan.php +++ b/app/channel/service/system/Feihan.php @@ -24,6 +24,12 @@ class Feihan extends Core $this->api='onlineorder.do'; return $this->submit( $param, $check); } + + public function dxcz_lt_mnp($param) + { + $param['paytype'] = 'dx'; + return $this->dxcz($param); + } public function ydcz($param) { $check = array diff --git a/app/channel/service/system/Jiyu.php b/app/channel/service/system/Jiyu.php index 8a8b6a8..f74e01b 100644 --- a/app/channel/service/system/Jiyu.php +++ b/app/channel/service/system/Jiyu.php @@ -13,18 +13,31 @@ class Jiyu extends Core $check = array ( 'mobile' => 'recharge_account', - 'cash'=>'cash' + 'cash'=>'quantity' ); $this->api='api/buy'; 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) { $check = array ( 'account' => 'recharge_account', - 'cash'=>'cash' + 'cash'=>'quantity' ); $this->api='api/buy'; return $this->submit($param, $check); @@ -138,7 +151,7 @@ class Jiyu extends Core $array = $this->json_decode($data); if (!$array) { $msg = 'error'; - } elseif ($array['code']=='ok') { + } elseif (isset($array['code']) && $array['code']=='ok') { # 正确 $msg = 'ok'; if(isset($array['cards'])){ @@ -152,7 +165,7 @@ class Jiyu extends Core } } else { # 错误 - $msg = isset($array['message']) ? $array['message'] : 'error'; + $msg = $array['message'] ?? 'error'; } 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) @@ -173,12 +204,15 @@ class Jiyu extends Core } $request = $param['detail']; $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['outer_order_id']=$param['order']; $request['product_id']=$this->getGid($param['cash']); $request['timestamp']=time(); - unset($request['cash']); +// unset($request['cash']); $request['sign'] = $this->_sign($request); $url = $this->host . $this->api; @@ -192,7 +226,7 @@ class Jiyu extends Core private function _sign($request) { - unset($request['cash']); +// unset($request['cash']); ksort($request); $str=$this->token; foreach($request as $k=>$v){ diff --git a/app/channel/service/system/Meicheng.php b/app/channel/service/system/Meicheng.php index c072ca5..3e142c5 100644 --- a/app/channel/service/system/Meicheng.php +++ b/app/channel/service/system/Meicheng.php @@ -62,6 +62,12 @@ class Meicheng extends Core return $this->hf_submit($param); } + public function dxcz_lt_mnp($param) + { + $param['paytype'] = 'dx'; + return $this->hf_submit($param); + } + public function hf_submit($param) { $check = array diff --git a/app/gateway/controller/v4/Core.php b/app/gateway/controller/v4/Core.php index 58bc6c3..760e07f 100644 --- a/app/gateway/controller/v4/Core.php +++ b/app/gateway/controller/v4/Core.php @@ -149,12 +149,8 @@ class Core extends Controller # 从数据库中或者缓存中取出商户的信息,并验证是否有效 $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']); @@ -255,6 +283,7 @@ class Core extends Controller if($mnp_cid){ $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){ @@ -279,6 +308,7 @@ class Core extends Controller } + } diff --git a/app/openapi/controller/Port.php b/app/openapi/controller/Port.php index 429d156..83f9a75 100644 --- a/app/openapi/controller/Port.php +++ b/app/openapi/controller/Port.php @@ -38,7 +38,8 @@ class Port extends Core 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()){ $this->yes('ok','暂无可用渠道'); }