From 19e3f5df3336846231d32b2b3ea5d7b3b7b672ac Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Fri, 14 Mar 2025 11:45:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E8=AF=A2=E7=9B=98=E5=88=86=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/ProductInquiry.php | 50 +++++++++++++++++++ app/admin/model/v1/ProductInquiryModel.php | 46 +++++++++++++++++ app/admin/route/v1.php | 5 +- app/common/model/ProductInquiryBaseModel.php | 1 + .../20241224080720_create_product_inquiry.php | 1 + 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/v1/ProductInquiry.php create mode 100644 app/admin/model/v1/ProductInquiryModel.php diff --git a/app/admin/controller/v1/ProductInquiry.php b/app/admin/controller/v1/ProductInquiry.php new file mode 100644 index 00000000..eca4bb2b --- /dev/null +++ b/app/admin/controller/v1/ProductInquiry.php @@ -0,0 +1,50 @@ +param([ + 'corp_name', + 'country_name', + 'created_at', + 'page/d' => 1, + 'size/d' => 10 + ]); + + $msgs = ProductInquiryModel::field([ + 'id', + 'first_name', + 'last_name', + 'email', + 'phone', + 'corp_name', + 'country_name', + 'industry', + 'message', + 'created_at' + ]) + ->withSearch(['corp_name', 'country_name', 'created_at'], [ + 'corp_name' => $param['corp_name'] ?? null, + 'country_name' => $param['country_name'] ?? null, + 'created_at' => !empty($param['created_at']) ? explode(',', $param['created_at']) : null, + ]) + ->language(request()->lang_id) + ->order(['id' => 'desc']) + ->paginate([ + 'list_rows' => $param['size'], + 'page' => $param['page'], + ]); + + return success('获取成功', $msgs); + } +} diff --git a/app/admin/model/v1/ProductInquiryModel.php b/app/admin/model/v1/ProductInquiryModel.php new file mode 100644 index 00000000..745254d5 --- /dev/null +++ b/app/admin/model/v1/ProductInquiryModel.php @@ -0,0 +1,46 @@ +where('language_id', '=', $value); + } + + // 按公司名称搜索 + public function searchCorpNameAttr($query, $value, $data) + { + if (is_null($value)) return; + $query->where('corp_name', 'like', '%'.$value.'%'); + } + + // 按国家名称搜索 + public function searchCountryNameAttr($query, $value, $data) + { + if (is_null($value)) return; + $query->where('country_name', 'like', '%'.$value.'%'); + } + + // 按提交时间搜索 + public function searchCreatedAtAttr($query, $value, $data) + { + if (is_null($value)) return; + if (is_array($value)) { + if (count($value) > 1) { + $query->whereBetweenTime('created_at', $value[0], $value[1]); + } else { + $query->whereTime('created_at', '>=', $value[0]); + } + } + } +} diff --git a/app/admin/route/v1.php b/app/admin/route/v1.php index 756829e5..daa73dda 100644 --- a/app/admin/route/v1.php +++ b/app/admin/route/v1.php @@ -532,7 +532,7 @@ Route::group('v1', function () { Route::group('bp/inquiry', function() { // 批量采购询盘可选品类 Route::get('interested', 'BulkPurchaseInquiry/interested'); - + // 批量采购底盘列表分页 Route::get('index', 'BulkPurchaseInquiry/index'); @@ -552,6 +552,9 @@ Route::group('v1', function () { Route::get('export', 'Agent/export'); }); + // 反馈管理 - 产品询盘列表 + Route::get('product/inquiry/index', 'ProductInquiry/index'); + // 配置项列表 Route::group('config', function() { // 配置分组 diff --git a/app/common/model/ProductInquiryBaseModel.php b/app/common/model/ProductInquiryBaseModel.php index 512663b0..ad219aa9 100644 --- a/app/common/model/ProductInquiryBaseModel.php +++ b/app/common/model/ProductInquiryBaseModel.php @@ -26,6 +26,7 @@ class ProductInquiryBaseModel extends BaseModel 'phone' => 'string', 'country_name' => 'string', 'industry' => 'string', + 'referer_url' => 'string', 'message' => 'string', 'created_at' => 'datetime' ]; diff --git a/database/migrations/20241224080720_create_product_inquiry.php b/database/migrations/20241224080720_create_product_inquiry.php index ba64faa1..fec45710 100644 --- a/database/migrations/20241224080720_create_product_inquiry.php +++ b/database/migrations/20241224080720_create_product_inquiry.php @@ -36,6 +36,7 @@ class CreateProductInquiry extends Migrator ->addColumn('phone', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '电话']) ->addColumn('country_name', 'string', ['limit' => 128, 'null' => true, 'default' => null, 'comment' => '所在国家名称']) ->addColumn('industry', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '所属行业']) + ->addColumn('referer_url', 'string', ['limit' => 256, 'null' => true, 'default' => null, 'comment' => '来源URL']) ->addColumn('message', 'text', ['null' => true, 'default' => null, 'comment' => '留言内容']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->create();