BoxBindingImport.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Imports;
  3. use App\Models\AdminMerchant;
  4. use App\Models\BoxBinding;
  5. use Illuminate\Support\Facades\Log;
  6. use Maatwebsite\Excel\Concerns\OnEachRow;
  7. use Maatwebsite\Excel\Concerns\ToModel;
  8. use Maatwebsite\Excel\Row;
  9. class BoxBindingImport implements OnEachRow
  10. {
  11. /**
  12. * 逐条插入
  13. * */
  14. public function onRow(Row $row)
  15. {
  16. $rowIndex = $row->getIndex();
  17. $row = $row->toArray();
  18. if ($rowIndex === 1) return false;
  19. if (!$row[1]) return false;
  20. return BoxBinding::updateOrCreate([
  21. 'box_no' => $row[0],
  22. ], [
  23. 'batch' => date('Ymd'),
  24. 'box_no' => $row[0],
  25. 'device_xing' => $row[8],
  26. 'imei_no' => $row[1],
  27. 'imsi_no' => $row[2],
  28. 'iccid_no' => $row[3],
  29. 'manufacturer' => 2,
  30. 'bluetooth_mac' => $row[4],
  31. 'bluetooth_token' => $row[5],
  32. 'merchant_id' => $row[6] ?? AdminMerchant::getMchId(),
  33. 'mold' => $row[7],
  34. 'pulse' => 60,
  35. 'freq' => 5,
  36. 'vibfilterremindt' => 30,
  37. 'server' => 'relay.bike.hanyiyun.com:8282'
  38. ]);
  39. }
  40. }