67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2019-2029 成都SAAS云科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.gobuysaas.com
|
|
* =========================================================
|
|
*/
|
|
|
|
namespace addon\ali1688\model;
|
|
|
|
use app\model\system\Config as ConfigModel;
|
|
use app\model\BaseModel;
|
|
|
|
/**
|
|
* 微信小程序配置
|
|
*/
|
|
class Config extends BaseModel
|
|
{
|
|
/***
|
|
* 设置配置信息
|
|
* @param $data
|
|
* @param $is_use
|
|
* @param $site_id
|
|
* @return array
|
|
*/
|
|
public function setConfig($data, $site_id, $is_use = 1)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '阿里1688系统设置', $is_use, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'ali1688']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取配置信息
|
|
* @param int $site_id
|
|
* @return array
|
|
*/
|
|
public function getConfig($site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'ali1688']]);
|
|
return $res;
|
|
}
|
|
|
|
|
|
public function accessToken($site_id, $data = '')
|
|
{
|
|
$config = new ConfigModel();
|
|
if ($data) {
|
|
$res = $config->setConfig($data, '阿里1688accessToken', 1, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', '1688accessToken']]);
|
|
return $res;
|
|
}
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', '1688accessToken']]);
|
|
if (empty($res['data']['value'])) {
|
|
return '';
|
|
} else {
|
|
$data = $res['data']['value'];
|
|
if ($data['expire_tiem'] - time() >= 0) {
|
|
return $data['access_token'];
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
} |