where('id', $data['id'])->first(); $corpId = 0; if ($info->recipient) { $uinfo = User::where('id', $info->recipient)->where('status', 1)->first(); if ($uinfo) { $corpId = $uinfo->corp_id; } } // 获取客户信息 $crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first(); if ($crmCustomerInfo) { $udata = [ 'corp_id' => $corpId, 'user_id' => $info->recipient, 'channel_id' => $info->channel, 'country_id' => $info->country, 'magnitude' => $info->quality, 'email' => $info->email, 'phone' => $info->tel, 'WhatsApp' => $info->whatsapp, 'contacts' => $info->contacts, 'desc_collect' => $info->content, ]; $crmCustomerInfo->update($udata); } else { // 同步客户数据 $crmCustomer = new CrmCustomer(); $crmCustomer->sn = $info->order_no; $crmCustomer->corp_id = $corpId; $crmCustomer->user_id = $info->recipient; $crmCustomer->type = 1; $crmCustomer->channel_id = $info->channel; $crmCustomer->country_id = $info->country; $crmCustomer->magnitude = $info->quality; $crmCustomer->email = $info->email; $crmCustomer->phone = $info->tel; $crmCustomer->WhatsApp = $info->whatsapp; $crmCustomer->contacts = $info->contacts; $crmCustomer->desc_collect = $info->content; $crmCustomer->enter_user_id = $info->enter_user_id; if(empty($info->recipient)){ $crmCustomer->deleted_at = time(); } // 修改同步CRM状态 $info->sync_crm = 1; // 保存 if (!$crmCustomer->save() || !$info->save()) { throw new BusinessException('同步失败~'); } // 发送邮件消息 if ($uinfo && $uinfo->email) { $options = [ 'id' => $info->id, 'email' => $uinfo->email ]; \Webman\RedisQueue\Redis::send('email-message', $options); } } } catch (\Throwable $th) { throw $th; } } // 消费失败回调 /* $package = [ 'id' => 1357277951, // 消息ID 'time' => 1709170510, // 消息时间 'delay' => 0, // 延迟时间 'attempts' => 2, // 消费次数 'queue' => 'send-mail', // 队列名 'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容 'max_attempts' => 5, // 最大重试次数 'error' => '错误信息' // 错误信息 ] */ public function onConsumeFailure(\Throwable $e, $package) { echo "consume failure\n"; echo $e->getMessage() . "\n"; // 无需反序列化 var_export($package); } }