| 
									
										
										
										
											2021-11-25 18:11:50 +08:00
										 |  |  | <?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', | 
					
						
							| 
									
										
										
										
											2021-12-14 17:34:27 +08:00
										 |  |  |         'deduction_money|扣除金额' => 'require|>=:0.1|<:5000', | 
					
						
							| 
									
										
										
										
											2021-11-25 18:11:50 +08:00
										 |  |  |         //'image_url|预览图' => '',
 | 
					
						
							|  |  |  |         //'using_rule|使用规则' => '',
 | 
					
						
							|  |  |  |         //'punishing_rule|处罚规则' => '',
 | 
					
						
							|  |  |  |         //'using_count|使用中' => '',
 | 
					
						
							|  |  |  |         //'received_count|已领取的优惠券数量' => '',
 | 
					
						
							|  |  |  |         //'edition|发布的版本' => '',
 | 
					
						
							|  |  |  |         'status|状态' => 'require|in:1,0', | 
					
						
							|  |  |  |         'on_shelf|上架状态' => 'require|in:1,0', | 
					
						
							|  |  |  |         //'intro|详情' => '',
 | 
					
						
							| 
									
										
										
										
											2021-12-13 15:57:27 +08:00
										 |  |  |         //'white_list|白名单' => '',
 | 
					
						
							| 
									
										
										
										
											2021-11-25 18:11:50 +08:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected $scene = [ | 
					
						
							|  |  |  |         'edit' => ['start_time', 'end_time', 'name',"status","on_shelf"], | 
					
						
							| 
									
										
										
										
											2021-12-13 15:57:27 +08:00
										 |  |  |         'api_edit' => ['name', 'type', 'start_time',"end_time","image_url"], | 
					
						
							| 
									
										
										
										
											2021-11-25 18:11:50 +08:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected function checkEndTime($value, $rule, $data = []) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (strtotime($value) <= strtotime($data['start_time'])) { | 
					
						
							|  |  |  |             return "结束时间不能小于等于开始时间"; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |