|
|
@@ -148,9 +148,9 @@ class MessageService extends BaseService
|
|
|
$setting = MemberSettingService::make()->getSetting($userId);
|
|
|
if($setting){
|
|
|
foreach ($setting as $k => $v){
|
|
|
- if($k == 'receive_order'){
|
|
|
+ if($k == 'receive_order' && $v==1){
|
|
|
$types[] = 2;
|
|
|
- }else if ($k == 'receive_account'){
|
|
|
+ }else if ($k == 'receive_account' && $v==1){
|
|
|
$types[] = 3;
|
|
|
}
|
|
|
}
|
|
|
@@ -329,20 +329,72 @@ class MessageService extends BaseService
|
|
|
*/
|
|
|
public function getBarCount($userId, $type=0)
|
|
|
{
|
|
|
- $cacheKey = "caches:messages:barCount:{$userId}_{$type}";
|
|
|
+ $cacheKey = "caches:barCount:{$userId}_{$type}";
|
|
|
$data = RedisService::get($cacheKey);
|
|
|
if($data){
|
|
|
return $data;
|
|
|
}
|
|
|
- $data1 = $this->getUnreadCount($userId, $type);
|
|
|
- $data1 = $data1? intval($data1) : 0;
|
|
|
- $data2 = ImChatService::make()->getUnreadCount($userId);
|
|
|
- $data = $data1+$data2;
|
|
|
+ $data = $this->getUnreadCount($userId,0, $type);
|
|
|
RedisService::set($cacheKey, $data, rand(3, 5));
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 推送站内消息
|
|
|
+ * @param $userId 用户ID
|
|
|
+ * @param $title 标题
|
|
|
+ * @param $message 消息内容
|
|
|
+ * @param int $type 类型:1-公告,2-订单,3-账户,4-客服,5-动态
|
|
|
+ * @return false
|
|
|
+ */
|
|
|
+ public function pushMessage($userId, $title, $message, $type=1, $fromUid=0)
|
|
|
+ {
|
|
|
+ $types = [4,5];
|
|
|
+ $pushStatus = false;
|
|
|
+ $datas = MemberSettingService::make()->getSetting($userId);
|
|
|
+ if($datas){
|
|
|
+ foreach ($datas as $k => $v){
|
|
|
+ if($v==1){
|
|
|
+ if($k == 'receive_app'){
|
|
|
+ $pushStatus = true;
|
|
|
+ $types[] = 1;
|
|
|
+ }else if ($k == 'receive_order'){
|
|
|
+ $types[] = 2;
|
|
|
+ }else if ($k == 'receive_account'){
|
|
|
+ $types[] = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $pushStatus = true;
|
|
|
+ $types = [1,2,3,4,5];
|
|
|
+ }
|
|
|
+
|
|
|
+ if($userId && $pushStatus && in_array($type, $types)){
|
|
|
+ $appName = ConfigService::make()->getConfigByCode('app_name', '星链社交');
|
|
|
+ $log = [
|
|
|
+ 'from_uid'=> $fromUid,
|
|
|
+ 'to_uid'=> $userId,
|
|
|
+ 'from_user_name'=> $appName,
|
|
|
+ 'chat_type'=> 0,
|
|
|
+ 'msg_type'=> 1,
|
|
|
+ 'type'=> $type,
|
|
|
+ 'title'=> $title,
|
|
|
+ 'description'=> $title,
|
|
|
+ 'content'=> $message,
|
|
|
+ 'chat_key'=> "0{$userId}",
|
|
|
+ 'create_time'=> time(),
|
|
|
+ 'status'=> 1,
|
|
|
+ 'mark'=> 1,
|
|
|
+ ];
|
|
|
+ return MessageModel::insert($log);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取
|
|
|
* @param $userId
|
|
|
* @return array|mixed
|