瀏覽代碼

fix card no check erro

stanley-king 4 年之前
父節點
當前提交
8c71e211a1
共有 3 個文件被更改,包括 52 次插入2 次删除
  1. 1 1
      data/model/topcard.model.php
  2. 0 1
      mobile/control/member_buy.php
  3. 51 0
      test/TestAddData.php

+ 1 - 1
data/model/topcard.model.php

@@ -24,6 +24,6 @@ class topcardModel extends Model
     }
     public function get_cards($low,$high)
     {
-        return $this->table('topcard')->where(['card_no' => ['between' => [$low,$high]]])->select();
+        return $this->table('topcard')->where(['card_no' => ['between',"{$low},{$high}"]])->select();
     }
 }

+ 0 - 1
mobile/control/member_buy.php

@@ -206,7 +206,6 @@ class member_buyControl extends mbMemberControl
 
     public function step_vsecondOp()
     {
-
         if(!$this->check_time()) {
             return self::outerr(errcode::ErrInputParam, '目前充值时间段为9:00--21:00,本周六周日运营商系统维护,请下周再来~');
         }

+ 51 - 0
test/TestAddData.php

@@ -390,8 +390,59 @@ class TestAddData extends TestCase
             $this->addFile($file);
         }
     }
+
+    public function testFindCard()
+    {
+        $card_key = Model('card_key');
+
+        $count = 1000;
+        $i = 0;
+
+        $pairs = [];
+        $pair = ['start' => 0,'end' => 0];
+        while (true)
+        {
+            $start = $i * $count;
+            $items = $card_key->field('*')->order('card_no asc')->limit("{$start},{$count}")->select();
+            if(empty($items)) {
+                break;
+            }
+            $i++;
+
+            foreach ($items as $item)
+            {
+                try {
+                    $card_no = intval($item['card_no']);
+
+                    if($pair['end'] + 1 == $card_no) {
+                        $pair['end'] = $card_no;
+                    }
+                    else {
+                        $pairs[] = $pair;
+                        $pair = ['start' => $card_no,'end' => $card_no];
+                    }
+                }
+                catch (Exception $ex) {
+                    Log::record($ex->getMessage(),Log::DEBUG);
+                }
+            }
+        }
+
+        foreach ($pairs as $pair) {
+            $count = $pair['end'] - $pair['start'] + 1;
+            Log::record("{$pair['start']}------{$pair['end']} count = {$count}",Log::DEBUG);
+        }
+    }
+
+    public function testCardCheck()
+    {
+        $card_no = 1000113300023292731;
+        $topcard = Model('topcard');
+        $items = $topcard->get_cards($card_no - 500,$card_no + 500);
+    }
 }
 
 //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAddData::testCancelOrder)( .*)?$/" --test-suffix TestAddData.php /var/www/html/test
 //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAddData::test20200821_addCard)( .*)?$/" --test-suffix TestAddData.php /var/www/html/test
 //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAddData::test20200910_addCard)( .*)?$/" --test-suffix TestAddData.php /var/www/html/test
+