添加公告列表

main
home.fengxinyhyl 8 months ago
parent 107aed74ed
commit 90d4a79576
  1. 2
      app/common/dao/system/notice/SystemNoticeDao.php
  2. 10
      app/common/repositories/system/notice/SystemNoticeRepository.php
  3. 8
      app/controller/api/Auth.php
  4. 2
      app/validate/admin/SystemNoticeValidate.php
  5. 2
      route/api.php
  6. 25
      view/admin/src/views/station/notice/index.vue

@ -31,6 +31,8 @@ class SystemNoticeDao extends BaseDao
$query->whereLike('notice_title|notice_content', '%' . $where['keyword'] . '%'); $query->whereLike('notice_title|notice_content', '%' . $where['keyword'] . '%');
})->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
getModelTime($query, $where['date'], 'create_time'); 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); })->where('is_del', 0);
} }
} }

@ -33,6 +33,7 @@ class SystemNoticeRepository extends BaseRepository
$data['admin_id'] = $admin_id; $data['admin_id'] = $admin_id;
$merchantRepository = app()->make(MerchantRepository::class); $merchantRepository = app()->make(MerchantRepository::class);
$ids = array();
if ($data['type'] == 1) { if ($data['type'] == 1) {
$ids = (array)$data['mer_id']; $ids = (array)$data['mer_id'];
$type_str = implode('/', $merchantRepository->names($ids)); $type_str = implode('/', $merchantRepository->names($ids));
@ -44,17 +45,18 @@ class SystemNoticeRepository extends BaseRepository
$type_str = implode('/', app()->make(MerchantCategoryRepository::class)->names((array)$data['category_id'])); $type_str = implode('/', app()->make(MerchantCategoryRepository::class)->names((array)$data['category_id']));
} else if ($data['type'] == 4) { } else if ($data['type'] == 4) {
$ids = $merchantRepository->search([])->column('mer_id'); $ids = $merchantRepository->search([])->column('mer_id');
$type_str = '全部'; $type_str = '商户';
} else { } else {
throw new ValidateException('商户类型有误'); $type_str = '用户';
} }
if (!count($ids)) throw new ValidateException('没有有效的商户信息'); // if (!count($ids)) throw new ValidateException('没有有效的商户信息');
$data['type_str'] = $type_str; $data['type_str'] = $type_str;
unset($data['is_trader'], $data['category_id'], $data['mer_id']); unset($data['is_trader'], $data['category_id'], $data['mer_id']);
return Db::transaction(function () use ($data, $ids) { return Db::transaction(function () use ($data, $ids) {
$notice = $this->dao->create($data); $notice = $this->dao->create($data);
if(isset($ids) and $ids){
$systemNoticeLogRepository = app()->make(SystemNoticeLogRepository::class); $systemNoticeLogRepository = app()->make(SystemNoticeLogRepository::class);
$inserts = []; $inserts = [];
foreach ($ids as $id) { foreach ($ids as $id) {
@ -65,6 +67,8 @@ class SystemNoticeRepository extends BaseRepository
]; ];
} }
$systemNoticeLogRepository->insertAll($inserts); $systemNoticeLogRepository->insertAll($inserts);
}
return $notice; return $notice;
}); });
} }

@ -18,6 +18,7 @@ use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\order\StoreRefundOrderRepository; use app\common\repositories\store\order\StoreRefundOrderRepository;
use app\common\repositories\system\HuitongRepository; use app\common\repositories\system\HuitongRepository;
use app\common\repositories\system\notice\SystemNoticeConfigRepository; 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\UserAssetsLogRepository;
use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserAssetsRepository;
use app\common\repositories\user\UserGroupRepository; 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 * @return mixed

@ -21,7 +21,7 @@ class SystemNoticeValidate extends Validate
protected $failException = true; protected $failException = true;
protected $rule = [ protected $rule = [
'type|商户类型' => 'require|in:1,2,3,4', 'type|商户类型' => 'require|in:4,5',
'mer_id|商户' => 'requireIf:type,1|array', 'mer_id|商户' => 'requireIf:type,1|array',
'is_trader|自营类型' => 'requireIf:type,2|in:0,1', 'is_trader|自营类型' => 'requireIf:type,2|in:0,1',
'category_id|商户分类' => 'requireIf:type,3|array', 'category_id|商户分类' => 'requireIf:type,3|array',

@ -25,6 +25,8 @@ Route::group('api/', function () {
//兑换配置 //兑换配置
Route::get('exchange/config', 'api.Auth/exchangeConfig'); Route::get('exchange/config', 'api.Auth/exchangeConfig');
Route::get('notice/list', 'api.Auth/noticeList');
//强制登录 //强制登录
Route::group(function () { Route::group(function () {
Route::group('v2', function () { Route::group('v2', function () {

@ -55,6 +55,11 @@
label="消息名称" label="消息名称"
min-width="150" min-width="150"
/> />
<el-table-column
prop="type_str"
label="类型"
min-width="150"
/>
<el-table-column <el-table-column
prop="create_time" prop="create_time"
label="发送日期" label="发送日期"
@ -66,17 +71,7 @@
<el-form-item> <el-form-item>
<span>{{ props.row.notice_content }}</span> <span>{{ props.row.notice_content }}</span>
</el-form-item> </el-form-item>
<el-form-item v-if="props.row.type === 3 || props.row.type === 4" label="商户分类:">
<span class="mr10">{{ props.row.type_str ? props.row.type_str : '-' }}</span>
</el-form-item>
<el-form-item v-if="props.row.type === 1 || props.row.type === 4" label="商户名称:">
<span v-if="props.row.type_str" class="mr10">{{ props.row.type_str ? props.row.type_str : '-' }}</span>
<span v-else>-</span>
</el-form-item>
<el-form-item v-if="props.row.type === 2 || props.row.type === 4" label="商户类别:">
<span v-if="props.row.type_str" class="mr10">{{ props.row.type_str ? props.row.type_str : '-' }}</span>
<span v-else>-</span>
</el-form-item>
</el-form> </el-form>
</template> </template>
</el-table-column> </el-table-column>
@ -105,12 +100,10 @@
<el-form-item label="消息内容:" prop="notice_content"> <el-form-item label="消息内容:" prop="notice_content">
<el-input v-model="formValidate.notice_content" maxLength="500" placeholder="仅限500字" type="textarea" :rows="2" /> <el-input v-model="formValidate.notice_content" maxLength="500" placeholder="仅限500字" type="textarea" :rows="2" />
</el-form-item> </el-form-item>
<el-form-item label="选择商户"> <el-form-item label="类型">
<el-radio-group v-model="formValidate.type"> <el-radio-group v-model="formValidate.type">
<el-radio :label="4">全部</el-radio> <el-radio :label="4">商户</el-radio>
<el-radio :label="1">商户名称</el-radio> <el-radio :label="5">用户</el-radio>
<el-radio :label="2">商户类别</el-radio>
<el-radio :label="3">商户分类</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item v-if="formValidate.type === 1" label="商户名称:"> <el-form-item v-if="formValidate.type === 1" label="商户名称:">

Loading…
Cancel
Save