|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
|
|
|
|
-namespace app\api\validate;
|
|
|
+namespace app\admin\validate;
|
|
|
|
|
|
use think\facade\Db;
|
|
|
use think\Validate;
|
|
@@ -11,134 +11,40 @@ class GoodValidate extends Validate
|
|
|
|
|
|
//验证规则
|
|
|
protected $rule = [
|
|
|
- //基础信息
|
|
|
+ 'good_cover_img|商品封面图' => 'require|max:255|url',
|
|
|
'good_name|商品名称' => 'require|max:255',
|
|
|
- 'tax|税点' => 'require|number|between:0,100',
|
|
|
- 'cat_id|分类ID' => 'require|number|gt:0|checkCatId:',
|
|
|
- 'companyNo|业务公司编码' => 'require|alphaNum|length:18|checkCompanyNo:',
|
|
|
- 'unit_id|单位ID' => 'require|number|gt:0|checkUnitId:',
|
|
|
- 'brand_id|品牌ID' => 'require|number|gt:0|checkBrandId:',
|
|
|
- 'exclusive_id|专属类型' => 'require|number|gt:0|checkExclusiveId:',//is_exclusive
|
|
|
- 'weight|商品重量' => 'require|float|max:999999999999.999',
|
|
|
- 'good_type|类型' => 'require|in:1,2',//1定制,2常规
|
|
|
- 'moq|定制起订量' => 'requireIf:good_type,1|number|gt:0|elt:999999999',
|
|
|
- 'customized|定制工期' => 'requireIf:good_type,1|number|gt:0|elt:999999999',
|
|
|
- 'after_sales|售后说明' => 'require|max:20000',
|
|
|
- 'good_remark|商品备注' => 'require|max:20000',
|
|
|
- 'craft_desc|工艺说明' => 'max:20000',
|
|
|
-
|
|
|
- //包装信息
|
|
|
- 'packing_way|包装方式' => 'require|max:255',
|
|
|
- 'packing_spec|装箱规格' => 'require|max:255',
|
|
|
- 'packing_weight|装箱重量' => 'require|float|max:9999999999999.99',
|
|
|
- 'packing_size|装箱尺寸' => 'require|max:255',
|
|
|
- 'good_size|商品尺寸' => 'require|max:255',
|
|
|
- 'good_bar|商品条形码' => 'max:255',
|
|
|
- 'packing_list|包装清单' => 'require|max:255',
|
|
|
-
|
|
|
- //规格信息
|
|
|
- 'speclist|规格列表' => 'require|array|max:100',//[{"id":"","spec_id":"60","spec_value_id":"17","is_del":"0"}]
|
|
|
-
|
|
|
- //发货信息
|
|
|
- 'delivery_place|发货地' => 'require|array|length:3',//130000,130300,130304
|
|
|
- 'supply_area|供货区域' => 'require|number|in:1,2',
|
|
|
- 'delivery_day|物流时间' => 'require|number|max:999999999',
|
|
|
- 'origin_place|产地' => 'require|array|length:3',//130000,130300,130304
|
|
|
- 'lead_time|供货周期' => 'number|max:999999999',
|
|
|
- 'sample_day|调样周期' => 'number|max:999999999',
|
|
|
-
|
|
|
- //图片信息
|
|
|
- 'good_thumb_img|商品缩略图' => 'require|max:255|url',
|
|
|
- 'good_img|商品主图' => 'require|array|length:3,10',
|
|
|
- 'good_info_img|详情介绍' => 'require|array|max:10',
|
|
|
-
|
|
|
- //固定与阶梯成本
|
|
|
- 'demo_fee|打样费' => 'require|float|max:99999999.99',
|
|
|
- 'open_fee|开模费' => 'require|float|max:99999999.99',
|
|
|
- 'sample_fee|调样费' => 'require|number|float|max:99999999.99',
|
|
|
- 'market_price|市场价' => 'require|number|float|max:99999999.99',
|
|
|
- 'good_ladder|阶梯列表' => 'require|array|max:100',//[{"id":"","min_num":"20","nake_fee":"21","cost_fee":"22","delivery_fee":"23","cert_fee":"24","mark_fee":"25","package_fee":"26","other_fee":"27","is_del":"0"}]
|
|
|
-
|
|
|
- //其他场景下的规则
|
|
|
- 'page|页码' => 'require|number|gt:0',
|
|
|
- 'size|每页数量' => 'require|number|gt:0|elt:100',
|
|
|
- 'spuCode|商品编码' => 'require|alphaNum|length:19',
|
|
|
- 'start|开始时间' => 'date',
|
|
|
- 'end|结束时间' => 'date',
|
|
|
+ 'moq|销售起订量' => 'require|number|min:1|max:999999999',
|
|
|
+ 'step|销售步长' => 'require|number|min:1|max:999999999',
|
|
|
+ 'good_banner_img|商品轮播图' => 'require|array|min:1|max:100',
|
|
|
+ 'good_img|商品详情图' => 'require|array|min:1|max:100',
|
|
|
+ 'good_param|商品参数' => 'require|array|min:1|max:100',
|
|
|
+ 'unit_id|单位id' => 'require|number|gt:0',
|
|
|
+ 'good_remark|商品备注' => 'require|max:255',
|
|
|
];
|
|
|
|
|
|
//创建商品
|
|
|
- public function sceneCreateGood()
|
|
|
+ public function sceneAdd()
|
|
|
{
|
|
|
return $this
|
|
|
->only([
|
|
|
- 'good_name',//商品名称
|
|
|
- 'tax',//税点
|
|
|
- 'cat_id',//分类ID
|
|
|
- 'companyNo',//业务公司编码
|
|
|
- 'unit_id',//单位ID
|
|
|
- 'brand_id',//品牌ID
|
|
|
- 'exclusive_id',//专属类型
|
|
|
- 'weight',//商品重量
|
|
|
- 'good_type',//类型
|
|
|
- 'moq',//定制起订量
|
|
|
- 'customized',//定制工期
|
|
|
- 'after_sales',//售后说明
|
|
|
- 'good_remark',//商品备注
|
|
|
- 'craft_desc',//工艺说明
|
|
|
- 'packing_way',//包装方式
|
|
|
- 'packing_spec',//装箱规格
|
|
|
- 'packing_weight',//装箱重量
|
|
|
- 'packing_size',//装箱尺寸
|
|
|
- 'good_size',//商品尺寸
|
|
|
- 'good_bar',//商品条形码
|
|
|
- 'packing_list',//包装清单
|
|
|
- 'speclist',//规格列表
|
|
|
- 'delivery_place',//发货地
|
|
|
- 'supply_area',//供货区域
|
|
|
- 'delivery_day',//物流时间
|
|
|
- 'origin_place',//产地
|
|
|
- 'lead_time',//供货周期
|
|
|
- 'sample_day',//调样周期
|
|
|
- 'good_thumb_img',//商品缩略图
|
|
|
- 'good_img',//商品主图
|
|
|
- 'good_info_img',//详情介绍
|
|
|
- 'demo_fee',//打样费
|
|
|
- 'open_fee',//开模费
|
|
|
- 'sample_fee',//调样费
|
|
|
- 'market_price',//市场价
|
|
|
- 'good_ladder',//阶梯列表
|
|
|
- ])
|
|
|
- ->remove('page', true)//true,移除所有规则
|
|
|
- ->remove('size', true)
|
|
|
- ->remove('spuCode', true)
|
|
|
- ->remove('start', true)
|
|
|
- ->remove('end', true);
|
|
|
+ 'good_cover_img',
|
|
|
+ 'good_name',
|
|
|
+ 'moq',
|
|
|
+ 'step',
|
|
|
+ 'good_banner_img',
|
|
|
+ 'good_img',
|
|
|
+ 'good_param',
|
|
|
+ 'unit_id',
|
|
|
+ 'good_remark',
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
- //查询商品
|
|
|
- public function sceneSelectGood()
|
|
|
- {
|
|
|
|
|
|
- return $this->only(['page', 'size', 'good_name', 'spuCode', 'cat_id', 'brand_id', 'start', 'end'])
|
|
|
- ->remove('good_name', ['require'])
|
|
|
- ->remove('spuCode', ['require', 'length'])
|
|
|
- ->remove('cat_id', ['require'])
|
|
|
- ->remove('brand_id', ['require']);
|
|
|
- }
|
|
|
|
|
|
- //修改商品基础信息
|
|
|
- public function sceneUpdateGoodBasicsInfo()
|
|
|
+ //修改商品信息
|
|
|
+ public function sceneEdit()
|
|
|
{
|
|
|
- return $this
|
|
|
- ->only(['spuCode', 'good_name', 'tax', 'cat_id', 'companyNo', 'unit_id', 'brand_id', 'exclusive_id', 'weight', 'good_type', 'moq', 'customized', 'after_sales', 'good_remark', 'craft_desc', 'packing_way', 'packing_spec', 'packing_weight', 'packing_size', 'good_size', 'good_bar', 'packing_list', 'speclist', 'delivery_place', 'delivery_day', 'origin_place', 'lead_time', 'sample_day', 'good_thumb_img', 'good_img', 'good_info_img', 'supply_area'])
|
|
|
- ->remove('brand_id', ['require'])
|
|
|
- ->remove('good_size', ['require'])
|
|
|
- ->remove('good_bar', ['require'])
|
|
|
- ->remove('speclist', ['require'])
|
|
|
- ->remove('lead_time', ['require'])
|
|
|
- ->remove('sample_day', ['require']);
|
|
|
-
|
|
|
+ return $this->append('id|主键', 'require|number|gt:0');
|
|
|
}
|
|
|
|
|
|
//修改商品价格信息
|