调整商城首页
This commit is contained in:
65
app/Admin/Controllers/Area/CodeController.php
Normal file
65
app/Admin/Controllers/Area/CodeController.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Area;
|
||||||
|
|
||||||
|
use App\Admin\Actions\Area\AddStock;
|
||||||
|
use App\Admin\Actions\Area\SubStock;
|
||||||
|
use App\Admin\Selectable\AreaStockAble;
|
||||||
|
use App\Admin\Selectable\ClerksSelectAble;
|
||||||
|
use App\Models\Area;
|
||||||
|
use App\Models\AreaCode;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Exception;
|
||||||
|
use Modules\Mall\Models\Region;
|
||||||
|
|
||||||
|
class CodeController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '提货码列表';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2023/1/11 13:44
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
public function grid(): Grid
|
||||||
|
{
|
||||||
|
$grid = new Grid(new AreaCode());
|
||||||
|
$grid->disableActions();
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
|
||||||
|
|
||||||
|
$grid->filter(function (Grid\Filter $filter) {
|
||||||
|
$filter->column(1 / 3, function (Grid\Filter $filter) {
|
||||||
|
$filter->like('area.title', '地区名称');
|
||||||
|
});
|
||||||
|
$filter->column(1 / 3, function (Grid\Filter $filter) {
|
||||||
|
$filter->equal('status', '状态')->select(AreaCode::STATUS);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->model()->with(['area']);
|
||||||
|
|
||||||
|
$grid->column('id', '序号');
|
||||||
|
$grid->column('code', '码');
|
||||||
|
$grid->column('user.username', '领取用户')
|
||||||
|
->display(function () {
|
||||||
|
return $this->user ? $this->user->show_name : '---';
|
||||||
|
});
|
||||||
|
$grid->column('manage.username', '管理人')
|
||||||
|
->display(function () {
|
||||||
|
return $this->manage ? $this->manage->show_name : '---';
|
||||||
|
});
|
||||||
|
$grid->column('area.title', '地区名称');
|
||||||
|
$grid->column('status', '状态')->using(AreaCode::STATUS);
|
||||||
|
$grid->column('created_at', '创建时间');
|
||||||
|
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,5 +6,5 @@ Route::group([
|
|||||||
'namespace' => 'Area',
|
'namespace' => 'Area',
|
||||||
], function (Router $router) {
|
], function (Router $router) {
|
||||||
$router->resource('areas', 'IndexController');
|
$router->resource('areas', 'IndexController');
|
||||||
$router->resource('areas/codes', 'IndexController');
|
$router->resource('areas_codes', 'CodeController');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,60 +49,35 @@ class StockOrderController extends AdminController
|
|||||||
});
|
});
|
||||||
$filter->column(1 / 2, function (Grid\Filter $filter) {
|
$filter->column(1 / 2, function (Grid\Filter $filter) {
|
||||||
$filter->between('created_at', '下单时间')->datetime();
|
$filter->between('created_at', '下单时间')->datetime();
|
||||||
$filter->equal('state', '订单状态')->select([
|
$filter->equal('state', '订单状态')->select(Order::STATUS_SAMPLE_MAP);
|
||||||
Order::STATUS_CANCEL => '已取消',
|
|
||||||
Order::STATUS_PAID => '待发货',
|
|
||||||
Order::STATUS_DELIVERED => '已发货',
|
|
||||||
Order::STATUS_SIGNED => '已签收',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// $filter->between('paid_at', '付款时间')->datetime();
|
// $filter->between('paid_at', '付款时间')->datetime();
|
||||||
// $filter->between('expired_at', '过期时间')->datetime();
|
// $filter->between('expired_at', '过期时间')->datetime();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
$grid->disableActions();
|
||||||
$actions->disableEdit();
|
|
||||||
$actions->disableDelete();
|
|
||||||
$actions->disableView();
|
|
||||||
if ($actions->row->can('pay') && $this->row->type == Order::TYPE_NORMAL) {
|
|
||||||
$actions->add(new Pay());
|
|
||||||
}
|
|
||||||
if ($actions->row->can('deliver')) {
|
|
||||||
$actions->add(new Delivered);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$grid->model()->with(['shop', 'user.info']);
|
$grid->model()->with(['shop', 'user.info']);
|
||||||
|
|
||||||
$grid->column('order_no', '订单编号')->display(function () {
|
$grid->column('order_no', '订单编号')->display(function () {
|
||||||
return sprintf('<a href="%s">%s</a>', route('admin.mall.stock_orders.show', $this), $this->order_no);
|
return sprintf('<a href="%s">%s</a>', route('admin.mall.stock_orders.show', $this), $this->order_no);
|
||||||
});
|
});
|
||||||
// $grid->column('shop.name', '所属店铺');
|
$grid->column('user.username', '提货用户')
|
||||||
$grid->column('user.username', '提货用户');
|
->display(function () {
|
||||||
// $grid->column('amount', '商品金额');
|
return $this->user->username."({$this->user->info->nickname})";
|
||||||
// $grid->column('freight', '运费');
|
});
|
||||||
$grid->column('qty', '提货数量')
|
$grid->column('qty', '提货数量')
|
||||||
->display(function () {
|
->display(function () {
|
||||||
return $this->items()->sum('qty');
|
return $this->items()->sum('qty');
|
||||||
});
|
});
|
||||||
// $grid->column('订单金额')->display(function () {
|
$grid->column('areaCode.code', '提货码');
|
||||||
// return $this->total;
|
|
||||||
// });
|
|
||||||
$grid->column('state', '订单状态')
|
$grid->column('state', '订单状态')
|
||||||
->display(function () {
|
->display(function () {
|
||||||
return $this->state_text;
|
return $this->state_text;
|
||||||
})
|
})
|
||||||
->label();
|
->label();
|
||||||
// $grid->column('type', '订单类型')->using(Order::TYPE_MAP)->label();
|
$grid->column('type', '订单类型')->using(Order::TYPE_MAP)->label();
|
||||||
// $grid->column('paid_at', '支付时间')->sortable();
|
|
||||||
// $grid->column('expired_at', '过期时间')->sortable();
|
|
||||||
$grid->column('versions_count', '操作日志')->link(function () {
|
|
||||||
return route('admin.mall.versions', [
|
|
||||||
'model' => get_class($this),
|
|
||||||
'key' => $this->id,
|
|
||||||
]);
|
|
||||||
}, '_self');
|
|
||||||
$grid->column('created_at', '下单时间')->sortable();
|
$grid->column('created_at', '下单时间')->sortable();
|
||||||
|
|
||||||
$grid->disableExport(false);
|
$grid->disableExport(false);
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ class Order extends Model
|
|||||||
self::REFUND_COMPLETED => '退款完成',
|
self::REFUND_COMPLETED => '退款完成',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const STATUS_SAMPLE_MAP = [
|
||||||
|
self::STATUS_INIT => '未付款',
|
||||||
|
self::STATUS_CANCEL => '已取消',
|
||||||
|
self::STATUS_PAID => '待提货',
|
||||||
|
self::STATUS_DELIVERED => '已提货',
|
||||||
|
];
|
||||||
|
|
||||||
const CANCEL_BY_USER = 2; // 买家取消
|
const CANCEL_BY_USER = 2; // 买家取消
|
||||||
const CANCEL_BY_SELLER = 3; // 卖家取消
|
const CANCEL_BY_SELLER = 3; // 卖家取消
|
||||||
const CANCEL_BY_SYSTEM = 4; // 系统取消
|
const CANCEL_BY_SYSTEM = 4; // 系统取消
|
||||||
@@ -92,7 +99,7 @@ class Order extends Model
|
|||||||
|
|
||||||
const TYPE_MAP = [
|
const TYPE_MAP = [
|
||||||
self::TYPE_NORMAL => '正常',
|
self::TYPE_NORMAL => '正常',
|
||||||
self::TYPE_SAMPLE => '领取',
|
self::TYPE_SAMPLE => '免费领取',
|
||||||
self::TYPE_SCORE => '积分兑换',
|
self::TYPE_SCORE => '积分兑换',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -162,8 +169,12 @@ class Order extends Model
|
|||||||
*/
|
*/
|
||||||
public function getStateTextAttribute(): string
|
public function getStateTextAttribute(): string
|
||||||
{
|
{
|
||||||
|
if ($this->type == self::TYPE_SAMPLE) {
|
||||||
|
return self::STATUS_SAMPLE_MAP[$this->state];
|
||||||
|
} else {
|
||||||
return self::STATUS_MAP[$this->state];
|
return self::STATUS_MAP[$this->state];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 订单类型
|
* Notes: 订单类型
|
||||||
|
|||||||
Reference in New Issue
Block a user