260 lines
9.8 KiB
PHP
Executable File
260 lines
9.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\index\controller;
|
|
|
|
use think\Loader;
|
|
use think\Cookie;
|
|
use think\Config;
|
|
use think\Session;
|
|
|
|
class Bulk extends BaseController {
|
|
|
|
public function Bulk() {
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
|
|
public function detail($id = 0) {
|
|
if ($id > 0) {
|
|
|
|
return $this->fetch();
|
|
} else {
|
|
return exception('数据有误,请检查后再操作');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 联系我们留言
|
|
* @author: Martin
|
|
* @email 1541350712@qq.com
|
|
* @version 1.0.0
|
|
* @date 2024-02-01
|
|
* @desc description
|
|
* @param [array] $params [输入参数]
|
|
*/
|
|
public function create()
|
|
{
|
|
|
|
$data = $this->request->post();
|
|
if (empty($data) || !is_array($data))
|
|
return $this->json(403, 'Data error ');
|
|
|
|
|
|
if ($data['username'] == '')
|
|
return $this->json(403-3, 'Your name cannot be empty');
|
|
if ($data['email'] == '')
|
|
return $this->json(403-4, 'Email cannot be empty');
|
|
|
|
|
|
$referer = isset($data['refer']) ? $data['refer'] : '';
|
|
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
|
|
|
$searchFeed = getKeywords($referer);
|
|
$channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : '';
|
|
$keyword = isset($searchFeed['search']) ? $searchFeed['search'] : '';
|
|
|
|
$fed = visitLog();
|
|
|
|
$insert_data = [
|
|
|
|
'first_name' => $data['username'],
|
|
'email' => $data['email'],
|
|
'message' => $data['message'],
|
|
|
|
'ip' => get_ip(),
|
|
'refer_url' => $_SERVER["HTTP_REFERER"],
|
|
'createtime' => date("Y-m-d H:i:s"),
|
|
'siteid' => $this->siteid,
|
|
'country_code' => $this->country_code,
|
|
|
|
'refer' => $referer,
|
|
'url' => $url,
|
|
'channels' => $channel,
|
|
'keyword' => $keyword,
|
|
'state' => $fed['country'],
|
|
'province' => $fed['province'],
|
|
'city' => $fed['city'],
|
|
'drvice' => $fed['drive'],
|
|
'user_agent' => $fed['system']." ".$fed['brower'],
|
|
];
|
|
|
|
$result = model('Bulk')->insert($insert_data);
|
|
if (!$result)
|
|
return $this->json(201, 'Failure to submit');
|
|
|
|
return $this->json(200, 'ok');
|
|
}
|
|
|
|
|
|
/**
|
|
* 商务订单 - 批量采购
|
|
* @author: Martin
|
|
* @email 1541350712@qq.com
|
|
* @version 1.0.0
|
|
* @date 2024-02-01
|
|
* @desc description
|
|
* @param [array] $params [输入参数]
|
|
*/
|
|
public function inquiry()
|
|
{
|
|
|
|
$data = $this->request->post();
|
|
if (empty($data) || !is_array($data))
|
|
return $this->json(403, 'Data error ');
|
|
|
|
if ($data['company'] == '')
|
|
return $this->json(403-2, 'Company name cannot be empty');
|
|
if ($data['name'] == '' && $data['last_name'])
|
|
return $this->json(403-3, 'Your name cannot be empty');
|
|
if ($data['email'] == '')
|
|
return $this->json(403-4, 'Email cannot be empty');
|
|
// if ($data['buy_source'] == '')
|
|
// return $this->json(-5, '购买渠道不能为空');
|
|
|
|
/*if ($data['customer_telephone'] != '' && !preg_match("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/", $data['customer_telephone']))
|
|
return $this->json(-6, 'Phone format error ');*/
|
|
if ($data['email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['email']))
|
|
return $this->json(403-6, 'Email Address format error');
|
|
|
|
$referer = isset($data['refer']) ? $data['refer'] : '';
|
|
$url = isset($data['url']) ? $data['url'] : '';
|
|
|
|
$searchFeed = getKeywords($referer);
|
|
$channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : '';
|
|
$keyword = isset($searchFeed['search']) ? $searchFeed['search'] : '';
|
|
|
|
$fed = visitLog();
|
|
|
|
|
|
$insert_data = [
|
|
'company' => $data['company'],
|
|
'first_name' => $data['name'],
|
|
'last_name' => $data['last_name'],
|
|
'email' => $data['email'],
|
|
'phone' => trim($data['phone']),
|
|
'interest' => $data['interested'],
|
|
'message' => $data['message'],
|
|
'url' => $data['url'],
|
|
'ip' => get_ip(),
|
|
'refer_url' => $_SERVER["HTTP_REFERER"],
|
|
'createtime' => date("Y-m-d H:i:s"),
|
|
'siteid' => $this->siteid,
|
|
'country_code' => $this->country_code,
|
|
|
|
'refer' => $referer,
|
|
'uri' => $url,
|
|
'channel' => $channel,
|
|
'keyword' => $keyword,
|
|
'ip' => $fed['ip'],
|
|
'state' => isset($fed['country']) ? $fed['country'] : '',
|
|
'province' => isset($fed['province']) ? $fed['province'] : '',
|
|
'city' => isset($fed['city']) ? $fed['city'] : '',
|
|
'drvice' => isset($fed['drive']) ? $fed['drive'] : '',
|
|
'user_agent' => $fed['system']." ".$fed['brower'],
|
|
];
|
|
|
|
$result = model('bulk_inquiry')->insert($insert_data);
|
|
if (!$result)
|
|
return $this->json(201, 'Failure to submit');
|
|
|
|
return $this->json(200, 'ok');
|
|
}
|
|
|
|
/**
|
|
* 代理商申请 Distributor
|
|
* @author: Martin
|
|
* @email 1541350712@qq.com
|
|
* @version 1.0.0
|
|
* @date 2024-02-01
|
|
* @desc description
|
|
* @param [array] $params [输入参数]
|
|
*/
|
|
public function agents()
|
|
{
|
|
|
|
$data = $this->request->post();
|
|
if (empty($data) || !is_array($data))
|
|
return $this->json(403, 'Data error ');
|
|
|
|
if ($data['company'] == '')
|
|
return $this->json(403-2, 'Company name cannot be empty');
|
|
/*if ($data['name'] == '' && $data['last_name'])
|
|
return $this->json(403-3, 'Your name cannot be empty');*/
|
|
if ($data['email'] == '')
|
|
return $this->json(403-4, 'Email cannot be empty');
|
|
/*if ($data['country'] == '')
|
|
return $this->json(403-5, 'Distribution region cannot be empty');*/
|
|
if ($data['business_type'] == '')
|
|
return $this->json(403-6, 'Business type cannot be empty');
|
|
if ($data['enterprise_size'] == '')
|
|
return $this->json(403-7, 'Enterprise size cannot be empty');
|
|
if ($data['phone'] == '')
|
|
return $this->json(403-8, 'Phone cannot be empty');
|
|
// if ($data['buy_source'] == '')
|
|
// return $this->json(-5, '购买渠道不能为空');
|
|
|
|
/*if ($data['customer_telephone'] != '' && !preg_match("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/", $data['customer_telephone']))
|
|
return $this->json(-6, 'Phone format error ');*/
|
|
if ($data['email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['email']))
|
|
return $this->json(403-6, 'Email Address format error');
|
|
|
|
|
|
$referer = isset($data['refer']) ? $data['refer'] : '';
|
|
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
|
|
|
$searchFeed = getKeywords($referer);
|
|
$channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : '';
|
|
$keyword = isset($searchFeed['search']) ? $searchFeed['search'] : '';
|
|
|
|
$fed = visitLog();
|
|
|
|
$insert_data = [
|
|
'company' => $data['company'],
|
|
'uri' => $data['uri'],
|
|
'email' => $data['email'],
|
|
'phone' => trim($data['phone']),
|
|
'address' => isset($data['address']) ? $data['address'] : '',
|
|
'message' => isset($data['message']) ? $data['message'] : '',
|
|
'enterprise_size' => isset($data['interested']) ? $data['interested'] : $data['message'],
|
|
'business_type' => isset($data['business_type']) ? $data['business_type'] : '',
|
|
'createtime' => date("Y-m-d H:i:s"),
|
|
'siteid' => $this->siteid,
|
|
'country_code' => $this->country_code,
|
|
'message' => isset($data['message']) ? $data['message'] : '',
|
|
|
|
|
|
'refer' => $referer,
|
|
'url' => $url,
|
|
'channel' => $channel,
|
|
'keyword' => $keyword,
|
|
'ip' => $fed['ip'],
|
|
'state' => $fed['country'],
|
|
'province' => $fed['province'],
|
|
'city' => $fed['city'],
|
|
'drvice' => $fed['drive'],
|
|
'user_agent' => $fed['system']." ".$fed['brower'],
|
|
|
|
|
|
|
|
'refer' => $referer,
|
|
'url' => $url,
|
|
'channel' => $channel,
|
|
'keyword' => $keyword,
|
|
'ip' => $fed['ip'],
|
|
'state' => $fed['country'],
|
|
'province' => $fed['province'],
|
|
'city' => $fed['city'],
|
|
'drvice' => $fed['drive'],
|
|
'user_agent' => $fed['system']." ".$fed['brower'],
|
|
|
|
];
|
|
|
|
$result = model('agents')->insert($insert_data);
|
|
if (!$result)
|
|
return $this->json(201, 'Failure to submit');
|
|
|
|
return $this->json(200, 'ok');
|
|
}
|
|
}
|