Procházet zdrojové kódy

add phone provider jc

ayHaru před 4 roky
rodič
revize
baae9b0f9f

+ 47 - 0
helper/refill/jc/RefillCallBack.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\jc;
+
+require_once(BASE_HELPER_PATH . '/refill/jc/config.php');
+
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sgn'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = $params['result'] . $params['msg'] . $params['order_no'] . $params['phone_no'] . $params['amount'] . $params['op_no'] . config::APP_SECRET;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['result']);
+        $order_sn = $params['op_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'];
+        $data['official_sn'] = $params['order'];
+        Model('refill_order')->edit($order_id, $data);
+
+        if ($status === 'success') {
+            return [$order_id, true, false,true];
+        } elseif ($status === 'fail') {
+            return [$order_id, false, true,true];
+        }
+    }
+}

+ 78 - 0
helper/refill/jc/RefillPhone.php

@@ -0,0 +1,78 @@
+<?php
+namespace refill\jc;
+
+require_once(BASE_HELPER_PATH . '/refill/jc/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['phone'] = $phone;
+        $params['order_no'] = $order_sn;
+        $params['s_id'] = config::APP_ID;
+        $params['amount'] = $amount;
+        $params['notify_url'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type,$amount,$params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no,$amount,$order_sn);
+        $sign = $this->sign($params);
+        $params['sgn'] = $sign;
+        $resp = http_request(config::ORDER_URL,$params,'GET');
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['result'] == 'SUCCESS') {
+                return [true,$resp['data']];
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderId'] = $refill_info['order_sn'];
+        $params['sid'] = config::APP_ID;
+        $content = $params['orderId'] . $params['sid'] . config::APP_SECRET;
+        $params['sign'] = strtoupper(md5($content));
+        $resp = http_request(config::QUERY_URL,$params);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp , true);
+            if($resp['result'] == 'SUCCESS') {
+
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::APP_SECRET;
+        $content = $params['amount'] . $params['notify_url'] . $params['order_no'] . $params['phone'] . $params['s_id'] . $key;
+        return strtoupper(md5($content));
+    }
+}

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

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\jc;
+
+
+class config
+{
+    const ORDER_URL = 'http://43.226.39.45:8080/api/order/invest';
+    const QUERY_URL = 'http://43.226.39.45:8080/api/order/queryStatus';
+    const APP_ID = 16100906466199438976;
+    const APP_SECRET = 'TeDZjpVGSVMEEkIEBQGOQLoXdtSyXMlhNlnNxi0waUi8wETOE5T20E5PFxEK5vRQ';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_jc.php";
+    const API_IP = NET_IP;
+}

+ 8 - 0
mobile/refill_jc.php

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