feat: 批量购买

This commit is contained in:
2025-04-22 14:30:04 +08:00
parent c5eaa21ad7
commit 02ef195bf4
10 changed files with 319 additions and 4 deletions

View File

@@ -6,8 +6,11 @@ namespace app\index\controller;
use app\index\model\AgentBusinessTypeModel;
use app\index\model\AgentEnterpriseSizeTypeModel;
use app\index\model\AgentModel;
use app\index\model\BulkPurchaseInquiryModel;
use app\index\model\LeaveMessageModel;
use app\index\model\SysBannerModel;
use app\index\model\SysConfigModel;
use app\index\validate\ContactUsBulkBuyValidate;
use app\index\validate\ContactUsDistributorValidate;
use app\index\validate\ContactUsMessageValidate;
use think\facade\View;
@@ -173,4 +176,63 @@ class ContactUs extends Common
return View::fetch('distributor');
}
/**
* 留言批量购买
*/
public function bulkbuy()
{
if (request()->isPost()) {
// 提交留言处理
$form_data = request()->post([
'corp_name',
'url',
'first_name',
'last_name',
'email',
'phone',
'interested',
'message'
]);
// 验证字段
$validate = new ContactUsBulkBuyValidate;
if (!$validate->check($form_data)) {
return error($validate->getError());
}
// 保存留言
$ret = BulkPurchaseInquiryModel::create([
'language_id' => $this->lang_id,
'corp_name' => $form_data['corp_name'],
'url' => $form_data['url'],
'first_name' => $form_data['first_name'],
'last_name' => $form_data['last_name'],
'email' => $form_data['email'],
'phone' => $form_data['phone'],
'interested' => $form_data['interested'],
'referer_url' => request()->header('referer'),
'website_url' => request()->header('host'),
'message' => $form_data['message'],
'ip' => request()->ip(),
]);
if ($ret->isEmpty()) {
return error(lang('contact_bulkbuy.send_fail'));
}
return success(lang('contact_bulkbuy.send_success'));
}
// 获取可选产品品类配置
$config = SysConfigModel::hasWhere('group', function($query) {
$query->where('language_id', '=', $this->lang_id);
})
->byName('bulk_purchase_inquiry_interested')
->find();
if (empty($config)) {
return error('当前选定语言的采购可选品类配置出错');
}
View::assign('interested', explode(',', preg_replace('/\r?\n/', ',', $config->value)));
return View::fetch('bulkbuy');
}
}