|
|
@ -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; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|