作者 赵彬吉

自定义推送询盘

... ... @@ -163,6 +163,62 @@ class FormGlobalsoApi
}
/**
*
* 自定义邮件发送接口
* @param string $to_email 接收邮箱
* @param string $subject 标题
* @param string $message 发送内容
* @param string $ip 发送ip
* @param string $refer 来源页面
* @param string $submit_time 询盘发送时间
* @param string $reply_email 回复邮箱
* @return bool
*/
function customizeInquiryEmail($to_email, $subject, $message, $ip, $refer, $submit_time, $reply_email = '')
{
$post_data['from_email'] = 'mail@goodao.cn';
$post_data['to_email'] = trim($to_email);
$post_data['title'] = trim($subject);
$post_data['message'] = $message;
$post_data['ip'] = trim($ip);
$post_data['refer'] = trim($refer);
$post_data['reply_email'] = trim($reply_email);
if(!$reply_email){
$post_data['reply_email'] = $post_data['from_email'];
}
$post_data['submit_time'] = $submit_time;
$url = "https://form.globalso.com/api/b4153b7556";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36');
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
$curl_response = curl_exec($curl);
curl_close($curl);
return true;
}
/**
* 推送自定义询盘短信
* @param string $phones 多个手机号码, 使用英文逗号隔开
* @param string $country
* @param string $domain
* @return mixed|string
*/
public function customizeInquirySms($phones, $country, $domain)
{
$param = compact('phones', 'country', 'domain');
$url = 'https://form.globalso.com/api/send_sms?' . http_build_query($param);
$result = http_get($url,['charset=utf-8']);
return $result;
}
/**
* @remark :获取当前项目所有询盘及询盘国家
* @name :getInquiryAll
* @author :lyh
... ...
... ... @@ -5,7 +5,6 @@ namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Models\Base;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
... ... @@ -42,7 +41,7 @@ class InquiryFormData extends Base
* @author zbj
* @date 2023/12/4
*/
public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data, $traffic = 0){
public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data, $project_id, $traffic = 0){
if(!empty($data['email'])){
$data['email'] = str_replace(' ', '', $data['email']);
}
... ... @@ -96,6 +95,14 @@ class InquiryFormData extends Base
}
}
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data, $traffic);
//自定义推送
if($project_id == 3870) { //走这里发送的,关杰那边也要取消发送邮件
list($mobile, $email) = self::SpecialMailPhone($referer);
Log::channel('inquiry')->info('自定义推送', [$mobile, $email]);
$body = self::specialInquiryTemplate($data['name'], $data['email'], $data['phone'] ?? "", $data['message'], $domain, $ip, $country);
(new FormGlobalsoApi())->customizeInquiryEmail($email, '询盘客户<' . $data['name'] . '>', $body, $ip, $referer, $submit_at);
(new FormGlobalsoApi())->customizeInquirySms($mobile, $country, $domain);
}
Log::channel('inquiry')->info('询盘发送邮件', [$data, $res]);
if(!$res){
throw new \Exception('询盘发送邮件失败');
... ... @@ -118,6 +125,119 @@ class InquiryFormData extends Base
}
/**
* 获取推送邮箱和手机号
* 邮件地址和手机号 根据链接匹配,没匹配到随机取一个邮件和手机号
* @param $referer
* @author zbj
* @date 2025/10/25
*/
public static function SpecialMailPhone($referer)
{
$mail_mobile_map = [
'luchfitness' => [15262817624, 'Sales02@luchfitness.com'],
'modernsporting' => [13073258707,'sales@modernsporting.com'],
'liveupsports' => [18355892630,'sales@liveupsports.com'],
'topflor' => [13912296731,'alan@topflor.cn'],
];
$url_map = [
'luchfitness' => [
'https://www.ntsportgoods.com/supplier/nantong-luch-fitness-co-ltd',
'https://www.ntsportgoods.com/benches-machines-luch-fitness/',
'https://www.ntsportgoods.com/free-weight-luch-fitness/',
'https://www.ntsportgoods.com/functional-training-luch-fitness/s/',
'https://www.ntsportgoods.com/studio-exercise-luch-fitness/',
'https://www.ntsportgoods.com/commercial-gym-half-power-rack-for-strength-training-product',
'https://www.ntsportgoods.com/heavy-duty-fitness-flat-bench-for-home-commercial-gym-product',
'https://www.ntsportgoods.com/durable-gym-dumbbell-flat-bench-for-weight-training-product',
'https://www.ntsportgoods.com/rubber-colored-bumper-plate-for-olympic-weightlifting-product',
'https://www.ntsportgoods.com/urethane-competition-bumper-plate-for-strength-training-product',
'https://www.ntsportgoods.com/10-pair-dumbbell-storage-rack-for-commercial-gyms-product',
'https://www.ntsportgoods.com/tpu-coated-dumbbells-for-home-and-commercial-fitness-product',
'https://www.ntsportgoods.com/urethane-weight-plate-for-powerlifting-strength-gym-product',
'https://www.ntsportgoods.com/iphifun-cpu-weight-plate-for-professional-training-product',
'https://www.ntsportgoods.com/men-s-weightlifting-barbell-bar-for-strength-training-product',
'https://www.ntsportgoods.com/women-s-weightlifting-barbell-bar-for-olympic-lifts-product',
'https://www.ntsportgoods.com/steel-competition-kettlebell-for-functional-training-product',
'https://www.ntsportgoods.com/adjustable-strength-jump-plyo-boxes-for-gym-training-product',
'https://www.ntsportgoods.com/commercial-soft-plyo-box-for-functional-gym-training-product',
'https://www.ntsportgoods.com/power-training-weight-bull-bag-for-strength-workout-product',
'https://www.ntsportgoods.com/pu-leather-power-bag-for-functional-strength-training-product',
'https://www.ntsportgoods.com/abdominal-muscle-mat-for-core-and-sit-up-training-product',
'https://www.ntsportgoods.com/gymnastics-training-mat-for-fitness-and-yoga-workout-product',
'https://www.ntsportgoods.com/adjustable-bench-stepper-for-aerobic-and-strength-gym-product',
'https://www.ntsportgoods.com/rubber-body-pump-set-for-cardio-and-strength-training-product',
'https://www.ntsportgoods.com/balance-training-yoga-ball-for-core-stability-workout-product',
'https://www.ntsportgoods.com/pull-up-resistance-band-for-strength-and-stretching-product',
],
'modernsporting' => [
'https://www.ntsportgoods.com/supplier/nantong-modern-sporting-industrial-co-ltdhttps://www.ntsportgoods.com/barbell-bars-modern-sporting/',
'https://www.ntsportgoods.com/storage-racks-modern-sporting/',
'https://www.ntsportgoods.com/dumbbells-modern-sporting/',
'https://www.ntsportgoods.com/rubber-plates-modern-sporting/',
'https://www.ntsportgoods.com/training-handles-modern-sporting/https://www.ntsportgoods.com/md4137-201cm-weightlifting-beginner-bar-product',
'https://www.ntsportgoods.com/md4143-220cm-hybrid-training-bar-product',
'https://www.ntsportgoods.com/md4149-powder-coated-pentagon-bar-product',
'https://www.ntsportgoods.com/gym-home-10-pairs-dumbbell-rack-stand-md6242-product',
'https://www.ntsportgoods.com/10-pairs-dumbbell-rack-for-home-gym-workouts-md6247-product',
'https://www.ntsportgoods.com/10-pairs-dumbbell-storage-rack-for-gym-home-md6250-product',
'https://www.ntsportgoods.com/urethane-dumbbells-set-for-strength-training-md2117-product',
'https://www.ntsportgoods.com/md2123-rubber-coated-studio-dumbbells-product',
'https://www.ntsportgoods.com/md2135-12-side-tpu-coated-dumbbells-product',
'https://www.ntsportgoods.com/rubber-bumper-plates-for-weightlifting-gym-use-md1056-product',
'https://www.ntsportgoods.com/high-quality-rubber-bumper-plates-for-gym-lifting-md1057-product',
'https://www.ntsportgoods.com/md1058-competition-weight-plates-product',
'https://www.ntsportgoods.com/tricep-press-down-bar-for-cable-machines-strength-md5128-product',
'https://www.ntsportgoods.com/md5132-tricep-press-down-bar-product',
'https://www.ntsportgoods.com/md5132-tricep-press-down-bar-product',
],
'liveupsports' => [
'https://www.ntsportgoods.com/supplier/nantong-liveup-sports-co-ltd/',
'https://www.ntsportgoods.com/yoga-pilates-liveup-sports/',
'https://www.ntsportgoods.com/training-equipment-liveup-sports/',
'https://www.ntsportgoods.com/gym-racks-and-equipment-liveup-sports/',
'https://www.ntsportgoods.com/20-25-30cm-pvc-customised-pilates-stability-exercise-ball-inflatable-soft-mini-pilates-small-yoga-bal-product/',
'https://www.ntsportgoods.com/55-65-75cm-bloom-workout-fitness-exercise-balance-gym-abs-anti-burst-yoga-ball-anti-slip-swiss-pilates-ball-product/',
'https://www.ntsportgoods.com/bodybuilding-fitness-exercise-custom-logo-gym-yoga-latex-hip-resistance-bands-loop-bands-set-product/',
'https://www.ntsportgoods.com/bloom-2080x4-5cm-natural-latex-loop-yoga-elastic-stretch-long-resistance-bands-exercise-band-product/',
'https://www.ntsportgoods.com/custom-logo-manufacturer-high-quality-eco-friendly-fitness-pilates-anti-slip-3-10mm-pu-rubber-tpe-cork-nbr-pvc-printed-yoga-mat-product/',
'https://www.ntsportgoods.com/custom-professional-manufacture-cheap-solid-cast-iron-dumbbell-weights-rubber-hex-dumbbell-sets-5-100lb-product/',
'https://www.ntsportgoods.com/professional-wholesale-custom-logo-free-weight-colored-rubber-bumper-gym-weight-barbell-plates-with-kg-mark-product/',
'https://www.ntsportgoods.com/gym-equipment-free-weights-fitness-12-sided-weightlifting-exercise-barbell-weight-lifting-polyurethane-fixed-barbell-product/',
'https://www.ntsportgoods.com/livepro-high-quality-steel-fitness-equipment-training-competition-gym-power-weightlifting-20kg-barbell-bar-product/',
'https://www.ntsportgoods.com/livepro-gym-commercial-equipment-fitness-storage-system-professional-multifunctional-training-frame-gym-storage-rack-product/',
'https://www.ntsportgoods.com/livepro-commercial-floor-mount-free-standing-cross-training-gym-rigs-multi-functional-training-rack-fitness-gym-rig-product/',
'https://www.ntsportgoods.com/livepro-oem-odm-fitness-equipment-multi-functional-trainer-smith-machine-station-home-using-gym-full-frame-cage-squat-power-rack-product/',
],
'topflor' => [
'https://www.ntsportgoods.com/supplier/nantong-topflor-co-ltd/',
'https://www.ntsportgoods.com/sports-flooring-topflor/',
'https://www.ntsportgoods.com/healthcare-flooring-topflor/',
'https://www.ntsportgoods.com/gym-flooring-topflor/',
'https://www.ntsportgoods.com/sprint-track-turf-for-high-performance-indoor-and-outdoor-training-product/',
'https://www.ntsportgoods.com/durable-gym-rubber-flooring-with-shock-absorption-and-slip-resistance-product/',
'https://www.ntsportgoods.com/interlocking-gym-flooring-tilesinterlocking-gym-flooring-tiles-product/',
'https://www.ntsportgoods.com/premium-hospital-vinyl-flooring-with-anti-bacterial-and-easy-clean-surface-product/',
'https://www.ntsportgoods.com/high-performance-healthcare-flooring-for-safe-and-hygienic-environments-product/',
'https://www.ntsportgoods.com/homogeneous-vinyl-flooring-with-high-durability-and-low-maintenance-product/',
'https://www.ntsportgoods.com/clinic-vinyl-flooring-with-anti-bacterial-and-wear-resistant-properties-product/',
'https://www.ntsportgoods.com/medical-pvc-flooring-with-anti-slip-hygienic-and-durable-features-product/',
'https://www.ntsportgoods.com/professional-badminton-court-pvc-sports-flooring-with-high-grip-and-shock-absorption-product/',
'https://www.ntsportgoods.com/indoor-basketball-sports-flooring-with-superior-ball-bounce-and-player-comfort-product/',
'https://www.ntsportgoods.com/multi-sport-indoor-pvc-flooring-for-volleyball-handball-badminton-and-fitness-product/',
'https://www.ntsportgoods.com/durable-multi-purpose-sports-flooring-for-schools-gyms-and-community-centers-product/',
'https://www.ntsportgoods.com/high-performance-multi-use-indoor-sports-flooring-with-easy-maintenance-product/',
],
];
foreach ($url_map as $k=>$urls) {
if(in_array($referer, $urls)) {
return $mail_mobile_map[$k];
}
}
return $mail_mobile_map[array_rand($mail_mobile_map)];
}
/**
* 特殊项目 邮件模版
* FIXME 后期有多个特殊项目,需要按照项目ID设置模板
* @param $name
... ... @@ -128,7 +248,7 @@ class InquiryFormData extends Base
* @param $country
* @return string
*/
public static function specialInquiryTemplate($name, $email, $phone, $message, $domain, $country)
public static function specialInquiryTemplate($name, $email, $phone, $message, $domain, $ip, $country)
{
$template = "
客户姓名:$name
... ... @@ -139,7 +259,7 @@ class InquiryFormData extends Base
$message
--------------------------------------------------------------------
发送询盘网址: $domain
客户IP地址: [ip]
客户IP地址: $ip
IP所在国家/地区: $country
--------------------------------------------------------------------";
return $template;
... ...
... ... @@ -283,7 +283,7 @@ class SyncSubmitTaskService
$data['referer'] = $this->handle_referer($data['referer']);
$id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data'], $traffic);
$id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data'], $data['project_id'], $traffic);
//转化询盘
... ...