|
@@ -0,0 +1,79 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+use PHPUnit\Framework\TestCase;
|
|
|
+use statistics\stat_refill;
|
|
|
+
|
|
|
+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');
|
|
|
+
|
|
|
+
|
|
|
+class TestExportOrder extends TestCase
|
|
|
+{
|
|
|
+ public static function setUpBeforeClass() : void
|
|
|
+ {
|
|
|
+ Base::run_util();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testXingzhiyu()
|
|
|
+ {
|
|
|
+ $end_time = strtotime("2021-06-15");
|
|
|
+ $this->exoprt(10132,null,$end_time);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function exoprt($mchid,$start_time = null,$end_time = null)
|
|
|
+ {
|
|
|
+ $cond['mchid'] = $mchid;
|
|
|
+ $cond['vr_order.order_state'] = 40;
|
|
|
+ if(!is_null($start_time) && !is_null($end_time)) {
|
|
|
+ $cond["refill_order.notify_time&refill_order.notify_time"] = ['_multi' => true, ['egt', $start_time], ['lt', $end_time]];
|
|
|
+ }
|
|
|
+ elseif(!is_null($start_time)) {
|
|
|
+ $cond["refill_order.notify_time"] = ['egt', $start_time];
|
|
|
+ }
|
|
|
+ elseif(!is_null($end_time)) {
|
|
|
+ $cond["refill_order.notify_time"] = ['lt', $end_time];
|
|
|
+ }
|
|
|
+
|
|
|
+ $path = BASE_DATA_PATH . "/log/{$mchid}.csv";
|
|
|
+ $fp = fopen($path, 'w');
|
|
|
+ fputcsv($fp,['序号','商户订单号','卡号','面额','流水号',"下单时间","回调时间"]);
|
|
|
+
|
|
|
+ $count = 1000;
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+ $index = 0;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ $start = $i * $count;
|
|
|
+ $items = Model('')->table('refill_order,vr_order')
|
|
|
+ ->field('mch_order,refill_order.card_no,refill_amount,mch_amount,official_sn,from_unixtime(order_time) as sorder_time,from_unixtime(notify_time) as snotify_time')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->where($cond)
|
|
|
+ ->limit("{$start},{$count}")
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ if(empty($items)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+
|
|
|
+ foreach ($items as $item)
|
|
|
+ {
|
|
|
+ $index++;
|
|
|
+ $data = [$index,$item['mch_order'],$item['card_no'],$item['refill_amount'],$item['mch_amount'],$item['official_sn'],$item['sorder_time'],$item['snotify_time']];
|
|
|
+ fputcsv($fp,$data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fclose($fp);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestExportOrder::testXingzhiyu)( .*)?$/" --test-suffix TestExportOrder.php /var/www/html/test
|