diff --git a/app/Http/Controllers/Mobile/SupplyDemandController.php b/app/Http/Controllers/Mobile/SupplyDemandController.php index 30c647a..75ee8eb 100755 --- a/app/Http/Controllers/Mobile/SupplyDemandController.php +++ b/app/Http/Controllers/Mobile/SupplyDemandController.php @@ -255,17 +255,6 @@ class SupplyDemandController extends CommonController 'to_user_id' => $all['to_user_id'], 'supply_demand_id' => $all['supply_demand_id'] ?? 0 ]); - // 增加联系次数 - if (isset($all['supply_demand_id'])) { - SupplyDemand::where('id', $all['supply_demand_id'])->increment('contact_count'); - } - } else { - // 存在对话,如果也存在供需信息id,则更新供需id到最新 - if (isset($all['supply_demand_id'])) { - $dialogue->supply_demand_id = $all['supply_demand_id']; - $dialogue->contact_count = $dialogue->contact_count + 1; - $dialogue->save(); - } } if (isset($all['supply_demand_id'])) { $now = date('Y-m-d'); @@ -274,6 +263,12 @@ class SupplyDemandController extends CommonController if ($supplyDemand->expire_time > $now) { return $this->fail([ResponseCode::ERROR_BUSINESS, '该信息已过期,不能私信']); } + if ($dialogue->supply_demand_id != $all['supply_demand_id']) { + // 第一次联系才增加一次 + SupplyDemand::where('id', $all['supply_demand_id'])->increment('contact_count'); + } + $dialogue->supply_demand_id = $all['supply_demand_id']; + $dialogue->save(); } // 每天限制私信次数限制 $message_limit = Config::getValueByKey('message_limit');