where('corpid', $params['corpid']) // ->where('enable', 1) // ->where('unionid', $params['unionid']) // ->first(); // // if(empty($customerInfo)) { // Log::logError('updateCustomerTag', [ // 'params' => $params, // 'errmsg' => '查询客户信息为空', // ], 'thirdPlatform'); // return ['查询客户信息为空', 1102]; // } // 查询客户是否在系统中 $customerDetails = CustomerDetails::suffix($params['corpid']) ->where('corpid', $params['corpid']) ->where('remark_mobiles', 'like' , '%' . $params['phone'] . '%') ->where('enable', 1) ->get(); if($customerDetails->isEmpty()) { Log::logError('updateCustomerTag', [ 'params' => $params, 'errmsg' => '查询客户信息为空', ], 'thirdPlatform'); return ['查询客户信息为空', 5002]; } // 根据传递的标签名称获取对应的标签id $addTagIdList = CustomerTagService::getTagIdListByTagName($params['corpid'], $params['add_tag']); if(empty($addTagIdList)) { Log::logError('updateCustomerTag', [ 'params' => $params, 'errmsg' => '查询标签结果异常', ], 'thirdPlatform'); return ['查询标签结果异常', 5003]; } foreach($customerDetails as $customerInfo) { $redisData = json_encode([ 'corpid' => $customerInfo->corpid, 'user_id' => $customerInfo->user_id, 'external_userid' => $customerInfo->external_userid, 'tag_id_list' => $addTagIdList, ]); RedisModel::lPush(CustomerTagService::CUSTOMER_TAG_UNIONID, $redisData); } return ['提交成功', 0]; } catch (\Exception $exception) { // 日志记录 Log::logError('updateCustomerTag', [ 'params' => $params, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ], 'thirdPlatform'); // 报警 EmailQueue::rPush('第三方调用修改客户标签异常', json_encode([ 'params' => $params, 'line' => $exception->getLine(), 'message' => $exception->getFile(), 'trace' => $exception->getTraceAsString(), ]), ['song.shen@kuxuan-inc.com'], ''); return ['系统异常,请稍后重试', 400]; } } }