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()); } }