StoreCouponValidate.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\merchant;
  12. use think\Validate;
  13. class StoreCouponValidate extends Validate
  14. {
  15. protected $failException = true;
  16. protected $rule = [
  17. 'title|优惠券名称' => 'require|max:32',
  18. 'coupon_price|优惠券面值' => 'require|float|>:0|dime',
  19. 'use_min_price|最低消费金额' => 'require|float',
  20. 'coupon_type|有效期类型' => 'require|in:0,1',
  21. 'coupon_time|有效期限' => 'requireIf:coupon_type,0|integer|>:0',
  22. 'use_start_time|有效期限' => 'requireIf:coupon_type,1|array|>:2',
  23. 'sort|排序' => 'require|integer',
  24. 'status|状态' => 'require|in:0,1',
  25. 'type|优惠券类型' => 'require|in:0,1',
  26. 'product_id|商品' => 'requireIf:type,1|array|>:0',
  27. 'send_type|类型' => 'require|in:0,1,2,3',
  28. 'full_reduction|满赠金额' => 'requireIf:send_type,1|float|>=:0',
  29. 'is_limited|是否限量' => 'require|in:0,1',
  30. 'is_timeout|是否限时' => 'require|in:0,1',
  31. 'range_date|领取时间' => 'requireIf:is_timeout,1|array|length:2',
  32. 'total_count|发布数量' => 'requireIf:is_limited,1|integer|>:0',
  33. ];
  34. protected function dime($value)
  35. {
  36. if (!bcadd($value, 0, 1) == $value)
  37. return '优惠券面值最多1位小数';
  38. return true;
  39. }
  40. }