cxfoot/models/common/CommonRechargeRuleEditForm.php
2023-10-24 14:54:18 +08:00

66 lines
1.4 KiB
PHP

<?php
/**
* @author Any
* @description KISS
* @date 2021年9月30日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\models\common;
use app\models\RechargeRule;
use app\models\Model;
use yii\data\Pagination;
class CommonRechargeRuleEditForm extends Model
{
public $name;
public $pay_price;
public $send_price;
public $cx_mch_id;
public $model;
public function rules()
{
return [
[['name'], 'trim'],
[['name'], 'string'],
[['pay_price', 'send_price'], 'number'],
[['model'], 'safe'],
[['pay_price', 'send_price', 'name', 'model', 'cx_mch_id'], 'required'],
];
}
public function attributeLabels()
{
return [
'cx_mch_id' => '平台商户ID',
'name' => '方案名称',
'pay_price' => '支付金额',
'send_price' => '赠送金额',
];
}
public function save()
{
if(!$this->validate()){
return $this->getModelError();
}
if($this->model->isNewRecord){
$this->model->cx_mch_id = $this->cx_mch_id;
}
$this->model->attributes = $this->attributes;
if(!$this->model->save()){
return $this->getModelError($this->model);
}
return $this->apiReturnSuccess('保存成功');
}
}