xiaoyu 3 anni fa
parent
commit
5107e0e55d

+ 10 - 0
data/config/win/refill.ini.php

@@ -153,6 +153,16 @@ $xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '3',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$legou_oil = ['name' => 'legou', 'store_id' => 80,'qualitys' => '3',
+    'amount' => [
+        100 => [['goods_id' => 6756, 'price' => 97, 'quality' => 3, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6757, 'price' => 194, 'quality' => 3, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6758, 'price' => 485, 'quality' => 3, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6759, 'price' => 970, 'quality' => 3, 'card_type' => 'sinopec']],
+        2000 => [['goods_id' => 6760, 'price' => 1940, 'quality' => 3, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],

+ 10 - 0
data/config/xyz/refill.ini.php

@@ -153,6 +153,16 @@ $xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '3',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$legou_oil = ['name' => 'legou', 'store_id' => 80,'qualitys' => '3',
+    'amount' => [
+        100 => [['goods_id' => 6756, 'price' => 97, 'quality' => 3, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6757, 'price' => 194, 'quality' => 3, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6758, 'price' => 485, 'quality' => 3, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6759, 'price' => 970, 'quality' => 3, 'card_type' => 'sinopec']],
+        2000 => [['goods_id' => 6760, 'price' => 1940, 'quality' => 3, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],

+ 10 - 0
data/config/xyzadm/refill.ini.php

@@ -153,6 +153,16 @@ $xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '3',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$legou_oil = ['name' => 'legou', 'store_id' => 80,'qualitys' => '3',
+    'amount' => [
+        100 => [['goods_id' => 6756, 'price' => 97, 'quality' => 3, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6757, 'price' => 194, 'quality' => 3, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6758, 'price' => 485, 'quality' => 3, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6759, 'price' => 970, 'quality' => 3, 'card_type' => 'sinopec']],
+        2000 => [['goods_id' => 6760, 'price' => 1940, 'quality' => 3, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],

+ 68 - 0
helper/refill/api/xyz/legou/RefillCallBack.php

@@ -0,0 +1,68 @@
+<?php
+
+
+namespace refill\legou;
+
+require_once(BASE_HELPER_RAPI_PATH . '/legou/config.php');
+
+use refill;
+use mtopcard\cards_helper;
+
+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)
+    {
+        $content  = config::USERNAME . $params['orderNumber'] . $params['cardNumber'] . $params['orderMoney'] . $params['orderPay'];
+        $content .= $params['resultCode'] . $params['rechargeDesc'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultCode']);
+        $order_sn = $params['orderNumber'];
+        $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'];
+        
+        $updata['official_sn'] = strtolower($params['rechargeVoucher']) == 'null' ? '' : $params['rechargeVoucher'];
+
+        if ($status === 2) {
+            Model('refill_order')->edit($order_id, $updata);
+            cards_helper::assign($order_id, '');
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            $this->onError($order_id, $params['rechargeDesc']);
+            return [$order_id, false, false,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+
+    private function onError($order_id, $desc)
+    {
+        $desc = json_decode($desc, true);
+        $status = $desc['rechargeStatus'];
+        $desc   = $desc['rechargeDesc'];
+
+        if (in_array($status, [600400, 600401, 600402, 600403, 600404, 600405])) {
+            cards_helper::freeze($order_id,$desc);
+        } else {
+            cards_helper::reuse($order_id);
+        }
+    }
+}

+ 167 - 0
helper/refill/api/xyz/legou/RefillPhone.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace refill\legou;
+
+require_once(BASE_HELPER_RAPI_PATH . '/legou/config.php');
+
+use mtopcard\cards_helper;
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone,$card_type, int $amount, string $order_sn)
+    {
+        $params['username'] = config::USERNAME;
+        $params['order  Number'] = $order_sn;
+        $params['cardNumber'] = $phone;
+        $params['cardExt'] = $amount;
+        $params['productNo'] = '400001';
+        $params['timestamp'] = $this->getMillisecond();
+        $params['notifyUrl'] = 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']);
+
+        [$success,$card] = cards_helper::reserve($card_type,$amount,$input['buyer_id'],$card_no,$card_type,$input['order_id'],config::StoreIDS);
+        if(!$success) {
+            return [false, '没有可用卡密', false];
+        }
+
+        $rcard_no = $card->card_no();
+        $rcard_key = $card->card_key();
+        $params['rechargeNum'] = $rcard_no;
+        $params['rechargePwd'] = $rcard_key;
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params['rechargeNum'] = $this->encryptWithOpenssl($rcard_no);
+        $params['rechargePwd'] = $this->encryptWithOpenssl($rcard_key);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders , $net_errno);
+
+        $order_id = $params['order_id'];
+        if (empty($resp)) {
+            cards_helper::reuse($order_id);
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+
+            if (empty($resp)) {
+                cards_helper::reuse($order_id);
+                return [false, '网络错误', true];
+            }
+
+            $status = intval($resp['code']['status']);
+            if ($status == 100000) {
+                return [true, $resp['obj'], false];
+            } else {
+                cards_helper::reuse($order_id);
+                Log::record("refill {$card_no} err: {$resp['code']['desc']}", Log::DEBUG);
+                return [false, $resp['code']['desc'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderNumber'] = $refill_info['order_sn'];
+        $params['username'] = config::USERNAME;
+        $content = $params['username'] . $params['orderNumber'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false , config::ExtHeaders);
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+
+            $oper_status = intval($resp['code']['status']);
+            if ($oper_status == 100000)
+            {
+                $obj = $resp['obj'];
+                $code = $obj['resultCode'];
+
+                $order_id = $refill_info['order_id'];
+
+                if ($code == 2) { //充值成功
+                    $order_state = ORDER_STATE_SUCCESS;
+                    $updata['official_sn'] = strtolower($obj['rechargeVoucher']) == 'null' ? '' : $obj['rechargeVoucher'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+
+                    cards_helper::assign($order_id, '');
+                } elseif ($code == 3) { //充值失败
+                    $order_state = ORDER_STATE_CANCEL;
+                    $this->onError($order_id, $obj['rechargeDesc']);
+                } elseif($code == 4) { //订单存疑,需要人工确认
+                    return [false, $resp['code']['desc']];
+                }
+                else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['code']['desc']];
+            }
+        }
+    }
+
+    private function onError($order_id, $desc)
+    {
+        $desc = json_decode($desc, true);
+        $status = $desc['rechargeStatus'];
+        $desc   = $desc['rechargeDesc'];
+
+        if (in_array($status, [600400, 600401, 600402, 600403, 600404, 600405])) {
+            cards_helper::freeze($order_id,$desc);
+        } else {
+            cards_helper::reuse($order_id);
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = $params['username'] . $params['orderNumber'] . $params['cardNumber'] . $params['cardExt'] . $params['rechargeNum'] . $params['rechargePwd'] . $params['productNo'];
+        $content .= $params['timestamp'] . $key;
+        return md5($content);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
+    }
+
+    private function encryptWithOpenssl($data = '')
+    {
+        $key = substr(config::KEY , 0 ,16);
+        $iv  = substr(config::KEY , -16);
+        return base64_encode(openssl_encrypt($data, "AES-128-CBC", $key, OPENSSL_RAW_DATA, $iv));
+    }
+}

+ 14 - 0
helper/refill/api/xyz/legou/account.txt

@@ -0,0 +1,14 @@
+账号:	bjyz
+密码:a74b895f
+后台网址:https://lego.shujubuy.com
+
+对接功能模块请使用具有权限的子账户,产品编码可在产品中心查看
+
+
+中石化短信代充    子账户:yezidx	密钥:1d6f8955-b2b3-484b-a045-b5b8033620b7
+
+
+中石化高透卡冲    子账户:yezioil      	密钥:	31ae80c0-27ea-4817-8462-8ef11185a4bf
+
+
+	

+ 16 - 0
helper/refill/api/xyz/legou/config.php

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\legou;
+
+class config
+{
+    const ORDER_URL = 'https://recv.shujubuy.com/api/recv/submitOrder';
+    const QUERY_URL = 'https://recv.shujubuy.com/api/recv/queryOrder';
+
+    const USERNAME = 'lzdc';
+    const KEY = '20cb7911-9037-44e5-8786-956eaffe1d3b';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_legou.php";
+    const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
+    const StoreIDS = [43];
+}

BIN
helper/refill/api/xyz/legou/乐友充值接口.docx


+ 4 - 0
mobile/callback/refill_legou.php

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