master
cody 4 months ago
parent f41ef94a39
commit d81ccd99ee

@ -15,7 +15,6 @@ use App\Models\Message;
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;
@ -65,12 +64,13 @@ class SupplyDemandController extends CommonController
$query->where('user_id', $this->getUserId());
}
if (isset($all['expire_type'])) {
$now = date('Y-m-d');
if ($all['expire_type'] == 1) {
$query->where(function ($q) {
$q->whereNull('expire_time')->orWhere('expire_time', '>', Carbon::now());
$query->where(function ($q) use ($now) {
$q->whereNull('expire_time')->orWhere('expire_time', '')->orWhere('expire_time', '>', $now);
});
} else {
$query->where('expire_time', '<', Carbon::now());
$query->where('expire_time', '<', $now);
}
}
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
@ -252,6 +252,14 @@ class SupplyDemandController extends CommonController
// 增加联系次数
SupplyDemand::where('id', $all['supply_demand_id'])->increment('contact_count');
}
if (isset($all['supply_demand_id'])) {
$now = date('Y-m-d');
// 过期数据不能私信
$supplyDemand = SupplyDemand::find($all['supply_demand_id']);
if ($supplyDemand->expire_time > $now) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '该信息已过期,不能私信']);
}
}
// 每天限制私信次数限制
$message_limit = Config::getValueByKey('message_limit');
$messageToday = Message::where('user_id', $this->getUserId())

Loading…
Cancel
Save