| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -10,12 +10,10 @@ use Dcat\Admin\Form; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Grid; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Show; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Controllers\AdminController; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\CouponReceiveType as ReceiveTypeModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\CouponSetting as SettingModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\Coupon as CouponModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\Market as MarketModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\Category as CategoryModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Form\NestedForm; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\v3\CouponUse as UseModel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class CouponController extends AdminController | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -47,6 +45,7 @@ class CouponController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                return $item; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $grid->active_type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $grid->weigh->editable(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $grid->status | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ->using( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    CouponModel::$status | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -105,56 +104,92 @@ class CouponController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    protected function detail($id) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    {  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        $builder = CouponModel::with('receiveType'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Show::make($id, $builder, function (Show $show) use($id){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->id; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->title; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->introduce; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->full_amount; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->discounts; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->discount_type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->inventory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->inventory_use; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->start_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->end_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->usable_start_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->usable_end_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->active_type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->column('receive_type.receive_type','')->as(function($receiveTypeId) use($show){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if($receiveTypeId > 0){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $receiveTypeName = SettingModel::getSettingInfo($receiveTypeId,'name'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = $receiveTypeName ? $receiveTypeName : $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->category_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->market_ids->as(function($marketId){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $text = '全部市场'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if($marketId > 0){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $market = marketModel::select('name')->find($marketId)->toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = $market ? $market['name'] : $text ; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Show::make($id, $builder, function (Show $show){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->row(function(Show\Row $show){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->id; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->title; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->introduce; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->full_amount; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->discounts; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->discount_type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->inventory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->inventory_use; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // $show->category_ids->as(function($storeTypeId){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     $text = '全部类型';
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     if($storeTypeId > 0){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //         $storeType = storeTypeModel::select('type_name')->find($storeTypeId)->toArray();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //         $text = $storeType ? $storeType['type_name'] : $text ;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     return $text;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // });
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->is_new_user_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->row(function(Show\Row $show){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->start_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->end_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->usable_start_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->usable_end_time_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->active_type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->column('receive_type.receive_type','领取方式')->as(function($receiveTypeId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if($receiveTypeId > 0){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $receiveTypeName = SettingModel::getSettingInfo($receiveTypeId,'name'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $text = $receiveTypeName ? $receiveTypeName : $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->type_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->category_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->market_ids->as(function($marketIds){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if(!empty($marketIds)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $market = marketModel::whereIn('id',$marketIds)->pluck('name')->toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        foreach($market as $value){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $value = $value ?? ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $text .= '['.$value.'] '; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    }else{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $text = '全部市场'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->category_ids->as(function($categoryIds){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if(!empty($categoryIds)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $market = CategoryModel::whereIn('id',$categoryIds)->pluck('title')->toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        foreach($market as $value){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $value = $value ?? ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $text .= '['.$value.'] '; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    }else{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        $text = '全部分类'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->activity_available->as(function($activityAvailable){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $activityAvailable = json_decode($activityAvailable); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if(!empty($activityAvailable)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        foreach($activityAvailable as $value){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $value = CouponModel::$activityAvailable[$value] ?? ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $text .= '['.$value.'] '; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->tags->as(function($tags){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $text = ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    $tags = json_decode($tags); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if(!empty($tags)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        foreach($tags as $value){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $value = $value ?? ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            $text .= '['.$value.'] '; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return $text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->is_new_user_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->usable_number; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->weigh; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->remark; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->status_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->created_at_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->updated_at_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->usable_number; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->weigh; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->remark; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->created_at_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->updated_at_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $show->width(6)->status_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->panel()->tools(function ($tools) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $tools->disableEdit(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -228,7 +263,7 @@ class CouponController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->column(12,function(Form $form){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $form->tags('activity_available','可用活动')->options(CouponModel::$activityAvailable); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $form->multipleSelect('activity_available','可用活动')->options(CouponModel::$activityAvailable); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $form->tags('tags','标签')->options(['新人专享','满39减10','满19减5']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                $form->text('remark')->maxLength(500,'最多只能输入500个字')->default(''); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -238,6 +273,7 @@ class CouponController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->disableViewCheck(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->disableEditingCheck(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->disableCreatingCheck(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->disableDeleteButton(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            /* 不显示字段 */     | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->hidden('id'); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |