158 lines
5.6 KiB
PHP
158 lines
5.6 KiB
PHP
<?php
|
||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||
* =========================================================
|
||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||
* ----------------------------------------------
|
||
* 官方网址: https://www.zjphp.com
|
||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||
* =========================================================
|
||
*/
|
||
|
||
namespace app\model\newModel;
|
||
|
||
use app\model\NewBaseModel;
|
||
use think\Exception;
|
||
use think\facade\Cache;
|
||
|
||
class Config extends NewBaseModel{
|
||
|
||
protected $pk = 'id'; // 默认主键id
|
||
protected $name = 'config';
|
||
//protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||
protected $createTime = 'create_time'; // 默认添加时间字段
|
||
protected $updateTime = 'modify_time'; // 默认编辑时间字段
|
||
protected $deleteTime = false; // 软删除字段
|
||
|
||
|
||
/**
|
||
* Common: 设置配置信息
|
||
* Author: wu-hui
|
||
* Time: 2022/10/20 16:05
|
||
* @param $params
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function setConfigInfo($params){
|
||
try{
|
||
$save = self::where('config_key',$params['config_key'])
|
||
->where('app_module',$params['app_module'])
|
||
->find();
|
||
if(!$save){
|
||
$save = new self();
|
||
$save->site_id = $params['site_id'];
|
||
$save->app_module = $params['app_module'];
|
||
$save->config_key = $params['config_key'];
|
||
}
|
||
$save->value = $params['value'];
|
||
$save->config_desc = $params['config_desc'];
|
||
$save->is_use = $params['is_use'];
|
||
|
||
Cache::delete($params['config_key']);
|
||
|
||
return $this->success($save->save());
|
||
}catch(Exception $e){
|
||
return $this->error('',$e->getMessage());
|
||
}
|
||
}
|
||
/**
|
||
* Common: 获取设置
|
||
* Author: wu-hui
|
||
* Time: 2022/10/20 16:32
|
||
* @param String $key
|
||
* @param string $module
|
||
* @return array|mixed
|
||
*/
|
||
public function getConfigInfo(String $key,String $module = 'shop'){
|
||
// 信息获取
|
||
$info = Cache::get($key);
|
||
if(!$info){
|
||
$info = self::where('config_key',$key)
|
||
->where('app_module',$module)
|
||
->value('value');
|
||
if($info) $info = json_decode($info, TRUE);
|
||
$funName = camelize($key).'Default';
|
||
if(method_exists($this,$funName)) $info = (array) $this->$funName($info);
|
||
|
||
Cache::set($key, $info);
|
||
}
|
||
|
||
return $info;
|
||
}
|
||
|
||
|
||
/**
|
||
* Common: 默认设置 —— 个人名片
|
||
* Author: wu-hui
|
||
* Time: 2022/10/20 16:32
|
||
* @param $info
|
||
* @return array
|
||
*/
|
||
public function businessCardSettingDefault($info){
|
||
return [
|
||
'is_examine' => $info['is_examine'] ? : 0,// 是否开启自动审核 0=否,1=是
|
||
'customer_service' => $info['customer_service'] ? : '',// 客服二维码图片
|
||
'agreement' => $info['agreement'] ? : '',// 用户协议
|
||
'nickname' => $info['nickname'] ? : '名片',// 文字替换 —— 名片
|
||
];
|
||
}
|
||
/**
|
||
* Common: 默认设置 —— 文章
|
||
* Author: wu-hui
|
||
* Time: 2022/10/21 15:01
|
||
* @param $info
|
||
* @return array
|
||
*/
|
||
public function articleSettingDefault($info){
|
||
return [
|
||
'banner_list' => $info['banner_list'] ?: [],// 轮播图
|
||
'share' => $info['share'] ?: '分享',// 文字替换 —— 分享
|
||
'integral' => (int)$info['integral'],// 分享文章奖励积分
|
||
'parent_integral' => (int)$info['parent_integral'],// 直推上级奖励积分
|
||
'max_integral' => (int)$info['max_integral'],// 每日积分获取上限
|
||
];
|
||
}
|
||
/**
|
||
* Common: 默认设置 —— 经销商
|
||
* Author: wu-hui
|
||
* Time: 2022/12/06 17:24
|
||
* @param $info
|
||
* @return array
|
||
*/
|
||
public function distributorSettingDefault($info){
|
||
return [
|
||
'switch' => $info['switch'] ?: 0,// 是否开启
|
||
'gradational' => $info['gradational'] ?: 0,// 级差是否开启
|
||
'same_grade' => $info['same_grade'] ?: 0,// 平级奖是否开启
|
||
'same_grade_ratio' => $info['same_grade_ratio'] ?: 0,// 平级奖结算比例
|
||
'settlement_time' => $info['settlement_time'] ?: 0,// 结算时间
|
||
'settlement_day' => $info['settlement_day'] ?: 0,// 结算天数
|
||
];
|
||
}
|
||
/**
|
||
* Common: 默认设置 —— 区域代理
|
||
* Author: wu-hui
|
||
* Time: 2023/02/07 10:52
|
||
* @param $info
|
||
* @return array
|
||
*/
|
||
public function areaBonusSettingDefault($info){
|
||
return [
|
||
'switch' => $info['switch'] ?: 0,// 是否开启
|
||
'province_ratio' => $info['province_ratio'] ?: 0,// 省级提成比例
|
||
'city_ratio' => $info['city_ratio'] ?: 0,// 市级提成比例
|
||
'district_ratio' => $info['district_ratio'] ?: 0,// 区/县提成比例
|
||
'is_averaging' => $info['is_averaging'] ?: 0,// 是否均分
|
||
'settlement_time' => $info['settlement_time'] ?: 0,// 结算时间
|
||
'settlement_day' => $info['settlement_day'] ?: 0,// 结算天数
|
||
];
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
} |