Browse Source

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

stanley-king 4 năm trước cách đây
mục cha
commit
165e43e941

+ 76 - 0
helper/refill/zzx/RefillCallBack.php

@@ -0,0 +1,76 @@
+<?php
+
+
+namespace refill\zzx;
+
+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 strtoupper(md5($body));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['orderNum'];
+
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false];
+        }
+        $order_id = $order_info['order_id'];
+        $data['ch_trade_no'] = $params['voucherNo'];
+        Model('refill_order')->edit($order_id, $data);
+        if ($status === 1) {
+            return [$order_id, true, false, true];
+        } elseif ($status === 0) {
+            return [$order_id, true, false, false];
+        } else {
+            return [$order_id, false, true, true];
+        }
+    }
+}

+ 72 - 0
helper/refill/zzx/RefillOil.php

@@ -0,0 +1,72 @@
+<?php
+
+
+namespace refill\zzx;
+
+require_once(BASE_HELPER_PATH . '/refill/zzx/config.php');
+
+
+use refill;
+use mtopcard;
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(string $card_no,int $card_type,int $amount,array $other)
+    {
+        $params['mid'] = config::MID;
+        $params['cardNo'] = $card_no;
+        $params['amount'] = $amount;
+        $params['orderNum'] = $other['order_sn'];
+        $params['backUrl'] = config::NOTIFY_URL;
+        return json_encode($params);
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if($val == '' || empty($val)){
+                continue;
+            }
+            $content .= "{$key}={$val}&";
+        }
+        $content .= "key=".config::KEY;
+
+        return strtoupper(md5($content));
+    }
+
+    public function add($card_no,$card_type,$amount,$input)
+    {
+        $params = $this->req_params($card_no,$card_type,$amount,$input);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL,$params,'POST',false, config::ExtHeaders);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['code'] == 0000 && $resp['respCode'] == 1111) {
+                return [true,$resp['msg']];
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+
+    }
+}

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

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace refill\zzx;
+
+
+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'];
+    }
+}

+ 16 - 0
helper/refill/zzx/config.php

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\zzx;
+
+
+class config
+{
+    const ORDER_URL = 'http://bank.daoken.club/youka/trade/order';
+    const MID = 1344178203820990464;
+    const KEY = 'c9c74dcb886e403fb8abc62dadaedd86';
+
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_zzx.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+    const API_IP = NET_IP;
+}

+ 8 - 0
mobile/refill_zzx.php

@@ -0,0 +1,8 @@
+<?php
+
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('zzx',$_POST);
+
+echo ('success');
+