|
@@ -730,4 +730,56 @@ class UserController
|
|
|
}
|
|
|
return app('json')->success($data);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息通知
|
|
|
+ * @param Request $request
|
|
|
+ * @return mixed
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function notice(Request $request)
|
|
|
+ {
|
|
|
+ $data = UtilService::getMore([
|
|
|
+ 'type',
|
|
|
+ 'page',
|
|
|
+ 'limit'
|
|
|
+ ]);
|
|
|
+ if ($data['type']){
|
|
|
+ $list = UserNotice::where('type', $data['type'])->where('uid', $request->uid())->order('id DESC')->page($data['page'], $data['limit'])->select();//系统消息
|
|
|
+ $list = empty($list)?[]:$list->toArray();
|
|
|
+ foreach ($list as &$item)
|
|
|
+ {
|
|
|
+ $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
|
|
|
+ }
|
|
|
+ return app('json')->success($list);
|
|
|
+ }else{
|
|
|
+ $list['xt'] = UserNotice::where('type', 1)->where('uid', $request->uid())->order('id DESC')->find();//系统消息
|
|
|
+ if ($list['xt']) $list['xt']['add_time'] = date('Y-m-d H:i:s', $list['xt']['add_time']);
|
|
|
+ $list['xx'] = UserNotice::where('type', 2)->where('uid', $request->uid())->order('id DESC')->find();//新增下线
|
|
|
+ if ($list['xx'])$list['xx']['add_time'] = date('Y-m-d H:i:s', $list['xx']['add_time']);
|
|
|
+ $list['yj'] = UserNotice::where('type', 3)->where('uid', $request->uid())->order('id DESC')->find();//佣金通知
|
|
|
+ if ($list['yj'])$list['yj']['add_time'] = date('Y-m-d H:i:s', $list['yj']['add_time']);
|
|
|
+ $list['fh'] = UserNotice::where('type', 4)->where('uid', $request->uid())->order('id DESC')->find();//发货通知
|
|
|
+ if ($list['fh'])$list['fh']['add_time'] = date('Y-m-d H:i:s', $list['fh']['add_time']);
|
|
|
+ $list['dg'] = UserNotice::where('type', 5)->where('uid', $request->uid())->order('id DESC')->find();//打怪通知
|
|
|
+ if ($list['dg'])$list['dg']['add_time'] = date('Y-m-d H:i:s', $list['dg']['add_time']);
|
|
|
+ return app('json')->success($list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function read(Request $request)
|
|
|
+ {
|
|
|
+ $data = UtilService::getMore([
|
|
|
+ 'id',
|
|
|
+ ]);
|
|
|
+ $notice = UserNotice::where('id', $data['id'])->find();
|
|
|
+ if (!$notice) return app('json')->fail('消息不存在');
|
|
|
+
|
|
|
+ $notice['status'] = 1;
|
|
|
+ $notice->save();
|
|
|
+ $notice = empty($notice)?[]:$notice->toArray();
|
|
|
+ return app('json')->success($notice);
|
|
|
+ }
|
|
|
}
|