Sfoglia il codice sorgente

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

stanley-king 4 anni fa
parent
commit
bf2b8dda7b

+ 4 - 1
helper/refill/api/lingzh/legou/RefillCallBack.php

@@ -6,6 +6,7 @@ namespace refill\legou;
 require_once(BASE_HELPER_RAPI_PATH . '/legou/config.php');
 
 use refill;
+use mtopcard\cards_helper;
 
 class RefillCallBack implements refill\IRefillCallBack
 {
@@ -37,9 +38,11 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_id = $order_info['order_id'];
         
         $data['official_sn'] = strtolower($params['rechargeVoucher']) == 'null' ? '' : $params['rechargeVoucher'];
-
+        $card = Model('card_key')->getCardByOrderId($order_id);
+        $card_id = $card[0]['card_id'];
         if ($status === 2) {
             Model('refill_order')->edit($order_id, $data);
+            cards_helper::assign($card_id, '');
             return [$order_id, true, false,true];
         }
         elseif ($status === 3) {

+ 22 - 2
helper/refill/api/lingzh/legou/RefillPhone.php

@@ -93,12 +93,24 @@ class RefillPhone extends refill\IRefillPhone
             }
             $status = intval($resp['code']['status']);
             if ($status == 100000) {
+                $card = Model('card_key')->getCardByOrderId($refill_info['order_id']);
+                $card_id = $card[0]['card_id'];
+
                 $order_state = -1;
                 $obj = $resp['obj'];
-                if ($obj['resultCode'] == 2) {
+                $data = json_decode($obj['rechargeDesc'], true);
+                $rechargeStatus = $data['rechargeStatus'];
+                $code = $obj['resultCode'];
+                if ($code == 2) {
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($obj['resultCode'] == 3) {
+                    $save['official_sn'] = strtolower($data['rechargeVoucher']) == 'null' ? '' : $data['rechargeVoucher'];
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                    cards_helper::assign($card_id, '');
+
+                } elseif ($code == 3) {
                     $order_state = ORDER_STATE_CANCEL;
+                    $this->recharge_error($card_id, $rechargeStatus);
+
                 } else {
                     $order_state = ORDER_STATE_SEND;
                 }
@@ -112,6 +124,14 @@ class RefillPhone extends refill\IRefillPhone
         }
     }
 
+    private function recharge_error($card_id, $rechargeStatus){
+        if(in_array($rechargeStatus , [600401,600404,600405])) {
+            cards_helper::freeze($card_id);
+        }else{
+            cards_helper::reuse($card_id);
+        }
+    }
+
     private function sign($params)
     {
         $key = config::KEY;

+ 1 - 1
helper/refill/api/lingzh/legou/config.php

@@ -10,7 +10,7 @@ class config
     const QUERY_URL = 'https://recv.shujubuy.com/api/recv/queryOrder';
 
     const USERNAME = 'lzdc';
-    const KEY = '20cb7911903744e58786956eaffe1d3b';
+    const KEY = '20cb7911-9037-44e5-8786-956eaffe1d3b';
     const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
     const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
 

+ 15 - 2
test/TestRefill.php

@@ -255,8 +255,21 @@ class TestRefill extends TestCase
 
     public function testLegouPhone()
     {
-        $providers = new refill\legou\RefillPhone([]);
-        $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '690653407667699667' , 'order_id' => 248 , 'buyer_id' => 52667]);
+//        $providers = new refill\legou\RefillPhone([]);
+//        $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '690653407667699667' , 'order_id' => 248 , 'buyer_id' => 52667]);
+//        $resp = $providers->query(['order_sn' => '690653407667699667']);
+
+        $params['username'] = 'lzdc';
+        $params['orderNumber'] = '690653407667699667';
+        $params['cardNumber'] = '18500608333';
+        $params['orderMoney'] = '30.0';
+        $params['orderPay'] = '1.0';
+        $params['resultCode'] = '2';
+        $params['rechargeDesc'] = '{"rechargeStatus":600200,"rechargeDesc":"充值成功"}';
+        $params['rechargeVoucher'] = '100407307092103291444050244599';
+        $params['sign'] = 'c054884422a8c3749cbfda0e82b9af70';
+
+        refill\RefillFactory::instance()->notify('legou',$params);
     }
 
     public function testTongyPhone()