'待付款', 1 => '待发货', 2 => '发货中', 3 => '已发货', 9 => '已完成', 10 => '已取消', ]; public $statusColor = [ 0 => 'primary', 1 => 'warning', 2 => 'danger', 3 => 'success', 9 => 'success', 10 => '#b3b9bf', ]; protected $translation = 'store-order'; protected function grid() { $grid = new Grid(Order::with(['user', 'inviter'])); $grid->model()->whereNotNull('inviter_id')->orderBy('created_at', 'desc'); $grid->column('sn')->copyable(); $grid->column('user.phone')->copyable(); $grid->column('inviter.phone')->copyable(); $grid->column('total_amount')->display(function ($value) { return bcdiv($value, 100, 2); })->prepend('¥'); $grid->column('sales_value'); $grid->column('order_status')->using($this->statusMap)->dot($this->statusColor); $grid->column('pay_way')->display(function ($v) { return $v?->mallText(); })->circleDot(PayWay::colors()); $grid->column('pay_at'); $grid->column('created_at'); $grid->showViewButton(); $grid->filter(function (Grid\Filter $filter) { $filter->panel(); $filter->like('sn')->width(3); $filter->like('user.phone')->width(3); $filter->like('inviter.phone')->width(3); $filter->between('created_at')->dateTime()->width(7); }); return $grid; } protected function detail($id) { $show = Show::make($id, Order::with(['user', 'inviter'])); $show->field('id'); $show->field('sn'); $show->field('user.phone'); $show->field('inviter.phone'); $show->field('total_amount')->as(function ($value) { return bcdiv($value, 100, 2); }); $show->field('sales_value'); $show->field('order_status')->as(function ($v) { return $this->order_status; })->using($this->statusMap)->dot($this->statusColor); $show->field('pay_way')->as(function ($v) { return $this->pay_way?->mallText(); })->circleDot(PayWay::colors()); $show->field('pay_at'); $show->field('created_at'); $show->panel()->tools(function ($tools) { $tools->disableEdit(); $tools->disableDelete(); }); $row = new Row(); $row->column(5, $show); $tab = Tab::make()->withCard(); $tab->add('商品', Card::make($this->gridProduct($id))); $tab->add('提货记录', Card::make($this->gridPackage($id))); $row->column(7, $tab); return $row; } protected function gridProduct($id) { $grid = Grid::make(OrderProduct::with([])); $grid->model()->where('order_id', $id); $grid->column('name'); $grid->column('sell_price', '销售价格')->display(function ($value) { return bcdiv($value, 100, 2); })->prepend('¥'); $grid->column('vip_price', '会员价格')->display(function ($value) { return bcdiv($value, 100, 2); })->prepend('¥'); $grid->column('quantity'); $grid->column('sales_value'); $grid->column('remain_quantity'); $grid->column('product_total_amount')->display(function () { return bcdiv($this->total_amount, 100, 2); })->prepend('¥'); $grid->disableActions(); $grid->disablePagination(); $grid->disableRefreshButton(); return $grid; } protected function gridPackage($id) { $grid = Grid::make(OrderPackage::with(['inviter', 'orderProducts'])); $grid->model()->where('order_id', $id)->orderBy('created_at', 'desc'); $grid->column('products', '商品')->display(function () { $html = ''; foreach($this->orderProducts as $item) { $html .= '