Point.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 验证器
  14. */
  15. class Point extends Validate
  16. {
  17. protected $rule = [
  18. 'member_name'=>'require',
  19. 'points_num'=>'number|min:1',
  20. 'goodsname'=>'require',
  21. 'goodsprice'=>'require',
  22. 'goodspoints'=>'require|number',
  23. 'goodsserial'=>'require',
  24. 'goodsstorage'=>'require|number',
  25. 'sort'=>'require|number',
  26. 'limitnum'=>'checkPointLimitnum:1',
  27. 'starttime'=>'checkPointStartTime:1',
  28. 'endtime'=>'checkPointEndTime:1',
  29. 'shippingcode'=>'require'
  30. ];
  31. protected $message = [
  32. 'member_name.require'=>'会员信息错误,请重新填写会员名',
  33. 'points_num.number'=>'积分值必须为数字',
  34. 'points_num.min'=>'积分值必须大于0',
  35. 'goodsname.require'=>'请添加礼品名称',
  36. 'goodsprice.require'=>'礼品原价必须为数字且大于等于0',
  37. 'goodspoints.require'=>'兑换积分为整数且大于等于0',
  38. 'goodspoints.number'=>'兑换积分为整数且大于等于0',
  39. 'goodsserial.require'=>'请添加礼品编号',
  40. 'goodsstorage.require'=>'礼品库存必须为整数且大于等于0',
  41. 'goodsstorage.number'=>'礼品库存必须为整数且大于等于0',
  42. 'sort.require'=>'礼品排序为整数且大于等于0',
  43. 'sort.number'=>'礼品排序为整数且大于等于0',
  44. 'limitnum.checkPointLimitnum'=>'礼品排序为整数且大于等于0',
  45. 'starttime.checkPointStartTime'=>'请添加开始时间',
  46. 'endtime.checkPointEndTime'=>'请添加结束时间',
  47. 'shippingcode.require'=>'请添加物流单号'
  48. ];
  49. protected $scene = [
  50. 'pointslog' => ['member_name', 'points_num'],
  51. 'prod_add' => ['goodsname', 'goodsprice', 'goodspoints', 'goodsserial', 'goodsstorage', 'sort', 'limitnum', 'starttime', 'endtime'],
  52. 'prod_edit' => ['goodsname', 'goodsprice', 'goodspoints', 'goodsserial', 'goodsstorage', 'sort', 'limitnum', 'starttime', 'endtime'],
  53. 'order_ship' => ['shippingcode'],
  54. ];
  55. protected function checkPointLimitnum($value)
  56. {
  57. if (input('post.sort') == 1 && !is_numeric($value)) {
  58. return '礼品排序为整数且大于等于0';
  59. }
  60. return true;
  61. }
  62. protected function checkPointStartTime($value)
  63. {
  64. if (input('post.islimittime')) {
  65. if (empty($value)) {
  66. return '请添加开始时间';
  67. }
  68. }
  69. return true;
  70. }
  71. protected function checkPointEndTime($value)
  72. {
  73. if (input('post.islimittime')) {
  74. if (empty($value)) {
  75. return '请添加结束时间';
  76. }
  77. }
  78. return true;
  79. }
  80. }