jh-admin/addon/pointcash/model/Config.php

59 lines
1.9 KiB
PHP
Raw Permalink 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
/**
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 成都SAAS云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.gobuysaas.com
* =========================================================
*/
namespace addon\pointcash\model;
use app\model\system\Config as ConfigModel;
use app\model\BaseModel;
/**
* 积分抵现配置
*/
class Config extends BaseModel
{
/**
* 积分抵现设置
* @param $data
* @param $site_id
* @param string $app_module
* @return array
*/
public function setPointCashConfig($data, $site_id, $app_module = 'shop')
{
$config = new ConfigModel();
$res = $config->setConfig($data, '积分抵现', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
return $res;
}
/**
* 获取积分抵现配置
* @param $site_id
* @param string $app_module
* @return array
*/
public function getPointCashConfig($site_id, $app_module = 'shop')
{
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
if (empty($res[ 'data' ][ 'value' ])) {
//默认值设置
$res[ 'data' ][ 'value' ] = [
'is_enable' => 0, // 是否开启
'cash_rate' => 0, // 抵现比率
'is_limit' => 0, // 是否限制订单金额门槛
'limit' => 0.00, // 订单金额门槛
'is_limit_use' => 0, // 是否限制使用上限
'type' => 0, // 限制类型 0固定金额 1订单百分比
'max_use' => 0 // 最大可用
];
}
return $res;
}
}