| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace hd\models\hb;
- use hd\models\BaseForm;
- /**
- * 更新红包表单模型
- *
- * 仅暴露允许更新的字段,避免被恶意修改 shopId/mainId 等敏感字段。
- */
- class UpdateHbForm extends BaseForm
- {
- /** @var int 红包ID */
- public $id;
- /** @var int 红包状态(-1 作废,0 未使用,1 已使用) */
- public $status;
- /** @var float 红包金额 */
- public $amount;
- /** @var float 最低消费金额 */
- public $minConsume;
- /** @var int 生效时间 */
- public $beginTime;
- /** @var int 失效时间 */
- public $endTime;
- /** @var int 预期失效时间 */
- public $willTime;
- /** @var int 有效天数 */
- public $duration;
- /** @var string 备注 */
- public $remark;
- /** @var int 订单ID */
- public $orderId;
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['id'], 'required', 'message' => '红包ID不能为空'],
- [['id'], 'integer', 'min' => 1, 'tooSmall' => '红包ID参数错误'],
- [['status'], 'in', 'range' => [-1, 0, 1], 'message' => '红包状态不正确'],
- [['beginTime', 'endTime', 'willTime'], 'integer', 'min' => 0, 'tooSmall' => '{attribute}必须大于等于0'],
- [['duration'], 'integer', 'min' => 0, 'max' => 3650, 'tooSmall' => '有效天数必须大于等于0', 'tooBig' => '有效天数过大'],
- [['amount'], 'number', 'min' => 0.01, 'tooSmall' => '{attribute}不能小于0.01'],
- [['minConsume'], 'number', 'min' => 0.00, 'tooSmall' => '{attribute}不能小于0'],
- [['remark'], 'default', 'value' => ''],
- [['remark'], 'filter', 'filter' => 'trim'],
- [['remark'], 'string'],
- //[['orderId'], 'default', 'value' => 0],
- [['orderId'], 'integer', 'min' => 1],
- [['orderId'], 'required', 'when' => function ($model) {
- return $model->status == 0;
- }, 'message' => '订单ID不能为空'],
- ];
- }
- /**
- * 获取属性标签
- * @return array
- */
- public function attributeLabels()
- {
- return [
- 'id' => '红包ID',
- 'status' => '红包状态',
- 'amount' => '红包金额',
- 'minConsume' => '最低消费金额',
- 'beginTime' => '生效时间',
- 'endTime' => '失效时间',
- 'willTime' => '预期失效时间',
- 'duration' => '有效天数',
- 'remark' => '备注',
- 'orderId' => '订单ID',
- ];
- }
- }
|