12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Tests\ContentManage\Services\CpManage;
- use Illuminate\Support\Facades\DB;
- use Modules\Common\Support\Trace\TraceContext;
- use Modules\ContentManage\Services\CpManage\BookSettlement;
- use PHPUnit\Framework\TestCase;
- class BookSettlementTest extends \Tests\TestCase
- {
- private $bid = 10002;
- protected function setUp11(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $startDate = '2023-01-23';
- $endDate = '2023-05-13';
- $date = $startDate;
- DB::table('cp_subscribe_statistic_data')
- ->where(['bid' => $this->bid])
- ->delete();
- while ($date <= $endDate) {
- $nextDate = date_add(date_create($date), date_interval_create_from_date_string('1 day'))->format('Y-m-d');
- DB::table('cp_subscribe_statistic_data')
- ->insert([
- 'bid' => $this->bid,
- 'calculate_date' => $nextDate,
- 'settlement_date' => $date,
- 'month' => date_create($date)->format('Y-m'),
- 'cp_name' => 'kanshu',
- 'yesterday_available_amount' => rand(1000 , 5000),
- 'yesterday_final_amount' => rand(100, 500),
- 'yesterday_total_coins' => rand(10000, 50000),
- 'book_settlement_type' => array_rand(['share', 'bottomline', 'buyout'])
- ]);
- $date = $nextDate;
- }
- }
- public function testRun()
- {
- $bid = 10002;
- $month = '2023-03';
- dump($pInfo = app(TraceContext::class)->getTraceInfo());
- $service = new BookSettlement($bid, $month);
- $service->traceContext = TraceContext::newFromParent($pInfo);
- dump($service->detail());
- }
- }
|