100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\models;
|
|
|
|
use app\models\Admin;
|
|
use app\models\Option;
|
|
use app\components\Utils;
|
|
|
|
class DistributionSettingEditForm extends AdminModel
|
|
{
|
|
|
|
// public $distributionOneBrokerage; //一级佣金
|
|
// public $distributionTwoBrokerage; //二级佣金
|
|
public $distributionOneGuildDaren; //一级分销公会佣金比例(为公会成员情况)
|
|
public $distributionOnePushUser; //一级分销推广员佣金比例(非公会成员情况)
|
|
public $distributionOneGuildUser; //一级分销公会佣金比例(非公会成员情况)
|
|
|
|
public $distributionPoster; //海报
|
|
public $distributionRuleIntro; //规则
|
|
|
|
public $cx_mch_id;
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['distributionRuleIntro','distributionOneGuildDaren','distributionOnePushUser','distributionOneGuildUser'], 'trim'],
|
|
[['cx_mch_id','distributionPoster'],'required'],
|
|
[['cx_mch_id','distributionOneGuildDaren','distributionOnePushUser','distributionOneGuildUser'], 'integer'],
|
|
[['distributionPoster', 'distributionRuleIntro'], 'string'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
// 'distributionOneBrokerage' => '一级佣金',
|
|
// 'distributionTwoBrokerage' => '二级佣金',
|
|
'distributionOneGuildDaren' => '一级分销公会佣金比例(为公会成员情况)',
|
|
'distributionOnePushUser' => '一级分销推广员佣金比例(非公会成员情况)',
|
|
'distributionOneGuildUser' => '一级分销公会佣金比例(非公会成员情况)',
|
|
'distributionPoster' => '海报',
|
|
'distributionRuleIntro' => '邀请规则介绍',
|
|
];
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
if($this->validate()){
|
|
$attrs = $this->attributes;
|
|
foreach ($attrs as $key => $value){
|
|
if(empty($value))
|
|
continue;
|
|
|
|
$key = Utils::hump2underline($key);
|
|
$key = strtoupper($key);
|
|
if($key == 'DISTRIBUTION_POSTER'){
|
|
if(!is_array($value)){
|
|
$distributionPoster = json_decode($value,true);
|
|
if(count($distributionPoster) > 10){
|
|
return [
|
|
'code' => 1,
|
|
'msg' => '海报图最多上传10张'
|
|
];
|
|
}
|
|
}
|
|
}
|
|
$f = Option::setOption($key, $value, $this->cx_mch_id);
|
|
if(!$f){
|
|
return [
|
|
'code' => 1,
|
|
'msg' => $key . '保存失败'
|
|
];
|
|
}
|
|
}
|
|
return [
|
|
'code' => 0,
|
|
'msg' => '保存成功'
|
|
];
|
|
} else {
|
|
return $this->getModelError();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
} |