313 lines
12 KiB
PHP
313 lines
12 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
|
|
namespace addon\saas\model;
|
|
|
|
use app\model\system\Config as ConfigModel;
|
|
use app\model\BaseModel;
|
|
use app\model\system\Document;
|
|
|
|
class Config extends BaseModel
|
|
{
|
|
/**
|
|
* 设置
|
|
* array $data
|
|
*/
|
|
public function setConfig($data, $site_id = 1, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '业务设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_FENGXIAO_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
*/
|
|
public function getConfig($site_id = 1, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_FENGXIAO_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
|
|
public function getSupplierConfig($site_id = 0, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SaaSSupplierConfig']]);
|
|
if (empty($res['data']['value'])) {
|
|
$res['data']['value'] = [
|
|
'is_supply' => 0,
|
|
'is_auto_warehousing' => 0,
|
|
'supplier_id' => 0,
|
|
'template_id' => 0
|
|
];
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
public function setSupplierConfig($data, $site_id = 0, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '供应商设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SaaSSupplierConfig']]);
|
|
return $res;
|
|
}
|
|
|
|
/***
|
|
* 基本设置
|
|
* @param $site_id
|
|
* @param $app_module
|
|
* @return array
|
|
*/
|
|
public function getBasicsConfig($site_id = 0, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_BasicsConfig']]);
|
|
$value = [
|
|
'is_point_cash' => 0,
|
|
'point_cash_rate' => 0,
|
|
'point_use_rate' => 0,
|
|
'isisp_year_fee' => 0,
|
|
'store_open' => 0,
|
|
'is_member_settled' => 0,
|
|
'settled_condition' => 0,
|
|
'consume_condition' => 0,
|
|
'consume_money' => 0,
|
|
'consume_count' => 0,
|
|
'is_open' => 0,
|
|
'is_invite' => 0,
|
|
'use_settle_number' => 0,
|
|
'district_money' => 0,
|
|
'goods_ids' => '',
|
|
'settlement_type' => 'month',
|
|
];
|
|
$res['data']['value'] = array_merge($value, $res['data']['value']);
|
|
return $res;
|
|
}
|
|
|
|
public function setBasicsConfig($data, $site_id = 1, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '营运设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_BasicsConfig']]);
|
|
return $res;
|
|
}
|
|
|
|
|
|
/**
|
|
* 设置结算配置
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function setSettlementConfig($data, $is_use, $site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
//分销商结算配置
|
|
$settlement_data = [
|
|
'account_type' => $data['account_type'],//佣金计算方式
|
|
];
|
|
$config->setConfig($settlement_data, '结算配置', $is_use, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'SAAS_WITHDRAW_CONFIG']]);
|
|
//分销商提现配置
|
|
$withdraw_data = [
|
|
'withdraw' => $data['withdraw'],//最低提现额度
|
|
'withdraw_rate' => $data['withdraw_rate'],//佣金提现手续费
|
|
'min_no_fee' => $data['min_no_fee'],//最低免手续费区间
|
|
'max_no_fee' => $data['max_no_fee'],//最高免手续费区间
|
|
'withdraw_status' => $data['withdraw_status'],//提现审核
|
|
'settlement_day' => $data['settlement_day'],//天数
|
|
'withdraw_type' => $data['withdraw_type'],//账户类型 alipay 支付宝 bank 银行卡
|
|
'transfer_type' => $data['transfer_type'],//提现方式
|
|
'max' => $data['max'],//提现方式
|
|
'is_auto_transfer' => $data['is_auto_transfer'], // 是否自动转账 1 手动转账 2 自动转账
|
|
'is_invoice' => $data['is_invoice'], // 是否自动转账 1 手动转账 2 自动转账
|
|
'time_week' => $data['time_week'], //转账提现时间
|
|
'invoice_title' => $data['invoice_title'],//是否索要发票
|
|
'invoice_taxid' => $data['invoice_taxid'],//是否索要发票
|
|
'invoice_service' => $data['invoice_service'],//是否索要发票
|
|
];
|
|
$res = $config->setConfig($withdraw_data, '提现配置', $is_use, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'SAAS_WITHDRAW_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 提现配置
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function getWithdrawConfig($site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'SAAS_WITHDRAW_CONFIG']]);
|
|
if (empty($res['data']['value'])) {
|
|
$res['data']['value'] = [
|
|
'withdraw' => 0,//最低提现额度
|
|
'withdraw_rate' => 0,//佣金提现手续费
|
|
'min_no_fee' => 0,//最低免手续费区间
|
|
'max_no_fee' => 0,//最高免手续费区间
|
|
'withdraw_status' => 1,//提现审核
|
|
'withdraw_type' => 0,//提现方式
|
|
'is_auto_transfer' => 0,
|
|
'is_invoice' => 0,
|
|
'transfer_type' => '',
|
|
'max' => 0
|
|
];
|
|
}
|
|
$value = $res['data']['value'];
|
|
if (!isset($value['transfer_type'])) {
|
|
$value['transfer_type'] = 'balance';
|
|
}
|
|
if (!isset($value['max'])) {
|
|
$value['max'] = 0;
|
|
}
|
|
if (!isset($value['is_auto_transfer'])) {
|
|
$value['is_auto_transfer'] = 0;
|
|
}
|
|
$res['data']['value'] = $value;
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 转账方式
|
|
*/
|
|
public function getTransferType($site_id = 0, $app_module = 'shop')
|
|
{
|
|
$withdraw_model = new ManageWithdraw();
|
|
$transfer_type_list = $withdraw_model->getTransferType($site_id);
|
|
$config = $this->getWithdrawConfig($site_id)["data"]['value'] ?? [];
|
|
$data = [];
|
|
$support_type = explode(",", $config["transfer_type"]);
|
|
foreach ($transfer_type_list as $k => $v) {
|
|
if (in_array($k, $support_type)) {
|
|
$data[$k] = $v;
|
|
}
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
|
|
/**
|
|
* 设置
|
|
* array $data
|
|
*/
|
|
public function setMiniConfig($data, $site_id, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->setConfig($data, '业务设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_MINI_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
*/
|
|
public function getMiniConfig($site_id, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_MINI_CONFIG']]);
|
|
return $res;
|
|
}
|
|
|
|
|
|
/***
|
|
* 设置模版
|
|
* @param $data
|
|
* @param $site_id
|
|
* @param $app_module
|
|
* @return array
|
|
*/
|
|
public function setTemplate($data, $site_id, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$config_data = [
|
|
'goods_title' => $data['goods_title'],//是否显示申请协议
|
|
'use_rule' => $data['use_rule'],//是否显示申请协议
|
|
'goods_images' => $data['goods_images'],//是否显示申请协议
|
|
];
|
|
$res = $config->setConfig($config_data, '模板设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_TEMPLATE']]);
|
|
$document = new Document();
|
|
$document->setDocument($data['goods_title'], $data['goods_content'], [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['document_key', '=', "SAAS_TEMPLATE"]]);
|
|
return $res;
|
|
}
|
|
|
|
/***
|
|
* 获取模版
|
|
* @param $site_id
|
|
* @param $app_module
|
|
* @return array
|
|
*/
|
|
public function getTemplate($site_id, $app_module = 'shop')
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SAAS_TEMPLATE']]);
|
|
$document = new Document();
|
|
$goods_content = $document->getDocument([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['document_key', '=', "SAAS_TEMPLATE"]]);
|
|
if (empty($res['data']['value'])) {
|
|
$res['data']['value'] = [
|
|
'goods_title' => '',//是否显示申请协议
|
|
'goods_images' => '',//是否显示申请协议
|
|
'goods_content' => '',//是否显示申请协议
|
|
'use_rule' => '优惠次卡:在指定的时间内您每次到店出示核销码核销后扣款
|
|
优惠周卡:在您签约日起次周系统自动扣款
|
|
优惠月卡:在您签约日起次月系统自动扣款
|
|
如果您在使用服务期间内取消服务,系统将扣回使用次数所优惠的价
|
|
在您签约后未使用您可以无责任取消',//是否显示申请协议
|
|
];
|
|
} else {
|
|
$res['data']['value']['goods_title'] = $goods_content['data']['title'];
|
|
$res['data']['value']['goods_content'] = $goods_content['data']['content'];
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 设置区域经理提现配置
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function setRegionSettlementConfig($data, $is_use, $site_id)
|
|
{
|
|
|
|
$config = new ConfigModel();
|
|
//分销商结算配置
|
|
$settlement_data = [
|
|
'account_type' => $data[ 'account_type' ],//佣金计算方式
|
|
];
|
|
|
|
$config->setConfig($settlement_data, '区域经理提现配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_SETTLEMENT_CONFIG' ] ]);
|
|
//分销商提现配置
|
|
$withdraw_data = [
|
|
'withdraw_rate' => $data[ 'withdraw_rate' ],//佣金提现手续费
|
|
'withdraw_status' => $data[ 'withdraw_status' ],//提现审核
|
|
'transfer_type' => $data[ 'transfer_type' ],//提现方式
|
|
'max' => $data[ 'max' ],//提现方式
|
|
'min' => $data[ 'min' ],//最低提现额度
|
|
'is_auto_transfer' => $data[ 'is_auto_transfer' ], // 是否自动转账 1 手动转账 2 自动转账
|
|
];
|
|
|
|
$res = $config->setConfig($withdraw_data, '区域经理提现配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'REGION_WITHDRAW_CONFIG' ] ]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 区域经理提现配置
|
|
* @return multitype:string mixed
|
|
*/
|
|
public function getRegionSettlementConfig($site_id)
|
|
{
|
|
$config = new ConfigModel();
|
|
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'REGION_WITHDRAW_CONFIG' ] ]);
|
|
if (empty($res[ 'data' ][ 'value' ])) {
|
|
$res[ 'data' ][ 'value' ] = [
|
|
'account_type' => 0,
|
|
'withdraw_status' => 1,
|
|
];
|
|
}
|
|
return $res;
|
|
}
|
|
}
|