DiverseYouthNightSchool/application/api/controller/WechatUtil.php

617 lines
28 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
namespace app\api\controller;
use addons\epay\library\Service;
use app\common\controller\Api;
use app\common\model\school\classes\VisitDistribution;
use app\common\model\style\HomeImages;
use think\Cache;
/**
* 微信工具类接口
*/
class WechatUtil extends Api
{
protected $noNeedLogin = '*';
protected $noNeedRight = ['*'];
public function index()
{
$this->success('请求成功');
}
/**
* @ApiTitle(微信小程序生成url-scheme)
* @ApiSummary(微信小程序生成url-scheme)
* @ApiRoute(/api/wechat_util/scheme)
* @ApiMethod(POST)
* @ApiParams (name="path", type="string", required=false, description="通过 scheme 码进入的小程序页面路径,必须是已经发布的小程序存在的页面,不可携带 query。path 为空时会跳转小程序主页。")
* @ApiParams (name="query", type="string", required=false, description="通过 scheme 码进入小程序时的 query最大1024个字符只支持数字大小写英文以及部分特殊字符")
* @ApiParams (name="env_version", type="string",required=false , description="默认值release。要打开的小程序版本。正式版为release体验版为trial开发版为develop仅在微信外打开时生效。")
* @ApiParams (name="expire_time", type="number",required=false , description="到期失效的 scheme 码的失效时间,为 Unix 时间戳。生成的到期失效 scheme 码在该时间前有效。最长有效期为30天。is_expire 为 true 且 expire_type 为 0 时必填")
* @ApiParams (name="expire_type", type="number",required=false , description="默认值0到期失效的 scheme 码失效类型失效时间0失效间隔天数1")
* @ApiParams (name="expire_interval", type="number",required=false , description="到期失效的 scheme 码的失效间隔天数。生成的到期失效 scheme 码在该间隔时间到达前有效。最长间隔天数为30天。is_expire 为 true 且 expire_type 为 1 时必填")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="openlink", type="string", required=true, sample="生成的小程序 scheme 码")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function scheme() {
$q_params = [];
$path = $this->request->post('path/s','');
$query = $this->request->post('query/s','');
$env_version = $this->request->post('env_version/s','release');
$expire_time = $this->request->post('expire_time/d',0);
$expire_type = $this->request->post('expire_type/d',0);
$expire_interval = $this->request->post('expire_interval/d',0);
$jump_wxa = compact('env_version');
if($path)$jump_wxa["path"] = $path;
if($query)$jump_wxa["query"] = $query;
if($expire_time)$q_params["expire_time"] = $expire_time;
if($expire_interval)$q_params["expire_interval"] = $expire_interval;
$q_params["expire_type"] = $expire_type;
$q_params["jump_wxa"] = $jump_wxa;
try {
// 实例对应的接口对象
$scheme = new \WeMini\Scheme(Service::wechatConfig());
$res= $scheme->create($q_params);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序生成url-link)
* @ApiSummary(微信小程序生成url-link)
* @ApiRoute(/api/wechat_util/link)
* @ApiMethod(POST)
* @ApiParams (name="path", type="string", required=false, description="通过 URL Link 进入的小程序页面路径,必须是已经发布的小程序存在的页面,不可携带 query 。path 为空时会跳转小程序主页")
* @ApiParams (name="query", type="string", required=false, description="通过 scheme 码进入小程序时的 query最大1024个字符只支持数字大小写英文以及部分特殊字符")
* @ApiParams (name="env_version", type="string",required=false , description="默认值release。要打开的小程序版本。正式版为release体验版为trial开发版为develop仅在微信外打开时生效。")
* @ApiParams (name="expire_time", type="number",required=false , description="到期失效的 scheme 码的失效时间,为 Unix 时间戳。生成的到期失效 scheme 码在该时间前有效。最长有效期为30天。is_expire 为 true 且 expire_type 为 0 时必填")
* @ApiParams (name="expire_type", type="number",required=false , description="默认值0到期失效的 scheme 码失效类型失效时间0失效间隔天数1")
* @ApiParams (name="cloud_env", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 云开发环境")
* @ApiParams (name="cloud_domain", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 静态网站自定义域名,不填则使用默认域名")
* @ApiParams (name="cloud_path", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 云开发静态网站 H5 页面路径,不可携带 query")
* @ApiParams (name="cloud_query", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 云开发静态网站 H5 页面 query 参数,最大 1024 个字符,只支持数字,大小写英文以及部分特殊字符")
* @ApiParams (name="cloud_resource_appid", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 第三方批量代云开发时必填,表示创建该 env 的 appid (小程序/第三方平台)")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="url_link", type="string", required=true, sample="生成的小程序 URL Link")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function link() {
$q_params = [];
$path = $this->request->post('path/s','');
$query = $this->request->post('query/s','');
$env_version = $this->request->post('env_version/s','release');
$expire_time = $this->request->post('expire_time/d',0);
$expire_type = $this->request->post('expire_type/d',0);
$expire_interval = $this->request->post('expire_interval/d',0);
$cloud_env = $this->request->post('cloud_env/s',0);
$cloud_domain = $this->request->post('cloud_domain/s',0);
$cloud_path = $this->request->post('cloud_path/s',0);
$cloud_query = $this->request->post('cloud_query/s',0);
$cloud_resource_appid = $this->request->post('cloud_resource_appid/s',0);
$cloud_base = [];
if($cloud_env)$cloud_base["env"] = $cloud_env;
if($cloud_domain)$cloud_base["domain"] = $cloud_domain;
if($cloud_path)$cloud_base["path"] = $cloud_path;
if($cloud_query)$cloud_base["cloud_query"] = $cloud_query;
if($cloud_resource_appid)$cloud_base["resource_appid"] = $cloud_resource_appid;
if($path)$q_params["path"] = $path;
if($query)$q_params["query"] = $query;
if($env_version)$q_params["env_version"] = $env_version;
if($expire_time)$q_params["expire_time"] = $expire_time;
if($expire_interval)$q_params["expire_interval"] = $expire_interval;
if($expire_type)$q_params["expire_type"] = $expire_type;
if($cloud_base)$q_params["cloud_base"] = $cloud_base;
try {
// 实例对应的接口对象
$scheme = new \WeMini\Scheme(Service::wechatConfig());
$res= $scheme->urlLink($q_params);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(获取不限制的小程序码(太阳码))
* @ApiSummary(获取不限制的小程序码(太阳码))
* @ApiRoute(/api/wechat_util/codeunlimit)
* @ApiMethod(POST)
* @ApiParams (name="page", type="string", required=false, description="默认是主页,页面 page例如 pages/index/index根路径前不要填加 /不能携带参数参数请放在scene字段里如果不填写这个字段默认跳主页面。scancode_time为系统保留参数不允许配置")
* @ApiParams (name="scene", type="string", required=false, description="最大32个可见字符只支持数字大小写英文以及部分特殊字符!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)")
* @ApiParams (name="env_version", type="string",required=false , description="默认值release。要打开的小程序版本。正式版为release体验版为trial开发版为develop仅在微信外打开时生效。")
* @ApiParams (name="check_path", type="bool",required=false , description="默认是true检查page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在, 但page 有数量上限60000个请勿滥用。")
* @ApiParams (name="width", type="number",required=false , description="默认430二维码的宽度单位 px最小 280px最大 1280px")
* @ApiParams (name="auto_color", type="bool",required=false , description="自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false")
* @ApiParams (name="line_color", type="json",required=false , description="默认是{r:0,g:0,b:0} 。auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {r:xxx,g:xxx,b:xxx} 十进制表示")
* @ApiParams (name="is_hyaline", type="bool",required=false , description="默认是false是否需要透明底色为 true 时,生成透明底色的小程序")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function codeunlimit() {
$page = $this->request->post('page/s','');
$scene = $this->request->post('scene/s','');
$env_version = $this->request->post('env_version/s','release');
$check_path = $this->request->post('check_path/d',1);
$width = $this->request->post('width/d',430);
$auto_color = $this->request->post('auto_color/d',0);
$line_color = $this->request->post('line_color/s',0);
$is_hyaline = $this->request->post('is_hyaline/d',1);
try {
// 实例对应的接口对象
$res = \bw\Common::getMiniappCode($scene, $page, $width, $auto_color ? true : false, $line_color, $is_hyaline ? true : false, null, $check_path ? true : false, $env_version,false);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序生成用户画像)
* @ApiSummary(微信小程序生成用户画像)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 开始日期与结束日期相差的天数限定为0/6/29分别表示查询最近1/7/30天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidUserportrait() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidUserportrait' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidUserportrait($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序访问页面)
* @ApiSummary(微信小程访问页面)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期限定查询1天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidVisitPage() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidVisitPage' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidVisitPage($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序月留存)
* @ApiSummary(微信小程序月留存)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期,为自然月第一天")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期,为自然月最后一天,限定查询一个月数据")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidMonthlyRetaininfo() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidMonthlyRetaininfo' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidMonthlyRetaininfo($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序周留存)
* @ApiSummary(微信小程序周留存)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期,为周一日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期,为周日日期,限定查询一周数据")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidWeeklyRetaininfo() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidWeeklyRetaininfo' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidWeeklyRetaininfo($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序日留存)
* @ApiSummary(微信小程序日留存)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期限定查询1天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidDailyRetaininfo() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidDailyRetaininfo' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidDailyRetaininfo($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序访问分布)
* @ApiSummary(微信小程序访问分布)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期限定查询1天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidVisitdistribution() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidVisitdistribution' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidVisitdistribution($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
VisitDistribution::setlog($begin_date,$end_date,$res);
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序月趋势)
* @ApiSummary(微信小程序月趋势)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期,为自然月第一天")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期,为自然月最后一天,限定查询一个月数据")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidMonthlyVisittrend() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidMonthlyVisittrend' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidMonthlyVisittrend($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序周趋势)
* @ApiSummary(微信小程序周趋势)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期,为周一日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期,为周日日期,限定查询一周数据")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidWeeklyVisittrend() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidWeeklyVisittrend' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidWeeklyVisittrend($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序访问分析)
* @ApiSummary(微信小程序访问分析)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期限定查询1天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidDailyVisittrend() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidDailyVisittrend' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidDailyVisittrend($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(微信小程序数据分析)
* @ApiSummary(微信小程序数据分析)
* @ApiMethod(POST)
* @ApiParams (name="begin_date", type="string", required=true, description="开始日期。格式为 yyyymmdd 如20170611 开始日期")
* @ApiParams (name="end_date", type="string", required=true, description="结束日期,格式为 yyyymmdd 如20170611 结束日期限定查询1天数据end_date允许设置的最大值为昨日")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getWeanalysisAppidDailySummarytrend() {
$begin_date = $this->request->post('begin_date/s',0);
$end_date = $this->request->post('end_date/s',0);
$cacheNmae = 'getWeanalysisAppidDailySummarytrend' . $begin_date . $begin_date;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getWeanalysisAppidDailySummarytrend($begin_date, $end_date);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
/**
* @ApiTitle(查询微信报错rid信息)
* @ApiSummary(本接口用于查询调用公众号/小程序/第三方平台等接口报错返回的rid详情信息辅助开发者高效定位问题)
* @ApiMethod(POST)
* @ApiParams (name="rid", type="string", required=true, description="调用接口报错返回的rid")
* @ApiReturn({
"code" => 1,
"msg" => "获取成功",
"data" => {}
*})
*/
public function getRidInfo() {
$rid = $this->request->post('rid/s',0);
$cacheNmae = 'getRidInfo' . $rid ;
try {
// 实例对应的接口对象
$weMiniTotal = new \WeMini\Total(Service::wechatConfig());
$res = $weMiniTotal->getRidInfo($rid);
// 缓存在3600秒之后过期
Cache::set($cacheNmae, $res, (3600 * 24 * 32));
} catch (\Exception $e){
// Log::log($e->getMessage());
$res = Cache::get($cacheNmae);
if($res){
$this->success('生成成功', $res);
}else{
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
}
$this->success('生成成功', $res);
}
}