| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace hd\models\hb;
- use hd\models\BaseForm;
- /**
- * 创建红包表单模型
- */
- class CreateHbForm extends BaseForm
- {
- /** @var int */
- public $userId;
- /** @var int */
- public $customId;
- /** @var int */
- public $amount;
- /** @var int */
- public $minConsume;
- /** @var int 有效天数 */
- public $days;
- /** @var int 发放张数 */
- public $count;
- /** @var string 备注 */
- public $remark;
- /** @var string 生效时间 */
- public $effectiveDate;
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['userId'], 'required', 'message' => '请选择用户'],
- [['customId'], 'required', 'message' => '请选择客户'],
- [['amount'], 'required', 'message' => '请填写红包金额'],
- [['minConsume'], 'required', 'message' => '请填写最低消费金额'],
- [['days'], 'default', 'value' => 0],
- [['count'], 'default', 'value' => 1],
- [['remark'], 'default', 'value' => ''],
- // 注意:不要对 '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', 'effectiveDate'], 'string'],
- [['remark'], 'filter', 'filter' => 'trim'],
- ];
- }
- /**
- * 获取属性标签
- * @return array
- */
- public function attributeLabels()
- {
- return [
- 'userId' => '用户ID',
- 'customId' => '客户ID',
- 'amount' => '红包金额',
- 'minConsume' => '最低消费',
- 'days' => '有效时长',
- 'count' => '红包个数',
- 'effectiveDate' => '生效时间',
- 'remark' => '备注信息',
- ];
- }
- }
|