Ver código fonte

add to local

stanley-king 4 anos atrás
pai
commit
f873c77dcb

+ 34 - 26
data/config/dev/refill.ini.php

@@ -1,38 +1,46 @@
 <?php
 
 
-$suhc_oil = ['name' => 'suhc','store_id' => 8,'card_type' => ['sinopec'],
-    'amount' => [100 => ['goods_id' => 6226,'price' => 96.8],
-        200 => ['goods_id' => 6227,'price' => 193.6],
-        500 => ['goods_id' => 6228,'price' => 484],
-        1000=> ['goods_id' => 6229,'price' => 968],
-        2000=> ['goods_id' => 6230,'price' => 1976]],
-    'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
-
-$suhctm_oil = ['name' => 'suhctm','store_id' => 8,'card_type' => ['sinopec'],
-    'amount' => [100 => ['goods_id' => 6226,'price' => 96.8],
-        200 => ['goods_id' => 6227,'price' => 193.6],
-        500 => ['goods_id' => 6228,'price' => 484],
-        1000=> ['goods_id' => 6229,'price' => 968],
-        2000=> ['goods_id' => 6230,'price' => 1976]],
-    'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
-
-$oil_providers = ['suhc' => $suhc_oil,'suhctm' => $suhctm_oil];
+$suhc_oil = ['name' => 'suhc', 'store_id' => 8, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6226, 'price' => 96.8],
+        200 => ['goods_id' => 6227, 'price' => 193.6],
+        500 => ['goods_id' => 6228, 'price' => 484],
+        1000 => ['goods_id' => 6229, 'price' => 968],
+        2000 => ['goods_id' => 6230, 'price' => 1976]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'api'];
+
+$suhctm_oil = ['name' => 'suhctm', 'store_id' => 8, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6226, 'price' => 96.8],
+        200 => ['goods_id' => 6227, 'price' => 193.6],
+        500 => ['goods_id' => 6228, 'price' => 484],
+        1000 => ['goods_id' => 6229, 'price' => 968],
+        2000 => ['goods_id' => 6230, 'price' => 1976]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'api'];
+
+$lx_oil = ['name' => 'lx', 'store_id' => 10, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6234, 'price' => 99],
+        200 => ['goods_id' => 6235, 'price' => 198],
+        500 => ['goods_id' => 6236, 'price' => 495],
+        1000 => ['goods_id' => 6237, 'price' => 990],
+        2000 => ['goods_id' => 6238, 'price' => 1980]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'inner_store'];
+
+$oil_providers = ['suhc' => $suhc_oil, 'suhctm' => $suhctm_oil,'lx' => $lx_oil];
 $config['oil_providers'] = $oil_providers;
 
 
-$beixt_phone = ['name' => 'beixt','store_id' => 9,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6231,'price' => 48.75],
-        100 => ['goods_id' => 6232,'price' => 97.5],
-        200 => ['goods_id' => 6233,'price' => 195]],
+$beixt_phone = ['name' => 'beixt', 'store_id' => 9, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6231, 'price' => 48.75],
+        100 => ['goods_id' => 6232, 'price' => 97.5],
+        200 => ['goods_id' => 6233, 'price' => 195]],
     'refill_type' => 'api'];
 
-$bxtwt_phone = ['name' => 'bxtwt','store_id' => 10,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6298,'price' => 48],
-        100 => ['goods_id' => 6299,'price' => 96],
-        200 => ['goods_id' => 6300,'price' => 192]],
+$bxtwt_phone = ['name' => 'bxtwt', 'store_id' => 10, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6298, 'price' => 48],
+        100 => ['goods_id' => 6299, 'price' => 96],
+        200 => ['goods_id' => 6300, 'price' => 192]],
     'refill_type' => 'api'];
 
-$phone_providers = ['beixt' => $beixt_phone , 'bxtwt' => $bxtwt_phone];
+$phone_providers = ['beixt' => $beixt_phone, 'bxtwt' => $bxtwt_phone];
 //$phone_providers = ['beixt' => $beixt_phone];
 $config['phone_providers'] = $phone_providers;

+ 5 - 1
helper/refill/RefillFactory.php

@@ -37,6 +37,10 @@ require_once(BASE_HELPER_PATH . '/refill/zzx/RefillOil.php');
 require_once(BASE_HELPER_PATH . '/refill/zzx/RefillPhone.php');
 require_once(BASE_HELPER_PATH . '/refill/zzx/RefillCallBack.php');
 
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillOil.php');
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillPhone.php');
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillCallBack.php');
+
 use Log;
 use mtopcard;
 use QueueClient;
@@ -282,7 +286,7 @@ class RefillFactory
 //            }
 
             $period = time() - $refill['order_time'];
-            if($period >= 15 * 60) {
+            if($period >= 10 * 60) {
                 return false;
             }
 

+ 74 - 0
helper/refill/lx/RefillCallBack.php

@@ -0,0 +1,74 @@
+<?php
+
+
+namespace refill\lx;
+
+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;
+        }
+    }
+
+    private 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}" . "=" . urldecode($v);
+                } else {
+                    $body .= "&" . "{$k}" . "=" . urldecode($v);
+                }
+                $i++;
+            }
+        }
+
+        $body .= "&key=" . config::KEY;
+        return md5($body);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['onlystr'];
+
+        $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 === 2) {
+            return [$order_id, true, false,true];
+        } else {
+            //速汇充反馈此时可以提交多次.
+            return [$order_id, false, true,true];
+        }
+    }
+}

+ 58 - 0
helper/refill/lx/RefillOil.php

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\lx;
+
+require_once(BASE_HELPER_PATH . '/refill/lx/config.php');
+
+
+use refill;
+use mtopcard;
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function add($card_no,$card_type,$amount,$input)
+    {
+        return [true,$input['order_sn']];
+    }
+
+    public function query($refill_info)
+    {
+        $params['batchid'] = $refill_info['ch_trade_no'];
+        $params['orgid'] = config::ORGID;
+        $params['cardno'] = $refill_info['card_no'];
+        $params['onlystr'] = $refill_info['order_sn'];
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_QUERY_URL,$params,'POST',false,config::ExtHeaders);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['state'] == 0) {
+                return [true,$resp['data']];
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+
+    private function store()
+    {
+        $count = count(config::STOREIDS);
+        $pos = mt_rand(0,$count - 1);
+
+        return config::STOREIDS[$pos];
+    }
+}

+ 24 - 0
helper/refill/lx/RefillPhone.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace refill\lx;
+
+
+use refill\IRefillPhone;
+
+class RefillPhone extends IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function add($card_no,$card_type,$amount,$input)
+    {
+        return [false,'No Implement'];
+    }
+    public function query($refill_info)
+    {
+        return [false,'No Implement'];
+    }
+}

+ 26 - 0
helper/refill/lx/config.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace refill\lx;
+
+
+class config
+{
+    const ORDER_URL = 'http://jiayouka.5800cc.com/kaOrder/createKaOrder.html';
+    const ORDER_QUERY_URL = 'http://jiayouka.5800cc.com/kaOrder/queryOrder.html';
+    const KEY = '7yDCLS6S2KzSAJQOUc3vsa';
+    const ORGID = 1590993600;
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_suhc.php";
+    const STOREIDS = ['10280838',
+        '611127',
+        '10109062',
+        '10053330',
+        '10108936'
+//        '10114157',
+//        '10143029',
+//        '10109046',
+//        '10135551',
+//        '678278'
+        ];
+    const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded' , 'Accept: application/json;charset=UTF-8'];
+}