| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace hd\models\hb;
- use hd\models\BaseForm;
- /**
- * 充值送红包规则项表单模型
- */
- class SendHbRuleItemForm extends BaseForm
- {
- /** @var int 红包金额 */
- public $hbAmount;
- /** @var int 红包张数 */
- public $hbNum;
- /** @var int 最低消费金额(0 表示不限制) */
- public $miniCost;
- /** @var int 有效天数(0 表示永不过期) */
- public $duration;
- /** @var int 生效类型
- * 1: 日期 2: 天数
- */
- public $effectiveType;
- /** @var string 生效日期 */
- public $effectiveDate;
- /** @var int 生效天数 */
- public $effectiveDays;
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['miniCost', 'duration'], 'default', 'value' => 0],
- [['hbAmount'], 'required', 'message' => '请填写红包金额'],
- // 注意:不要对字段做 intval 过滤,避免 "abc" 被转成 0 导致校验绕过
- [['hbAmount'], 'number', 'min' => 0.01, 'tooSmall' => '{attribute}必须大于等于0.01'],
- [['hbNum', 'miniCost'], 'integer', 'message' => '{attribute}必须为正整数', 'min' => 0, 'tooSmall' => '{attribute}不能小于0'],
- [['duration'], 'integer', 'min' => 0, 'max' => 3650, 'tooSmall' => '{attribute}不能小于0', 'tooBig' => '{attribute}过大'],
- [['effectiveType'], 'in', 'range' => [1, 2]],
- [['effectiveDate'], 'default', 'value' => null],
- [['effectiveDate'], 'filter', 'filter' => function($value) {
- return $value === '0000-00-00' ? null : $value;
- }],
- [['effectiveDate'], 'datetime', 'format' => 'php:Y-m-d'],
- [['effectiveDays'], 'integer', 'min' => 0, 'max' => 365, 'tooSmall' => '{attribute}不能小于0', 'tooBig' => '{attribute}过大'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'hbAmount' => '红包金额',
- 'hbNum' => '红包数量',
- 'miniCost' => '最低消费金额',
- 'duration' => '有效天数',
- 'effectiveType' => '生效类型',
- 'effectiveDate' => '生效日期',
- 'effectiveDays' => '生效天数',
- ];
- }
- }
|