|
|
@@ -3,8 +3,6 @@
|
|
|
namespace App\Module\Mex\AdminControllers;
|
|
|
|
|
|
use App\Module\Mex\Repositories\MexWarehouseRepository;
|
|
|
-use App\Module\Mex\Models\MexWarehouse;
|
|
|
-use App\Module\Mex\Logic\MexWarehouseLogic;
|
|
|
use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
use UCore\DcatAdmin\AdminController;
|
|
|
use Dcat\Admin\Form;
|
|
|
@@ -35,8 +33,8 @@ class MexWarehouseController extends AdminController
|
|
|
{
|
|
|
return Grid::make(new MexWarehouseRepository(), function (Grid $grid) {
|
|
|
$grid->column('id', 'ID')->sortable();
|
|
|
- $grid->column('item_id', '商品ID')->link(function ($value) {
|
|
|
- return admin_url("game-items/{$value}");
|
|
|
+ $grid->column('item_id', '商品ID')->display(function ($value) {
|
|
|
+ return "<a href='" . admin_url("game-items/{$value}") . "' target='_blank'>{$value}</a>";
|
|
|
});
|
|
|
$grid->column('quantity', '当前库存')->display(function ($value) {
|
|
|
return number_format($value);
|
|
|
@@ -54,17 +52,15 @@ class MexWarehouseController extends AdminController
|
|
|
return number_format($value, 5);
|
|
|
});
|
|
|
$grid->column('average_buy_price', '平均买入价')->display(function () {
|
|
|
- $warehouse = $this;
|
|
|
- if ($warehouse->total_buy_quantity > 0) {
|
|
|
- $avgPrice = bcdiv($warehouse->total_buy_amount, $warehouse->total_buy_quantity, 5);
|
|
|
+ if ($this->total_buy_quantity > 0) {
|
|
|
+ $avgPrice = bcdiv($this->total_buy_amount, $this->total_buy_quantity, 5);
|
|
|
return number_format($avgPrice, 5);
|
|
|
}
|
|
|
return '-';
|
|
|
});
|
|
|
$grid->column('average_sell_price', '平均卖出价')->display(function () {
|
|
|
- $warehouse = $this;
|
|
|
- if ($warehouse->total_sell_quantity > 0) {
|
|
|
- $avgPrice = bcdiv($warehouse->total_sell_amount, $warehouse->total_sell_quantity, 5);
|
|
|
+ if ($this->total_sell_quantity > 0) {
|
|
|
+ $avgPrice = bcdiv($this->total_sell_amount, $this->total_sell_quantity, 5);
|
|
|
return number_format($avgPrice, 5);
|
|
|
}
|
|
|
return '-';
|
|
|
@@ -129,14 +125,14 @@ class MexWarehouseController extends AdminController
|
|
|
$show->field('net_quantity', '净买入数量')->as(function () {
|
|
|
return $this->total_buy_quantity - $this->total_sell_quantity;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$show->divider('金额信息');
|
|
|
$show->field('total_buy_amount', '累计买入金额');
|
|
|
$show->field('total_sell_amount', '累计卖出金额');
|
|
|
$show->field('net_amount', '净买入金额')->as(function () {
|
|
|
return bcsub($this->total_buy_amount, $this->total_sell_amount, 5);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$show->divider('价格信息');
|
|
|
$show->field('average_buy_price', '平均买入价')->as(function () {
|
|
|
if ($this->total_buy_quantity > 0) {
|