| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -19,7 +19,6 @@ use Dcat\Admin\Form; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Grid; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Show; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Http\Controllers\AdminController; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Widgets\Alert; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -75,7 +74,9 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->switch() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->else() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->using(ProductStatus::array()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$grid->column('is_rec')->switch()->help('推荐后将在“我的”页面下方显示'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (Admin::user()->type != AgentType::CLUSTER) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$grid->column('is_rec')->switch()->help('推荐后将在“我的”页面下方显示'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $grid->column('updated_at'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $grid->filter(function (Grid\Filter $filter) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -102,7 +103,7 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    protected function detail($id) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Show::make($id, new AgentProduct(['agent:id,name', 'product.supplier:id,name', 'user:id,nickname', 'guide:id,name']), function (Show $show) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Show::make($id, new AgentProduct(['agent:id,name', 'category:id,name', 'product.supplier:id,name', 'guide:id,name']), function (Show $show) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//不允许查看非自己的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($show->model()->agent_id != Admin::user()->id) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									Admin::exit('数据不存在'); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -115,26 +116,27 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('original_price'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('sale'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('stock'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('channel_id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('category_id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('category.name', '分类'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('status')->using(ProductStatus::array()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('verifier.nickname', '核销人员'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (Admin::user()->type == AgentType::CLUSTER) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('guide.name', '地接'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('is_rec')->using(['未推荐', '已推荐']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('title'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('pictures')->image('', 80, 80); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('know')->unescape(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('content')->unescape(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('earnest'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('earnest_timeout'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('deposit'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('deposit_timeout'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (Admin::user()->type != AgentType::CLUSTER) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('is_rec')->using(['未推荐', '已推荐']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('channel_id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('earnest'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('earnest_timeout'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('deposit'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$show->field('deposit_timeout'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('created_at'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $show->field('updated_at'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->html(Alert::make(null, '供应商产品详情')->info()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								/*$show->html(Alert::make(null, '供应商产品详情')->info()); 因为可能是组合销售多个产品,这里暂时不显示 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.id', '供应商产品ID'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.supplier.name'); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -145,7 +147,7 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.sale'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.stock'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.created_at', '创建时间'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.updated_at', '更新时间'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$show->field('product.updated_at', '更新时间');*/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -166,55 +168,63 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->display('id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//组团版旅行社不允许选择组团云产品
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$options = Admin::user()->type == AgentType::CLUSTER ? [1 => '组合销售'] : ['单品销售', '组合销售', '组团云产品']; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->radio('type') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->options($options) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->default(Admin::user()->type == AgentType::CLUSTER ? 1 : 0)->required() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->help('单品销售无需审核,组合销售需要审核才能上架') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->when(0, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//组团版没有单品选择功能
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if (Admin::user()->type == AgentType::CLUSTER) return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										/** 单品销售 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->selectTable('product_id', '供应商产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->help('产品列表显示的是该产品的标题和图片') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->from(SelectProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									})->when(1, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										/** 组合销售 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->multipleSelectTable('product_ids', '供应商产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->help('可单选或多选组合销售') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->from(SelectProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										/** 自定义内容 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->text('title'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->multipleImage('pictures')->removable(false)->uniqueName(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->editor('know'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->editor('content'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									})->when(2, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//组团版旅行社不允许选择组团云产品
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if (Admin::user()->type == AgentType::CLUSTER) return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										/** 组团云产品 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$form->selectTable('agent_cloud_pid', '组团云产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->help('产品列表显示的是该产品的标题和图片') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->from(SelectAgentCloudProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->text('price')->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->text('original_price')->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->text('sale')->default(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->text('stock')->default(8888)->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$options = Channel::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->multipleSelect('channel_id')->options(array_slice($options, 1, null, true)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (Admin::user()->type == AgentType::CLUSTER) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->hidden('product_id')->value(0)->default(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->hidden('type')->value(1)->default(1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									/** 组合销售 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->multipleSelectTable('product_ids', '供应商产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->help('请选择两个或两个以上的产品组合销售') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->from(SelectProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									/** 自定义内容 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->text('title'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->multipleImage('pictures')->removable(false)->uniqueName(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->editor('know'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->editor('content'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->radio('type') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->options(['单品销售', '组合销售', '组团云产品']) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->default(Admin::user()->type == AgentType::CLUSTER ? 1 : 0)->required() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->help('单品销售无需审核,组合销售需要审核才能上架') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->when(0, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											/** 单品销售 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->selectTable('product_id', '供应商产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->help('产品列表显示的是该产品的标题和图片') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->from(SelectProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										})->when(1, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											/** 组合销售 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->multipleSelectTable('product_ids', '供应商产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->help('可单选或多选组合销售') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->from(SelectProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->model(Product::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											/** 自定义内容 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->text('title'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->multipleImage('pictures')->removable(false)->uniqueName(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->editor('know'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->editor('content'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										})->when(2, function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											/** 组团云产品 **/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->selectTable('agent_cloud_pid', '组团云产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->help('产品列表显示的是该产品的标题和图片') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->title('选择产品') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->dialogWidth('80%;min-width:825px;') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->from(SelectAgentCloudProduct::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												->model(\App\Models\AgentProduct::class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->number('price')->min(0)->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->number('original_price')->min(0)->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->number('sale')->min(0)->default(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->number('stock')->min(0)->default(8888)->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$options = Category::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            $form->select('category_id') | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -232,7 +242,6 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										]) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->required(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->switch('is_rec')->help('推荐后将在小程序“我的”页面下方显示'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//$form->selectTable('verifier')
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//	->title('选择核销人员')
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//	->dialogWidth('50%;min-width:600px;') //不起作用
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -248,16 +257,22 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->dialogWidth('50%;min-width:600px;') //不起作用
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->from(SelectGuide::make()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->model(Guide::class, 'id', 'name'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->confirm('提示', '如果修改了标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->switch('is_rec')->help('推荐后将在小程序“我的”页面下方显示'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$options = Channel::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->multipleSelect('channel_id')->options(array_slice($options, 1, null, true)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->number('earnest')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->default(0)->help('单位:元。不输入或输入 0 则不支持定金支付,必须和定金超时时间同时设置才会生效'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->number('earnest_timeout')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->number('deposit')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->default(0)->help('单位:元。不输入或输入 0 则不支持订金支付,必须和订金超时时间同时设置才会生效'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$form->number('deposit_timeout')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->number('earnest')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->default(0)->help('单位:元。不输入或输入 0 则不支持定金支付,必须和定金超时时间同时设置才会生效'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->number('earnest_timeout')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->number('deposit')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->default(0)->help('单位:元。不输入或输入 0 则不支持订金支付,必须和订金超时时间同时设置才会生效'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$form->number('deposit_timeout')->min(0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        })->saving(function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//不允许修改非自己的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -292,6 +307,15 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											if (in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												return $form->response()->error('产品待审核或审核拒绝,不允许修改!'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											//组团云产品处理
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											if ($form->type == 2) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$cloud_product = AgentProduct::find($form->agent_cloud_pid); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												if (!$cloud_product || $cloud_product->status != ProductStatus::ON_SALE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
													return $form->response()->error('你选择的组团云产品状态异常,上架失败!'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->model()->status = $form->status == 1 ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$form->model()->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											return $form->response()->success('更新成功!'); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -480,11 +504,10 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//如果是组团云产品,同步信息到其它产品
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//如果是组团云产品,且处于上架状态,同步信息到其它产品,否则下架所有关联的产品
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($form->is_cloud) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									\App\Models\AgentProduct::query() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->where(['agent_cloud_pid' => $form->getKey(), 'type' => 2]) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->update([ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($form->status == ProductStatus::ON_SALE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$data = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'product_id' => $form->product_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'product_ids' => $form->product_ids, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'guide_id' => $form->guide_id, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -492,7 +515,13 @@ class AgentProductController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'pictures' => explode(',', $form->pictures), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'know' => $form->know, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											'content' => $form->content, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$data = ['status' => ProductStatus::SOLD_OUT]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									\App\Models\AgentProduct::query() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->where(['agent_cloud_pid' => $form->getKey(), 'type' => 2]) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										->update($data); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							})->deleting(function (Form $form) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//不允许删除非自己的数据
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |