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