DistributionGoodsValidate.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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\adminapi\validate\distribution;
  20. use app\common\validate\BaseValidate;
  21. /**
  22. * 分销商品验证器
  23. * Class DistributionGoodsValidate
  24. * @package app\adminapi\validate\distribution
  25. */
  26. class DistributionGoodsValidate extends BaseValidate
  27. {
  28. protected $rule = [
  29. 'goods_id' => 'require',
  30. 'is_distribution' => 'require|in:0,1',
  31. 'rule' => 'require|in:1,2',
  32. 'ratio_data' => 'requireIf:rule,2|array',
  33. 'ids' => 'require|array',
  34. 'id' => 'require',
  35. ];
  36. protected $message = [
  37. 'goods_id.require' => '商品id不存在',
  38. 'is_distribution.require' => '分销状态不能为空',
  39. 'is_distribution.in' => '分销状态值错误',
  40. 'rule.require' => '请选择佣金规则',
  41. 'rule.in' => '佣金规则值错误',
  42. 'ratio_data.requireIf' => '分佣比例数据不存在',
  43. 'ids.require' => '商品id不能为空',
  44. 'ids.array' => '商品id数据格式不正确',
  45. 'id.require' => '参数缺失',
  46. ];
  47. /**
  48. * @notes 设置佣金场景
  49. * @return DistributionGoodsValidate
  50. * @author Tab
  51. * @date 2021/7/23 16:42
  52. */
  53. public function sceneSet()
  54. {
  55. return $this->only(['goods_id', 'is_distribution', 'rule', 'ratio_data']);
  56. }
  57. /**
  58. * @notes 参与/不参与分销的场景
  59. * @return DistributionGoodsValidate
  60. * @author Tab
  61. * @date 2021/7/23 17:36
  62. */
  63. public function sceneJoin()
  64. {
  65. return $this->only(['ids', 'is_distribution']);
  66. }
  67. /**
  68. * @notes 获取分销商品详情场景
  69. * @return DistributionGoodsValidate
  70. * @author Tab
  71. * @date 2021/7/23 18:18
  72. */
  73. public function sceneDetail()
  74. {
  75. return $this->only(['id']);
  76. }
  77. }