zb727 hai 1 ano
pai
achega
f5f0ae2662

+ 34 - 12
data/config/mh/refill.ini.php

@@ -227,7 +227,7 @@ $seven_kami = ['name' => 'seven_kami', 'store_id' => 387, 'qualitys' => '3',
         ],
         100 => [
             ['goods_id' => 9024, 'price' => 99.95, 'quality' => 3, 'card_type' => 'chinamobile'],
-            ['goods_id' => 9024, 'price' => 97.20, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9024, 'price' => 94.20, 'quality' => 3, 'card_type' => 'chinaunicom'],
             ['goods_id' => 9024, 'price' => 99.99, 'quality' => 3, 'card_type' => 'chinatelecom']
         ],
     ],
@@ -330,12 +330,12 @@ $zhixin_fast = ['name' => 'zhixin_fast', 'store_id' => 391, 'qualitys' => '2',
         200 => [
             ['goods_id' => 9057, 'price' => 200.3,  'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 9057, 'price' => 200.1,  'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 9057, 'price' => 200.3,  'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 9057, 'price' => 200.4,  'quality' => 2, 'card_type' => 'chinatelecom'],
         ],
         300 => [
-            ['goods_id' => 9058, 'price' => 300.45,   'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 9058, 'price' => 300.15,  'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 9058, 'price' => 300.45,  'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 9058, 'price' => 300.45, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9058, 'price' => 300.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9058, 'price' => 300.6,  'quality' => 2, 'card_type' => 'chinatelecom'],
         ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
@@ -349,7 +349,7 @@ $mifeng_kami = ['name' => 'mifeng_kami', 'store_id' => 392, 'qualitys' => '3',
             ['goods_id' => 9063, 'price' => 49.8,   'quality' => 3, 'card_type' => 'chinaunicom'],
         ],
         100 => [
-            ['goods_id' => 9064, 'price' => 97.8, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9064, 'price' => 97.7,   'quality' => 3, 'card_type' => 'chinaunicom'],
         ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
@@ -365,7 +365,7 @@ $mifeng_fast = ['name' => 'mifeng_fast', 'store_id' => 393, 'qualitys' => '2',
             ['goods_id' => 9071, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinatelecom'],
         ],
         100 => [
-            ['goods_id' => 9072, 'price' => 100.18, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9072, 'price' => 100.15, 'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 9072, 'price' => 100.3, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         200 => [
@@ -391,13 +391,34 @@ $zhixin_fs = ['name' => 'zhixin_fs', 'store_id' => 394, 'qualitys' => '1',
 $mifeng_kami98 = ['name' => 'mifeng_kami98', 'store_id' => 395, 'qualitys' => '3',
     'amount' => [
         30 => [
-            ['goods_id' => 9086, 'price' => 29.88,  'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9086, 'price' => 29.88, 'quality' => 3, 'card_type' => 'chinaunicom'],
         ],
         50 => [
-            ['goods_id' => 9087, 'price' => 49.8,   'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9087, 'price' => 49.8,  'quality' => 3, 'card_type' => 'chinaunicom'],
         ],
         100 => [
-            ['goods_id' => 9088, 'price' => 97.79, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9088, 'price' => 95.4,  'quality' => 3, 'card_type' => 'chinaunicom'],
+        ],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
+$dixin_halfhour = ['name' => 'dixin_halfhour', 'store_id' => 396, 'qualitys' => '1',
+    'amount' => [
+        50 => [
+            ['goods_id' => 9095, 'price' => 48.75,'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9095, 'price' => 48.75,'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9095, 'price' => 48.75,'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9096, 'price' => 97.50, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9096, 'price' => 97.50, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9096, 'price' => 97.50, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9097, 'price' => 195.00, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9097, 'price' => 195.00, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9097, 'price' => 195.00, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
@@ -420,7 +441,8 @@ $phone_providers = [
     ['name' => 'mifeng_kami', 'cfg' => $mifeng_kami],
     ['name' => 'mifeng_fast', 'cfg' => $mifeng_fast],
     ['name' => 'zhixin_fs', 'cfg' => $zhixin_fs],
-    ['name' => 'mifeng_kami98', 'cfg' => $mifeng_kami98]
+    ['name' => 'mifeng_kami98', 'cfg' => $mifeng_kami98],
+    ['name' => 'dixin_halfhour', 'cfg' => $dixin_halfhour]
 ];
 
 $config['phone_providers'] = $phone_providers;
@@ -447,5 +469,5 @@ $config['sms_mchids'] = [];
 
 #风险流水号管理
 $config['risk_official_sn'] = [
-    'exclude_stores' => [377, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395]
+    'exclude_stores' => [377, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396]
 ];

+ 7 - 0
helper/refill/api/mh/dixin_halfhour/ReadMe.MD

@@ -0,0 +1,7 @@
+登陆地址:https://xin.baiopen.com/#/login?redirect=%2F404
+账号:15652921127
+初始密码:xl123456
+
+半小时
+dixinhour
+dixinhour@1234

+ 48 - 0
helper/refill/api/mh/dixin_halfhour/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\dixin_halfhour;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dixin_halfhour/config.php');
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = config::sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
+    public function notify($params): array
+    {
+        $order_sn = $params['merchant_no'];
+        $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'];
+        $ch_trade_no = $params['order_no'];
+
+        $status = intval($params['recharge_status']);
+        if ($status === 3) {
+            $official_sn = $params['official_sn'] ?? '';
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no,'official_sn' => $official_sn]);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif (in_array($status,[4,5])) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 173 - 0
helper/refill/api/mh/dixin_halfhour/RefillPhone.php

@@ -0,0 +1,173 @@
+<?php
+
+namespace refill\dixin_halfhour;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dixin_halfhour/config.php');
+
+use mtopcard;
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function add_params(int $phone, int $amount, string $order_sn, int $card_type): array
+    {
+        $oper_getter = function ($card_type)
+        {
+            if($card_type == mtopcard\ChinaMobileCard) {
+                return 'YD';
+            }
+            elseif($card_type == mtopcard\ChinaUnicomCard) {
+                return 'LT';
+            }
+            elseif($card_type == mtopcard\ChinaTelecomCard) {
+                return 'DX';
+            }
+            else {
+                return false;
+            }
+        };
+
+        $operator = $oper_getter($card_type);
+        $sku_code = config::sku_code($card_type,$amount);
+
+        if($operator === false || empty($sku_code)) {
+            return [];
+        }
+
+        $params = [
+            'merchant_no' => $order_sn,
+            'sku_code' => $sku_code,
+            'format' =>  ['account' => $phone],
+            "format_type" => "common",
+            'notice_url' => config::NOTIFY_URL,
+            "uid" => "123456"
+        ];
+
+        $result = $this->method('create.order',$params);
+
+        return $result;
+    }
+
+    private function method($method,$data = [],$attach = '')
+    {
+        $param = [
+            'access_token' => config::ACCESS_TOKEN,
+            'once' => uniqid(),
+            'timestamp' => $this->getUnixTimestamp(),
+            'attach' => $attach,
+            'format' => 'JSON',
+            'sign_type' => 'MD5',
+            'version' => '1.0.0',
+            'method' => $method,
+            'data' => json_encode($data, 256),
+        ];
+        $param = array_merge($param, ['sign' => config::sign($param)]);
+        return $param;
+    }
+    private function getUnixTimestamp ()
+    {
+        list($s1, $s2) = explode(' ', microtime());
+        return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
+    }
+
+    //[$state, $errmsg, $neterr]
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
+
+        $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): array
+    {
+        $params['merchant_no'] = $refill_info['order_sn'];  //sn码
+        $params = $this->method('query.order',$params);//查数据库情况,查询全部数据结构包括orderid
+        $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)
+            {
+                $val = $resp['data'][0];
+                $status = $val['recharge_status'];
+                $official_sn = '';//strtolower($val['official_sn']) == 'null' ? '' : $val['official_sn'];
+
+                //充值状态:1=待充值,2=充值中,3=充值完成,4=充值失败,5=运营商维护,8=部分到账
+                if ($status == '3') {
+                    $save['ch_trade_no'] = $val['order_no'];//平台的订单号
+                    $save['official_sn'] = $official_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                    $order_state = ORDER_STATE_SUCCESS;
+                }
+                elseif (in_array($status,[4,5])) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['order_no']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+                else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+            else
+            {
+                return [false, $resp['message'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params = $this->method('query.balance',[]);
+        $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, ncPriceFormat($resp['data']['predict_money'])];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+}

+ 74 - 0
helper/refill/api/mh/dixin_halfhour/config.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace refill\dixin_halfhour;
+
+use mtopcard;
+
+class config
+{
+    const ACCESS_TOKEN = '406c0c33c27e18662a756b369a1074c1';
+    const KEY = 'a6573b34c420dc7304c4331672297f7d';
+    const ORDER_URL = 'https://m.baiopen.com/openapi/method';
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/dixin_halfhour.php";
+    const IS_DEBUG = false;
+    private static $stStoreProducts = [
+        50  => [4 => 'G38032362348704592', 5 => 'G38032362358944672', 6 => 'G38032362353824632'],
+        100 => [4 => 'G38032362350752808', 5 => 'G38032362360480584', 6 => 'G38032362355360544'],
+        200 => [4 => 'G38032362352288720', 5 => 'G38032362362016496', 6 => 'G38032362357408760']
+    ];
+
+    public static function sign($params)
+    {
+        if (is_object($params)) { //对象转数组
+            $params = json_decode(json_encode($params), true);
+        }
+
+        $params['sign_key'] = config::KEY;
+        ksort($params);
+
+        $formatData = [];
+        foreach ($params as $k => $v) {
+            if (is_array($v) || is_object($v)) {
+                $v = json_encode($v, JSON_UNESCAPED_UNICODE);
+            }
+            if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
+                $formatData[] = "$k=$v";
+            }
+        }
+        $signStr = implode('&', $formatData);
+
+        return md5($signStr);
+    }
+
+    public static function sku_code($card_type,$amount)
+    {
+        if(config::IS_DEBUG)
+        {
+            if($card_type === mtopcard\ChinaMobileCard)
+            {
+                switch ($amount)
+                {
+                    case 50:
+                        return 'G34707828905632832';
+                }
+            }
+            elseif($card_type === mtopcard\ChinaUnicomCard)
+            {
+                switch ($amount)
+                {
+                    case 50:
+                        return 'G34707828917408824';
+                }
+            }
+        }
+        else
+        {
+            if(array_key_exists($amount,self::$stStoreProducts)) {
+                if(array_key_exists($card_type,self::$stStoreProducts[$amount])) {
+                    return self::$stStoreProducts[$amount][$card_type];
+                }
+            }
+            return false;
+        }
+    }
+}

+ 9 - 0
racc/callback/mh/dixin_halfhour.php

@@ -0,0 +1,9 @@
+<?php
+
+$content = $_SERVER['post_content'];
+Log::record("dixin_halfhour content=$content",Log::DEBUG);
+
+$input = json_decode($content,true);
+refill\util::push_notify('dixin_halfhour',$input);
+
+echo ('success');