diff --git a/app/common/model/CrmCustomer.php b/app/common/model/CrmCustomer.php index bc439db..2c262b3 100644 --- a/app/common/model/CrmCustomer.php +++ b/app/common/model/CrmCustomer.php @@ -40,7 +40,7 @@ class CrmCustomer extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'sn', 'corp_abbr', 'user_id', 'user_sn', 'type', 'grade', 'sex', 'channel_id', 'country_id', 'car_type_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'desc_collect', 'address', 'lat', 'lng', 'follow_last', 'follow_next', 'warn', 'follow_remark', 'enter_user_id', 'created_at', 'updated_at', 'deleted_at']; + protected $fillable = ['id', 'sn', 'corp_id', 'user_id', 'user_sn', 'type', 'grade', 'sex', 'channel_id', 'country_id', 'car_type_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'desc_collect', 'address', 'lat', 'lng', 'follow_last', 'follow_next', 'warn', 'follow_remark', 'enter_user_id', 'created_at', 'updated_at', 'deleted_at']; /** * 不允许自动填充模型字段 diff --git a/app/common/utils/email/Emails.php b/app/common/utils/email/Emails.php index 18b06c2..68aca42 100644 --- a/app/common/utils/email/Emails.php +++ b/app/common/utils/email/Emails.php @@ -480,7 +480,7 @@ class Emails // 同步客户 $crmCustomer = new CrmCustomer(); $crmCustomer->sn = $inquiryLogResult->order_no; - $crmCustomer->corp_abbr = $recipientInfo->corp_id; + $crmCustomer->corp_id = $recipientInfo->corp_id; $crmCustomer->user_id = $assignedUid; $crmCustomer->type = 1; $crmCustomer->channel_id = $inquiryLogResult->channel; @@ -497,22 +497,28 @@ class Emails } // 邮件模板 + // $data = [ + // 'order_no' => $inquiryLogResult->order_no, + // 'enter_user_id' => $enterUser->name, + // 'recipient' => $recipientInfo->name, + // 'quality' => (new \app\inquiry\service\InquiryLogService())->qualityName($inquiryLogResult->quality), + // 'channel' => $channelInfo->name, + // 'email' => $inquiryLogResult->email && $inquiryLogResult->email != '' ? $inquiryLogResult->email : ' - ', + // 'tel' => $inquiryLogResult->tel && $inquiryLogResult->tel != '' ? $inquiryLogResult->tel : ' - ', + // 'whatsapp' => $inquiryLogResult->whatsapp && $inquiryLogResult->whatsapp != '' ? $inquiryLogResult->whatsapp : ' - ', + // 'country' => $countryName, + // 'contacts' => $inquiryLogResult->contacts && $inquiryLogResult->contacts != '' ? $inquiryLogResult->contacts : ' - ', + // 'content' => $inquiryLogResult->content && $inquiryLogResult->content != '' ? $inquiryLogResult->content : ' - ', + // 'r_time' => $inquiryLogResult->r_time ? date('Y-m-d H:i:s', $inquiryLogResult->r_time) : ' - ', + // 't_time' => $inquiryLogResult->t_time ? date('Y-m-d H:i:s', $inquiryLogResult->t_time) : ' - ' + // ]; + // \app\common\utils\email\MailSend::send($recipientInfo->email, '【XYH】新的客户线索', replaceTpl($data)); + + // 9.2 修改消息发送 $data = [ - 'order_no' => $inquiryLogResult->order_no, - 'enter_user_id' => $enterUser->name, - 'recipient' => $recipientInfo->name, - 'quality' => (new \app\inquiry\service\InquiryLogService())->qualityName($inquiryLogResult->quality), - 'channel' => $channelInfo->name, - 'email' => $inquiryLogResult->email && $inquiryLogResult->email != '' ? $inquiryLogResult->email : ' - ', - 'tel' => $inquiryLogResult->tel && $inquiryLogResult->tel != '' ? $inquiryLogResult->tel : ' - ', - 'whatsapp' => $inquiryLogResult->whatsapp && $inquiryLogResult->whatsapp != '' ? $inquiryLogResult->whatsapp : ' - ', - 'country' => $countryName, - 'contacts' => $inquiryLogResult->contacts && $inquiryLogResult->contacts != '' ? $inquiryLogResult->contacts : ' - ', - 'content' => $inquiryLogResult->content && $inquiryLogResult->content != '' ? $inquiryLogResult->content : ' - ', - 'r_time' => $inquiryLogResult->r_time ? date('Y-m-d H:i:s', $inquiryLogResult->r_time) : ' - ', - 't_time' => $inquiryLogResult->t_time ? date('Y-m-d H:i:s', $inquiryLogResult->t_time) : ' - ' + 'id' => $inquiryLogResult->id ]; - \app\common\utils\email\MailSend::send($recipientInfo->email, '【XYH】新的客户线索', replaceTpl($data)); + \Webman\RedisQueue\Redis::send('inquiry-to-crm-new', $data); // 更新状态 $record->update(['status' => 1]); diff --git a/app/crm/service/CustomerService.php b/app/crm/service/CustomerService.php index 01d8115..c20ceab 100644 --- a/app/crm/service/CustomerService.php +++ b/app/crm/service/CustomerService.php @@ -358,7 +358,10 @@ class CustomerService * 查询客户关系是否重复 */ public function distinct($params,$corpId){ - + // 9.1 add 报重修正 + if (!$params['email'] && !$params['phone'] && !$params['whatsApp']) { + return false; + } $customer = Customer::where('corp_id',$corpId) ->where((function (Builder $query) use ($params) { if(!empty($params['email']))