From 2594cabc4da045c42cc1f839c6908b7b447bc12e Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Wed, 16 Jul 2025 14:20:06 +0800 Subject: [PATCH] update --- .../Admin/SupplyDemandController.php | 2 +- .../Mobile/SupplyDemandController.php | 20 +++++++++-- app/Models/SupplyDemand.php | 7 ++++ ..._20_100410_create_supply_demands_table.php | 2 +- ...7_16_133839_alert_supply_demands_table.php | 35 +++++++++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2025_07_16_133839_alert_supply_demands_table.php diff --git a/app/Http/Controllers/Admin/SupplyDemandController.php b/app/Http/Controllers/Admin/SupplyDemandController.php index 8ecfc6b..29bac40 100755 --- a/app/Http/Controllers/Admin/SupplyDemandController.php +++ b/app/Http/Controllers/Admin/SupplyDemandController.php @@ -156,7 +156,7 @@ class SupplyDemandController extends BaseController * @OA\Parameter(name="wechat", in="query", @OA\Schema(type="string"), required=false, description="微信号"), * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="电话"), * @OA\Parameter(name="email", in="query", @OA\Schema(type="string"), required=false, description="邮箱"), - * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="审核状态(0:待审核;1:通过;2:拒绝)"), + * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"), * @OA\Response( * response=200, * description="操作成功" diff --git a/app/Http/Controllers/Mobile/SupplyDemandController.php b/app/Http/Controllers/Mobile/SupplyDemandController.php index aa4242d..f53a407 100755 --- a/app/Http/Controllers/Mobile/SupplyDemandController.php +++ b/app/Http/Controllers/Mobile/SupplyDemandController.php @@ -16,6 +16,7 @@ use App\Models\SupplyDemand; use App\Models\SupplyDemandKeep; use App\Notifications\BirthdayNotify; use App\Notifications\SupplyDemandNotify; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Validator; @@ -32,11 +33,12 @@ class SupplyDemandController extends CommonController * @OA\Parameter(name="myself", in="query", @OA\Schema(type="integer"), required=true, description="是否只看自己的0否1是"), * @OA\Parameter(name="type", in="query", @OA\Schema(type="integer"), required=true, description="类型"), * @OA\Parameter(name="keyword", in="query", @OA\Schema(type="integer"), required=true, description="关键词"), - * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=true, description="状态0待审核1通过2拒绝"), + * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=true, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"), * @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"), * @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"), * @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"), * @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"), + * @OA\Parameter(name="expire_type", in="query", @OA\Schema(type="string"), required=false, description="有效期类型1有效期内2失效的"), * @OA\Response( * response="200", * description="暂无" @@ -63,6 +65,15 @@ class SupplyDemandController extends CommonController if (isset($all['myself']) && $all['myself'] == 1) { $query->where('user_id', $this->getUserId()); } + if (isset($all['expire_type'])) { + if ($all['expire_type'] == 1) { + $query->where(function ($q) { + $q->whereNull('expire_time')->orWhere('expire_time', '>', Carbon::now()); + }); + } else { + $query->where('expire_time', '<', Carbon::now()); + } + } })->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc') ->paginate($all['page_size'] ?? 20); return $this->success(compact('supplyDemands')); @@ -100,6 +111,8 @@ class SupplyDemandController extends CommonController // 增加view_count $detail->increment('view_count'); $detail->save(); + // 判断是否发送过私信 + $detail->messages_count = Message::where('supply_demand_id', $detail->id)->where('user_id', $this->getUserId())->count(); return $this->success($detail); } @@ -118,7 +131,10 @@ class SupplyDemandController extends CommonController * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="电话"), * @OA\Parameter(name="email", in="query", @OA\Schema(type="string"), required=false, description="邮箱"), * @OA\Parameter(name="expire_time", in="query", @OA\Schema(type="string"), required=false, description="过期时间"), - * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="审核状态(0:待审核;1:通过;2:拒绝)"), + * @OA\Parameter(name="public_way", in="query", @OA\Schema(type="string"), required=false, description="公开模式1直接公开2私信后自动公开3不公开"), + * @OA\Parameter(name="file_ids", in="query", @OA\Schema(type="string"), required=false, description="文件id数组"), + * @OA\Parameter(name="contact_name", in="query", @OA\Schema(type="string"), required=false, description="联系人名字"), + * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), required=false, description="状态0待审核1通过2拒绝3退回修改4永久隐藏"), * @OA\Response( * response="200", * description="暂无" diff --git a/app/Models/SupplyDemand.php b/app/Models/SupplyDemand.php index af24f16..8dab203 100755 --- a/app/Models/SupplyDemand.php +++ b/app/Models/SupplyDemand.php @@ -9,6 +9,13 @@ use Illuminate\Support\Facades\Cache; class SupplyDemand extends SoftDeletesModel { + protected $casts = ['file_ids' => 'json']; + + public function getFilesAttribute($value) + { + if (empty($this->file_ids)) return []; + return Upload::whereIn('id', $this->file_ids)->get(); + } public function user() { return $this->hasOne(User::class, 'id', 'user_id'); diff --git a/database/migrations/2025_06_20_100410_create_supply_demands_table.php b/database/migrations/2025_06_20_100410_create_supply_demands_table.php index 6b73473..bfb251e 100644 --- a/database/migrations/2025_06_20_100410_create_supply_demands_table.php +++ b/database/migrations/2025_06_20_100410_create_supply_demands_table.php @@ -31,7 +31,7 @@ return new class extends Migration { // 邮箱 $table->string('email')->nullable()->comment('邮箱'); // 审核状态 - $table->tinyInteger('status')->default(0)->comment('状态0待审核1通过2拒绝'); + $table->tinyInteger('status')->default(0)->comment('状态0待审核1通过2拒绝3退回修改4永久隐藏'); // 浏览次数 $table->integer('view_count')->default(0)->comment('浏览次数'); // 联系次数 diff --git a/database/migrations/2025_07_16_133839_alert_supply_demands_table.php b/database/migrations/2025_07_16_133839_alert_supply_demands_table.php new file mode 100644 index 0000000..cc52619 --- /dev/null +++ b/database/migrations/2025_07_16_133839_alert_supply_demands_table.php @@ -0,0 +1,35 @@ +boolean('public_way')->default(false)->comment('公开模式1直接公开2私信后自动公开3不公开'); + $table->json('file_ids')->nullable()->comment('文件'); + // 联系人名字 + $table->string('contact_name')->nullable()->comment('联系人名字'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('supply_demands', function (Blueprint $table) { + // + }); + } +};