ayHaru 4 jaren geleden
bovenliggende
commit
5cf5f68c6a

+ 3 - 2
admin/control/merchant.php

@@ -1032,7 +1032,7 @@ class merchantControl extends SystemControl
             return $result;
         };
 
-        $match = function ($all,$cur)
+        $match = function ($all, $cur)
         {
             $inserts = $updates = [];
             foreach ($all as $key => $value)
@@ -1048,7 +1048,7 @@ class merchantControl extends SystemControl
                     $updates[] = $update;
                 }
             }
-            return [$inserts,$updates];
+            return [$inserts, $updates];
         };
 
         $updater = function ($mod,$updates)
@@ -1068,6 +1068,7 @@ class merchantControl extends SystemControl
                 $mod->insert($data);
             }
         };
+
         global $config;
         $oil_configs = $config['oil_providers'];
         $pho_configs = $config['phone_providers'];

+ 7 - 6
admin/templates/default/merchant.edit.php

@@ -64,12 +64,13 @@
             </tr>
             <tr class="noborder">
                 <td class="vatop">
-                    <input id="activity_state1" name="quality" <?php if($output['merchant']['quality'] == 1){ echo 'checked';}?> value="1" type="radio">普通
-                    <input id="activity_state0" name="quality" <?php if($output['merchant']['quality'] == 2){ echo 'checked';}?> value="2" type="radio">快速
-                    <input id="activity_state1" name="quality" <?php if($output['merchant']['quality'] == 3){ echo 'checked';}?> value="3" type="radio">卡密
-                    <input id="activity_state1" name="quality" <?php if($output['merchant']['quality'] == 4){ echo 'checked';}?> value="4" type="radio">三方
-                    <input id="activity_state1" name="quality" <?php if($output['merchant']['quality'] == 5){ echo 'checked';}?> value="5" type="radio">慢充
-                    <input id="activity_state1" name="quality" <?php if($output['merchant']['quality'] == 11){ echo 'checked';}?> value="11" type="radio">系统默认
+                    <input name="quality" <?php if($output['merchant']['quality'] == 1){ echo 'checked';}?> value="1" type="radio">普通
+                    <input name="quality" <?php if($output['merchant']['quality'] == 2){ echo 'checked';}?> value="2" type="radio">快速
+                    <input name="quality" <?php if($output['merchant']['quality'] == 3){ echo 'checked';}?> value="3" type="radio">卡密
+                    <input name="quality" <?php if($output['merchant']['quality'] == 4){ echo 'checked';}?> value="4" type="radio">三方
+                    <input name="quality" <?php if($output['merchant']['quality'] == 5){ echo 'checked';}?> value="5" type="radio">慢充
+                    <input name="quality" <?php if($output['merchant']['quality'] == 11){ echo 'checked';}?> value="11" type="radio">慢充一次+普充
+                    <input name="quality" <?php if($output['merchant']['quality'] == 12){ echo 'checked';}?> value="12" type="radio">三方一次+普充
                 </td>
             </tr>
             </tbody>

+ 2 - 1
data/config/dev/base.ini.php

@@ -129,4 +129,5 @@ $config['appjump_prefix'] = 'xyzshop://www.xyzshops.com';
 
 $config['client_setting'] = ['running' => 174,'home' => 0];
 $config['wsd_bradge_port'] = 60987;
-$config['card_key_stores'] = [6];
+$config['card_key_stores'] = [6];
+$config['phone_life_check'] = false;

+ 2 - 2
data/config/lingzh/base.ini.php

@@ -109,7 +109,7 @@ $config['return_address'] = ['address' => '上海市金山区朱吕公路7335号
 $config['area_version'] = 5;
 
 $config['appjump_prefix'] = 'xyzshop://www.xyzshops.com';
-
 $config['client_setting'] = ['running' => 174,'home' => 0];
+$config['wsd_bradge_port'] = 60987;
 
-$config['wsd_bradge_port'] = 60987;
+$config['phone_life_check'] = false;

+ 3 - 1
data/config/xyz/base.ini.php

@@ -111,4 +111,6 @@ $config['appjump_prefix'] = 'xyzshop://www.xyzshops.com';
 
 $config['client_setting'] = ['running' => 174,'home' => 0];
 $config['wsd_bradge_port'] = 60987;
-$config['card_key_stores'] = [6];
+$config['card_key_stores'] = [6];
+
+$config['phone_life_check'] = true;

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

@@ -333,16 +333,16 @@ $tonglu_phone = ['name' => 'tonglu', 'store_id' => 33,'qualitys' => '4',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
-$xc_phone = ['name' => 'xc', 'store_id' => 34,'qualitys' => '1',
+$xc_phone = ['name' => 'xc', 'store_id' => 34, 'qualitys' => '4',
     'amount' => [
-        10 => [['goods_id' => 6430, 'price' => 9.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6431, 'price' => 19.2, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6432, 'price' => 28.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6433, 'price' => 48, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6434, 'price' => 96, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6435, 'price' => 192, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6436, 'price' => 288, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6437, 'price' => 480, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+        10 => [['goods_id' => 6430, 'price' => 9.6, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6431, 'price' => 19.2, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6432, 'price' => 28.8, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6433, 'price' => 48, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6434, 'price' => 96, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6435, 'price' => 192, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6436, 'price' => 288, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6437, 'price' => 480, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
@@ -359,10 +359,9 @@ $phone_providers = [
     ['name' => 'afandeng', 'cfg' => $afandeng_phone],
     ['name' => 'afandnew', 'cfg' => $afandnew_phone],
     ['name' => 'lingzh', 'cfg' => $lingzh_phone],
-//    ['name' => 'lingzhdl', 'cfg' => $lingzhdl_phone],
     ['name' => 'tongy', 'cfg' => $tongy_phone],
     ['name' => 'weiyi', 'cfg' => $weiyi_phone],
     ['name' => 'tonglu', 'cfg' => $tonglu_phone],
-//    ['name' => 'xc', 'cfg' => $xc_phone],
+    ['name' => 'xc', 'cfg' => $xc_phone]
 ];
 $config['phone_providers'] = $phone_providers;

+ 4 - 4
data/config/xyz/vgoods.ini.php

@@ -22,11 +22,11 @@ $handlers[6217] = $mcard_params;
 
 #oil card
 $oil_params = ['type' => 'oil_card',
-    'order_check'     => 'OnOilCardCheck',
+    'order_check' => 'OnOilCardCheck',
     'order_method' => 'OnReserveOilCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
-    'input_params' => ['card_no','card_type','phone_no']];
+    'input_params' => ['card_no', 'card_type', 'phone_no']];
 
 $handlers[6218] = $oil_params;
 $handlers[6219] = $oil_params;
@@ -35,11 +35,11 @@ $handlers[6227] = $oil_params;
 
 #phone card
 $phone_card_prams = ['type' => 'phone_card',
-    'order_check'     => 'OnPhoneCardCheck',
+    'order_check' => 'OnPhoneCardCheck',
     'order_method' => 'OnReservePhoneCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
-    'input_params' => ['card_no','card_type']];
+    'input_params' => ['card_no', 'card_type']];
 
 $handlers[6221] = $phone_card_prams;
 $handlers[6228] = $phone_card_prams;

+ 2 - 1
data/config/xyztest/base.ini.php

@@ -106,4 +106,5 @@ $config['appjump_prefix'] = 'xyzshop://www.xyzshops.com';
 
 $config['client_setting'] = ['running' => 174,'home' => 0];
 $config['wsd_bradge_port'] = 60987;
-$config['card_key_stores'] = [6];
+$config['card_key_stores'] = [6];
+$config['phone_life_check'] = false;

+ 5 - 2
data/logic/queue.logic.php

@@ -1230,11 +1230,12 @@ class queueLogic
         $amount = $this->getTopcardAmound($order['goods_id']);
         $member_id = $order['buyer_id'];
         $order_id = $order['order_id'];
+        $store_id = $order['store_id'];
 
         $extra_info = json_decode($order['extra_info'], true);
         $card_no = $extra_info['input']['card_no'];
         $card_type = mtopcard\topcard_type($extra_info['input']['card_type']);
-        $ret = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper, $amount, $member_id, $card_no, $card_type, $order_id);
+        [$ret,$info] = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper, $amount, $member_id, $card_no, $card_type, $order_id,$store_id);
 
         $vr_order = Model();
         $vr_order->table('vr_order')->where(['order_id' => $order_id])->update(['card_no' => $card_no]);
@@ -1248,11 +1249,13 @@ class queueLogic
         $amount = $this->getTopcardAmound($order['goods_id']);
         $member_id = $order['buyer_id'];
         $order_id = $order['order_id'];
+        $store_id = $order['store_id'];
+
 
         $extra_info = json_decode($order['extra_info'], true);
         $card_no = $extra_info['input']['card_no'];
         $card_type = mtopcard\topcard_type($extra_info['input']['card_type']);
-        $ret = mtopcard\cards_helper::reserve(mtopcard\PhoneCardPaper, $amount, $member_id, $card_no, $card_type, $order_id);
+        [$ret,$info] = mtopcard\cards_helper::reserve(mtopcard\PhoneCardPaper, $amount, $member_id, $card_no, $card_type, $order_id, $store_id);
 
         $vr_order = Model();
         $vr_order->table('vr_order')->where(['order_id' => $order_id])->update(['card_no' => $card_no]);

+ 5 - 3
data/model/card_key.model.php

@@ -45,13 +45,15 @@ class card_keyModel extends Model
     public function getUsable($card_type, $amount)
     {
         return $this->where(['card_state' => UnusedCard, 'card_type' => $card_type, 'amount' => $amount])
-                    ->find();
+            ->lock(true)
+            ->master(true)
+            ->find();
     }
 
     public function reserve($card_id)
     {
         return $this->where(['card_id' => $card_id, 'card_state' => UnusedCard])
-                    ->update(['card_state' => ReserveCard]);
+            ->update(['card_state' => ReserveCard]);
     }
 
     public function assign($card_id, $oper)
@@ -65,7 +67,7 @@ class card_keyModel extends Model
         //只有已经预留了的卡才可以重新回收使用。
         return $this->where(['card_id' => $card_id, 'card_state' => ReserveCard])
                     ->update(['card_state' => UnusedCard,'member_id' => 0,'order_id' => 0,
-                              'receive_card_no' => '','receive_card_type' => '',
+                              'receive_card_no' => '','receive_card_type' => '', 'out_store_id' => 0,
                               'reserved_time' => 0, 'assigned_time' => 0]);
     }
     public function freeze($card_id)

+ 8 - 6
helper/mtopcard/cards_helper.php

@@ -10,34 +10,36 @@ use Log;
 
 class cards_helper
 {
-    static public function reserve($card_type, $amount, $userid, $user_card_no, $user_card_type,$order_id = 0)
+    static public function reserve($card_type, $amount, $userid, $user_card_no, $user_card_type,$order_id,$store_id = 0)
     {
         try {
             $model = Model('card_key');
             $trans = new trans_wapper($model, __METHOD__);
             $info = $model->getUsable($card_type, $amount);
             if (empty($info)) {
+                $trans->commit();
                 Log::record("cards_helper::reserve 找不到可用的卡了", Log::ERR);
-                return false;
+                return [false,"没有可用的卡密了"];
             }
+
             $card = new CardPaper($info);
             $card_id = $card->card_id();
             $model->reserve($card_id);
+            $trans->commit();
 
             $ret = $model->where(['card_id' => $card_id])
                          ->update(['member_id' => $userid,
                                    'order_id' => $order_id,
                                    'receive_card_no' => $user_card_no,
                                    'receive_card_type' => $user_card_type,
+                                   'out_store_id' => $store_id,
                                    'reserved_time' => time()]);
             $rows = $model->affected_rows();
-            $trans->commit();
-
-            return ($ret && $rows > 0);
+            return [true,$card];
         } catch (Exception $e) {
             $trans->rollback();
             Log::record("cards_helper::reserve exception {$e}", Log::ERR);
-            return false;
+            return [false,$e->getMessage()];
         }
     }
 

+ 1 - 1
helper/mtopcard/mtopcard.php

@@ -242,7 +242,7 @@ function valid_phone($phone) : bool
     {
         // "status": 1 //状态 0:空号;1:实号;2:停机;3:库无;4:沉默号;5:风险号
         $status = intval($resp['data']['status']);
-        if (in_array($status, [0, 3, 4, 5])) {
+        if (in_array($status, [0])) {
             Log::record("valid_phone phone:{$phone}, status : {$status}", Log::DEBUG);
             return false;
         } else {

+ 8 - 3
helper/refill/RefillBase.php

@@ -239,9 +239,14 @@ class RefillBase
             $notify_url = "";
         }
 
-        $minfo = new member_info($buyer_id);
-        $calc = new CalcMerchantPrice($mchid, $amount, $card_type,$quality);
-        $mch_amount = $calc->calc_vgoods_price([]);
+        try {
+            $minfo = new member_info($buyer_id);
+            $calc = new CalcMerchantPrice($mchid, $amount, $card_type,$quality);
+            $mch_amount = $calc->calc_vgoods_price([]);
+        }
+        catch (Exception $ex) {
+            return [errcode::MERCHANT_PRICE_UNSETTING, "没有协商商品价格",$last_orderid,false];
+        }
 
         $available = $minfo->available_predeposit();
         if ($mch_amount > $available) {

+ 1 - 1
helper/refill/api/lingzh/amingjd/RefillPhone.php

@@ -22,7 +22,7 @@ class RefillPhone extends refill\IRefillPhone
         $params['orderid'] = $order_sn;
         $params['price'] = $amount;
         $params['teltype'] = $this->phone_type($phone);
-        $params['timeout'] = 600;
+        $params['timeout'] = config::TIMEOUT;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
         $params['rand'] = rand(100000,999999);

+ 1 - 0
helper/refill/api/lingzh/amingjd/config.php

@@ -12,4 +12,5 @@ class config
     const MCHID = 10003;
     const KEY = '14d5ede552830bff5f25d6ae069aad12';
     const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/amingjd.php";
+    const TIMEOUT = 1800;
 }

+ 14 - 10
helper/refill/api/xyz/xc/RefillPhone.php

@@ -46,20 +46,22 @@ class RefillPhone extends refill\IRefillPhone
         }
     }
 
-    public function query($refill_info){
+    public function query($refill_info)
+    {
         $params['pay_orderid'] = $refill_info['order_sn'];
         $params['pay_memberid'] = config::NUMBER_ID;
-        $sign = $this->sign($params,true);
+        $sign = $this->sign($params, true);
         $params['sign'] = $sign;
 
-        $resp = http_request(config::QUERY_ORDER_URL,$params,'POST');
-        if($resp === false) {
-            return [false,'系统错误'];
-        }
+        $resp = http_request(config::QUERY_ORDER_URL, $params, 'POST');
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } 
         else
         {
-            Log::record($resp,Log::DEBUG);
-            $resp = json_decode($resp,true);
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
             $order_state = -1;
             $status = $resp['data']['status'];
             if ($status == 1) {
@@ -68,13 +70,15 @@ class RefillPhone extends refill\IRefillPhone
                 Model('refill_order')->edit($refill_info['order_id'], $save);
             } elseif ($status == 0) {
                 $order_state = ORDER_STATE_CANCEL;
-            } elseif ($status == 2){
+            } elseif ($status == 2) {
                 $order_state = ORDER_STATE_SEND;
             }
+
             if ($order_state == -1) {
                 return [false, $resp['info']];
+            } else {
+                return [true, $order_state];
             }
-            return [true, $order_state];
         }
     }
 

+ 1 - 1
helper/refill/api/xyz/xc/config.php

@@ -8,7 +8,7 @@ class config
 {
     const ORDER_URL = 'http://202.79.172.201/pay/order/upload';
     const QUERY_ORDER_URL = 'http://202.79.172.201/chaxun/order/queryStatus';
-    const NUMBER_ID= '10010';
+    const NUMBER_ID = '10010';
     const KEY = '11a5e71e0da0e3ae0942cbd6b7c62f2a';
     const NOTIFY_URL =  BASE_SITE_URL."/mobile/refill_xc.php";
 }

+ 1 - 0
helper/refill/errcode.php

@@ -10,5 +10,6 @@ class errcode
     const MERCHANT_SHORT_MONEY = 203;
     const MERCHANT_REFILL_ERROR = 204;
     const PROVIDER_OVERLOAD = 205;
+    const MERCHANT_PRICE_UNSETTING = 206;
 
 }

+ 41 - 13
helper/refill/policy/quaility.php

@@ -78,25 +78,53 @@ class Quality
     {
         $left_time = $time_out - $used_time;
         if($left_time <= 0 || $max_times <= $times) return [];
-        $qualities = array_reverse($qualities);
 
-        $result = [];
-        foreach ($qualities as $quality)
+        Log::record("calc_quality begin qualities = " . implode(',',$qualities),Log::DEBUG);
+        $times_checker = function($qualities, $times)
         {
-            $per_secs = $this->mSpeeds[$quality]['per_secs'];
-            $left_time -= $per_secs;
-            if($left_time > 0) {
+            $result = [];
+            $pre_times = 0;
+            foreach ($qualities as $quality)
+            {
+                $pre_times += $this->mSpeeds[$quality]['retry_times'];
+                if($times < $pre_times) {
+                    $result[] = $quality;
+                }
+            }
+
+            return $result;
+        };
+
+        $timeout_checker = function ($qualities, $left_time)
+        {
+            $qualities = array_reverse($qualities);
+            $result = [];
+            foreach ($qualities as $quality)
+            {
+                $per_secs = $this->mSpeeds[$quality]['per_secs'];
+                $left_time -= $per_secs;
+                if($left_time > 0) {
+                    $result[] = $quality;
+                } else {
+                    break;
+                }
+            }
+
+            if(count($qualities) > 0 && empty($result)) {
                 $result[] = $quality;
-            } else {
-                break;
             }
-        }
+            $result = array_reverse($result);
+
+            return $result;
+        };
 
-        if(empty($result)) {
-            $result[] = $quality;
+        if($times > 0) {
+            $qualities = $times_checker($qualities,$times);
+            Log::record("calc_quality times_checker result = " . implode($qualities),Log::DEBUG);
+            $qualities = $timeout_checker($qualities,$left_time);
+            Log::record("calc_quality timeout_checker result = " . implode($qualities),Log::DEBUG);
         }
 
-        $result = array_reverse($result);
-        return $result;
+        return $qualities;
     }
 }

+ 4 - 3
helper/refill/policy/xyz/quality_ploy.php

@@ -13,7 +13,7 @@ class quality_ploy extends Quality
             self::Quick => ['retry_times' => 10,'retry_timeout' => 60,'per_secs' => 30],
             self::CardKey => ['retry_times' => 60,'retry_timeout' => 900,'per_secs' => 60],
             self::ThirdShop => ['retry_times' => 60,'retry_timeout' => 900,'per_secs' => 600],
-            self::Slow => ['retry_times' => 60,'retry_timeout' => 86400,'per_secs' => 3600],
+            self::Slow => ['retry_times' => 1,'retry_timeout' => 1800,'per_secs' => 900],
 
             self::DefNormal => ['retry_times' => 60,'retry_timeout' => 900,'per_secs' => 60],
             self::DefSuccess => ['retry_times' => 60,'retry_timeout' => 900,'per_secs' => 60],
@@ -26,8 +26,9 @@ class quality_ploy extends Quality
             self::ThirdShop => [self::ThirdShop],
             self::Slow => [self::Slow],
 
-            self::DefNormal  => [self::ThirdShop,self::Normal],
-            self::DefSuccess => [self::ThirdShop,self::CardKey,self::Normal,self::Quick]
+//            self::DefNormal  => [self::ThirdShop,self::Normal],
+            self::DefNormal => [self::Slow, self::Normal],
+            self::DefSuccess => [self::ThirdShop, self::CardKey, self::Normal, self::Quick]
         ];
     }
 }

+ 8 - 3
rdispatcher/proxy.php

@@ -4,6 +4,7 @@ require_once (BASE_ROOT_PATH . '/helper/model_helper.php');
 
 use mtopcard;
 use refill;
+use refill\errcode;
 
 class proxy
 {
@@ -31,12 +32,16 @@ class proxy
         $org_quality = intval($params['org_quality']) ?? 0;
         $card_type   = intval($params['card_type']) ?? 0;
 
+        Log::record("proxy::add mch_order={$mch_order} card_no = {$card_no}",Log::DEBUG);
+
         $need_check = false;
         if($card_type == 0)
         {
             $card_type = mtopcard\card_type($card_no);
             $params['card_type'] = $card_type;
-            if($card_type != mtopcard\PetroChinaCard && $card_type != mtopcard\SinopecCard) {
+
+            global $config;
+            if($config['phone_life_check'] == true && $card_type != mtopcard\PetroChinaCard && $card_type != mtopcard\SinopecCard) {
                 $need_check = true;
             }
         }
@@ -63,7 +68,7 @@ class proxy
         if($errcode !== true)
         {
             $fNotify = true;
-            if(($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr) || $errcode == refill\errcode::PROVIDER_OVERLOAD)
+            if(($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr) || $errcode == refill\errcode::PROVIDER_OVERLOAD || $errcode == errcode::MERCHANT_PRICE_UNSETTING)
             {
                 [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($mchid,$amount,$card_type,$org_quality,$commit_times,time() - $order_time);
                 if ($quality > 0) {
@@ -92,7 +97,7 @@ class proxy
                     }
                 }
                 else {
-                    $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
+                    $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
                 }
 
                 QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);

+ 37 - 0
test/TestCardKey.php

@@ -0,0 +1,37 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+require_once(BASE_HELPER_PATH . '/mcard/mcard.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+require_once(BASE_HELPER_PATH . '/util_helper.php');
+
+require_once(BASE_HELPER_PATH . '/order_helper.php');
+require_once(BASE_HELPER_PATH . '/bonus_helper.php');
+require_once(BASE_HELPER_PATH . '/vrorder_helper.php');
+
+
+class TestCardKey extends TestCase
+{
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+    }
+
+    public function testGetUsable()
+    {
+        $amount = 1000;
+        [$ret,$info] = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard,0);
+
+
+
+    }
+}

+ 2 - 2
test/TestMemberCard.php

@@ -308,9 +308,9 @@ class TestMemberCard extends TestCase
     public function testReserve()
     {
         $amount = 1000;
-        $card = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard);
+        [$ret,$info] = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard);
         mtopcard\cards_helper::assign(1,'xiongmao');
-        mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard);
+        [$ret,$info] = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard);
         mtopcard\cards_helper::reuse(4);
     }