feat(zy): 添加消息通知功能并优化活动相关逻辑
- 在 Circle 控制器中添加点赞、评论和审核通知 - 在 Game 控制器中添加退坑、取消活动和发送消息功能 - 优化 Activity 控制器中的订单关联逻辑 - 更新语言包,添加新的活动状态翻译
This commit is contained in:
@@ -6,6 +6,7 @@ use think\Db;
|
||||
use think\Exception;
|
||||
use app\admin\model\zy\Tags;
|
||||
use think\exception\PDOException;
|
||||
use app\admin\model\zy\link\Message;
|
||||
use app\admin\model\shopro\user\User;
|
||||
use app\admin\model\zy\circle\Circle;
|
||||
use app\admin\model\zy\link\Complaint;
|
||||
@@ -50,7 +51,7 @@ class Sys extends Base
|
||||
$this->error('举报内容不能为空');
|
||||
}
|
||||
$user = auth_user();
|
||||
$res = Complaint::get(['user_id' => $user['id'], 'target_id' => $params['target_id'], 'type' => $params['type'],'status' => 0]);
|
||||
$res = Complaint::get(['user_id' => $user['id'], 'target_id' => $params['target_id'], 'type' => $params['type'], 'status' => 0]);
|
||||
if ($res) {
|
||||
$this->error('您已举报过该对象');
|
||||
}
|
||||
@@ -70,4 +71,43 @@ class Sys extends Base
|
||||
}
|
||||
$this->success('Success');
|
||||
}
|
||||
|
||||
// 发送用户消息
|
||||
public function sendMsg()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if ($params['user_id'] == $this->auth->id) {
|
||||
$this->error('不能发送给自己');
|
||||
}
|
||||
$user = auth_user();
|
||||
$target = User::get($params['user_id']);
|
||||
if (empty($target)) {
|
||||
$this->error('用户不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$result = (new Message())->allowField(true)->save([
|
||||
'type' => 2,
|
||||
'name' => $user['nickname'],
|
||||
'avatar' => $user['avatar'],
|
||||
'from_id' => $user['id'],
|
||||
'target_id' => $params['user_id'],
|
||||
'content' => json_encode([
|
||||
'topic' => '好友消息',
|
||||
'time' => date('Y-m-d H:i:s'),
|
||||
'content' => $params['content']
|
||||
]),
|
||||
'status' => 0
|
||||
]);
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error('操作失败');
|
||||
}
|
||||
$this->success('Success');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user