Przeglądaj źródła

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

stanley-king 2 lat temu
rodzic
commit
6d152d644f
37 zmienionych plików z 1231 dodań i 283 usunięć
  1. 16 1
      data/config/yl/refill.ini.php
  2. 1 1
      helper/rbridge/fulu_ylyw/config.php
  3. 19 8
      helper/rbridge/fulu_ylyw/product.php
  4. 5 1
      helper/rbridge/fulu_ylyw/readme.txt
  5. 12 21
      helper/refill/api/xyz/feimingyu/RefillCallBack.php
  6. 52 55
      helper/refill/api/xyz/feimingyu/RefillPhone.php
  7. 50 41
      helper/refill/api/xyz/feimingyu/config.php
  8. BIN
      helper/refill/api/xyz/feimingyu/互联网增值业务接口文档.pdf
  9. BIN
      helper/refill/api/xyz/feimingyu/产品编码.xlsx
  10. 0 8
      helper/refill/api/xyz/feimingyu/北京椰子对接信息.txt
  11. 0 8
      helper/refill/api/xyz/feimingyu/对接信息.txt
  12. 33 0
      helper/refill/api/xyz/feimingyu/开户信息.txt
  13. 48 0
      helper/refill/api/xyz/huiyuan/RefillCallBack.php
  14. 216 0
      helper/refill/api/xyz/huiyuan/RefillPhone.php
  15. 36 0
      helper/refill/api/xyz/huiyuan/api.txt
  16. 74 0
      helper/refill/api/xyz/huiyuan/config.php
  17. BIN
      helper/refill/api/xyz/huiyuan/retCode接口状态梳理.xlsx
  18. BIN
      helper/refill/api/xyz/huiyuan/直充商品--直连接口文档(800j).doc
  19. 11 0
      helper/refill/api/xyz/yongjia/API信息.txt
  20. 48 0
      helper/refill/api/xyz/yongjia/RefillCallBack.php
  21. 143 0
      helper/refill/api/xyz/yongjia/RefillOil.php
  22. 30 0
      helper/refill/api/xyz/yongjia/config.php
  23. 13 22
      helper/refill/api/yl/feimingyu/RefillCallBack.php
  24. 52 55
      helper/refill/api/yl/feimingyu/RefillPhone.php
  25. 50 41
      helper/refill/api/yl/feimingyu/config.php
  26. BIN
      helper/refill/api/yl/feimingyu/互联网增值业务接口文档.pdf
  27. BIN
      helper/refill/api/yl/feimingyu/产品编码.xlsx
  28. 0 8
      helper/refill/api/yl/feimingyu/北京椰子对接信息.txt
  29. 0 8
      helper/refill/api/yl/feimingyu/对接信息.txt
  30. 33 0
      helper/refill/api/yl/feimingyu/开户信息.txt
  31. 76 0
      helper/refill/api/yl/zhiyuan/RefillCallBack.php
  32. 161 0
      helper/refill/api/yl/zhiyuan/RefillPhone.php
  33. 7 0
      helper/refill/api/yl/zhiyuan/api.txt
  34. 13 0
      helper/refill/api/yl/zhiyuan/config.php
  35. 1 1
      mobile/callback/refill_feimingyu.php
  36. 4 0
      mobile/callback/refill_zhiyuan.php
  37. 27 4
      test/TestRefill.php

+ 16 - 1
data/config/yl/refill.ini.php

@@ -7182,6 +7182,20 @@ $meihan_fs_phone = ['name' => 'meihan_fs', 'store_id' => 267, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$zhiyuan_phone = ['name' => 'zhiyuan', 'store_id' => 268, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 8218, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 8219, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 8220, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 8221, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 8222, 'price' => 100, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 8223, 'price' => 200, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 8224, 'price' => 300, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 8225, 'price' => 500, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7294,7 +7308,7 @@ $phone_providers = [
     ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
     ['name' => 'linzhu', 'cfg' => $linzhu_phone],
 //    ['name' => 'huafutongman', 'cfg' => $huafutongman_phone],
-//    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone],
+    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone],
     ['name' => 'dashang_normal', 'cfg' => $dashang_normal_phone],
     ['name' => 'yunchonggongfs', 'cfg' => $yunchonggongfs_phone],
 //    ['name' => 'dingchi', 'cfg' => $dingchi_phone],
@@ -7408,6 +7422,7 @@ $phone_providers = [
     ['name' => 'siyicheng', 'cfg' => $siyicheng_phone],
     ['name' => 'meihan', 'cfg' => $meihan_phone],
     ['name' => 'meihan_fs', 'cfg' => $meihan_fs_phone],
+    ['name' => 'zhiyuan', 'cfg' => $zhiyuan_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 1 - 1
helper/rbridge/fulu_ylyw/config.php

@@ -4,7 +4,7 @@ namespace rbridge\fulu_ylyw;
 
 class config
 {
-    const DEFAULT_MCHID = 10320;
+    const DEFAULT_MCHID = 10326;
     const MCH_KEY  = '';
     const MCH_NOTIFY_URL = 'fulu_ylyw';
 

+ 19 - 8
helper/rbridge/fulu_ylyw/product.php

@@ -4,19 +4,30 @@ namespace rbridge\fulu_ylyw;
 
 global $fulu_ylyw_product;
 $fulu_ylyw_product = [
-    10320 => [
+// 椰子
+//    10320 => [
+//        //移动
+//        502540719 => [4, 5, 6],
+//        503196622 => [4, 5, 6],
+//        508604768 => [4, 5, 6],
+//        506875500 => [4, 5, 6],
+//    ],
+//
+//    10327 => [
+//        //移动
+//        509090268 => [4, 5, 6],
+//        507634297 => [4, 5, 6],
+//        503855886 => [4, 5, 6],
+//    ],
+
+
+// 椰林
+    10326 => [
         //移动
         502540719 => [4, 5, 6],
         503196622 => [4, 5, 6],
         508604768 => [4, 5, 6],
         506875500 => [4, 5, 6],
     ],
-
-    10327 => [
-        //移动
-        509090268 => [4, 5, 6],
-        507634297 => [4, 5, 6],
-        503855886 => [4, 5, 6],
-    ],
 ];
 

+ 5 - 1
helper/rbridge/fulu_ylyw/readme.txt

@@ -36,4 +36,8 @@ https://www.xyzshops.cn/mobile/bridge/fulu_ylyw.php
 2023.1.2
 下架 509090268 三网通话费-全国-50元-直充-【95%成功率1-15分回调】
 下架 507634297 三网通话费-全国-100元-直充-【95%成功率 1-15分回调】
-下架 503855886 三网通话费-全国-200元-直充-【95%成功率 1-15分回调】
+下架 503855886 三网通话费-全国-200元-直充-【95%成功率 1-15分回调】
+
+2023.4.22
+10326 替换 10320
+https://ylapi.xyzshops.cn/mobile/bridge/fulu_ylyw.php

+ 12 - 21
helper/refill/api/xyz/feimingyu/RefillCallBack.php

@@ -4,15 +4,13 @@ namespace refill\feimingyu;
 require_once(BASE_HELPER_RAPI_PATH . '/feimingyu/config.php');
 
 use refill;
-
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
         $input = $params;
         unset($input['sign']);
-        unset($input['voucher']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -20,32 +18,25 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function sign($params)
-    {
-        ksort($params);
-        $str = implode('', $params);
-        $str .= config::KEY;
-        return strtoupper(md5($str));
-    }
-
     public function notify($params)
     {
-        $status = $params['state'];
-        $order_sn = $params['user_order'];
+        $status = $params['orderStatus'];
+        $order_sn = $params['applyNo'];
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         if (empty($order_info)) {
-            return [false, false, false,false];
+            return [false, false, false, false, ''];
         }
 
         $order_id = $order_info['order_id'];
-        if ($status === 'success') {
-            $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+        if ($status === 'SUCCESS') {
+            $official_sn = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            $data['official_sn'] = $official_sn;
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false, true];
-        } elseif ($status === 'failed') {
-            return [$order_id, false, true, true];
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 'FAILED') {
+            return [$order_id, false, true, true, ''];
         } else {
-            return [$order_id, false, false, false];
+            return [$order_id, false, false, false, ''];
         }
     }
-}
+}

+ 52 - 55
helper/refill/api/xyz/feimingyu/RefillPhone.php

@@ -1,5 +1,4 @@
 <?php
-declare(strict_types=0);
 
 namespace refill\feimingyu;
 
@@ -17,14 +16,13 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['buy_type'] = 1;
-        $params['account'] = $phone;
-        $params['product_id'] = config::Products[$card_type][$amount];
-        $params['amount'] = $amount;
-        $params['user_order'] = $order_sn;
-
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['applyNo'] = $order_sn;
+        $params['rechargeNo'] = $phone;
+        $params['agentProductId'] = config::PRODUCT[$card_type][$amount];
+        $params['denomination'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
         return $params;
     }
 
@@ -32,11 +30,13 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-        $sign = $this->sign($params);
+        if(empty($params['agentProductId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $sign = config::sign($params);
         $params['sign'] = $sign;
-        $params['cat_id'] = config::operator[$card_type];
 
-        $resp = http_request(config::ORDER_URL, $params, 'GET', false, [], $net_errno);
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
         if (empty($resp)) {
             return [false, '网络错误', true];
@@ -47,72 +47,68 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            }
-            $status = $resp['status'];
-
-            if ($status === '0') {
-                return [true, $resp['order_id'], false];
-            } elseif (in_array($status, config::ERR_NOS, true)) {
-                return [false, $resp['msg'], false];
-            } elseif (in_array($status, ['110', '113', '-999'], true)) {
-                $net_errno = "HTTP-{$status}";
+            } elseif ($resp['code'] === '00000') {
+                return [true, $resp['data']['orderNo'], false];
+            } elseif ($resp['code'] === 'A0503') {
+                $net_errno = "HTTP-{$resp['code']}";
                 return [false, $resp['msg'], true];
             } else {
-                //未知状态码
-                $net_errno = "HTTP-998";
-                return [false, $resp['msg'], true];
+                return [false, $resp['msg'], false];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['user_order'] = $refill_info['order_sn'];
-        $params['sign'] = $this->sign($params);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['applyNo'] = $refill_info['order_sn'];
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::QUERY_URL, $params);
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
         if (empty($resp)) {
-            return [false, '网络错误'];
+            return [false, '网络错误', ''];
         }
         else
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-            if (empty($resp))
-            {
-                return [false, '网络错误'];
+            if (empty($resp)) {
+                return [false, '网络错误', ''];
             }
-            elseif ($resp['status'] === '0')
+            elseif ($resp['code'] === '00000')
             {
-                $status = $resp['state'];
-                if ($status === 'success') {
-                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['voucher']]);
+                $offical_sn = '';
+                $status = $resp['data']['orderStatus'];
+                if ($status === 'SUCCESS') {
+                    $offical_sn = $resp['data']['ext1'];
+                    $updata['official_sn'] = $offical_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status === 'failed') {
+                } elseif ($status === 'FAILED') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status === 'untreated') {
+                } elseif ($status === 'PROCESSING' || $status === 'INIT') {
                     $order_state = ORDER_STATE_SEND;
                 } else {
-                    return [false, $status];
+                    return [false, $resp['msg'], $offical_sn];
                 }
-                return [true, $order_state];
+                return [true, $order_state, $offical_sn];
             }
-            else {
-                return [false, $resp['msg']];
+            else
+            {
+                return [false, $resp['msg'], ''];
             }
         }
     }
 
     public function balance()
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['sign'] = $this->sign($params);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::BALANCE_URL, $params);
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -123,19 +119,20 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['status'] === '0') {
-                return [true, $resp['balance']];
+            } elseif ($resp['code'] === '00000') {
+                return [true, $resp['data']['balance']];
             } else {
                 return [false, $resp['msg']];
             }
         }
     }
 
-    private function sign($params)
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
     {
-        ksort($params);
-        $str = implode('', $params);
-        $str .= config::KEY;
-        return strtoupper(md5($str));
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
     }
-}
+}

+ 50 - 41
helper/refill/api/xyz/feimingyu/config.php

@@ -6,50 +6,59 @@ namespace refill\feimingyu;
 use mtopcard;
 class config
 {
-    //回调地址需配置
-    const ORDER_URL = 'http://47.98.163.205:80/recharge/buy.do';
-    const QUERY_URL= 'http://47.98.163.205:80/recharge/query.do';
-    const BALANCE_URL = 'http://47.98.163.205:80/user/balance.do';
+    const ORDER_URL = 'http://119.91.194.222:9999/api/v1/order/submit';
+    const QUERY_URL = 'http://119.91.194.222:9999/api/v1/order/query';
+    const BALANCE_URL = 'http://119.91.194.222:9999/api/v1/agent/balance';
 
-    const USER_ID= '69876';
-    const KEY = 'AC7F7353AAA6';
+    const APP_ID = 'VIP006';
+    const APP_SECRET = 'Ik5APKkMhUJ9NQ6ntJ2R7g==';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feimingyu.php";
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 334,
+            50  => 335,
+            100 => 336,
+            200 => 337,
+        ],
 
-    const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
+        mtopcard\ChinaUnicomCard => [
+            30  => 331,
+            50  => 330,
+            100 => 332,
+            200 => 333,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 338,
+            50  => 339,
+            100 => 340,
+            200 => 341,
+        ]
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
-    const Products = [
-        mtopcard\ChinaMobileCard =>
-            [
-                30  => 20003,
-                50  => 20004,
-                100 => 20005,
-                200 => 20006,
-                300 => 20007,
-                500 => 20008
-            ],
-        mtopcard\ChinaUnicomCard =>
-            [
-                30  => 20011,
-                50  => 20012,
-                100 => 20013,
-                200 => 20014,
-                300 => 20015,
-                500 => 20016
-            ],
-        mtopcard\ChinaTelecomCard =>
-            [
-                30  => 20019,
-                50  => 20020,
-                100 => 20021,
-                200 => 20022,
-                300 => 20023,
-                500 => 20024
-            ]
-    ];
+    public static function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
 
-    const ERR_NOS = ['101', '102', '103', '104', '105', '106', '107', '108', '109', '100', '112', '115', '116', '117', '118', '119', '120'];
-}
+        return false;
+    }
+}

BIN
helper/refill/api/xyz/feimingyu/互联网增值业务接口文档.pdf


BIN
helper/refill/api/xyz/feimingyu/产品编码.xlsx


+ 0 - 8
helper/refill/api/xyz/feimingyu/北京椰子对接信息.txt

@@ -1,8 +0,0 @@
-客户端入口:http://47.98.163.205:80/
-下单接口:http://47.98.163.205:80/recharge/buy.do
-订单查询:http://47.98.163.205:80/recharge/query.do
-余额查询:http://47.98.163.205:80/user/balance.do
-帐号:北京椰子
-密码:123456
-用户编号:69876
-秘钥:AC7F7353AAA6

+ 0 - 8
helper/refill/api/xyz/feimingyu/对接信息.txt

@@ -1,8 +0,0 @@
-客户端入口:http://47.98.163.205:80/
-下单接口:http://47.98.163.205:80/recharge/buy.do
-订单查询:http://47.98.163.205:80/recharge/query.do
-余额查询:http://47.98.163.205:80/user/balance.do
-帐号:北京椰子
-密码:123456
-用户编号:69876
-秘钥:AC7F7353AAA6

+ 33 - 0
helper/refill/api/xyz/feimingyu/开户信息.txt

@@ -0,0 +1,33 @@
+后台地址:http://119.91.194.222/login
+账号:VIP006
+默认密码:123456
+
+APPID:VIP006
+APPSECRET:Ik5APKkMhUJ9NQ6ntJ2R7g==
+
+后台-产品列表,可查看已配置商品信息
+后台-个人中心,可配置IP白名单
+回调地址请在提单接口动态传入
+产品已配置,产品ID请登录后台进行查看
+
+对接文档: https://galaxy168.yuque.com/yxumsu/dbqgf8?#%20%E3%80%8A%E6%98%9F%E4%BA%91%E5%B9%B3%E5%8F%B0%E3%80%8B
+
+话费直充接口:http://119.91.194.222:9999/api/v1/order/submit
+订单查询接口:http://119.91.194.222:9999/api/v1/order/query
+余额查询接口:http://119.91.194.222:9999/api/v1/agent/balance
+
+
+334	全国移动快充30
+335	全国移动快充50
+336	全国移动快充100
+337	全国移动快充200
+
+331	全国联通快充30
+330	全国联通快充50
+332	全国联通快充100
+333	全国联通快充200
+
+338	全国电信快充30
+339	全国电信快充50
+340	全国电信快充100
+341	全国电信快充200

+ 48 - 0
helper/refill/api/xyz/huiyuan/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\huiyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/huiyuan/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $agent_id = config::AGENT_ID;
+        $key = config::KEY;
+        $content = "agent_id={$agent_id}&bill_id={$params['bill_id']}&jnet_bill_no={$params['jnet_bill_no']}&par_price={$params['par_price']}&purchase_amt={$params['purchase_amt']}";
+        $content .= "&bill_charge_time={$params['bill_charge_time']}&bill_status={$params['bill_status']}|||{$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['bill_status'];
+        $order_sn = $params['bill_id'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+        $order_id = $order_info['order_id'];
+
+        if ($status === '成功') {
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === '失败') {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 216 - 0
helper/refill/api/xyz/huiyuan/RefillPhone.php

@@ -0,0 +1,216 @@
+<?php
+
+namespace refill\huiyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/huiyuan/config.php');
+
+use refill;
+use Log;
+use QueueClient;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    {
+        $params['agent_id'] = config::AGENT_ID;
+        $params['bill_id'] = $order_sn;
+        $params['bill_time'] = date("YmdHis", time()-1);
+        $params['supply_type'] = 1;
+        $params['supply_id'] = 1;
+        $params['product_code'] = config::Product[$card_type][$amount];
+        $params['product_num'] = 1;
+        $params['region_id'] = -1;
+        $params['server_id'] = -1;
+        $params['charge_account'] = $phone;
+        $params['charge_amt'] = config::charge_amt[$amount];
+        $params['client_ip'] = config::API_IP;
+        $params['notify_url'] = config::NOTIFY_URL;
+        $params['time_stamp'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_id = $params['order_id'];
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->decode_tag($resp);
+
+            $ret_code = $resp['ret_code'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+            elseif ($ret_code === '0')
+            {
+                $bill_status = $resp['bill_status'];
+                if ($bill_status === '成功' || $bill_status === '失败') {
+                    QueueClient::async_push("QueryRefillState",['order_id' => $order_id],5);
+                }
+                return [true, $resp['jnet_bill_no'], false];
+            }
+            elseif (in_array($ret_code, ['-1', '997', '998'], true))
+            {
+                QueueClient::async_push("QueryRefillState",['order_id' => $order_id],5);
+                return [true, $resp['jnet_bill_no'], false];
+            }
+            elseif (in_array($ret_code, config::ERR_NOS, true))
+            {
+                return [false, $resp['ret_msg'], false];
+            }
+            elseif (in_array($ret_code, ['5', '100', '999'], true))
+            {
+                $net_errno = "HTTP-{$ret_code}";
+                return [false, $resp['ret_msg'], true];
+            }
+            else
+            {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['ret_msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['agent_id'] = config::AGENT_ID;
+        $params['bill_id'] = $refill_info['order_sn'];
+        $params['time_stamp'] = date("YmdHis");
+
+        $key = config::KEY;
+        $content = "agent_id={$params['agent_id']}&bill_id={$params['bill_id']}&time_stamp={$params['time_stamp']}|||{$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            $resp = $this->decode_tag($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            elseif ($resp['ret_code'] === '0')
+            {
+                $status = $resp['bill_status'];
+                if ($status === '成功') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '失败') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '处理中') {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['ret_msg']];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['ret_code'] === '-1')
+            {
+                if($resp['bill_status'] === '失败' ||$resp['ret_msg'] === '接口单失败'){
+                    return [true, ORDER_STATE_CANCEL];
+                }else{
+                    return [false, $resp['ret_msg']];
+                }
+            }
+            elseif ($resp['ret_code'] === '8' && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['ret_msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['agent_id'] = config::AGENT_ID;
+        $params['time_stamp'] = date("YmdHis");
+
+        $key = config::KEY;
+        $content = "agent_id={$params['agent_id']}&time_stamp={$params['time_stamp']}|||{$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->decode_tag($resp);
+
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['ret_code'] === '0') {
+                return [true, $resp['can_used_amt']];
+            } else {
+                return [false, $resp['ret_msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content = "agent_id={$params['agent_id']}&bill_id={$params['bill_id']}&bill_time={$params['bill_time']}&supply_type={$params['supply_type']}&supply_id={$params['supply_id']}";
+        $content .= "&product_code={$params['product_code']}&product_num={$params['product_num']}&region_id={$params['region_id']}&server_id={$params['server_id']}";
+        $content .= "&charge_account={$params['charge_account']}&time_stamp={$params['time_stamp']}|||{$key}";
+        return md5($content);
+    }
+
+    public function decode_tag($squery)
+    {
+        if(empty($squery)) return false;
+        $squery = mb_convert_encoding($squery, "UTF-8", "GB2312");
+        $squery = urldecode($squery);
+
+        $result = [];
+        $params = preg_split('/&/', $squery);
+        foreach ($params as $pair)
+        {
+            if(empty($pair)) continue;
+
+            $kv = explode('=', $pair);
+            $count = count($kv);
+            if($count === 1) {
+                $key = $kv[0];
+                $val = "";
+            }
+            elseif($count === 2) {
+                $key = $kv[0];
+                $val = urldecode($kv[1]);
+            }
+            else {
+                continue;
+            }
+
+            if(!empty($key)) {
+                $result[$key] = $val;
+            }
+        }
+
+        return $result;
+    }
+}

+ 36 - 0
helper/refill/api/xyz/huiyuan/api.txt

@@ -0,0 +1,36 @@
+账号:guoyan123
+密码:guoyan131419
+www.800jun.com
+
+商户ID:2145738
+签名密钥:4458A6BD7839
+
+
+产品编码
+
+ABJSUPZGYD010CZ:中国移动_10元直充
+ABJSUPZGYD020CZ:中国移动_20元直充
+ABJSUPZGYD030CZ:中国移动_30元直充
+ABJSUPZGYD050CZ:中国移动_50元直充
+ABJSUPZGYD100CZ:中国移动_100元直充
+ABJSUPZGYD200CZ:中国移动_200元直充
+ABJSUPZGYD300CZ:中国移动_300元直充
+ABJSUPZGYD500CZ:中国移动_500元直充
+
+ABJSUPZGLT010CZ:中国联通_10元直充
+ABJSUPZGLT020CZ:中国联通_20元直充
+ABJSUPZGLT030CZ:中国联通_30元直充
+ABJSUPZGLT050CZ:中国联通_50元直充
+ABJSUPZGLT100CZ:中国联通_100元直充
+ABJSUPZGLT200CZ:中国联通_200元直充
+ABJSUPZGLT300CZ:中国联通_300元直充
+ABJSUPZGLT500CZ:中国联通_500元直充
+
+ABJSUPZGDX010CZ:中国电信_10元直充
+ABJSUPZGDX020CZ:中国电信_20元直充
+ABJSUPZGDX030CZ:中国电信_30元直充
+ABJSUPZGDX050CZ:中国电信_50元直充
+ABJSUPZGDX100CZ:中国电信_100元直充
+ABJSUPZGDX200CZ:中国电信_200元直充
+ABJSUPZGDX300CZ:中国电信_300元直充
+ABJSUPZGDX500CZ:中国电信_500元直充

+ 74 - 0
helper/refill/api/xyz/huiyuan/config.php

@@ -0,0 +1,74 @@
+<?php
+
+
+namespace refill\huiyuan;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://Service.800j.com/Charge/Submit.aspx';
+    const QUERY_URL= 'http://Service.800j.com/Charge/Query.aspx';
+    const BALANCE_URL = 'http://Service.800j.com/Common/BalanceQueryService.aspx';
+
+    const AGENT_ID= '2145738';
+    const KEY = '4458A6BD7839';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_huiyuan.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+
+    const API_IP = NET_IP;
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=GB2312'];
+
+    const ERR_NOS = [
+        '1', '2', '3', '4', '6', '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18'
+    ];
+
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            10 => 'ABJSUPZGYD010CZ',
+            20 => 'ABJSUPZGYD020CZ',
+            30 => 'ABJSUPZGYD030CZ',
+            50 => 'ABJSUPZGYD050CZ',
+            100 => 'ABJSUPZGYD100CZ',
+            200 => 'ABJSUPZGYD200CZ',
+            300 => 'ABJSUPZGYD300CZ',
+            500 => 'ABJSUPZGYD500CZ',
+        ],
+        mtopcard\ChinaUnicomCard => [
+            10 => 'ABJSUPZGLT010CZ',
+            20 => 'ABJSUPZGLT020CZ',
+            30 => 'ABJSUPZGLT030CZ',
+            50 => 'ABJSUPZGLT050CZ',
+            100 => 'ABJSUPZGLT100CZ',
+            200 => 'ABJSUPZGLT200CZ',
+            300 => 'ABJSUPZGLT300CZ',
+            500 => 'ABJSUPZGLT500CZ',
+        ],
+        mtopcard\ChinaTelecomCard => [
+            10 => 'ABJSUPZGDX010CZ',
+            20 => 'ABJSUPZGDX020CZ',
+            30 => 'ABJSUPZGDX030CZ',
+            50 => 'ABJSUPZGDX050CZ',
+            100 => 'ABJSUPZGDX100CZ',
+            200 => 'ABJSUPZGDX200CZ',
+            300 => 'ABJSUPZGDX300CZ',
+            500 => 'ABJSUPZGDX500CZ',
+        ],
+    ];
+
+    const charge_amt = [
+        10 => 10.5,
+        20 => 20.1,
+        30 => 30.1,
+        50 => 50.1,
+        100 => 100.1,
+        200 => 200.1,
+        300 => 300.1,
+        500 => 500.1,
+    ];
+}

BIN
helper/refill/api/xyz/huiyuan/retCode接口状态梳理.xlsx


BIN
helper/refill/api/xyz/huiyuan/直充商品--直连接口文档(800j).doc


+ 11 - 0
helper/refill/api/xyz/yongjia/API信息.txt

@@ -0,0 +1,11 @@
+测试参数
+ID:1
+秘钥:52e4fd509410446a8259fd8a93de6c85
+
+
+下单地址:http://123.56.68.57:1008/hqorder/api/submit
+查询地址:http://123.56.68.57:1008/hqorder/api/query
+查询余额地址:http://123.56.68.57:1008/hqorder/api/balance
+
+测试产品(需传产品编码)
+3000200	全国电信200元

+ 48 - 0
helper/refill/api/xyz/yongjia/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\yongjia;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yongjia/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)
+    {
+        $mchid = config::MCHID;
+        $key = config::KEY;
+        $content  = "mchid={$mchid}&orderid={$params['orderid']}&oid={$params['oid']}&number={$params['number']}&status={$params['status']}&key={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $order_sn = $params['orderid'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        $status = intval($params['status']);
+        if ($status === 2) {
+            $official_sn = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 143 - 0
helper/refill/api/xyz/yongjia/RefillOil.php

@@ -0,0 +1,143 @@
+<?php
+
+namespace refill\yongjia;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yongjia/config.php');
+
+use refill;
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $card_type, int $amount, string $order_sn)
+    {
+        $params['mchid'] = config::MCHID;
+        $params['orderid'] = $order_sn;
+        $params['number'] = $phone;
+        $params['productid'] = config::PRODUCT[$card_type][$amount];
+        $params['timestamp'] = $this->getMillisecond();
+        $params['backurl'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $input, &$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $input['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['status'] === 0) {
+                return [true, $resp['oid'], false];
+            } elseif ($resp['status'] === -1) {
+                return [false, $resp['msg'], false];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mchid'] = config::MCHID;
+        $params['orderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "mchid={$params['mchid']}&orderid={$params['orderid']}&key={$key}";
+        $params['sign'] = md5($content);
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', ''];
+            }
+            else {
+                $offical_sn = '';
+                $status = $resp['status'];
+                if ($status === 2) {
+                    $offical_sn = $resp['voucher'];
+                    $updata['official_sn'] = $offical_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 1) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === 4 && (time() - $refill_info['commit_time'] > 300)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $status, $offical_sn];
+                }
+                return [true, $order_state, $offical_sn];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['mchid'] = config::MCHID;
+        $key = config::KEY;
+        $content = "mchid={$params['mchid']}&key={$key}";
+        $params['sign'] = md5($content);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::BALANCE_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['status'] === 1) {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = "mchid={$params['mchid']}&orderid={$params['orderid']}&number={$params['number']}&productid={$params['productid']}";
+        $content .= "&timestamp={$params['timestamp']}&key={$key}";
+        return md5($content);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        return intval($cur * 1000);
+    }
+}

+ 30 - 0
helper/refill/api/xyz/yongjia/config.php

@@ -0,0 +1,30 @@
+<?php
+
+
+namespace refill\yongjia;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://123.56.68.57:1008/hqorder/api/submit';
+    const QUERY_URL = 'http://123.56.68.57:1008/hqorder/api/query';
+    const BALANCE_URL = 'http://123.56.68.57:1008/hqorder/api/balance';
+
+    const MCHID = '1';
+    const KEY = '52e4fd509410446a8259fd8a93de6c85';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yongjia.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            200 => 3000200
+        ]
+    ];
+    const ExtHeaders = ['Content-Type: application/json'];
+}

+ 13 - 22
helper/refill/api/yl/feimingyu/RefillCallBack.php

@@ -4,15 +4,13 @@ namespace refill\feimingyu;
 require_once(BASE_HELPER_RAPI_PATH . '/feimingyu/config.php');
 
 use refill;
-
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
         $input = $params;
         unset($input['sign']);
-        unset($input['voucher']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -20,32 +18,25 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function sign($params)
-    {
-        ksort($params);
-        $str = implode('', $params);
-        $str .= config::KEY;
-        return strtoupper(md5($str));
-    }
-
     public function notify($params)
     {
-        $status = $params['state'];
-        $order_sn = $params['user_order'];
-        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        $status = $params['orderStatus'];
+        $order_sn = $params['applyNo'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         if (empty($order_info)) {
-            return [false, false, false,false];
+            return [false, false, false, false, ''];
         }
 
         $order_id = $order_info['order_id'];
-        if ($status === 'success') {
-            $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+        if ($status === 'SUCCESS') {
+            $official_sn = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            $data['official_sn'] = $official_sn;
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false, true];
-        } elseif ($status === 'failed') {
-            return [$order_id, false, true, true];
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 'FAILED') {
+            return [$order_id, false, true, true, ''];
         } else {
-            return [$order_id, false, false, false];
+            return [$order_id, false, false, false, ''];
         }
     }
-}
+}

+ 52 - 55
helper/refill/api/yl/feimingyu/RefillPhone.php

@@ -1,5 +1,4 @@
 <?php
-declare(strict_types=0);
 
 namespace refill\feimingyu;
 
@@ -17,14 +16,13 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['buy_type'] = 1;
-        $params['account'] = $phone;
-        $params['product_id'] = config::Products[$card_type][$amount];
-        $params['amount'] = $amount;
-        $params['user_order'] = $order_sn;
-
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['applyNo'] = $order_sn;
+        $params['rechargeNo'] = $phone;
+        $params['agentProductId'] = config::PRODUCT[$card_type][$amount];
+        $params['denomination'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
         return $params;
     }
 
@@ -32,11 +30,13 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-        $sign = $this->sign($params);
+        if(empty($params['agentProductId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $sign = config::sign($params);
         $params['sign'] = $sign;
-        $params['cat_id'] = config::operator[$card_type];
 
-        $resp = http_request(config::ORDER_URL, $params, 'GET', false, [], $net_errno);
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
         if (empty($resp)) {
             return [false, '网络错误', true];
@@ -47,72 +47,68 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            }
-            $status = $resp['status'];
-
-            if ($status === '0') {
-                return [true, $resp['order_id'], false];
-            } elseif (in_array($status, config::ERR_NOS, true)) {
-                return [false, $resp['msg'], false];
-            } elseif (in_array($status, ['110', '113', '-999'], true)) {
-                $net_errno = "HTTP-{$status}";
+            } elseif ($resp['code'] === '00000') {
+                return [true, $resp['data']['orderNo'], false];
+            } elseif ($resp['code'] === 'A0503') {
+                $net_errno = "HTTP-{$resp['code']}";
                 return [false, $resp['msg'], true];
             } else {
-                //未知状态码
-                $net_errno = "HTTP-998";
-                return [false, $resp['msg'], true];
+                return [false, $resp['msg'], false];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['user_order'] = $refill_info['order_sn'];
-        $params['sign'] = $this->sign($params);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['applyNo'] = $refill_info['order_sn'];
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::QUERY_URL, $params);
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
         if (empty($resp)) {
-            return [false, '网络错误'];
+            return [false, '网络错误', ''];
         }
         else
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-            if (empty($resp))
-            {
-                return [false, '网络错误'];
+            if (empty($resp)) {
+                return [false, '网络错误', ''];
             }
-            elseif ($resp['status'] === '0')
+            elseif ($resp['code'] === '00000')
             {
-                $status = $resp['state'];
-                if ($status === 'success') {
-                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['voucher']]);
+                $offical_sn = '';
+                $status = $resp['data']['orderStatus'];
+                if ($status === 'SUCCESS') {
+                    $offical_sn = $resp['data']['ext1'];
+                    $updata['official_sn'] = $offical_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status === 'failed') {
+                } elseif ($status === 'FAILED') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status === 'untreated') {
+                } elseif ($status === 'PROCESSING' || $status === 'INIT') {
                     $order_state = ORDER_STATE_SEND;
                 } else {
-                    return [false, $status];
+                    return [false, $resp['msg'], $offical_sn];
                 }
-                return [true, $order_state];
+                return [true, $order_state, $offical_sn];
             }
-            else {
-                return [false, $resp['msg']];
+            else
+            {
+                return [false, $resp['msg'], ''];
             }
         }
     }
 
     public function balance()
     {
-        $params['userid'] = config::USER_ID;
-        $params['create_time'] = date("YmdHis");
-        $params['sign'] = $this->sign($params);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::BALANCE_URL, $params);
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -123,19 +119,20 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['status'] === '0') {
-                return [true, $resp['balance']];
+            } elseif ($resp['code'] === '00000') {
+                return [true, $resp['data']['balance']];
             } else {
                 return [false, $resp['msg']];
             }
         }
     }
 
-    private function sign($params)
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
     {
-        ksort($params);
-        $str = implode('', $params);
-        $str .= config::KEY;
-        return strtoupper(md5($str));
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
     }
-}
+}

+ 50 - 41
helper/refill/api/yl/feimingyu/config.php

@@ -6,50 +6,59 @@ namespace refill\feimingyu;
 use mtopcard;
 class config
 {
-    //回调地址需配置
-    const ORDER_URL = 'http://47.98.163.205:80/recharge/buy.do';
-    const QUERY_URL= 'http://47.98.163.205:80/recharge/query.do';
-    const BALANCE_URL = 'http://47.98.163.205:80/user/balance.do';
+    const ORDER_URL = 'http://119.91.194.222:9999/api/v1/order/submit';
+    const QUERY_URL = 'http://119.91.194.222:9999/api/v1/order/query';
+    const BALANCE_URL = 'http://119.91.194.222:9999/api/v1/agent/balance';
 
-    const USER_ID= '69876';
-    const KEY = 'AC7F7353AAA6';
+    const APP_ID = 'VIP007';
+    const APP_SECRET = 'UuF9LDamNNYV70iZ8hjHdQ==';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feimingyu.php";
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 347,
+            50  => 348,
+            100 => 349,
+            200 => 350,
+        ],
 
-    const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
+        mtopcard\ChinaUnicomCard => [
+            30  => 344,
+            50  => 343,
+            100 => 345,
+            200 => 346,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 351,
+            50  => 352,
+            100 => 353,
+            200 => 354,
+        ]
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
-    const Products = [
-        mtopcard\ChinaMobileCard =>
-            [
-                30  => 20003,
-                50  => 20004,
-                100 => 20005,
-                200 => 20006,
-                300 => 20007,
-                500 => 20008
-            ],
-        mtopcard\ChinaUnicomCard =>
-            [
-                30  => 20011,
-                50  => 20012,
-                100 => 20013,
-                200 => 20014,
-                300 => 20015,
-                500 => 20016
-            ],
-        mtopcard\ChinaTelecomCard =>
-            [
-                30  => 20019,
-                50  => 20020,
-                100 => 20021,
-                200 => 20022,
-                300 => 20023,
-                500 => 20024
-            ]
-    ];
+    public static function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
 
-    const ERR_NOS = ['101', '102', '103', '104', '105', '106', '107', '108', '109', '100', '112', '115', '116', '117', '118', '119', '120'];
-}
+        return false;
+    }
+}

BIN
helper/refill/api/yl/feimingyu/互联网增值业务接口文档.pdf


BIN
helper/refill/api/yl/feimingyu/产品编码.xlsx


+ 0 - 8
helper/refill/api/yl/feimingyu/北京椰子对接信息.txt

@@ -1,8 +0,0 @@
-客户端入口:http://47.98.163.205:80/
-下单接口:http://47.98.163.205:80/recharge/buy.do
-订单查询:http://47.98.163.205:80/recharge/query.do
-余额查询:http://47.98.163.205:80/user/balance.do
-帐号:北京椰子
-密码:123456
-用户编号:69876
-秘钥:AC7F7353AAA6

+ 0 - 8
helper/refill/api/yl/feimingyu/对接信息.txt

@@ -1,8 +0,0 @@
-客户端入口:http://47.98.163.205:80/
-下单接口:http://47.98.163.205:80/recharge/buy.do
-订单查询:http://47.98.163.205:80/recharge/query.do
-余额查询:http://47.98.163.205:80/user/balance.do
-帐号:北京椰子
-密码:123456
-用户编号:69876
-秘钥:AC7F7353AAA6

+ 33 - 0
helper/refill/api/yl/feimingyu/开户信息.txt

@@ -0,0 +1,33 @@
+后台地址:http://119.91.194.222/login
+账号:VIP007
+默认密码:123456
+
+APPID:VIP007
+APPSECRET:UuF9LDamNNYV70iZ8hjHdQ==
+
+后台-产品列表,可查看已配置商品信息
+后台-个人中心,可配置IP白名单
+回调地址请在提单接口动态传入
+产品已配置,产品ID请登录后台进行查看
+
+对接文档: https://galaxy168.yuque.com/yxumsu/dbqgf8?#%20%E3%80%8A%E6%98%9F%E4%BA%91%E5%B9%B3%E5%8F%B0%E3%80%8B
+
+话费直充接口:http://119.91.194.222:9999/api/v1/order/submit
+订单查询接口:http://119.91.194.222:9999/api/v1/order/query
+余额查询接口:http://119.91.194.222:9999/api/v1/agent/balance
+
+
+347	全国移动快充30
+348	全国移动快充50
+349	全国移动快充100
+350	全国移动快充200
+
+344	全国联通快充30
+343	全国联通快充50
+345	全国联通快充100
+346	全国联通快充200
+
+351	全国电信快充30
+352	全国电信快充50
+353	全国电信快充100
+354	全国电信快充200

+ 76 - 0
helper/refill/api/yl/zhiyuan/RefillCallBack.php

@@ -0,0 +1,76 @@
+<?php
+namespace refill\zhiyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhiyuan/config.php');
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+
+        $body = "";
+        $i = 0;
+        foreach ($params as $k => $v) {
+            if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
+                if ($i == 0) {
+                    $body .= "{$k}" . "=" . urlencode($v);
+                } else {
+                    $body .= "&" . "{$k}" . "=" . urlencode($v);
+                }
+                $i++;
+            }
+        }
+
+        $body .= "&key=".config::KEY;
+        return md5($body);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['state'];
+        $order_sn = $params['order_sn'];
+        $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'];
+        if ($status === 'SUCCESS') {
+            $data['ch_trade_no'] = $params['trade_no'];
+            $data['official_sn'] = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'CANCEL') {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['trade_no']]);
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 161 - 0
helper/refill/api/yl/zhiyuan/RefillPhone.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace refill\zhiyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhiyuan/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'add';
+        $params['mchid'] = config::MCH_ID;
+        $params['cardno'] = $phone;
+        $params['amount'] = $amount;
+        $params['order_sn'] = $order_sn;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $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 , [] , $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === 200) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'query';
+        $params['mchid'] = config::MCH_ID;
+        $params['order_sn'] = $refill_info['order_sn'];
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['code'] === 200)
+            {
+                $data = $resp['datas'];
+                if ($data['order_state'] == '40') {
+                    $save['ch_trade_no'] = $data['trade_no'];
+                    $save['official_sn'] = strtolower($resp['official_sn']) == 'null' ? '' : $resp['official_sn'];
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['order_state'] === '0') {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $data['trade_no']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($data['order_state'], ['10', '20', '30', '50'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['message']];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['code'] === 202 && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'balance';
+        $params['mchid'] = config::MCH_ID;
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === 200) {
+                return [true, $resp['datas']['balance']];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+
+        $body = "";
+        $i = 0;
+        foreach ($params as $k => $v) {
+            if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
+                if ($i == 0) {
+                    $body .= "{$k}" . "=" . urlencode($v);
+                } else {
+                    $body .= "&" . "{$k}" . "=" . urlencode($v);
+                }
+                $i++;
+            }
+        }
+
+        $body .= "&key=".config::KEY;
+
+        return md5($body);
+    }
+}

+ 7 - 0
helper/refill/api/yl/zhiyuan/api.txt

@@ -0,0 +1,7 @@
+https://co-data.zylife.co//merchant/#/login
+
+yelin
+yelin67890
+
+1
+9e41b0e52d0894fd5dc60e9db84145e2

+ 13 - 0
helper/refill/api/yl/zhiyuan/config.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace refill\zhiyuan;
+
+class config
+{
+    const ORDER_URL = 'https://co-api.zylife.co/mobile/index.php';
+
+    const MCH_ID = 1;
+    const KEY = '9e41b0e52d0894fd5dc60e9db84145e2';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zhiyuan.php";
+
+}

+ 1 - 1
mobile/callback/refill_feimingyu.php

@@ -1,4 +1,4 @@
 <?php
 
 refill\util::push_notify('feimingyu',$_POST);
-echo ('Success');
+echo json_encode(['code' => '00000']);

+ 4 - 0
mobile/callback/refill_zhiyuan.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('zhiyuan',$_POST);
+echo ('SUCCESS');

+ 27 - 4
test/TestRefill.php

@@ -1302,12 +1302,12 @@ class TestRefill extends TestCase
     {
 //        $provider = $this->getProvider('feimingyu');
 //        $resp = $provider->balance();
-//        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '99741635757876781160']);
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn(), 'regin_no' => 18]);
+//        $resp = $provider->query(['order_sn' => '33891681804839775889']);
 
-        $body = '{"userid":"69876","order_id":"21110117111869876daed6b187","account":"18500608333","amount":"30","price":"28.41","state":"failed","user_order":"99741635757876781160","sign":"C82F4821547BBFC462E9758EE28287E1","voucher":""}';
+        $body = '{"finishTime":"20230418160354079","orderNo":"XY3569958846292104149","appId":"VIP006","applyNo":"33891681804839775889","orderStatusDesc":"\u5931\u8d25","sign":"9196fe618512ad84fe1fdbbeb687253a","orderStatus":"FAILED","ext2":"NORMAL_FAILED","timestamp":"20230418160657014"}';
         $params = json_decode($body, true);
-        $provider = $this->getProvider('feimingyu', 'RefillCallBack');
+        $provider = $this->getProvider('feimingyu', 'RefillCallback');
         $ret = $provider->verify($params);
         $resp = $provider->notify($params);
     }
@@ -3249,6 +3249,29 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testYongjia()
+    {
+//        $provider = $this->getProvider('yongjia','RefillOil');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18074608795, 6, 200, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '67461681184143372378']);
+
+        $body = '{"number":"18074608795","mchid":"1","orderid":"67461681184143372378","price":"200.0","voucher":"","sign":"b9c011c70734707b88351ec5efd96d98","oid":134,"status":"3"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('yongjia', 'RefillCallback');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+
+    }
+
+    public function testHuiyuan()
+    {
+        $provider = $this->getProvider('huiyuan');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 10, ['order_sn' => $this->make_sn(), 'regin_no' => 18]);
+        $resp = $provider->query(['order_sn' => '12721681790791705529']);
+    }
+
     public function testDezhi_yi()
     {
         $provider = $this->getProvider('dezhi_yi');