You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB

<?php
namespace app\modules\mch\models;
use app\models\ScratchSetting;
class ScratchSettingForm extends MchModel
{
public $store_id;
public $model;
public $probability;
public $oppty;
public $type;
public $start_time;
public $end_time;
public $title;
public $rule;
public $deplete_register;
public function rules()
{
return [
[['store_id', 'probability', 'oppty', 'type', 'start_time', 'end_time', 'deplete_register'], 'required'],
[['probability', 'oppty', 'start_time', 'end_time', 'deplete_register'], 'integer','max'=>2000000000],
[['title'], 'string', 'max' => 255],
[['rule'], 'string', 'max' => 1000],
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'store_id' => 'Store ID',
'probability' => '概率',
'oppty' => '抽奖次数',
'type' => '1.天 2 用户',
'start_time' => '开始时间',
'end_time' => '结束时间',
'title' => '小程序标题',
'rule' => '规则说明',
'deplete_register' => '消耗积分',
];
}
public function save()
{
if (!$this->validate()) {
return $this->errorResponse;
}
$this->model->store_id = $this->store_id;
$this->model->type = $this->type;
$this->model->probability = $this->probability;
$this->model->oppty = $this->oppty;
$this->model->rule = $this->rule;
$this->model->start_time = $this->start_time;
$this->model->end_time = $this->end_time;
$this->model->title = $this->title;
$this->model->deplete_register = $this->deplete_register;
if ($this->model->save()) {
return [
'code'=>0,
'msg'=>'保存成功'
];
} else {
return $this->getErrorResponse($this->model);
}
}
}