| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\adminapi\validate\coupon;
- use app\common\validate\BaseValidate;
- /**
- * CouponRules验证器
- * Class CouponRulesValidate
- * @package app\adminapi\validate\coupon
- */
- class CouponRulesValidate extends BaseValidate
- {
- /**
- * 设置校验规则
- * @var string[]
- */
- protected $rule = [
- 'id' => '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']);
- }
- }
|