dlhmaster/app/api/controller/Notice.php
2024-06-18 17:43:24 +08:00

91 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\common\basics\Api;
use app\common\logic\SystemNoticeLogic;
use app\common\model\Client_;
use app\common\model\user\UserAuth;
use app\common\server\JsonServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
class Notice extends Api
{
/**
* Notes: 消息中心
* @author 段誉(2021/6/22 0:55)
* @return \think\response\Json
*/
public function index()
{
return JsonServer::success('获取成功', SystemNoticeLogic::index($this->user_id));
}
/**
* Notes: 消息列表
* @author 段誉(2021/6/22 0:55)
*/
public function lists()
{
$type = $this->request->get('type');
$lists = SystemNoticeLogic::lists($this->user_id, $type, $this->page_no, $this->page_size);
return JsonServer::success('获取成功', $lists);
}
/**
* @notes 本地生活消息订阅模板ID,需要将template_id放在配置文件中
*/
public function getLocalLifeTemplateId()
{
return JsonServer::success('获取成功', ['id' => ['w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM']]);
}
/**
* @notes 将template_id放在配置文件中
*/
public function sendMsg()
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$user = UserAuth::where(['user_id' => $this->user_id, 'client' => Client_::mnp])->find();
$data = [
'template_id' => 'w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM', // 所需下发的订阅模板id
'touser' => $user['openid'], // 接收者(用户)的 openid
'page' => '/pages/goods_cate/goods_cate', // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
'data' => [ // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
'thing1' => [
'value' => '我的店铺',
],
'thing4' => [
'value' => '您的店铺审核成功',
],
'phrase5' => [
'value' => '审核成功'
]
],
];
$app->subscribe_message->send($data);
}
}