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();