| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- use App\OwnerFeeDetail;
- use App\OwnerLogisticFeeDetail;
- use Carbon\Carbon;
- use Illuminate\Database\Seeder;
- class OwnerLogisticFeeDetailSeeder extends Seeder
- {
- /**
- * Run the database seeds.
- *
- * @return void
- */
- public function run()
- {
- // $ownerFeeDetails = OwnerFeeDetail::query()
- // ->with('items')
- // ->where('type', '发货')
- // ->where('outer_table_name', 'orders')
- // ->whereHas('logistic', function ($query) {
- // $query->where('type', '快递');
- // })
- // ->where('owner_id', [12])
- // ->where('worked_at', '>=', Carbon::parse('2021-05-30')->startOfDay())
- // ->where('worked_at', '<=', Carbon::parse('2021-05-31')->endOfDay())
- // ->get();
- // foreach ($ownerFeeDetails as $ownerFeeDetail) {
- // factory(\App\OwnerLogisticFeeDetail::class)->create([
- // 'owner_fee_detail_id' => $ownerFeeDetail->id,
- // 'logistic_bill' => $ownerFeeDetail->items->first()->logistic_bill??$ownerFeeDetail->logistic_bill,
- // 'logistic_id'=>$ownerFeeDetail->logistic_id,
- // 'province'=>$ownerFeeDetail->province
- // ]);
- // }
- // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
- // [
- // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(1),
- // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(2)
- // ]
- // );
- //
- // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
- // [
- // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(2),
- // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(3)
- // ]
- // );
- //
- // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
- // [
- // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(3),
- // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(4)
- // ]
- // );
- OwnerLogisticFeeDetail::query()->truncate();
- OwnerFeeDetail::query()->truncate();
- factory(OwnerLogisticFeeDetail::class)->times(200)->create();
- $details = OwnerLogisticFeeDetail::all();
- foreach ($details as $detail) {
- factory(OwnerFeeDetail::class)->create([
- 'type' => '发货',
- 'outer_table_name'=>'orders',
- 'logistic_id'=>$detail->logistic_id,
- 'owner_id'=>$detail->owner_id,
- 'worked_at'=>now()->subMonth()->startOfMonth()->addDays(random_int(1,28)) ->toDateTimeString(),
- ]);
- }
- }
- }
|