Voucher.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 验证器
  13. */
  14. class Voucher extends Validate
  15. {
  16. protected $rule = [
  17. 'promotion_voucher_price' => 'require|number',
  18. 'promotion_voucher_storetimes_limit' => 'require|number',
  19. 'promotion_voucher_buyertimes_limit' => 'require|number|elt:100',
  20. 'voucher_price' => 'require',
  21. 'voucher_price_describe' => 'require',
  22. 'voucher_points' => 'require',
  23. 'vouchertemplate_title' => 'require|length:1,50',
  24. 'vouchertemplate_total' => 'require|number',
  25. 'vouchertemplate_price' => 'require|number',
  26. 'vouchertemplate_limit' => 'require',
  27. 'vouchertemplate_desc' => 'require|length:1,255'
  28. ];
  29. protected $message = [
  30. 'promotion_voucher_price.require' => '购买单价应为大于0的整数',
  31. 'promotion_voucher_price.number' => '购买单价应为大于0的整数',
  32. 'promotion_voucher_storetimes_limit.require' => '每月活动数量应为大于0的整数',
  33. 'promotion_voucher_storetimes_limit.number' => '每月活动数量应为大于0的整数',
  34. 'promotion_voucher_buyertimes_limit.require' => '最大领取数量应为大于0小于100的整数',
  35. 'promotion_voucher_buyertimes_limit.number' => '最大领取数量应为大于0小于100的整数',
  36. 'promotion_voucher_buyertimes_limit.elt' => '最大领取数量应为大于0小于100的整数',
  37. 'voucher_price.require' => '代金券面额应为大于0的整数',
  38. 'voucher_price_describe.require' => '描述不能为空',
  39. 'voucher_points.require' => '默认兑换积分数应为大于0的整数',
  40. 'vouchertemplate_title.require' => '模版名称不能为空且不能大于50个字符',
  41. 'vouchertemplate_title.length' => '模版名称不能为空且不能大于50个字符',
  42. 'vouchertemplate_total.require' => '可发放数量不能为空且必须为整数',
  43. 'vouchertemplate_total.number' => '可发放数量不能为空且必须为整数',
  44. 'vouchertemplate_price.require' => '模版面额不能为空且必须为整数,且面额不能大于限额',
  45. 'vouchertemplate_price.number' => '模版面额不能为空且必须为整数,且面额不能大于限额',
  46. 'vouchertemplate_limit.require' => '模版使用消费限额不能为空且必须是数字',
  47. 'vouchertemplate_desc.require' => '模版描述不能为空且不能大于255个字符',
  48. 'vouchertemplate_desc.length' => '模版描述不能为空且不能大于255个字符'
  49. ];
  50. protected $scene = [
  51. 'setting' => ['promotion_voucher_price', 'promotion_voucher_storetimes_limit', 'promotion_voucher_buyertimes_limit'],
  52. 'priceadd' => ['voucher_price', 'voucher_price_describe', 'voucher_points'],
  53. 'priceedit' => ['voucher_price', 'voucher_price_describe', 'voucher_points'],
  54. 'templateadd' => ['vouchertemplate_title', 'vouchertemplate_total', 'vouchertemplate_price', 'vouchertemplate_limit', 'vouchertemplate_desc'],
  55. 'templateedit' => ['vouchertemplate_title', 'vouchertemplate_total', 'vouchertemplate_price', 'vouchertemplate_limit', 'vouchertemplate_desc'],
  56. ];
  57. }