|
|
@@ -15,10 +15,10 @@ class CreateHbForm extends BaseForm
|
|
|
/** @var int */
|
|
|
public $customId;
|
|
|
|
|
|
- /** @var float */
|
|
|
+ /** @var int */
|
|
|
public $amount;
|
|
|
|
|
|
- /** @var float */
|
|
|
+ /** @var int */
|
|
|
public $minConsume;
|
|
|
|
|
|
/** @var int 有效天数 */
|
|
|
@@ -45,18 +45,31 @@ class CreateHbForm extends BaseForm
|
|
|
[['count'], 'default', 'value' => 1],
|
|
|
[['remark'], 'default', 'value' => ''],
|
|
|
|
|
|
- [['userId', 'customId', 'days', 'count'], 'filter', 'filter' => 'intval'],
|
|
|
- [['amount', 'minConsume'], 'filter', 'filter' => 'floatval'],
|
|
|
+ // 注意:不要对 'userId', 'customId', 'days' 使用 intval 过滤;否则非数字(如 "ggg")会被转成 0,导致校验绕过
|
|
|
+ //[['userId', 'customId', 'days'], 'filter', 'filter' => 'intval'],
|
|
|
+ [['amount', 'minConsume'], 'number', 'min' => 0.01, 'message' => '{attribute}必须大于等于0.01'],
|
|
|
+ [['userId', 'customId'], 'integer', 'min' => 1, 'tooSmall' => '{attribute}参数错误'],
|
|
|
+ [['days'], 'integer', 'min' => 0, 'max' => 3650, 'tooSmall' => '{attribute}必须大于等于0', 'tooBig' => '{attribute}过大'],
|
|
|
+ [['count'], 'integer', 'min' => 1, 'max' => 1000, 'tooSmall' => '{attribute}必须大于等于1', 'tooBig' => '{attribute}过大'],
|
|
|
+ [['remark'], 'string'],
|
|
|
[['remark'], 'filter', 'filter' => 'trim'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
|
|
|
- [['userId', 'customId'], 'integer', 'min' => 1, 'tooSmall' => '参数错误'],
|
|
|
- [['days'], 'integer', 'min' => 1, 'max' => 3650, 'tooSmall' => '有效天数必须大于0', 'tooBig' => '有效天数过大'],
|
|
|
- [['count'], 'integer', 'min' => 1, 'max' => 1000, 'tooSmall' => '发放张数必须大于0', 'tooBig' => '发放张数过大'],
|
|
|
-
|
|
|
- [['amount'], 'number', 'min' => 1, 'tooSmall' => '红包金额必须大于0'],
|
|
|
- [['minConsume'], 'number', 'min' => 0, 'tooSmall' => '最低消费金额不能小于0'],
|
|
|
-
|
|
|
- [['remark'], 'string'],
|
|
|
+ /**
|
|
|
+ * 获取属性标签
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function attributeLabels()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ 'userId' => '用户ID',
|
|
|
+ 'customId' => '客户ID',
|
|
|
+ 'amount' => '红包金额',
|
|
|
+ 'minConsume' => '最低消费',
|
|
|
+ 'days' => '有效时长',
|
|
|
+ 'count' => '红包个数',
|
|
|
+ 'remark' => '备注信息',
|
|
|
];
|
|
|
}
|
|
|
}
|