| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\model; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use think\Collection; | 
					
						
							|  |  |  | use think\db\exception\DataNotFoundException; | 
					
						
							|  |  |  | use think\db\exception\DbException; | 
					
						
							|  |  |  | use think\db\exception\ModelNotFoundException; | 
					
						
							| 
									
										
										
										
											2021-11-30 15:26:38 +08:00
										 |  |  | use think\Model; | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2022-03-31 14:42:56 +08:00
										 |  |  |  * 签到券主表 | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  |  * Class CouponMain | 
					
						
							|  |  |  |  * @package app\model | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class CouponMain extends Base | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |         const status_on     = 0;//进行中
 | 
					
						
							|  |  |  |         const status_off    = 1;//停止
 | 
					
						
							|  |  |  |         const on_shelf_on   = 0;//上架状态
 | 
					
						
							|  |  |  |         const on_shelf_off  = 1;//下架状态
 | 
					
						
							| 
									
										
										
										
											2021-11-24 14:41:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-20 13:56:21 +08:00
										 |  |  |         const on_screen_yes = 1;//展示到商圈大屏
 | 
					
						
							| 
									
										
										
										
											2022-02-08 14:32:23 +08:00
										 |  |  |         const on_screen_no  = 0;//不展示到商圈大屏
 | 
					
						
							| 
									
										
										
										
											2022-02-08 14:37:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-15 14:10:36 +08:00
										 |  |  |         const min_redpack_money  = 0.3;//
 | 
					
						
							| 
									
										
										
										
											2022-02-25 18:17:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const receive_status_over       = 2;//领取状态 已领完
 | 
					
						
							|  |  |  |         const receive_status_received   = 1;//领取状态 已领完
 | 
					
						
							|  |  |  |         const receive_status_default    = 0;//领取状态 可领取
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-20 13:56:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 14:41:24 +08:00
										 |  |  |     public function business() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasOne(Business::class, 'code',"business_code"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-11-24 16:34:56 +08:00
										 |  |  |     public function couponType() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasOne(CouponType::class, 'id',"type_id"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-19 13:40:46 +08:00
										 |  |  |     //public function usingRule()
 | 
					
						
							|  |  |  |     //{
 | 
					
						
							|  |  |  |     //    return $this->hasOne(UsingRule::class, 'coupon_id',"id");
 | 
					
						
							|  |  |  |     //}
 | 
					
						
							| 
									
										
										
										
											2021-12-14 17:34:27 +08:00
										 |  |  |     //创建完成之后
 | 
					
						
							| 
									
										
										
										
											2021-11-30 15:26:38 +08:00
										 |  |  |     public static function onAfterInsert( $obj) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-12-14 17:34:27 +08:00
										 |  |  |         $obj->sort                  = $obj->id; | 
					
						
							|  |  |  |         $obj->using_count           = $obj->count; | 
					
						
							|  |  |  |         $obj->received_count        = 0; | 
					
						
							|  |  |  |         $obj->verification_count    = 0; | 
					
						
							| 
									
										
										
										
											2021-11-30 15:26:38 +08:00
										 |  |  |         $obj->save(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | } |