123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <?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 CompleteInfoRemind
- * @package App\Notifications
- */
- class CompleteInfoRemind extends Notification
- {
- protected $title = "提醒用户补全信息";
- /** @var array 绑定数据 */
- protected $buildData = array(
- 'remind_nickname' => "提醒者昵称",
- 'is_remind_nickname' => '被提醒者昵称'
- );
- /**
- * Create a new notification instance.
- *
- * @param $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/my-friend-card-editor/my-friend-card-editor";
- }
- /**
- *
- * @return TemplateChannel
- */
- public function toFpdxTemplate()
- {
- $templateIds = array(
- [
- 'template_id' => "MsktKh_eS5HMnjmCGznVYZFTAAm2JGHQfXmZgJNt4Qk",
- 'data' => [
- 'first' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => "{$this->buildData['is_remind_nickname']}"
- ],
- 'keyword2' => [
- 'value' => "邀请你完善交友卡片"
- ],
- 'keyword3' => [
- 'value' => date('Y-m-d')
- ],
- 'remark' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~",
- ]
- ]
- ],
- [
- 'template_id' => "aDsZW0gzbSTcEwxzqC44Cq-luC-8YHLp8CaPCrWAlBo",
- 'data' => [
- 'first' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => "{$this->buildData['is_remind_nickname']}"
- ],
- 'keyword2' => [
- 'value' => "邀请你完善交友卡片"
- ],
- 'keyword3' => [
- 'value' => date('Y-m-d')
- ],
- 'remark' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~",
- ]
- ]
- ]
- );
- $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' => "RJNTbLGdlK7tLRgt5uoKIEWxlB7-bwCdwgE5yR11aHk",
- 'data' => [
- 'first' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => "{$this->buildData['is_remind_nickname']}"
- ],
- 'keyword2' => [
- 'value' => "邀请你完善交友卡片"
- ],
- 'keyword3' => [
- 'value' => date('Y-m-d')
- ],
- 'remark' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~",
- ]
- ]
- ],
- [
- 'template_id' => "buiSCGP-jKweNEVi7V8ZK-8Lspem1FopbD5Kvupg1Ig",
- 'data' => [
- 'first' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword1' => [
- 'value' => "{$this->buildData['is_remind_nickname']}"
- ],
- 'keyword2' => [
- 'value' => "邀请你完善交友卡片"
- ],
- 'keyword3' => [
- 'value' => date('Y-m-d')
- ],
- 'remark' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~",
- ]
- ]
- ]
- );
- $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 = "hc6Av4hGLXLzcVgc4JkDNmrYJ18rztBPU_NCfYUNy7U";
- $data = array(
- 'keyword1' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword2' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~"
- ],
- 'keyword3' => [
- 'value' => "{$this->buildData['is_remind_nickname']}"
- ],
- );
- return new MiniTemplateChannel($this->to_uid, $templateId, $data);
- }
- /**
- * @return QQMiniTemplateChannel
- */
- public function toQQMiniTemplate()
- {
- $templateId = "481d4c5aaeb77b6b0cc3b962edd0e54d";
- $data = array(
- 'keyword1' => [
- 'value' => "{$this->buildData['remind_nickname']}对你的资料很感兴趣,邀请你完善交友卡片~"
- ],
- 'keyword2' => [
- 'value' => "邀请你完善交友卡片"
- ],
- 'keyword3' => [
- 'value' => "点此继续补全信息,可获得更高曝光度~"
- ],
- );
- return (new QQMiniTemplateChannel())
- ->setAppId('1109365561')
- ->setTitle($this->title)
- ->setPage($this->getPagePath())
- ->toUser($this->to_uid)
- ->setTemplateId($templateId)
- ->setParameters($data)
- ->send();
- }
- }
|