Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
PaoPao
/
serviceWork
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
91722542
...
91722542f34af65027ab54490445087402a0ae1d
authored
2024-05-27 15:53:48 +0800
by
杨俊
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(develop): 移除极光推送,微信推送
1 parent
c47dcb22
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1 additions
and
218 deletions
app/Actions/ActivityPublishApply.php
app/Channels/WechatNotificationChannel.php
app/Http/Container/AppSection/Controllers/AuditionController.php
app/Http/Container/ProviderSection/Controllers/IMCallbackController.php
app/Http/Service/ActivityService.php
app/Jobs/UserSingerLimitJob.php
app/Jobs/WechatTemplateMessageJob.php
config/horizon.php
app/Actions/ActivityPublishApply.php
deleted
100644 → 0
View file @
c47dcb2
<?php
namespace
App\Actions
;
use
App\Jobs\WechatTemplateMessageJob
;
use
App\Models\Activity
;
use
App\Models\SystemRole
;
use
App\Models\User
;
use
Carbon\Carbon
;
use
Lorisleiva\Actions\Concerns\AsAction
;
use
Lorisleiva\Actions\Concerns\AsJob
;
class
ActivityPublishApply
{
use
AsAction
,
AsJob
;
protected
string
$template
=
'o9i6qtgr4ghtGvU-piimB9_mAaSOAXDDMzqx9zXYkss'
;
public
function
handle
(
Activity
$activity
)
:
void
{
$activity
->
loadMissing
(
'user:id,nick_name,real_name'
);
$roleIds
=
SystemRole
::
query
()
->
whereRelation
(
'permissions'
,
fn
(
$query
)
=>
$query
->
where
(
'guard'
,
'Admin'
)
->
where
(
'system_permissions.name'
,
'audition-activity-audit-audit'
))
->
where
(
'system_roles.status'
,
1
)
->
pluck
(
'system_roles.id'
)
->
toArray
();
User
::
query
()
->
join
(
'user_has_roles'
,
'user_has_roles.user_id'
,
'users.id'
)
->
whereIn
(
'user_has_roles.role_id'
,
$roleIds
)
->
where
(
'users.status'
,
1
)
->
where
(
'users.official_status'
,
1
)
->
distinct
()
->
pluck
(
'users.official_id'
)
->
each
(
fn
(
$item
)
=>
WechatTemplateMessageJob
::
dispatch
(
$item
,
$this
->
template
,
[
'first'
=>
'厂牌提交试唱发布申请'
,
'keyword1'
=>
'海星试唱提交了上架申请'
,
'keyword2'
=>
sprintf
(
'%s(%s)'
,
data_get
(
$activity
,
'user.nick_name'
),
data_get
(
$activity
,
'user.real_name'
)),
'keyword3'
=>
(
string
)
data_get
(
$activity
,
'created_at'
,
Carbon
::
now
()
->
toDateTimeString
()),
'keyword4'
=>
sprintf
(
'【%s】活动上架需要您的审核'
,
$activity
->
getAttribute
(
'song_name'
)),
'remark'
=>
''
]));
}
}
app/Channels/WechatNotificationChannel.php
View file @
9172254
...
...
@@ -2,24 +2,14 @@
namespace
App\Channels
;
use
App\Jobs\WechatTemplateMessageJob
;
use
App\Models\User
;
use
Illuminate\Notifications\Notification
;
use
Illuminate\Support\Arr
;
class
WechatNotificationChannel
{
public
function
send
(
User
$notifiable
,
Notification
$notification
)
:
void
{
// @phpstan-ignore-next-line
$message
=
$notification
->
toWechat
(
$notifiable
);
WechatTemplateMessageJob
::
dispatchSync
(
openId
:
Arr
::
get
(
$message
,
'openId'
,
''
),
template
:
Arr
::
get
(
$message
,
'template'
,
''
),
data
:
Arr
::
get
(
$message
,
'data'
,
[]),
url
:
Arr
::
get
(
$message
,
'url'
,
''
),
page
:
Arr
::
get
(
$message
,
'page'
,
''
)
);
$notification
->
toWechat
(
$notifiable
);
}
}
...
...
app/Http/Container/AppSection/Controllers/AuditionController.php
View file @
9172254
...
...
@@ -3,7 +3,6 @@
namespace
App\Http\Container\AppSection\Controllers
;
use
App\Helpers\JsonResource
;
use
App\Jobs\JPushMessageJob
;
use
App\Models\Activity
;
use
App\Models\ActivityShareUser
;
use
App\Models\Pivots\UserActivityCollectionPivot
;
...
...
@@ -184,19 +183,6 @@ public function sub(Request $request)
$resp
=
Http
::
asJson
()
->
post
(
$url
,
$req_data
)
->
json
();
}
}
# 极光推送-歌手收藏
$j_title
=
"您的歌手收藏了试唱"
;
$j_content
=
"您的歌手"
.
$user
->
nick_name
.
"收藏了试唱活动《"
.
$song_name
.
"》"
;
$jdata
=
[
"title"
=>
$j_title
,
"content"
=>
$j_content
,
"content_type"
=>
"text"
,
"receiver_value"
=>
[
$business_id
],
"extras"
=>
[
"type"
=>
"ToTaCollection"
,
"value"
=>
""
]];
JPushMessageJob
::
dispatch
(
$business_id
,
$j_title
,
$j_content
,
$jdata
);
}
return
JsonResource
::
success
(
'收藏成功'
);
...
...
app/Http/Container/ProviderSection/Controllers/IMCallbackController.php
View file @
9172254
...
...
@@ -5,12 +5,9 @@
use
App\Exceptions\TestCallbackException
;
use
App\Helpers\IMHelper
;
use
App\Jobs\ImMessageSaveJob
;
use
App\Jobs\WechatTemplateMessageJob
;
use
App\Models\ActivityGroup
;
use
App\Models\ActivityGroupUser
;
use
App\Models\SystemConfig
;
use
App\Models\User
;
use
Carbon\Carbon
;
use
GuzzleHttp\Promise\PromiseInterface
;
use
Hikoon\LaravelApi\Support\ApiController
;
use
Illuminate\Http\Client\Response
;
...
...
@@ -84,46 +81,12 @@ protected function stateStateChange(array $data): JsonResponse
*/
protected
function
c2CCallbackAfterSendMsg
(
array
$data
)
:
JsonResponse
{
$toId
=
Arr
::
get
(
$data
,
'To_Account'
);
$formId
=
Arr
::
get
(
$data
,
'From_Account'
);
$online
=
Arr
::
get
(
$data
,
'OnlineOnlyFlag'
,
0
);
$time
=
Arr
::
get
(
$data
,
'MsgTime'
,
Carbon
::
now
()
->
getTimestamp
());
throw_unless
(
$this
->
gate
(
$formId
),
TestCallbackException
::
class
);
$hashKey
=
'imOfflineMsg'
;
$sendTime
=
Carbon
::
createFromTimestamp
(
$time
)
->
toDateTimeString
();
$toId
=
IMHelper
::
accountToUserKey
(
$toId
);
$formId
=
IMHelper
::
accountToUserKey
(
$formId
);
ImMessageSaveJob
::
dispatch
(
$data
);
$openId
=
User
::
query
()
->
where
(
'id'
,
$toId
)
->
where
(
'audit_status'
,
1
)
->
where
(
'status'
,
1
)
->
where
(
'im_client'
,
'Web'
)
->
where
(
'im_status'
,
0
)
->
value
(
'official_id'
);
if
(
$openId
&&
(
int
)
$online
===
0
&&
!
Redis
::
client
()
->
hExists
(
$hashKey
,
$formId
))
{
Redis
::
client
()
->
hSet
(
$hashKey
,
$formId
,
0
);
$customerId
=
SystemConfig
::
query
()
->
where
(
'identifier'
,
'customer_service'
)
->
value
(
'remark'
);
$formUser
=
User
::
with
(
'artTags:id,name'
)
->
find
(
$formId
,
[
'id'
,
'nick_name'
]);
$formName
=
$formUser
->
getAttribute
(
'nick_name'
);
$formTag
=
$formUser
->
getRelation
(
'artTags'
)
?
$formUser
->
getRelation
(
'artTags'
)
->
implode
(
'name'
,
','
)
:
'无'
;
$data
=
$customerId
===
$formId
?
[
'first'
=>
'您收到平台客服发来的消息'
,
'keyword1'
=>
$formName
,
'keyword2'
=>
'平台客服'
,
'keyword3'
=>
'平台官方'
,
'keyword4'
=>
$sendTime
,
'remark'
=>
'点击查看'
]
:
[
'first'
=>
'您收到新的私聊消息'
,
'keyword1'
=>
$formName
,
'keyword2'
=>
$formTag
,
'keyword3'
=>
'私聊消息'
,
'keyword4'
=>
$sendTime
,
'remark'
=>
'点击查看'
];
WechatTemplateMessageJob
::
dispatch
(
$openId
,
'HTRAwaRoJksSGCiSeVCyvpF9vXdeQhC6R4PbSYnO8NM'
,
$data
);
}
Redis
::
client
()
->
hIncrBy
(
$hashKey
,
$formId
,
1
);
return
new
JsonResponse
([
'ActionStatus'
=>
'OK'
,
'ErrorInfo'
=>
''
,
'ErrorCode'
=>
0
]);
}
...
...
app/Http/Service/ActivityService.php
View file @
9172254
...
...
@@ -2,7 +2,6 @@
namespace
App\Http\Service
;
use
App\Actions\ActivityPublishApply
;
use
App\Actions\ActivityWorkAuditFail
;
use
App\Actions\ActivityWorkAuditSuccess
;
use
App\Enums\ActivityAuditStatusEnum
;
...
...
@@ -160,7 +159,6 @@ public function createActivityApply(array $attribute, bool $checkConfig = true):
return
DB
::
transaction
(
static
function
()
use
(
$attribute
)
{
$activity
=
Activity
::
query
()
->
create
(
array_merge
(
$attribute
,
[
'song_type'
=>
ActivitySongTypeEnum
::
SONG
->
value
]));
OperationLog
::
guard
()
->
subject
(
$activity
)
->
createAction
()
->
content
(
'歌曲《%s》,申请上架'
,
$activity
->
getAttribute
(
'song_name'
));
ActivityPublishApply
::
dispatch
(
$activity
);
return
$activity
;
});
}
...
...
app/Jobs/UserSingerLimitJob.php
View file @
9172254
...
...
@@ -41,26 +41,6 @@ public function __construct(array $jPushMessage, array $wechatMessage)
*/
public
function
handle
()
:
void
{
User
::
query
()
->
where
(
'status'
,
1
)
->
whereIn
(
'id'
,
explode
(
','
,
SystemConfig
::
query
()
->
where
(
'identifier'
,
'DBYsQqJrvuPf_d_zMR4va'
)
->
value
(
'content'
)
??
''
))
->
select
([
'id'
,
'nick_name'
,
'real_name'
,
'official_id'
,
'official_status'
,
'area_code'
,
'phone'
])
->
eachById
(
function
(
User
$user
)
{
JPushMessageJob
::
dispatch
(
$user
->
getKey
(),
Arr
::
get
(
$this
->
jPushMessage
,
'title'
,
''
),
Arr
::
get
(
$this
->
jPushMessage
,
'content'
,
''
),
Arr
::
get
(
$this
->
jPushMessage
,
'data'
,
[])
);
if
(
$user
->
getAttribute
(
'official_status'
)
===
UserOfficialStatusEnum
::
SUBSCRIBE
)
{
WechatTemplateMessageJob
::
dispatch
(
$user
->
getAttribute
(
'official_id'
),
'GFJxUXdJs37HX2hYB_jdOeR2FQHj2RpkJo57q24Lkkc'
,
[
'keyword1'
=>
'歌手额度上限提醒'
,
'keyword2'
=>
Arr
::
get
(
$this
->
wechatMessage
,
'title'
,
''
),
'keyword3'
=>
Arr
::
get
(
$this
->
wechatMessage
,
'content'
,
''
),
'keyword4'
=>
Arr
::
get
(
$this
->
wechatMessage
,
'limit'
,
$this
->
defaultLimit
),
'keyword5'
=>
Arr
::
get
(
$this
->
wechatMessage
,
'limit'
,
$this
->
defaultLimit
),
]);
}
});
}
}
...
...
app/Jobs/WechatTemplateMessageJob.php
deleted
100644 → 0
View file @
c47dcb2
<?php
namespace
App\Jobs
;
use
App\Helpers\ServiceHelper
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Foundation\Bus\Dispatchable
;
use
Illuminate\Queue\InteractsWithQueue
;
use
Illuminate\Queue\SerializesModels
;
use
function
array_key_exists
;
class
WechatTemplateMessageJob
implements
ShouldQueue
{
use
Dispatchable
,
InteractsWithQueue
,
Queueable
,
SerializesModels
;
// private const API_URI = 'cgi-bin/message/template/send';
/**
* @var array<string,mixed>
*/
private
array
$data
;
/**
* Create a new job instance.
*
* @param string $openId
* @param string $template
* @param array<string,mixed> $data
* @param string $url
* @param string $page
*/
public
function
__construct
(
string
$openId
,
string
$template
,
array
$data
=
[],
string
$url
=
''
,
string
$page
=
''
)
{
$this
->
data
=
[
'openId'
=>
$openId
,
'template'
=>
$template
,
'data'
=>
$this
->
formatData
(
$data
),
'page'
=>
$page
,
'url'
=>
$url
];
}
/**
* Execute the job.
*
* @return void
* @throws \JsonException
*/
public
function
handle
()
:
void
{
//Access_Token 问题,暂时访问Admin服务推送接口
ServiceHelper
::
sendWechatOfficial
(
$this
->
data
);
}
/**
* @param array<string,mixed> $data
* @return array<string,array<string,string>>
*/
protected
function
formatData
(
array
$data
)
:
array
{
$formatted
=
[];
foreach
(
$data
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
if
(
array_key_exists
(
'value'
,
$value
))
{
$formatted
[
$key
]
=
$value
;
continue
;
}
if
(
count
(
$value
)
>=
2
)
{
$value
=
[
'value'
=>
$value
[
0
],
'color'
=>
$value
[
1
],
];
}
}
else
{
$value
=
[
'value'
=>
(
string
)
$value
,];
}
$formatted
[
$key
]
=
$value
;
}
return
$formatted
;
}
/**
* @param string $page
* @return array<string,string>
*/
protected
function
formatMiniPage
(
string
$page
)
:
array
{
return
[
'appid'
=>
config
(
'easywechat.mini_app.default.app_id'
),
'pagepath'
=>
$page
];
}
}
config/horizon.php
View file @
9172254
...
...
@@ -120,9 +120,7 @@
*/
'silenced'
=>
[
\App\Jobs\JPushMessageJob
::
class
,
\App\Jobs\SmsMessageJob
::
class
,
\App\Jobs\WechatTemplateMessageJob
::
class
,
],
/*
...
...
Please
register
or
sign in
to post a comment