|
@@ -137,39 +137,44 @@ class DynamicService
|
|
DynamicModel::create($data);
|
|
DynamicModel::create($data);
|
|
|
|
|
|
//推送消息
|
|
//推送消息
|
|
|
|
+ $push_users = [];
|
|
if($user->sex==1){
|
|
if($user->sex==1){
|
|
$push_users = User::query()->where(['notice_status'=>1,'sex'=>2])->whereNotNull('registrationId')->get(['id','registrationId'])->toArray();
|
|
$push_users = User::query()->where(['notice_status'=>1,'sex'=>2])->whereNotNull('registrationId')->get(['id','registrationId'])->toArray();
|
|
}elseif($user->sex==2){
|
|
}elseif($user->sex==2){
|
|
$push_users = User::query()->where(['notice_status'=>1,'sex'=>1])->whereNotNull('registrationId')->get(['id','registrationId'])->toArray();
|
|
$push_users = User::query()->where(['notice_status'=>1,'sex'=>1])->whereNotNull('registrationId')->get(['id','registrationId'])->toArray();
|
|
}
|
|
}
|
|
|
|
|
|
- $registrationIds = array_column($push_users,'registrationId');
|
|
|
|
|
|
+ if(!empty($push_users)){
|
|
|
|
+ $registrationIds = array_column($push_users,'registrationId');
|
|
|
|
|
|
- $user_info = UserInfoModel::query()->where('user_id',$user->id)->first();
|
|
|
|
|
|
+ $user_info = UserInfoModel::query()->where('user_id',$user->id)->first();
|
|
|
|
|
|
- //设置推送的图标
|
|
|
|
- if(count($dynamicParam->img_url)>0){
|
|
|
|
- $image = ($dynamicParam->img_url)[0];
|
|
|
|
- }else{
|
|
|
|
- $image = $user_info->avatar;
|
|
|
|
- }
|
|
|
|
|
|
+ //设置推送的图标
|
|
|
|
+ if(count($dynamicParam->img_url)>0){
|
|
|
|
+ $image = ($dynamicParam->img_url)[0];
|
|
|
|
+ }else{
|
|
|
|
+ $image = $user_info->avatar;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- JPushService::pushNotify([
|
|
|
|
- //标题
|
|
|
|
- 'title' => "@".$user_info->nickname."发布了新动态,来打个招呼吧~",
|
|
|
|
- //内容
|
|
|
|
- 'content' => $dynamicParam->content,
|
|
|
|
- //设备标识,跟设备相关
|
|
|
|
- 'reg_id' => $registrationIds,
|
|
|
|
- 'image' => $image,
|
|
|
|
- //扩展字段
|
|
|
|
- 'extras' => [
|
|
|
|
- 'type' => 'notice',
|
|
|
|
- ],
|
|
|
|
- //推送类型
|
|
|
|
- 'type' => JPushService::PUSH_TYPE_REG_ID,
|
|
|
|
- ]);
|
|
|
|
|
|
+ JPushService::pushNotify([
|
|
|
|
+ //标题
|
|
|
|
+ 'title' => "@".$user_info->nickname."发布了新动态,来打个招呼吧~",
|
|
|
|
+ //内容
|
|
|
|
+ 'content' => $dynamicParam->content,
|
|
|
|
+ //设备标识,跟设备相关
|
|
|
|
+ 'reg_id' => $registrationIds,
|
|
|
|
+ 'image' => $image,
|
|
|
|
+ //扩展字段
|
|
|
|
+ 'extras' => [
|
|
|
|
+ 'type' => 'notice',
|
|
|
|
+ ],
|
|
|
|
+ //推送类型
|
|
|
|
+ 'type' => JPushService::PUSH_TYPE_REG_ID,
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|