12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Imports;
- use App\Models\AdminMerchant;
- use App\Models\BoxBinding;
- use Illuminate\Support\Facades\Log;
- use Maatwebsite\Excel\Concerns\OnEachRow;
- use Maatwebsite\Excel\Concerns\ToModel;
- use Maatwebsite\Excel\Row;
- class BoxBindingImport implements OnEachRow
- {
- /**
- * 逐条插入
- * */
- public function onRow(Row $row)
- {
- $rowIndex = $row->getIndex();
- $row = $row->toArray();
- if ($rowIndex === 1) return false;
- if (!$row[1]) return false;
- return BoxBinding::updateOrCreate([
- 'box_no' => $row[0],
- ], [
- 'batch' => date('Ymd'),
- 'box_no' => $row[0],
- 'device_xing' => $row[8],
- 'imei_no' => $row[1],
- 'imsi_no' => $row[2],
- 'iccid_no' => $row[3],
- 'manufacturer' => 2,
- 'bluetooth_mac' => $row[4],
- 'bluetooth_token' => $row[5],
- 'merchant_id' => $row[6] ?? AdminMerchant::getMchId(),
- 'mold' => $row[7],
- 'pulse' => 60,
- 'freq' => 5,
- 'vibfilterremindt' => 30,
- 'server' => 'relay.bike.hanyiyun.com:8282'
- ]);
- }
- }
|