6
0
Fork 0

调整商家端语音播报推送

release
vine_liutk 2022-01-05 13:19:47 +08:00
parent b9d68c2db6
commit d2eb0f422a
3 changed files with 90 additions and 14 deletions

View File

@ -41,19 +41,21 @@ class QuotaV1SendCommand extends Command
$walletService = new WalletService();
//依次分红
foreach ($userInfos as $userInfo) {
$log = new QuotaV1SendLog();
$log->user_id = $userInfo->user_id;
$log->job_id = $job->id;
$log->amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
$log->save();
try {
DB::beginTransaction();
$log->update(['status'=>1]);
$walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
report($th);
if ($userInfo->bonusable) {//只针对享受分红的人发放
$log = new QuotaV1SendLog();
$log->user_id = $userInfo->user_id;
$log->job_id = $job->id;
$log->amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
$log->save();
try {
DB::beginTransaction();
$log->update(['status'=>1]);
$walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
report($th);
}
}
}
});

View File

@ -65,7 +65,7 @@ class MerchantUnipushService extends UniPushService
return false;
}
return $this->pushCid($sn, $message->user->cid->m_cid, $message->title, $message->content, [
return $this->pushPayload($sn, $message->user->cid->m_cid, $message->title, $message->content, [
'jump_type' => $message->jump_type == 0 ? 1 : $message->jump_type,
'jump_link' => $message->type == 1 || empty($message->jump_link) ? '/pages/news/index' : $message->jump_link,
]);

View File

@ -190,6 +190,61 @@ class UniPushService
];
}
protected function createPushPayloadData($title, $body, $params = [])
{
$payload = json_encode($params);
return [
'settings'=>[
'ttl'=> 3600000,
'strategy'=> [
'default'=>1,
'ios'=>4,
],
],
'push_message'=>[
'transmission'=> json_encode([
// 'title' => $title,
// 'content'=> $body,
'payload'=> $title,
]),
// 'notification'=>[
// 'title' => $title,
// 'body' => $body,
// 'click_type'=> 'payload', //默认打开首页
// 'payload'=> $payload,
// ],
],
'push_channel'=>[
'android'=>[
'ups'=> [
'transmission'=> json_encode([
// 'title' => $title,
// 'content'=> $body,
'payload'=> $title,
]),
// 'notification'=>[
// 'title' => $title,
// 'body' => $body,
// 'click_type'=> 'payload', //默认打开首页
// 'payload'=> $payload,
// ],
],
],
'ios'=>[
'type'=>'notify',
'payload' => $payload,
'aps'=>[
'alert'=>[
'title'=>$title,
'body'=>$body,
],
'content-available'=> 0,
],
],
],
];
}
/**
* 绑定cid和user_id
*
@ -252,6 +307,25 @@ class UniPushService
);
}
/**
* Undocumented function
*
* @return void
*/
public function pushPayload(string $sn, string $cid, string $title, string $body, array $params = [])
{
return $this->formatResStatus(
$this->post('push/single/cid', array_merge([
'request_id' => $sn,
'audience'=>[
'cid'=>[
$cid,
],
],
], $this->createPushPayloadData($title, $body, $params)))
);
}
protected function formatResStatus($res): bool
{
if (Arr::get($res, 'code', 1) === 0) {