|
@@ -0,0 +1,88 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | likeshop100%开源免费商用商城系统
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
+// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
+// | 商业版本务必购买商业授权,以免引起法律纠纷
|
|
|
|
|
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
|
|
|
|
+// | gitee下载:https://gitee.com/likeshop_gitee
|
|
|
|
|
+// | github下载:https://github.com/likeshop-github
|
|
|
|
|
+// | 访问官网:https://www.likeshop.cn
|
|
|
|
|
+// | 访问社区:https://home.likeshop.cn
|
|
|
|
|
+// | 访问手册:http://doc.likeshop.cn
|
|
|
|
|
+// | 微信公众号:likeshop技术社区
|
|
|
|
|
+// | likeshop团队 版权所有 拥有最终解释权
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | author: likeshopTeam
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+namespace app\adminapi\validate\goods;
|
|
|
|
|
+
|
|
|
|
|
+use app\common\validate\BaseValidate;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 商品规格价格验证器
|
|
|
|
|
+ * Class GoodsSpecPriceValidate
|
|
|
|
|
+ * @package app\adminapi\validate\goods
|
|
|
|
|
+ */
|
|
|
|
|
+class GoodsSpecPriceValidate extends BaseValidate
|
|
|
|
|
+{
|
|
|
|
|
+ protected $rule = [
|
|
|
|
|
+ 'file' => 'require|file|fileExt:xlsx,xls',
|
|
|
|
|
+ 'goods_id' => 'require|integer|gt:0',
|
|
|
|
|
+ 'item_id' => 'require|integer|gt:0',
|
|
|
|
|
+ 'sell_price' => 'float|egt:0',
|
|
|
|
|
+ 'lineation_price' => 'float|egt:0',
|
|
|
|
|
+ 'cost_price' => 'float|egt:0',
|
|
|
|
|
+ 'stock' => 'integer|egt:0',
|
|
|
|
|
+ 'weight' => 'float|egt:0',
|
|
|
|
|
+ 'volume' => 'float|egt:0',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ protected $message = [
|
|
|
|
|
+ 'file.require' => '请上传导入文件',
|
|
|
|
|
+ 'file.file' => '上传的文件格式不正确',
|
|
|
|
|
+ 'file.fileExt' => '只支持xlsx和xls格式的Excel文件',
|
|
|
|
|
+ 'goods_id.require' => '商品ID不能为空',
|
|
|
|
|
+ 'goods_id.integer' => '商品ID必须为整数',
|
|
|
|
|
+ 'goods_id.gt' => '商品ID必须大于0',
|
|
|
|
|
+ 'item_id.require' => '规格ID不能为空',
|
|
|
|
|
+ 'item_id.integer' => '规格ID必须为整数',
|
|
|
|
|
+ 'item_id.gt' => '规格ID必须大于0',
|
|
|
|
|
+ 'sell_price.float' => '销售价格必须为数字',
|
|
|
|
|
+ 'sell_price.egt' => '销售价格不能小于0',
|
|
|
|
|
+ 'lineation_price.float' => '划线价格必须为数字',
|
|
|
|
|
+ 'lineation_price.egt' => '划线价格不能小于0',
|
|
|
|
|
+ 'cost_price.float' => '成本价格必须为数字',
|
|
|
|
|
+ 'cost_price.egt' => '成本价格不能小于0',
|
|
|
|
|
+ 'stock.integer' => '库存数量必须为整数',
|
|
|
|
|
+ 'stock.egt' => '库存数量不能小于0',
|
|
|
|
|
+ 'weight.float' => '重量必须为数字',
|
|
|
|
|
+ 'weight.egt' => '重量不能小于0',
|
|
|
|
|
+ 'volume.float' => '体积必须为数字',
|
|
|
|
|
+ 'volume.egt' => '体积不能小于0',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @notes 导入场景
|
|
|
|
|
+ * @return GoodsSpecPriceValidate
|
|
|
|
|
+ * @author
|
|
|
|
|
+ * @date 2024/01/01 00:00
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sceneImport()
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->only(['file']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @notes 单条数据验证场景
|
|
|
|
|
+ * @return GoodsSpecPriceValidate
|
|
|
|
|
+ * @author
|
|
|
|
|
+ * @date 2024/01/01 00:00
|
|
|
|
|
+ */
|
|
|
|
|
+ public function sceneItem()
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->only(['goods_id', 'item_id', 'sell_price', 'lineation_price', 'cost_price', 'stock', 'weight', 'volume']);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|