AfterSaleValidate.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\validate;
  20. use app\common\validate\BaseValidate;
  21. /**
  22. * 售后验证器
  23. * Class AfterSaleValidate
  24. * @package app\shopapi\validate
  25. */
  26. class AfterSaleValidate extends BaseValidate
  27. {
  28. protected $rule = [
  29. 'refund_method' => 'require|in:1,2',
  30. 'refund_reason' => 'require',
  31. 'order_goods_id' => 'require',
  32. 'id' => 'require',
  33. 'express_name' => 'require',
  34. 'invoice_no' => 'require',
  35. 'type' => 'require',
  36. 'voucher' => 'array|checkCount',
  37. ];
  38. protected $message = [
  39. 'refund_method.require' => '请选择售后方式',
  40. 'refund_method.in' => '售后方式错误',
  41. 'refund_reason.require' => '请输入退款原因',
  42. 'order_goods_id.require' => '请提供子订单ID',
  43. 'id.require' => '参数缺失',
  44. 'express_name.require' => '请填写快递公司',
  45. 'invoice_no.require' => '请填写物流单号',
  46. 'type.require' => '请选择列表类型',
  47. 'voucher.array' => '凭证须为数组格式',
  48. ];
  49. /**
  50. * @notes 获取子订单商品信息场景
  51. * @return AfterSaleValidate
  52. * @author Tab
  53. * @date 2021/7/31 17:50
  54. */
  55. public function sceneOrderGoodsInfo()
  56. {
  57. return $this->only(['order_goods_id', 'refund_method'])
  58. ->remove('refund_method', 'require');
  59. }
  60. /**
  61. * @notes 申请商品售后场景
  62. * @author Tab
  63. * @date 2021/7/30 19:07
  64. */
  65. public function sceneApply()
  66. {
  67. return $this->only(['refund_method', 'refund_reason', 'order_goods_id', 'voucher']);
  68. }
  69. /**
  70. * @notes 买家取消售后场景
  71. * @return AfterSaleValidate
  72. * @author Tab
  73. * @date 2021/8/3 10:07
  74. */
  75. public function sceneCancel()
  76. {
  77. return $this->only(['id']);
  78. }
  79. /**
  80. * @notes 买家确认退货场景
  81. * @return AfterSaleValidate
  82. * @author Tab
  83. * @date 2021/8/3 11:24
  84. */
  85. public function sceneReturnGoods()
  86. {
  87. return $this->only(['id', 'express_name', 'invoice_no']);
  88. }
  89. /**
  90. * @notes 列表场景
  91. * @return AfterSaleValidate
  92. * @author Tab
  93. * @date 2021/8/10 10:17
  94. */
  95. public function sceneLists()
  96. {
  97. return $this->only(['type']);
  98. }
  99. /**
  100. * @notes 售后详情场景
  101. * @return AfterSaleValidate
  102. * @author Tab
  103. * @date 2021/8/10 15:13
  104. */
  105. public function sceneDetail()
  106. {
  107. return $this->only(['id']);
  108. }
  109. /**
  110. * @notes 凭证数量限制
  111. * @param $voucher
  112. * @return bool|string
  113. * @author Tab
  114. * @date 2021/8/26 10:36
  115. */
  116. public function checkCount($voucher)
  117. {
  118. if (count($voucher) > 3) {
  119. return '最多上传3张凭证';
  120. }
  121. return true;
  122. }
  123. }