|
|
@@ -56,7 +56,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function orderCountingRecords_remember()
|
|
|
+ public function orderCountingRecords_remember_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(2)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -73,7 +73,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromCache_all()
|
|
|
+ public function dataFromCache_all_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(2)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -87,13 +87,13 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
}
|
|
|
}
|
|
|
$result = $this->newOrderCountingRecordService->dataFromCache($start, $end, $unit);
|
|
|
- $this->assertCount(6, $result['dataByDayFromCache']);
|
|
|
+ $this->assertCount(6, $result['dataFromCache']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromCache_empty()
|
|
|
+ public function dataFromCache_empty_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(2)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -110,7 +110,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromMiddleTable_all()
|
|
|
+ public function dataFromMiddleTable_all_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -122,9 +122,9 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
factory(OrderCountingRecord::class)->times(2)->create(['date_target' => Carbon::now()->subDays(1)->toDateString(), 'owner_id' => $owner1->id]);
|
|
|
factory(OrderCountingRecord::class)->times(2)->create(['date_target' => Carbon::now()->subDays(1)->toDateString(), 'owner_id' => $owner2->id]);
|
|
|
$dateArray = $this->newOrderCountingRecordService->dateUtils($start, $end, $unit);
|
|
|
- $result = $this->newOrderCountingRecordService->dataByDayFromMiddleTable($dateArray, $unit);
|
|
|
+ $result = $this->newOrderCountingRecordService->dataFromMiddleTable($dateArray, $unit);
|
|
|
|
|
|
- $this->assertCount(8, $result['dataByDayFromMiddleTable']);
|
|
|
+ $this->assertCount(8, $result['dataFromMiddleTable']);
|
|
|
$this->assertCount(0, $result['unQueryCondition'][Carbon::now()->toDateString()]);
|
|
|
$this->assertCount(0, $result['unQueryCondition'][Carbon::now()->subDays(1)->toDateString()]);
|
|
|
}
|
|
|
@@ -132,7 +132,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromMiddleTable_empty()
|
|
|
+ public function dataFromMiddleTable_empty_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -141,9 +141,9 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
$owner2 = factory(Owner::class)->create();
|
|
|
|
|
|
$dateArray = $this->newOrderCountingRecordService->dateUtils($start, $end, $unit);
|
|
|
- $result = $this->newOrderCountingRecordService->dataByDayFromMiddleTable($dateArray, $unit);
|
|
|
+ $result = $this->newOrderCountingRecordService->dataFromMiddleTable($dateArray, $unit);
|
|
|
|
|
|
- $this->assertCount(0, $result['dataByDayFromMiddleTable']);
|
|
|
+ $this->assertCount(0, $result['dataFromMiddleTable']);
|
|
|
$this->assertCount(2, $result['unQueryCondition'][Carbon::now()->toDateString()]);
|
|
|
$this->assertCount(2, $result['unQueryCondition'][Carbon::now()->subDays(1)->toDateString()]);
|
|
|
}
|
|
|
@@ -151,7 +151,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromMiddleTable_common()
|
|
|
+ public function dataFromMiddleTable_common_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -162,9 +162,9 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
$dateArray = $this->newOrderCountingRecordService->dateUtils($start, $end, $unit);
|
|
|
factory(OrderCountingRecord::class)->times(2)->create(['date_target' => Carbon::now()->toDateString(), 'owner_id' => $owner1->id]);
|
|
|
|
|
|
- $result = $this->newOrderCountingRecordService->dataByDayFromMiddleTable($dateArray, $unit);
|
|
|
+ $result = $this->newOrderCountingRecordService->dataFromMiddleTable($dateArray, $unit);
|
|
|
|
|
|
- $this->assertCount(2, $result['dataByDayFromMiddleTable']);
|
|
|
+ $this->assertCount(2, $result['dataFromMiddleTable']);
|
|
|
$this->assertCount(1, $result['unQueryCondition'][Carbon::now()->toDateString()]);
|
|
|
$this->assertCount(2, $result['unQueryCondition'][Carbon::now()->subDays(1)->toDateString()]);
|
|
|
}
|
|
|
@@ -172,7 +172,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function insertIntoCache()
|
|
|
+ public function insertIntoCache_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -183,9 +183,9 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
$dateArray = $this->newOrderCountingRecordService->dateUtils($start, $end, $unit);
|
|
|
$orderCountingRecord = factory(OrderCountingRecord::class)->times(2)->create(['date_target' => Carbon::now()->toDateString(), 'owner_id' => $owner1->id]);
|
|
|
|
|
|
- $result = $this->newOrderCountingRecordService->dataByDayFromMiddleTable($dateArray, $unit);
|
|
|
+ $result = $this->newOrderCountingRecordService->dataFromMiddleTable($dateArray, $unit);
|
|
|
|
|
|
- $this->newOrderCountingRecordService->insertIntoCache($result['dataByDayFromMiddleTable'], $unit);
|
|
|
+ $this->newOrderCountingRecordService->insertIntoCache($result['dataFromMiddleTable'], $unit);
|
|
|
$key = 'order_counting_records_' . Carbon::now()->toDateString() . '_' . $owner1->id . '_' . $unit;
|
|
|
$this->assertNotNull(cache()->get($key));
|
|
|
$this->assertNotNull($orderCountingRecord->toArray());
|
|
|
@@ -195,7 +195,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromOrder()
|
|
|
+ public function dataFromOrder_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -211,7 +211,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
factory(Order::class)->times(3)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner1->id]);
|
|
|
factory(Order::class)->times(4)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner2->id]);
|
|
|
|
|
|
- $result = $this->newOrderCountingRecordService->dataByDayFromOrder($unQueryCondition, $unit);
|
|
|
+ $result = $this->newOrderCountingRecordService->dataFromOrder($unQueryCondition, $unit);
|
|
|
$this->assertEquals(1, $result->where('date_target', Carbon::now()->toDateString())->where('owner_id', $owner1->id)->first()->amount);
|
|
|
$this->assertEquals(2, $result->where('date_target', Carbon::now()->toDateString())->where('owner_id', $owner2->id)->first()->amount);
|
|
|
$this->assertEquals(3, $result->where('date_target', Carbon::now()->subDays(1)->toDateString())->where('owner_id', $owner1->id)->first()->amount);
|
|
|
@@ -221,7 +221,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromOrder_insertMiddleTable()
|
|
|
+ public function dataFromOrder_insertMiddleTable_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -237,7 +237,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
factory(Order::class)->times(3)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner1->id]);
|
|
|
factory(Order::class)->times(4)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner2->id]);
|
|
|
|
|
|
- $this->newOrderCountingRecordService->dataByDayFromOrder($unQueryCondition, $unit);
|
|
|
+ $this->newOrderCountingRecordService->dataFromOrder($unQueryCondition, $unit);
|
|
|
//当天的数据不入中间表
|
|
|
$this->assertCount(0, OrderCountingRecord::query()->where('date_target', Carbon::now()->toDateString())->get());
|
|
|
$this->assertCount(2, OrderCountingRecord::query()->where('date_target', Carbon::now()->subDays(1)->toDateString())->get());
|
|
|
@@ -247,7 +247,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function dataByDayFromOrder_insertCache()
|
|
|
+ public function dataFromOrder_insertCache_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
@@ -263,7 +263,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
factory(Order::class)->times(3)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner1->id]);
|
|
|
factory(Order::class)->times(4)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner2->id]);
|
|
|
|
|
|
- $this->newOrderCountingRecordService->dataByDayFromOrder($unQueryCondition, $unit);
|
|
|
+ $this->newOrderCountingRecordService->dataFromOrder($unQueryCondition, $unit);
|
|
|
$key1 = 'order_counting_records_' . Carbon::now()->toDateString() . '_' . $owner1->id . '_' . $unit;
|
|
|
$key2 = 'order_counting_records_' . Carbon::now()->toDateString() . '_' . $owner2->id . '_' . $unit;
|
|
|
$key3 = 'order_counting_records_' . Carbon::now()->subDays(1)->toDateString() . '_' . $owner1->id . '_' . $unit;
|
|
|
@@ -277,7 +277,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
/**
|
|
|
* @test
|
|
|
*/
|
|
|
- public function orderCountingRecordsDay()
|
|
|
+ public function orderCountingRecordsDay_day()
|
|
|
{
|
|
|
$start = Carbon::now()->subDays(1)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|