'require', 'amount_require' => 'require', 'event_name' => 'require', 'expire_time' => 'require', 'goods_category_ids' => 'require', 'mold_type' => 'require|checkMoldType', 'voucher_count' => 'require', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'amount_require' => '满减金额', 'event_name' => '优惠卷名称', 'expire_time' => '到期时间', 'mold_type' => '折扣方式', 'voucher_count' => '优惠卷数量', 'goods_category_ids' => '服务类目不能为空', ]; public function checkMoldType($moldType, $rule, $data) { if ($moldType == 1) { if (!isset($data['discount_ratio']) || empty($data['discount_ratio'])) { return '请输入折扣'; } if($data['discount_ratio'] <0 || $data['discount_ratio'] > 10){ return '折扣在0~10之间'; } } else if($moldType ==2){ if(!isset($data['amount']) || empty($data['amount'])){ return '请输入折扣金额'; } } return true; } /** * @notes 添加场景 * @return CouponRulesValidate * @author likeadmin * @date 2024/07/18 10:11 */ public function sceneAdd() { return $this->only(['amount_require','event_name','expire_time','mold_type','voucher_count']); } /** * @notes 编辑场景 * @return CouponRulesValidate * @author likeadmin * @date 2024/07/18 10:11 */ public function sceneEdit() { return $this->only(['id','amount_require','event_name','expire_time','mold_type','voucher_count']); } /** * @notes 删除场景 * @return CouponRulesValidate * @author likeadmin * @date 2024/07/18 10:11 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return CouponRulesValidate * @author likeadmin * @date 2024/07/18 10:11 */ public function sceneDetail() { return $this->only(['id']); } }