Presell.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 验证器
  10. */
  11. class Presell extends Validate
  12. {
  13. protected $rule = [
  14. 'presell_type' => 'require|in:1,2',
  15. 'goods_id' => 'require',
  16. 'presell_deposit_amount' => 'requireIf:presell_type,2|float',
  17. 'presell_price' => 'require|float|gt:0',
  18. 'presell_start_time' => 'require',
  19. 'presell_end_time' => 'require',
  20. 'presell_shipping_time' => 'requireIf:presell_type,1',
  21. ];
  22. protected $message = [
  23. 'presell_type.require' => '请选择预售类型',
  24. 'presell_type.in' => '预售类型错误',
  25. 'goods_id.require' => '请选择预售商品',
  26. 'presell_deposit_amount.requireIf' => '请填写定金',
  27. 'presell_deposit_amount.float' => '定金错误',
  28. 'presell_price.require' => '请填写预售价',
  29. 'presell_price.float' => '预售价错误',
  30. 'presell_price.gt' => '预售价错误',
  31. 'presell_start_time.require' => '请选择开始时间',
  32. 'presell_end_time.require' => '请选择结束时间',
  33. 'presell_shipping_time.requireIf' => '请选择发货时间',
  34. ];
  35. protected $scene = [
  36. 'presell_add' => ['presell_type', 'goods_id', 'presell_deposit_amount', 'presell_price', 'presell_start_time', 'presell_end_time', 'presell_shipping_time'],
  37. 'presell_edit' => ['presell_deposit_amount', 'presell_price', 'presell_shipping_time'],
  38. ];
  39. }