From 144bfaa097254f494aeefe513e1ccfc2b6bb718d Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 3 Jul 2025 13:25:46 +0800 Subject: [PATCH] update --- app/Http/Controllers/Mobile/SupplyDemandController.php | 10 +++++++--- .../2025_06_25_150423_create_calendars_table.php | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Mobile/SupplyDemandController.php b/app/Http/Controllers/Mobile/SupplyDemandController.php index 306883c..1cf389a 100755 --- a/app/Http/Controllers/Mobile/SupplyDemandController.php +++ b/app/Http/Controllers/Mobile/SupplyDemandController.php @@ -226,9 +226,11 @@ class SupplyDemandController extends CommonController SupplyDemand::where('id', $all['supply_demand_id'])->increment('view_count'); } // 判断是否有会话,没有则创建 - $dialogue = Dialogue::where('user_id', $this->getUserId()) - ->where('to_user_id', $all['to_user_id']) - ->first(); + $dialogue = Dialogue::where(function ($query) use ($all) { + $query->where('user_id', $this->getUserId())->where('to_user_id', $all['to_user_id']); + })->orWhere(function ($query) use ($all) { + $query->where('user_id', $all['to_user_id'])->where('to_user_id', $this->getUserId()); + })->first(); if (empty($dialogue)) { // 创建一条会话 $dialogue = Dialogue::create([ @@ -248,10 +250,12 @@ class SupplyDemandController extends CommonController // 有且仅有自己发的信息,则不能发再 $myMessage = Message::where('user_id', $this->getUserId()) ->where('to_user_id', $all['to_user_id']) + ->where('dialogue_id', $dialogue->id) ->first(); // 对方的信息 $otherMessage = Message::where('user_id', $all['to_user_id']) ->where('user_id', $this->getUserId()) + ->where('dialogue_id', $dialogue->id) ->first(); if ($myMessage && empty($otherMessage)) { return $this->fail([ResponseCode::ERROR_BUSINESS, '对方回复以后才可以再次发送消息']); diff --git a/database/migrations/2025_06_25_150423_create_calendars_table.php b/database/migrations/2025_06_25_150423_create_calendars_table.php index 84d955f..90792d0 100644 --- a/database/migrations/2025_06_25_150423_create_calendars_table.php +++ b/database/migrations/2025_06_25_150423_create_calendars_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. * @@ -15,6 +14,12 @@ return new class extends Migration { Schema::create('calendars', function (Blueprint $table) { $table->id(); + // 数据类型 + $table->tinyInteger('type')->nullable()->comment('数据类型1课程2自定义事件'); + // 日期 + $table->date('date')->nullable()->comment('日期'); + + $table->timestamps(); $table->softDeletes(); });