123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace App\Notifications;
- use App\Services\NoticeService\Channels\MiniTemplateChannel;
- use App\Services\NoticeService\Channels\QQMiniTemplateChannel;
- use App\Services\NoticeService\Channels\TemplateChannel;
- use App\Services\NoticeService\Notification;
- /**
- * 补全信息完成
- * Class CompletedInfo
- * @package App\Notifications
- */
- class CompletedInfo extends Notification
- {
- protected $title = "提醒用户补全信息回应";
- /** @var array 绑定数据 */
- protected $buildData = array(
- 'is_remind_nickname' => '被提醒者昵称',
- 'is_remind_user_partner_id' => null
- );
- /**
- * Create a new notification instance.
- *
- * @param int $to_uid
- */
- public function __construct(int $to_uid)
- {
- parent::__construct($to_uid);
- }
- /**
- * Get the notification's delivery channels.
- *
- * @return array
- */
- public function via(): array
- {
- return [
- $this->toFpdxTemplate(),
- $this->toSyjTemplate(),
- $this->toMiniTemplate(),
- // $this->toQQMiniTemplate()
- ];
- }
- /**
- * @param array $build
- * @return $this
- */
- public function buildData(array $build)
- {
- $this->buildData = $build;
- return $this;
- }
- /**
- * 跳转地址
- * @return string
- */
- protected function getPagePath()
- {
- return "pages/other-friend-card/other-friend-card?partner_id={$this->buildData['is_remind_user_partner_id']}";
- }
- /**
- *
- * @return TemplateChannel
- */
- public function toFpdxTemplate()
- {
- $templateIds = array(
- [
- 'template_id' => "vj03Lys62tcWH0BAx2bKdDbzxBnhwe4Fhs3GXqbxkTg",
- 'data' => [
- 'first' => [
- 'value' => "你提醒的{$this->buildData['is_remind_nickname']},已完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => "提醒成功"
- ],
- 'keyword2' => [
- 'value' => date('Y-m-d H:i:s')
- ],
- 'remark' => [
- 'value' => "点此可查看{$this->buildData['is_remind_nickname']}详细资料",
- ]
- ]
- ]
- );
- $template = $templateIds[rand(0, count($templateIds) - 1)];
- $templateId = $template['template_id'];
- $data = $template['data'];
- $publicId = config("wechat.fpdx.public_id");
- return new TemplateChannel($this->to_uid, $templateId, $data, $publicId);
- }
- /**
- * @return TemplateChannel
- */
- public function toSyjTemplate()
- {
- $templateIds = array(
- [
- 'template_id' => "T5AvN3tkUKywz1-hVeW2RFLNYV1Ex_EfXI0OE_JQBxM",
- 'data' => [
- 'first' => [
- 'value' => "你提醒的{$this->buildData['is_remind_nickname']},已完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => date('Y-m-d H:i:s')
- ],
- 'keyword2' => [
- 'value' => "提醒成功"
- ],
- 'keyword3' => [
- 'value' => "点此可查看{$this->buildData['is_remind_nickname']}详细资料"
- ]
- ]
- ]
- );
- $template = $templateIds[rand(0, count($templateIds) - 1)];
- $templateId = $template['template_id'];
- $data = $template['data'];
- $publicId = config("wechat.fpdx.public_id");
- return new TemplateChannel($this->to_uid, $templateId, $data, $publicId);
- }
- /**
- * @return MiniTemplateChannel
- */
- public function toMiniTemplate()
- {
- $templateId = "THT3gLhSTLvs9Koli8wxdbKYq2_noErJKy7aov-YmMg";
- $data = array(
- 'keyword1' => [
- 'value' => "你提醒的{$this->buildData['is_remind_nickname']},已完善交友卡片~"
- ],
- 'keyword2' => [
- 'value' => date('Y-m-d H:i:s')
- ],
- 'keyword3' => [
- 'value' => "提醒成功"
- ],
- 'keyword4' => [
- 'value' => '更新成功'
- ],
- 'keyword5' => [
- 'value' => "点此可查看{$this->buildData['is_remind_nickname']}详细资料"
- ]
- );
- return new MiniTemplateChannel($this->to_uid, $templateId, $data);
- }
- /**
- * @return QQMiniTemplateChannel
- */
- public function toQQMiniTemplate()
- {
- $templateId = "3f90ecc0a1eed20431caee8212279ce3";
- $data = array(
- 'keyword1' => [
- 'value' => "你提醒的{$this->buildData['is_remind_nickname']},已完善交友卡片~"
- ],
- 'keyword2' => [
- 'value' => date('Y-m-d H:i:s')
- ],
- 'keyword3' => [
- 'value' => "提醒成功"
- ],
- 'keyword4' => [
- 'value' => '更新成功'
- ],
- 'keyword5' => [
- 'value' => "点此可查看{$this->buildData['is_remind_nickname']}详细资料"
- ]
- );
- return (new QQMiniTemplateChannel())->setTitle($this->title)
- ->toUser($this->to_uid)->setTemplateId($templateId)
- ->setPage($this->getPagePath())
- ->setParameters($data)->send();
- }
- }
|