Browse Source

gdsinopec

xiaoyu 2 years ago
parent
commit
fe0c2dfc96

+ 39 - 6
docker/compose/xiaoyu/admin/docker-compose.yml

@@ -9,7 +9,7 @@ services:
       - ../../../../:/var/www/html
       - ../../../../:/var/www/html
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ../conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
-      - /d/phpstudy_pro/WWW/xyzshop/data/upload:/var/www/html/data/upload
+      - ../../../../data/upload:/var/www/html/data/upload
     container_name: "panda-nginx"
     container_name: "panda-nginx"
     command: [nginx,'-g','daemon off;']
     command: [nginx,'-g','daemon off;']
 
 
@@ -22,8 +22,8 @@ services:
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/php/php-local-debug.ini:/usr/local/etc/php/php.ini
       - ../conf/php/php-local-debug.ini:/usr/local/etc/php/php.ini
       - ../conf/php/mch-spwan-start:/usr/local/bin/docker-spwan-start
       - ../conf/php/mch-spwan-start:/usr/local/bin/docker-spwan-start
-      - /d/phpstudy_pro/WWW/xyzshop/data/upload:/var/www/html/data/upload
-      - /d/phpstudy_pro/WWW/xyzshop/data/upload/log:/var/www/html/data/log
+      - ../../../../data/upload:/var/www/html/data/upload
+      - ../../../../data/log:/var/www/html/data/log
     container_name: "panda-merchant"
     container_name: "panda-merchant"
     command: [docker-spwan-start]
     command: [docker-spwan-start]
     deploy:
     deploy:
@@ -38,8 +38,8 @@ services:
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
       - ../conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
       - ../conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
-      - /d/phpstudy_pro/WWW/xyzshop/data/upload:/var/www/html/data/upload
-      - /d/phpstudy_pro/WWW/xyzshop/data/upload/log:/var/www/html/data/log
+      - ../../../../data/upload:/var/www/html/data/upload
+      - ../../../../data/log:/var/www/html/data/log
     container_name: "panda-web"
     container_name: "panda-web"
     command: [php-fpm]
     command: [php-fpm]
 
 
@@ -52,4 +52,37 @@ services:
       - /d/phpstudy_pro/WWW/xyzshop/docker/conf/redis/6379.conf:/etc/redis/redis.conf
       - /d/phpstudy_pro/WWW/xyzshop/docker/conf/redis/6379.conf:/etc/redis/redis.conf
       - /d/phpstudy_pro/WWW/xyzshop/docker/conf/redis:/var/redis
       - /d/phpstudy_pro/WWW/xyzshop/docker/conf/redis:/var/redis
     container_name: "panda-redis"
     container_name: "panda-redis"
-    command: [ redis-server,"/etc/redis/redis.conf" ]
+    command: [ redis-server,"/etc/redis/redis.conf" ]
+
+  accedit:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../../../../data/log:/var/www/html/data/log
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - ../../../../data/upload:/var/www/html/data/upload
+    container_name: "panda-accedit"
+    command: [ php,"/var/www/html/crontab/index.php",'minutes','account_edit' ]
+
+  crontask:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../../../../data/log:/var/www/html/data/log
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - ../../../../data/upload:/var/www/html/data/upload
+    container_name: "panda-task"
+    command: [ php,"/var/www/html/crontab/index.php",'minutes','task' ]
+
+  token_refresh:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php-local-debug.ini:/usr/local/etc/php/php.ini
+      - ../../../../data/upload:/var/www/html/data/upload
+      - ../../../../data/log:/var/www/html/data/log
+    container_name: "panda-token-refresh"
+    command: [ php,"/var/www/html/crontab/index.php",'vendor','token_refresh' ]

+ 40 - 5
helper/refill/api/xyz/gdsinopec/RefillOil.php

@@ -14,8 +14,12 @@ class RefillOil extends refill\IRefillOil
         parent::__construct($cfgs);
         parent::__construct($cfgs);
     }
     }
 
 
-    public function get_supplier($access_token)
+    public function get_supplier()
     {
     {
+        $access_token = config::token();
+        if($access_token === false) {
+            return [false, 'token获取失败'];
+        }
         $params['access_token'] = $access_token;
         $params['access_token'] = $access_token;
 
 
         $resp = http_request(config::SUPPLIER_URL, $params, 'GET', false, config::ExtHeaders, $net_errno);
         $resp = http_request(config::SUPPLIER_URL, $params, 'GET', false, config::ExtHeaders, $net_errno);
@@ -62,6 +66,26 @@ class RefillOil extends refill\IRefillOil
         }
         }
     }
     }
 
 
+    private function match_product($supplier_origin, $amount)
+    {
+        [$state, $products] = $this->find_list($supplier_origin);
+        if($state === false) {
+            return [false, $products];
+        } else {
+            $match_products = [];
+            foreach ($products as $product)
+            {
+                $value = intval($product['value']);
+                $match_products[$value] = $product;
+            }
+            if(!empty($match_products) && array_key_exists($amount, $match_products)) {
+                return [true, $match_products[$amount]];
+            }else{
+                return [false, '面值匹配失败'];
+            }
+        }
+    }
+
     private function req_params(int $phone, $supplier_origin, $product_id, string $order_sn, $sku)
     private function req_params(int $phone, $supplier_origin, $product_id, string $order_sn, $sku)
     {
     {
         $params['supplier_origin'] = $supplier_origin;
         $params['supplier_origin'] = $supplier_origin;
@@ -76,6 +100,10 @@ class RefillOil extends refill\IRefillOil
 
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
     {
+        $province = $params['province'] ?? -1;
+        if($province <= 0) {
+            return [false, '省份获取错误', false];
+        }
         $tokener = function ()
         $tokener = function ()
         {
         {
             $times = 10;
             $times = 10;
@@ -98,10 +126,17 @@ class RefillOil extends refill\IRefillOil
         }
         }
 
 
         $order_sn = $params['order_sn'];
         $order_sn = $params['order_sn'];
-        $supplier_origin = $params['supplier_origin'];
-        $product_id = $params['product_id'];
-        $sku = $params['sku'];
-        $params = $this->req_params($card_no, $supplier_origin, $product_id, $order_sn, $sku);
+        $supplier_origin = config::SUPPLIER_ORIGIN[$province];
+        if(empty($supplier_origin)) {
+            return [false, '该省份不支持', false];
+        }
+        [$state, $product] = $this->match_product($supplier_origin, $amount);
+        if($state === false) {
+            return [false, $product, false];
+        }
+        $product_id = $product['id'];
+        $sku = $product['sku'];
+        $params = $this->req_params($card_no, $province, $product_id, $order_sn, $sku);
 
 
         $url = config::ORDER_URL . $access_token;
         $url = config::ORDER_URL . $access_token;
         $resp = http_post_data($url, $params, config::ExtHeaders, $net_errno);
         $resp = http_post_data($url, $params, config::ExtHeaders, $net_errno);

+ 13 - 8
helper/refill/api/xyz/gdsinopec/config.php

@@ -6,18 +6,23 @@ use Log;
 
 
 class config
 class config
 {
 {
-    const TOKEN_URL = 'http://dev.tetong.9aijoy.com/open/api/token'; //获取AccessToken
-    const SUPPLIER_URL = 'http://dev.tetong.9aijoy.com/open/api/coupon/findSupplierList'; //获取电子券来源
-    const LIST_URL = 'http://dev.tetong.9aijoy.com/open/api/coupon/findList'; //获取电子券列表
-    const ORDER_URL = 'http://dev.tetong.9aijoy.com/open/api/coupon/purchase?access_token='; //采购电子券
-    const QUERY_URL = 'http://dev.tetong.9aijoy.com/open/api/coupon/orderStatus'; //订单查询
+    const TOKEN_URL = 'http://open.huizhichun.com/open/api/token'; //获取AccessToken
+    const SUPPLIER_URL = 'http://open.huizhichun.com/open/api/coupon/findSupplierList'; //获取电子券来源
+    const LIST_URL = 'http://open.huizhichun.com/open/api/coupon/findList'; //获取电子券列表
+    const ORDER_URL = 'http://open.huizhichun.com/open/api/coupon/purchase?access_token='; //采购电子券
+    const QUERY_URL = 'http://open.huizhichun.com/open/api/coupon/orderStatus'; //订单查询
 
 
-    const APP_ID = 'KA5423116';
-    const APP_SECRET = '612151d4d59a4d12bbcd65c7c4c54c57';
+    const APP_ID = 'KA2702579';
+    const APP_SECRET = '5af4a0fe9e4c4763b7ab54123778d0ca';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_sinopec.php";
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_sinopec.php";
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
     const PAGE_SIZE = 200;
     const PAGE_SIZE = 200;
 
 
+    //省份映射 我方省份 => 上游省份编号
+    const SUPPLIER_ORIGIN = [
+        19 => 100, //广东
+        20 => 101, //广西
+    ];
 
 
     public function get_access_token()
     public function get_access_token()
     {
     {
@@ -57,7 +62,7 @@ class config
         $expires_time = $result['gdsinopec-time'];
         $expires_time = $result['gdsinopec-time'];
         $token = $result['gdsinopec-token'];
         $token = $result['gdsinopec-token'];
 
 
-        if ($expires_time > $token) {
+        if ($expires_time > time()) {
             return $token;
             return $token;
         } else {
         } else {
             return false;
             return false;

BIN
helper/refill/api/xyz/gdsinopec/中石化电子加油券接口文档Rev1.0.docx


BIN
helper/refill/api/xyz/gdsinopec/中石化电子加油券接口文档Rev1.1-上海紫枢.docx


+ 3 - 0
helper/refill/api/xyz/gdsinopec/开户信息.txt

@@ -0,0 +1,3 @@
+正式环境:
+appid:KA2702579
+secret:5af4a0fe9e4c4763b7ab54123778d0ca

+ 3 - 8
test/TestRefill.php

@@ -2309,15 +2309,10 @@ class TestRefill extends TestCase
     {
     {
         $provider = $this->getProvider('gdsinopec','RefillOil');
         $provider = $this->getProvider('gdsinopec','RefillOil');
 //        [$state, $access_token] = $provider->get_access_token();
 //        [$state, $access_token] = $provider->get_access_token();
-        $access_token = '039957e4b8224ecba34def77cefde8f7';
-        $supplier_origin = 100;
 //        $resp = $provider->find_list($supplier_origin);
 //        $resp = $provider->find_list($supplier_origin);
-        $product_id = '01502d00dfeb48fcb4e32e9cb769ae9e';
-        $sku = 'A0025';
-//        $resp = $provider->add(18500608333, 5, 50, [
-//            'order_sn' => $this->make_sn(), 'supplier_origin' => $supplier_origin,
-//            'product_id' => $product_id, 'sku' => $sku
-//        ]);
+        $resp = $provider->add(13699279618, 4, 50, [
+            'order_sn' => $this->make_sn(), 'province' => 19
+        ]);
         $resp = $provider->query(['order_sn' => '42381653467866036142']);
         $resp = $provider->query(['order_sn' => '42381653467866036142']);
 
 
     }
     }