105 lines
3.2 KiB
PHP
105 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* Member.php
|
|
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2015-2025 成都云之牛科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.cdcloudshop.com
|
|
* =========================================================
|
|
* @author : niuteam
|
|
* @date : 2022.8.8
|
|
* @version : v5.0.0.1
|
|
*/
|
|
|
|
namespace app\api\controller;
|
|
|
|
use think\Exception;
|
|
use think\facade\Db;
|
|
|
|
/**
|
|
* Common: 模板消息相关API
|
|
* Author: wu-hui
|
|
* Time: 2023/01/10 11:15
|
|
* Class Message
|
|
* @package app\api\controller
|
|
*/
|
|
class Message extends BaseApi{
|
|
|
|
|
|
/**
|
|
* Common: 模板消息配置信息获取 —— 入口
|
|
* Author: wu-hui
|
|
* Time: 2023/01/10 11:54
|
|
* @return false|string
|
|
*/
|
|
public function entrance(){
|
|
// 参数获取
|
|
$keywords = json_decode(input('keywords',''),TRUE);
|
|
if(!$keywords) $this->response($this->error("", "参数错误!"));
|
|
// 获取对应的信息
|
|
try{
|
|
// 获取对应的信息
|
|
$className = $this->params['app_type'].'TemplateInfo';
|
|
$classList = get_class_methods(self::class);
|
|
$info = [];
|
|
if(in_array($className,$classList)) $info = $this->$className($keywords);
|
|
|
|
return $this->response($this->success($info));
|
|
}catch(Exception $e){
|
|
return $this->response($this->error("", $e->getMessage()));
|
|
}
|
|
}
|
|
/**
|
|
* Common: 模板消息配置信息获取 —— 支付宝模板消息获取
|
|
* Author: wu-hui
|
|
* Time: 2023/01/10 11:54
|
|
* @param $keywords
|
|
* @return array
|
|
*/
|
|
public function aliappTemplateInfo($keywords){
|
|
$templateIds = Db::name('message')
|
|
->whereIn('keywords',$keywords)
|
|
->where('aliapp_is_open',1)
|
|
->column('aliapp_template_id');
|
|
|
|
return array_filter($templateIds);
|
|
}
|
|
// 模板消息配置信息获取 —— 微信小程序
|
|
public function weappTemplateInfo($keywords){}
|
|
// 模板消息配置信息获取 —— 微信公众号
|
|
public function wechatTemplateInfo($keywords){}
|
|
/**
|
|
* Common: 记录小程序订阅消息订阅记录
|
|
* Author: wu-hui
|
|
* Time: 2023/01/10 14:07
|
|
* @return false|string|void
|
|
*/
|
|
public function subscriptionRecord(){
|
|
$token = $this->checkToken();
|
|
if ($token[ 'code' ] < 0) return $this->response($token);
|
|
// 参数获取
|
|
$currentSubscribedEntityIds = json_decode(input('currentSubscribedEntityIds',''),TRUE);
|
|
if(is_array($currentSubscribedEntityIds) && $currentSubscribedEntityIds){
|
|
$insertData = [];
|
|
foreach($currentSubscribedEntityIds as $templateId){
|
|
$insertData[] = [
|
|
'site_id' => $this->site_id,
|
|
'uid' => $this->member_id,
|
|
'template_id' => $templateId,
|
|
'type' => $this->params['app_type'] ?? '',
|
|
'create_time' => time(),
|
|
];
|
|
}
|
|
Db::name('message_form_id')->insertAll($insertData);
|
|
}
|
|
return $this->response($this->success('操作完成'));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |