CustomerReceivingThirdPlatFormJob.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Jobs;
  3. use App\Model\CustomerFromThreePlatForm;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Queue\SerializesModels;
  9. use Illuminate\Support\Facades\Log;
  10. use Symfony\Component\Console\Output\OutputInterface;
  11. class CustomerReceivingThirdPlatFormJob implements ShouldQueue
  12. {
  13. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14. protected $data;
  15. public function __construct($data)
  16. {
  17. $this->data = $data;
  18. }
  19. public function handle()
  20. {
  21. try {
  22. if(empty($this->data) || empty($this->data["data"])) {
  23. $this->delete();
  24. return;
  25. }
  26. $data = $this->data["data"];
  27. $array = json_decode($data,true);
  28. $content = $array["content"];
  29. $adv_id = "";
  30. if(! empty($content['adInfo'])){
  31. $adInfo = json_decode($content['adInfo'],true);
  32. $adv_id = $adInfo['advId'] ?? "";
  33. }
  34. $insert = [
  35. 'crt_time' => time(),
  36. 'city' => $content['city'] ?? "",
  37. 'actionType' => $content["actionType"] ?? 0,
  38. 'acquireTime' => $content["acquireTime"] ?? "",
  39. 'clueType' => $content["clueType"] ?? 0,
  40. 'product' => $content["product"] ?? "",
  41. 'wechat' => $content["wechat"] ?? "",
  42. 'clueId' => $content["clueId"] ?? "",
  43. 'transformType' => $content["transformType"] ?? "",
  44. 'clueSource' => $content["clueSource"] ?? "",
  45. 'clueSourceId' => $content["clueSourceId"] ?? "",
  46. 'customerName' => $content["customerName"] ?? "",
  47. 'platform' => $content["platform"] ?? 0,
  48. 'ipLocationCity' => $content["ipLocationCity"] ?? "",
  49. 'phone' => $content["phone"] ?? "",
  50. 'isRepeatClue' => $content["isRepeatClue"] ?? 0,
  51. 'flowType' => $content["flowType"] ?? 0,
  52. 'fromUserId' => $array["fromUserId"] ?? "",
  53. 'adv_id' => $adv_id,
  54. ];
  55. CustomerFromThreePlatForm::insert($insert);
  56. } catch (\Throwable $e) {
  57. Log::error('Queue error:', ['exception' => $e->getMessage() . '|' . $e->getLine()]);
  58. $this->delete();
  59. }
  60. }
  61. protected function echoMessage(OutputInterface $output)
  62. {
  63. //输出消息
  64. $output->writeln(json_encode($this->data));
  65. }
  66. }