hy-farm/muchang/backend/models/ConfigComm.php
2026-05-29 19:54:56 +08:00

89 lines
2.7 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: zn
* Date: 2017/6/19
* Time: 18:49
*/
namespace app\models;
use common\services\GameConfigServices;
use yii\base\Model;
/**
* 通用配置表设置
*
*/
class ConfigComm extends Model
{
//分销返点
public $rebate_1;
public $rebate_2;
public $rebate_3;
//交易提成
public $draw_percentage;
public function rules()
{
return [
['rebate_1', 'default', 'value' => 0],
['rebate_1', 'number', 'integerOnly' => true, 'min' => 0, 'max' => 100],
['rebate_2', 'default', 'value' => 0],
['rebate_2', 'number', 'integerOnly' => true, 'min' => 0, 'max' => 100],
['rebate_3', 'default', 'value' => 0],
['rebate_3', 'number', 'integerOnly' => true, 'min' => 0, 'max' => 100],
['draw_percentage', 'default', 'value' => 0],
['draw_percentage', 'number', 'integerOnly' => true, 'min' => 0, 'max' => 100],
];
}
public static function findByConfig()
{
$data = new ConfigComm();
$data->rebate_1 = GameConfigServices::getCommonNumByID(GameConfigServices::COMMON_REBATE_1);
$data->rebate_2 = GameConfigServices::getCommonNumByID(GameConfigServices::COMMON_REBATE_2);
$data->rebate_3 = GameConfigServices::getCommonNumByID(GameConfigServices::COMMON_REBATE_3);
$data->draw_percentage = GameConfigServices::getCommonNumByID(GameConfigServices::COMMON_DRAW_PERCENTAGE);
return $data;
}
public function saveConfig()
{
$config = GameConfigServices::getGameConfig();
$config['common'][GameConfigServices::COMMON_REBATE_1]['min'] = $this->rebate_1;
$config['common'][GameConfigServices::COMMON_REBATE_1]['max'] = $this->rebate_1;
$config['common'][GameConfigServices::COMMON_REBATE_2]['min'] = $this->rebate_2;
$config['common'][GameConfigServices::COMMON_REBATE_2]['max'] = $this->rebate_2;
$config['common'][GameConfigServices::COMMON_REBATE_3]['min'] = $this->rebate_3;
$config['common'][GameConfigServices::COMMON_REBATE_3]['max'] = $this->rebate_3;
$config['common'][GameConfigServices::COMMON_DRAW_PERCENTAGE]['min'] = $this->draw_percentage;
$config['common'][GameConfigServices::COMMON_DRAW_PERCENTAGE]['max'] = $this->draw_percentage;
return GameConfigServices::saveGameConfig($config);
}
public function attributeLabels()
{
return [
'rebate_1' => '1级分销返点',
'rebate_2' => '2级分销返点',
'rebate_3' => '3级分销返点',
'draw_percentage' => '赠送交易抽成',
];
}
}