diff --git a/app/common/dao/system/notice/SystemNoticeDao.php b/app/common/dao/system/notice/SystemNoticeDao.php index fc3811d..6cc75a2 100644 --- a/app/common/dao/system/notice/SystemNoticeDao.php +++ b/app/common/dao/system/notice/SystemNoticeDao.php @@ -31,6 +31,8 @@ class SystemNoticeDao extends BaseDao $query->whereLike('notice_title|notice_content', '%' . $where['keyword'] . '%'); })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { getModelTime($query, $where['date'], 'create_time'); + })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) { + $query->where('type', $where['type']); })->where('is_del', 0); } } diff --git a/app/common/repositories/system/notice/SystemNoticeRepository.php b/app/common/repositories/system/notice/SystemNoticeRepository.php index b032ca2..a1528f3 100644 --- a/app/common/repositories/system/notice/SystemNoticeRepository.php +++ b/app/common/repositories/system/notice/SystemNoticeRepository.php @@ -33,6 +33,7 @@ class SystemNoticeRepository extends BaseRepository $data['admin_id'] = $admin_id; $merchantRepository = app()->make(MerchantRepository::class); + $ids = array(); if ($data['type'] == 1) { $ids = (array)$data['mer_id']; $type_str = implode('/', $merchantRepository->names($ids)); @@ -44,27 +45,30 @@ class SystemNoticeRepository extends BaseRepository $type_str = implode('/', app()->make(MerchantCategoryRepository::class)->names((array)$data['category_id'])); } else if ($data['type'] == 4) { $ids = $merchantRepository->search([])->column('mer_id'); - $type_str = '全部'; + $type_str = '商户'; } else { - throw new ValidateException('商户类型有误'); + $type_str = '用户'; } - if (!count($ids)) throw new ValidateException('没有有效的商户信息'); +// if (!count($ids)) throw new ValidateException('没有有效的商户信息'); $data['type_str'] = $type_str; unset($data['is_trader'], $data['category_id'], $data['mer_id']); return Db::transaction(function () use ($data, $ids) { $notice = $this->dao->create($data); - $systemNoticeLogRepository = app()->make(SystemNoticeLogRepository::class); - $inserts = []; - foreach ($ids as $id) { - if (!$id) continue; - $inserts[] = [ - 'mer_id' => (int)$id, - 'notice_id' => $notice->notice_id - ]; + if(isset($ids) and $ids){ + $systemNoticeLogRepository = app()->make(SystemNoticeLogRepository::class); + $inserts = []; + foreach ($ids as $id) { + if (!$id) continue; + $inserts[] = [ + 'mer_id' => (int)$id, + 'notice_id' => $notice->notice_id + ]; + } + $systemNoticeLogRepository->insertAll($inserts); } - $systemNoticeLogRepository->insertAll($inserts); + return $notice; }); } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index e921907..50cb065 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -18,6 +18,7 @@ use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\order\StoreRefundOrderRepository; use app\common\repositories\system\HuitongRepository; use app\common\repositories\system\notice\SystemNoticeConfigRepository; +use app\common\repositories\system\notice\SystemNoticeRepository; use app\common\repositories\user\UserAssetsLogRepository; use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserGroupRepository; @@ -148,6 +149,13 @@ class Auth extends BaseController } } + public function noticeList() + { + [$page, $limit] = $this->getPage(); + $where = array('type' => 5); + return app('json')->success(app(SystemNoticeRepository::class)->getList($where, $page, $limit)); + } + /** * @return mixed diff --git a/app/validate/admin/SystemNoticeValidate.php b/app/validate/admin/SystemNoticeValidate.php index 56a7518..bfb11d9 100644 --- a/app/validate/admin/SystemNoticeValidate.php +++ b/app/validate/admin/SystemNoticeValidate.php @@ -21,7 +21,7 @@ class SystemNoticeValidate extends Validate protected $failException = true; protected $rule = [ - 'type|商户类型' => 'require|in:1,2,3,4', + 'type|商户类型' => 'require|in:4,5', 'mer_id|商户' => 'requireIf:type,1|array', 'is_trader|自营类型' => 'requireIf:type,2|in:0,1', 'category_id|商户分类' => 'requireIf:type,3|array', diff --git a/route/api.php b/route/api.php index 8e21c10..e6d326b 100644 --- a/route/api.php +++ b/route/api.php @@ -25,6 +25,8 @@ Route::group('api/', function () { //兑换配置 Route::get('exchange/config', 'api.Auth/exchangeConfig'); + Route::get('notice/list', 'api.Auth/noticeList'); + //强制登录 Route::group(function () { Route::group('v2', function () { diff --git a/view/admin/src/views/station/notice/index.vue b/view/admin/src/views/station/notice/index.vue index f91dd6f..6cc0f0e 100644 --- a/view/admin/src/views/station/notice/index.vue +++ b/view/admin/src/views/station/notice/index.vue @@ -55,6 +55,11 @@ label="消息名称" min-width="150" /> + {{ props.row.notice_content }} - - {{ props.row.type_str ? props.row.type_str : '-' }} - - - {{ props.row.type_str ? props.row.type_str : '-' }} - - - - - {{ props.row.type_str ? props.row.type_str : '-' }} - - - + @@ -105,12 +100,10 @@ - + - 全部 - 商户名称 - 商户类别 - 商户分类 + 商户 + 用户