47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
| <?php
 | |
| 
 | |
| namespace app\validate;
 | |
| 
 | |
| use think\Validate;
 | |
| 
 | |
| class CouponRelease extends Validate
 | |
| {
 | |
|     protected $rule = [
 | |
|         'business_code|商家code' => 'require',
 | |
|         //'lng|经度' => 'require',
 | |
|         //'lat|纬度' => 'require',
 | |
|         'count|总数' => 'require|number|>:0',
 | |
|         'type|优惠券类型' => 'require',
 | |
|         'start_time|开始时间' => 'require|date',
 | |
|         'end_time|结束时间' => 'require|date|checkEndTime',
 | |
|         'name|优惠券名称' => 'require|length:3,32',
 | |
|         'money|金额' => 'require|>:0|<:5000',
 | |
|         'deduction_money|扣除金额' => 'require|>=:0.1|<:5000',
 | |
|         //'image_url|预览图' => '',
 | |
|         //'using_rule|使用规则' => '',
 | |
|         //'punishing_rule|处罚规则' => '',
 | |
|         //'using_count|使用中' => '',
 | |
|         //'received_count|已领取的优惠券数量' => '',
 | |
|         //'edition|发布的版本' => '',
 | |
|         'status|状态' => 'require|in:1,0',
 | |
|         'on_shelf|上架状态' => 'require|in:1,0',
 | |
|         //'intro|详情' => '',
 | |
|         //'white_list|白名单' => '',
 | |
|     ];
 | |
| 
 | |
| 
 | |
|     protected $scene = [
 | |
|         'edit' => ['start_time', 'end_time', 'name',"status","on_shelf"],
 | |
|         'api_edit' => ['name', 'type', 'start_time',"end_time","image_url"],
 | |
|     ];
 | |
| 
 | |
|     protected function checkEndTime($value, $rule, $data = [])
 | |
|     {
 | |
|         if (strtotime($value) <= strtotime($data['start_time'])) {
 | |
|             return "结束时间不能小于等于开始时间";
 | |
|         }
 | |
|         return true;
 | |
| 
 | |
|     }
 | |
| 
 | |
| } |