ImportRecord.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 导入记录
  4. // +----------------------------------------------------------------------
  5. // | Author: ymob
  6. // +----------------------------------------------------------------------
  7. namespace app\admin\model;
  8. class ImportRecord extends Common
  9. {
  10. protected $name = 'admin_import_record';
  11. protected $autoWriteTimestamp = true;
  12. protected $createTime = 'create_time';
  13. protected $updateTime = false;
  14. /**
  15. * 保存记录
  16. *
  17. * @param array $data
  18. * @return void
  19. * @author Ymob
  20. * @datetime 2019-10-22 11:46:41
  21. */
  22. public function createData($data)
  23. {
  24. $res = $this->save($data);
  25. $message_type_list = [
  26. 'crm_customer' => Message::IMPORT_CUSTOMER,
  27. 'crm_contacts' => Message::IMPORT_CONTACTS,
  28. 'crm_leads' => Message::IMPORT_LEADS,
  29. 'crm_product' => Message::IMPORT_PRODUCT,
  30. 'task' => Message::IMPORT_TASK,
  31. ];
  32. if ($res) {
  33. (new Message())->send(
  34. $message_type_list[$data['type']],
  35. [
  36. 'total' => $data['total'],
  37. 'error' => $data['error'],
  38. 'done' => $data['done'],
  39. 'success' => $data['done'] - $data['error'],
  40. 'cover' => $data['cover'],
  41. 'title' => $data['error'] > 0 ? '点击下载错误数据' : '',
  42. 'action_id' => $this->id,
  43. ],
  44. User::userInfo('id'),
  45. false
  46. );
  47. }
  48. }
  49. }