1.优化拉取公告列表接口/api/notice/noticeList
2.移除强弹窗确认已读接口/api/notice/noticeConfirm
This commit is contained in:
@@ -25,23 +25,28 @@ class Notice extends MobileBase
|
||||
'list_rows' => $pageSize,
|
||||
]);
|
||||
|
||||
$noticeIds = [];
|
||||
$popoutNoticeIds = [];
|
||||
foreach ($paginate->items() as $row) {
|
||||
$noticeIds[] = $row->id;
|
||||
if ($this->intValue($row->notice_type, 0) === 1) {
|
||||
$popoutNoticeIds[] = $row->id;
|
||||
}
|
||||
}
|
||||
$readRows = [];
|
||||
if ($noticeIds !== []) {
|
||||
$readRows = UserNoticeRead::where('user_id', $this->auth->id)->whereIn('notice_id', $noticeIds)->column('notice_id');
|
||||
$readMap = [];
|
||||
if ($popoutNoticeIds !== []) {
|
||||
$readRows = UserNoticeRead::where('user_id', $this->auth->id)->whereIn('notice_id', $popoutNoticeIds)->column('notice_id');
|
||||
$readMap = array_flip($readRows);
|
||||
}
|
||||
$readMap = array_flip($readRows);
|
||||
|
||||
$list = [];
|
||||
foreach ($paginate->items() as $row) {
|
||||
$isPopout = $this->intValue($row->notice_type, 0) === 1;
|
||||
$list[] = [
|
||||
'notice_id' => $row->id,
|
||||
'title' => $row->title,
|
||||
'notice_type' => $this->intValue($row->notice_type, 0) === 1 ? 'popout' : 'silent',
|
||||
'is_read' => isset($readMap[$row->id]),
|
||||
'content' => $row->content,
|
||||
'notice_type' => $isPopout ? 'popout' : 'silent',
|
||||
'must_confirm' => $isPopout,
|
||||
'is_read' => $isPopout && isset($readMap[$row->id]),
|
||||
'publish_time' => $row->publish_at,
|
||||
];
|
||||
}
|
||||
@@ -49,30 +54,6 @@ class Notice extends MobileBase
|
||||
return $this->mobileSuccess(['list' => $list]);
|
||||
}
|
||||
|
||||
public function noticeDetail(Request $request): Response
|
||||
{
|
||||
$response = $this->initializeMobile($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
$id = $this->intValue($request->input('notice_id', 0), 0);
|
||||
if ($id < 1) {
|
||||
return $this->mobileError(1001, 'Missing parameters');
|
||||
}
|
||||
$notice = OperationNotice::where('id', $id)->where('status', 1)->find();
|
||||
if (!$notice) {
|
||||
return $this->mobileError(2004, 'Notice does not exist');
|
||||
}
|
||||
return $this->mobileSuccess([
|
||||
'notice_id' => $notice->id,
|
||||
'title' => $notice->title,
|
||||
'content' => $notice->content,
|
||||
'notice_type' => $this->intValue($notice->notice_type, 0) === 1 ? 'popout' : 'silent',
|
||||
'must_confirm' => $this->intValue($notice->notice_type, 0) === 1,
|
||||
'publish_time' => $notice->publish_at,
|
||||
]);
|
||||
}
|
||||
|
||||
public function noticeConfirm(Request $request): Response
|
||||
{
|
||||
$response = $this->initializeMobile($request);
|
||||
@@ -87,14 +68,18 @@ class Notice extends MobileBase
|
||||
if (!$notice) {
|
||||
return $this->mobileError(2004, 'Notice does not exist');
|
||||
}
|
||||
if ($this->intValue($notice->notice_type, 0) !== 1) {
|
||||
return $this->mobileError(2004, 'Notice does not require confirmation');
|
||||
}
|
||||
|
||||
$exists = UserNoticeRead::where('user_id', $this->auth->id)->where('notice_id', $noticeId)->find();
|
||||
$readRow = UserNoticeRead::where('user_id', $this->auth->id)->where('notice_id', $noticeId)->find();
|
||||
$now = time();
|
||||
if ($exists) {
|
||||
$exists->save([
|
||||
'confirmed' => 1,
|
||||
'read_at' => $now,
|
||||
]);
|
||||
if ($readRow) {
|
||||
$readRow->read_at = $now;
|
||||
if ($this->intValue($readRow->confirmed, 0) !== 1) {
|
||||
$readRow->confirmed = 1;
|
||||
}
|
||||
$readRow->save();
|
||||
} else {
|
||||
UserNoticeRead::create([
|
||||
'user_id' => $this->auth->id,
|
||||
|
||||
@@ -43,6 +43,7 @@ return [
|
||||
'Current process does not allow this operation' => 'Current process does not allow this operation',
|
||||
'Order does not exist' => 'Order does not exist',
|
||||
'Notice does not exist' => 'Notice does not exist',
|
||||
'Notice does not require confirmation' => 'This notice does not require confirmation',
|
||||
// Deposit / Withdraw
|
||||
'Idempotency key is too long' => 'Idempotency key is too long',
|
||||
'Idempotency key conflict' => 'Idempotency key conflict, please do not submit repeatedly',
|
||||
|
||||
@@ -75,6 +75,7 @@ return [
|
||||
'Current process does not allow this operation' => '当前流程不允许该操作',
|
||||
'Order does not exist' => '订单不存在',
|
||||
'Notice does not exist' => '公告不存在',
|
||||
'Notice does not require confirmation' => '该公告无需确认已读',
|
||||
// 充值 / 提现
|
||||
'Idempotency key is too long' => '幂等键过长',
|
||||
'Idempotency key conflict' => '幂等键冲突(请勿重复提交)',
|
||||
|
||||
Reference in New Issue
Block a user