|
@@ -21,7 +21,17 @@ class TestCardInfo extends TestCase
|
|
//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestCardInfo::testImport)( .*)?$/" --test-suffix TestCardInfo.php /var/www/html/test
|
|
//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestCardInfo::testImport)( .*)?$/" --test-suffix TestCardInfo.php /var/www/html/test
|
|
public function testImport()
|
|
public function testImport()
|
|
{
|
|
{
|
|
- $import_hour = function ($end)
|
|
|
|
|
|
+ $mod_cardinfo = Model('card_info');
|
|
|
|
+ $importer = function ($info) use($mod_cardinfo)
|
|
|
|
+ {
|
|
|
|
+ $card_no = trim($info['card_no']);
|
|
|
|
+ if(strlen($card_no) != 11) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ $mod_cardinfo->import_old($info);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $import_hour = function ($end) use ($importer)
|
|
{
|
|
{
|
|
$start = $end - 3600;
|
|
$start = $end - 3600;
|
|
$cond = ['order_time&order_time' => ['_multi' => true, ['egt', $start], ['lt', $end]],
|
|
$cond = ['order_time&order_time' => ['_multi' => true, ['egt', $start], ['lt', $end]],
|
|
@@ -38,9 +48,8 @@ class TestCardInfo extends TestCase
|
|
$i++;
|
|
$i++;
|
|
|
|
|
|
if(empty($items)) break;
|
|
if(empty($items)) break;
|
|
- foreach ($items as $item)
|
|
|
|
- {
|
|
|
|
- Log::record("{$item['card_no']}",Log::DEBUG);
|
|
|
|
|
|
+ foreach ($items as $item) {
|
|
|
|
+ $importer($item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -48,16 +57,14 @@ class TestCardInfo extends TestCase
|
|
$import_date = function ($end) use ($import_hour)
|
|
$import_date = function ($end) use ($import_hour)
|
|
{
|
|
{
|
|
$start = $end - 86400;
|
|
$start = $end - 86400;
|
|
- for ($hour = $end; $hour >= $start; $hour -= 3600)
|
|
|
|
- {
|
|
|
|
|
|
+ for ($hour = $end; $hour >= $start; $hour -= 3600) {
|
|
$import_hour($hour);
|
|
$import_hour($hour);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- $import_days = function ($start_date,$end_date) use ($import_date)
|
|
|
|
|
|
+ $import_days = function ($start_date, $end_date) use ($import_date)
|
|
{
|
|
{
|
|
- for ($date = $end_date; $date > $start_date; $date -= 86400)
|
|
|
|
- {
|
|
|
|
|
|
+ for ($date = $end_date; $date > $start_date; $date -= 86400) {
|
|
$import_date($date);
|
|
$import_date($date);
|
|
}
|
|
}
|
|
};
|
|
};
|