You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							163 lines
						
					
					
						
							5.3 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							163 lines
						
					
					
						
							5.3 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminSupplier\Controllers;
							 | 
						|
								
							 | 
						|
								use App\AdminSupplier\Extensions\Grid\IndustryOrderAudit;
							 | 
						|
								use App\AdminSupplier\Extensions\Grid\IndustryOrderStatus;
							 | 
						|
								use App\AdminSupplier\Repositories\IndustryOrder;
							 | 
						|
								use App\Common\OrderStatus;
							 | 
						|
								use App\Common\PayType;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Form;
							 | 
						|
								use Dcat\Admin\Grid;
							 | 
						|
								use Dcat\Admin\Show;
							 | 
						|
								use Dcat\Admin\Http\Controllers\AdminController;
							 | 
						|
								use Dcat\Admin\Widgets\Table;
							 | 
						|
								
							 | 
						|
								class IndustryOrderController extends AdminController
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * Make a grid builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Grid
							 | 
						|
								     */
							 | 
						|
								    protected function grid()
							 | 
						|
								    {
							 | 
						|
								        return Grid::make(new IndustryOrder(['agent:id,company_name', 'spec']), function (Grid $grid) {
							 | 
						|
											$grid->disableCreateButton();
							 | 
						|
											$grid->disableRowSelector();
							 | 
						|
											$grid->disableActions();
							 | 
						|
								
							 | 
						|
								        	$grid->model()->where('supplier_id', Admin::user()->id);
							 | 
						|
								
							 | 
						|
								            $grid->column('id')->sortable();
							 | 
						|
								            $grid->column('agent.company_name', '代理商名称')->limit(10);
							 | 
						|
								            $grid->column('order_no')->limit(10);
							 | 
						|
								            $grid->column('num');
							 | 
						|
								            $grid->column('price');
							 | 
						|
								            $grid->column('name');
							 | 
						|
								            $grid->column('mobile');
							 | 
						|
											$grid->column('info', '信息收集')
							 | 
						|
												->display('查看')
							 | 
						|
												->modal('信息收集', function ($modal) {
							 | 
						|
													$modal->xl();
							 | 
						|
													$info = $this->info ?? [];
							 | 
						|
													$info = array_map(function($v) {
							 | 
						|
														if (isset($v['value'], $v['type'])) {
							 | 
						|
															if ($v['type'] == 'image') {
							 | 
						|
																if (is_array($v['value'])) {
							 | 
						|
																	return array_reduce($v['value'], fn($v2, $v3) => $v2 . '<img data-action="preview-img" src="' . $v3 . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail">  ');
							 | 
						|
																} else {
							 | 
						|
																	return '<img data-action="preview-img" src="' . $v['value'] . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail">';
							 | 
						|
																}
							 | 
						|
															} else {
							 | 
						|
																return is_string($v['value']) ? $v['value'] : join(',', $v['value']);
							 | 
						|
															}
							 | 
						|
														}
							 | 
						|
														return is_string($v) ? $v : json_encode($v);
							 | 
						|
													}, $info);
							 | 
						|
													return Table::make([], $info);
							 | 
						|
												});
							 | 
						|
											$grid->column('规格信息')
							 | 
						|
												->display('查看')
							 | 
						|
												->modal('规格信息', function ($model) {
							 | 
						|
													$info = [
							 | 
						|
														'规格名称' => $this->spec->name ?? '',
							 | 
						|
														'规格日期' => $this->spec->date ?? '',
							 | 
						|
													];
							 | 
						|
													return Table::make([], $info);
							 | 
						|
												});
							 | 
						|
											$grid->column('industry_product_id', '产品ID');
							 | 
						|
								            $grid->column('title')->limit(15);
							 | 
						|
											$grid->column('pay_type')->using(PayType::array());
							 | 
						|
											$grid->column('status')
							 | 
						|
												->using(OrderStatus::array())
							 | 
						|
												//审核拒绝
							 | 
						|
												->if(fn() => $this->audit_status == -1)
							 | 
						|
												->then(function ($column) {
							 | 
						|
													$column->display('已拒绝')->label();
							 | 
						|
												})
							 | 
						|
												//审核通过
							 | 
						|
												->if(fn() => $this->audit_status == 1)
							 | 
						|
												->then(function ($column) {
							 | 
						|
													if ($this->status == OrderStatus::OFFLINE_UNPAID) {
							 | 
						|
														$column->action(new IndustryOrderStatus);
							 | 
						|
													} else {
							 | 
						|
														$column->display(OrderStatus::array()[$this->status]);
							 | 
						|
													}
							 | 
						|
												});
							 | 
						|
											$grid->column('操作')
							 | 
						|
												//待审核
							 | 
						|
												->if(fn() => $this->audit_status == 0)
							 | 
						|
												->then(function ($column) {
							 | 
						|
													$column->append((new IndustryOrderAudit(null, 1))->setKey($this->id))->append(' ');
							 | 
						|
													$column->append((new IndustryOrderAudit(null, 2))->setKey($this->id));
							 | 
						|
												})
							 | 
						|
												->if(fn() => !empty($this->show_qrcode))
							 | 
						|
												->then(function ($column) {
							 | 
						|
													$verify_code = $this->id . '-' . $this->verify_code;
							 | 
						|
													$column->append(admin_url('industry_order/qrcode', $verify_code))->image('', 60, 60);
							 | 
						|
													$column->append('<br>' . $verify_code . '<br>');
							 | 
						|
												});
							 | 
						|
								            $grid->column('paid_at')->width(100);
							 | 
						|
								            $grid->column('created_at')->width(100);
							 | 
						|
								
							 | 
						|
								            $grid->filter(function (Grid\Filter $filter) {
							 | 
						|
								                $filter->equal('id')->width(2);
							 | 
						|
												$filter->equal('order_no')->width(3);
							 | 
						|
								            });
							 | 
						|
								        });
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
									public function qrcode()
							 | 
						|
									{
							 | 
						|
										return (new \App\AdminAgent\Controllers\IndustryOrderController)->qrcode();
							 | 
						|
									}
							 | 
						|
								
							 | 
						|
										/**
							 | 
						|
								     * Make a show builder.
							 | 
						|
								     *
							 | 
						|
								     * @param mixed $id
							 | 
						|
								     *
							 | 
						|
								     * @return Show
							 | 
						|
								     */
							 | 
						|
								    protected function detail($id)
							 | 
						|
								    {
							 | 
						|
								        /*return Show::make($id, new IndustryOrder(), function (Show $show) {
							 | 
						|
								            $show->field('id');
							 | 
						|
								            $show->field('agent_id');
							 | 
						|
								            $show->field('supplier_id');
							 | 
						|
								            $show->field('order_no');
							 | 
						|
								            $show->field('industry_product_id');
							 | 
						|
								            $show->field('num');
							 | 
						|
								            $show->field('price');
							 | 
						|
								            $show->field('name');
							 | 
						|
								            $show->field('mobile');
							 | 
						|
								            $show->field('title');
							 | 
						|
								            $show->field('picture');
							 | 
						|
								            $show->field('status');
							 | 
						|
								            $show->field('paid_at');
							 | 
						|
								            $show->field('verify_code');
							 | 
						|
								            $show->field('timeout');
							 | 
						|
								            $show->field('created_at');
							 | 
						|
								            $show->field('updated_at');
							 | 
						|
								        });*/
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Make a form builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Form
							 | 
						|
								     */
							 | 
						|
								    protected function form()
							 | 
						|
								    {
							 | 
						|
								        return Form::make(new IndustryOrder(), function (Form $form) {
							 | 
						|
								            $form->display('id');
							 | 
						|
								//            $form->select('status')->options([OrderStatus::OFFLINE_PAID => '已付款']);
							 | 
						|
								        })->saving(function(Form $form) {
							 | 
						|
								        	return $form->response()->error('操作禁止');
							 | 
						|
										})->deleting(function(Form $form) {
							 | 
						|
											return $form->response()->error('操作禁止');
							 | 
						|
										});
							 | 
						|
								    }
							 | 
						|
								}
							 |