GoodsSpecPriceValidate.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\goods;
  20. use app\common\validate\BaseValidate;
  21. /**
  22. * 商品规格价格验证器
  23. * Class GoodsSpecPriceValidate
  24. * @package app\adminapi\validate\goods
  25. */
  26. class GoodsSpecPriceValidate extends BaseValidate
  27. {
  28. protected $rule = [
  29. 'file' => 'require|file|fileExt:xlsx,xls',
  30. 'goods_id' => 'require|integer|gt:0',
  31. 'item_id' => 'require|integer|gt:0',
  32. 'sell_price' => 'float|egt:0',
  33. 'lineation_price' => 'float|egt:0',
  34. 'cost_price' => 'float|egt:0',
  35. 'stock' => 'integer|egt:0',
  36. 'weight' => 'float|egt:0',
  37. 'volume' => 'float|egt:0',
  38. ];
  39. protected $message = [
  40. 'file.require' => '请上传导入文件',
  41. 'file.file' => '上传的文件格式不正确',
  42. 'file.fileExt' => '只支持xlsx和xls格式的Excel文件',
  43. 'goods_id.require' => '商品ID不能为空',
  44. 'goods_id.integer' => '商品ID必须为整数',
  45. 'goods_id.gt' => '商品ID必须大于0',
  46. 'item_id.require' => '规格ID不能为空',
  47. 'item_id.integer' => '规格ID必须为整数',
  48. 'item_id.gt' => '规格ID必须大于0',
  49. 'sell_price.float' => '销售价格必须为数字',
  50. 'sell_price.egt' => '销售价格不能小于0',
  51. 'lineation_price.float' => '划线价格必须为数字',
  52. 'lineation_price.egt' => '划线价格不能小于0',
  53. 'cost_price.float' => '成本价格必须为数字',
  54. 'cost_price.egt' => '成本价格不能小于0',
  55. 'stock.integer' => '库存数量必须为整数',
  56. 'stock.egt' => '库存数量不能小于0',
  57. 'weight.float' => '重量必须为数字',
  58. 'weight.egt' => '重量不能小于0',
  59. 'volume.float' => '体积必须为数字',
  60. 'volume.egt' => '体积不能小于0',
  61. ];
  62. /**
  63. * @notes 导入场景
  64. * @return GoodsSpecPriceValidate
  65. * @author
  66. * @date 2024/01/01 00:00
  67. */
  68. public function sceneImport()
  69. {
  70. return $this->only(['file']);
  71. }
  72. /**
  73. * @notes 单条数据验证场景
  74. * @return GoodsSpecPriceValidate
  75. * @author
  76. * @date 2024/01/01 00:00
  77. */
  78. public function sceneItem()
  79. {
  80. return $this->only(['goods_id', 'item_id', 'sell_price', 'lineation_price', 'cost_price', 'stock', 'weight', 'volume']);
  81. }
  82. }