114 lines
4.5 KiB
PHP
114 lines
4.5 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\wxoplatform\model;
|
|
use app\model\system\Config as ConfigModel;
|
|
use app\model\BaseModel;
|
|
use app\model\system\UniAccount;
|
|
use think\facade\Db;
|
|
/**
|
|
* 微信公众号配置
|
|
* 版本 1.0.4
|
|
*/
|
|
class Config extends BaseModel
|
|
{
|
|
|
|
/******************************************************************** 微信小程序配置 start *************************************************************************/
|
|
/**
|
|
* 商家设置
|
|
* @param $data 设置数组
|
|
* @param $is_use 是否开启
|
|
* @param int $site_id 商家ID
|
|
* @param string $app_module 应用模块
|
|
* @return array
|
|
*/
|
|
public function setWeappConfig($appid,$site_id,$data)
|
|
{
|
|
$config = new UniAccount();
|
|
$condition=['appid'=>$appid,'site_id'=>$site_id];
|
|
$res = $config->setUniConfig($condition,'WEAPP_CONFIG','weapp',$data,$data['weapp_original']??0);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取微信小程序配置信息
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function getWeappConfig($site_id, $config_key = 'WEAPP_CONFIG')
|
|
{
|
|
$config = new UniAccount();
|
|
// $bound_info = model('config')->getInfo([ [ 'app_module', '=', 'shop' ], [ 'config_key', 'in', [ 'WECHAT_CONFIG', 'WEAPP_CONFIG' ] ], [ 'value', 'like', '%' . $data['authorizer_appid'] . '%' ] ], 'site_id');
|
|
$res = $config->getUniConfig(['site_id'=> $site_id,'app_type'=>'weapp'],$config_key);
|
|
return $res;
|
|
}
|
|
/**
|
|
* 根据appid获取配置信息
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function getAppidConfig($appid,$config_key = 'WEAPP_CONFIG')
|
|
{
|
|
$config = new ConfigModel();
|
|
$bound_info = Db::name('config')
|
|
// ->where('value->appid',$appid)
|
|
->where([[ 'app_module', '=', 'shop' ],[ 'config_key', 'in', [ 'WECHAT_CONFIG', 'WEAPP_CONFIG' ] ], [ 'value', 'like', '%'.$appid.'%' ] ])
|
|
->json(['value'])
|
|
->cache($appid,3600)
|
|
->find();
|
|
return $bound_info;
|
|
}
|
|
|
|
/******************************************************************** 微信开放平台配置 start ****************************************************************************/
|
|
/**
|
|
* 设置开放平台配置
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function setOplatformConfig($data, $is_use)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '微信开放平台设置', $is_use, [['site_id', '=', 0], ['app_module', '=', 'admin'], ['config_key', '=', 'OPLATFORM_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取开放平台配置信息
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function getOplatformConfig($site_id=0,$app_module='admin')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'OPLATFORM_CONFIG']]);
|
|
if(empty($res['data']['value'])){
|
|
$res['data']['value']=config('wechat.platform');
|
|
}
|
|
return $res;
|
|
}
|
|
/******************************************************************** 微信开放平台配置 end ****************************************************************************/
|
|
|
|
public function setComponentVerifyTicket($data, $is_use)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, 'ComponentVerifyTicket', $is_use, [['site_id', '=', 0], ['app_module', '=', 'admin'], ['config_key', '=', 'ComponentVerifyTicket_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
public function getComponentVerifyTicket($site_id=0,$app_module='admin')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'ComponentVerifyTicket_CONFIG']]);
|
|
if(empty($res['data']['value'])){
|
|
$res['data']['value']=config('wechat.platform');
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
}
|