Kaynağa Gözat

Merge branch 'oilrun' of 39.97.239.116:gyfl/xyzshop into oilrun

stanley-king 4 yıl önce
ebeveyn
işleme
f10f809255

+ 3 - 0
admin/control/predeposit.php

@@ -171,6 +171,9 @@ class predepositControl extends SystemControl{
         if (!empty($_GET['mname'])){
         	$condition['lg_member_name'] = $_GET['mname'];
         }
+        if (!empty($_GET['lg_member_id'])){
+            $condition['lg_member_id'] = $_GET['lg_member_id'];
+        }
         if (!empty($_GET['aname'])){
             $condition['lg_admin_name'] = $_GET['aname'];
         }

+ 3 - 2
admin/templates/default/pd_log.list.php

@@ -21,8 +21,9 @@
         <tr>
           <th><label><?php echo $lang['admin_predeposit_membername'];?></label></th>
           <td><input type="text" name="mname" class="txt" value='<?php echo $_GET['mname'];?>'></td>
-                    
-          <th><label><?php echo $lang['admin_predeposit_maketime']; ?></label></th>
+        <th><label>会员ID</label></th>
+        <td><input type="text" name="lg_member_id" class="txt" value='<?php echo $_GET['lg_member_id'];?>'></td>
+          <th><label><?php echo $lang['lg_member_id']; ?></label></th>
           <td><input type="text" id="stime" name="stime" class="txt date" value="<?php echo $_GET['stime'];?>" >
             <label>~</label>
             <input type="text" id="etime" name="etime" class="txt date" value="<?php echo $_GET['etime'];?>" ></td>

+ 11 - 1
data/config/prod/refill.ini.php

@@ -155,6 +155,15 @@ $weit_phone = ['name' => 'weit', 'store_id' => 18, 'card_type' => ['chinaunicom'
         300 => ['goods_id' => 6335, 'price' => 285],
         500 => ['goods_id' => 6336, 'price' => 475]], 'official_sn' => true, 'refill_type' => 'api'];
 
+$afand_phone = ['name' => 'afand', 'store_id' => 26, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [
+        30 => ['goods_id' => 6374, 'price' => 28.5],
+        50 => ['goods_id' => 6375, 'price' => 47.5],
+        100 => ['goods_id' => 6376, 'price' => 95],
+        200 => ['goods_id' => 6377, 'price' => 190],
+        300 => ['goods_id' => 6378, 'price' => 285],
+        500 => ['goods_id' => 6379, 'price' => 475]], 'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
     ['name' => 'beixt', 'cfg' => $beixt_phone, 'opened' => false, 'sort' => 1],
     ['name' => 'bxtwt', 'cfg' => $bxtwt_phone, 'opened' => false, 'sort' => 2],
@@ -163,5 +172,6 @@ $phone_providers = [
     ['name' => 'tianx', 'cfg' => $tianx_phone, 'opened' => true, 'sort' => 2],
     ['name' => 'yifa', 'cfg' => $yifa_phone, 'opened' => false, 'sort' => 5],
     ['name' => 'jiec', 'cfg' => $jiec_phone, 'opened' => false, 'sort' => 1],
-    ['name' => 'weit', 'cfg' => $weit_phone, 'opened' => false, 'sort' => 1]];
+    ['name' => 'weit', 'cfg' => $weit_phone, 'opened' => false, 'sort' => 1],
+    ['name' => 'afand', 'cfg' => $afand_phone, 'opened' => false, 'sort' => 1]];
 $config['phone_providers'] = $phone_providers;

+ 1 - 1
helper/fcgi_server.php

@@ -31,7 +31,7 @@ class fcgi_server
             'refill_tianjt.php','refill_suhctm.php','refill_suhcpdd.php','refill_gftd.php',
             'refill_beixt.php','refill_bxtwt.php','refill_bjb.php','refill_xyz.php',
             'refill_zzx.php','refill_inner.php','refill_jiec.php','refill_yifa.php',
-            'bridge_shr.php','refill_weit.php','refill_tianx.php'
+            'bridge_shr.php','refill_weit.php','refill_tianx.php','refill_afand.php'
         ];
         $path = BASE_ROOT_PATH . '/mobile/';
         $file = str_replace($path,'',$file);

+ 3 - 0
helper/refill/RefillFactory.php

@@ -74,6 +74,9 @@ require_once(BASE_HELPER_PATH . '/refill/bjbyd/RefillCallBack.php');
 require_once(BASE_HELPER_PATH . '/refill/tianx/RefillPhone.php');
 require_once(BASE_HELPER_PATH . '/refill/tianx/RefillCallBack.php');
 
+require_once(BASE_HELPER_PATH . '/refill/afand/RefillPhone.php');
+require_once(BASE_HELPER_PATH . '/refill/afand/RefillCallBack.php');
+
 use Log;
 use mtopcard;
 use QueueClient;

+ 53 - 0
helper/refill/afand/RefillCallBack.php

@@ -0,0 +1,53 @@
+<?php
+
+
+namespace refill\afand;
+
+require_once(BASE_HELPER_PATH . '/refill/afand/config.php');
+
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $content  = config::MCHID . $params['pt_order_id'] . $params['mch_order_id'] . $params['op_order_id'] . $params['tel'];
+        $content .= $params['price'] . $params['pay_type'] . $params['status'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['mch_order_id'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+        $order_id = $order_info['order_id'];
+        
+        $data['official_sn'] = strtolower($params['op_order_id']) == 'null' ? '' : $params['op_order_id'];
+        Model('refill_order')->edit($order_id, $data);
+
+        if ($status === 1) {
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 0) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 110 - 0
helper/refill/afand/RefillPhone.php

@@ -0,0 +1,110 @@
+<?php
+
+namespace refill\afand;
+
+require_once(BASE_HELPER_PATH . '/refill/afand/config.php');
+
+use refill;
+use Log;
+use mtopcard;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['tel'] = $phone;
+        $params['mch_order_id'] = $order_sn;
+        $params['mchid'] = config::MCHID;
+        $params['price'] = $amount;
+        $params['notify'] = config::NOTIFY_URL;
+        $params['teltype'] = $this->phone_type($phone);
+        $params['timeout'] = 50;
+        $params['time'] = time();
+        $params['rand'] = rand(100000,999999);
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if ($resp['code'] == 0) {
+                return [true, $resp['pt_order_id']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mch_order_id'] = $refill_info['order_sn'];
+        $params['mchid'] = config::MCHID;
+        $params['pt_order_id'] = $refill_info['ch_trade_no'];
+        $params['mch_order_id'] = $refill_info['order_sn'];
+        $params['op_order_id'] = $refill_info['official_sn'];
+        $params['tel'] = $refill_info['card_no'];
+        $params['time'] = time();
+        $params['rand'] = rand(100000,999999);
+        $content = $params['mchid'] . $params['pt_order_id'] . $params['mch_order_id'] . $params['op_order_id'] . $params['tel'] . $params['time'] . $params['rand'] . config::KEY;
+        $params['sign'] = md5($content);
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if ($resp['code'] == 0) {
+                $order_state = '';
+                if ($resp['status'] == 3) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resp['status'] == 4) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($resp['status'] == 2){
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if (empty($order_state)) {
+                    return [false, $resp['data']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = $params['mchid'] . $params['tel'] . $params['mch_order_id'] . $params['price'] . $params['teltype'] . $params['timeout'] . $params['notify'];
+        $content .= $params['time'] . $params['rand'] . $key;
+        return md5($content);
+    }
+
+    private function phone_type($phone)
+    {
+        $card_type = mtopcard\card_type($phone);
+
+        if ($card_type == mtopcard\ChinaMobileCard) {
+            return 2;
+        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
+            return 1;
+        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
+            return 3;
+        }
+    }
+}

+ 15 - 0
helper/refill/afand/config.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\afand;
+
+
+class config
+{
+    const ORDER_URL = 'http://47.98.208.197/api/telpay';
+    const QUERY_URL = 'http://47.98.208.197/api/telpay/query';
+
+    const MCHID = 10019;
+    const KEY = '953b8e10a70ef4e85b77f09448c0e316';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_afand.php";
+}

+ 3 - 3
helper/refill/tianx/RefillCallBack.php

@@ -28,7 +28,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
     public function notify($params)
     {
-        $status = intval($params['code']);
+        $status = intval($params['status']);
         $order_sn = $params['order_id'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
@@ -39,11 +39,11 @@ class RefillCallBack implements refill\IRefillCallBack
         $data['official_sn'] = strtolower($params['out_order_id']) == 'null' ? '' : $params['out_order_id'];
         Model('refill_order')->edit($order_id, $data);
 
-        if ($status === 100) {
+        if ($status === 1) {
             return [$order_id, true, false,true];
         }
         elseif ($status === 0) {
-            return [$order_id, false, false,true];
+            return [$order_id, false, true,true];
         }
         else {
             return [$order_id, false, false,false];

+ 2 - 2
helper/refill/tianx/RefillPhone.php

@@ -42,8 +42,8 @@ class RefillPhone extends refill\IRefillPhone
         } else {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-            if ($resp['code'] == 1) {
-                return [true, $resp['data']];
+            if ($resp['code'] == 0) {
+                return [true, $resp['order_id']];
             } else {
                 return [false, $resp['msg']];
             }

+ 9 - 0
mobile/refill_afand.php

@@ -0,0 +1,9 @@
+<?php
+
+//捷充的回调接口
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('afand',$_POST);
+
+echo ('success');
+

+ 6 - 0
test/TestRefill.php

@@ -101,6 +101,12 @@ class TestRefill extends TestCase
         $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
     }
 
+    public function testAfandPhone()
+    {
+        $providers = new refill\afand\RefillPhone([]);
+        $resp = $providers->add(18518267398, 4, 30, ['order_sn' => $this->make_sn()]);
+    }
+
     public function testYifaPhone()
     {
         $providers = new refill\yifa\RefillPhone([]);