Voucher.php 3.3 KB

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