6
0
Fork 0

store-order

base
panliang 2023-02-24 16:35:50 +08:00
parent 1cb9e73a2c
commit 37953b7206
4 changed files with 16 additions and 25 deletions

View File

@ -65,15 +65,10 @@ class OrderController extends AdminController
<span class="label bg-success">{$phone}</span> <span class="label bg-success">{$phone}</span>
HTML; HTML;
}); });
$grid->column('total_amount')->display(function ($value) { $grid->column('total_amount')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
return bcdiv($value, 100, 2); $grid->column('market_price')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
})->prepend('¥'); $grid->column('cost_price')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
$grid->column('market_price')->display(function ($value) { $grid->column('profit_price')->display(fn () => round(($this->total_amount - $this->cost_price) / 100, 2, PHP_ROUND_HALF_DOWN));
return bcdiv($value, 100, 2);
})->prepend('¥');
$grid->column('cost_price')->display(function ($value) {
return bcdiv($value, 100, 2);
})->prepend('¥');
$grid->column('sales_value'); $grid->column('sales_value');
$grid->column('order_status')->using($this->statusMap)->dot($this->statusColor); $grid->column('order_status')->using($this->statusMap)->dot($this->statusColor);
$grid->column('created_at'); $grid->column('created_at');
@ -149,7 +144,7 @@ class OrderController extends AdminController
$market_price = round($query->sum('market_price') / 100, 2, PHP_ROUND_HALF_DOWN); $market_price = round($query->sum('market_price') / 100, 2, PHP_ROUND_HALF_DOWN);
$cost_price = round($query->sum('cost_price') / 100, 2, PHP_ROUND_HALF_DOWN); $cost_price = round($query->sum('cost_price') / 100, 2, PHP_ROUND_HALF_DOWN);
$sales_value = round($query->sum('sales_value'), 2, PHP_ROUND_HALF_DOWN); $sales_value = round($query->sum('sales_value'), 2, PHP_ROUND_HALF_DOWN);
$profit = round($total_amount - $cost_price, 2, PHP_ROUND_HALF_DOWN); $profit_price = round($total_amount - $cost_price, 2, PHP_ROUND_HALF_DOWN);
return <<<HTML return <<<HTML
<table class="table table-bordered"> <table class="table table-bordered">
<tbody> <tbody>
@ -157,7 +152,7 @@ class OrderController extends AdminController
<td>统计</td> <td>统计</td>
<td>订单数: $count</td> <td>订单数: $count</td>
<td>订单总额: $total_amount</td> <td>订单总额: $total_amount</td>
<td>总毛利: $profit</td> <td>总毛利: $profit_price</td>
<td>成长值: $sales_value</td> <td>成长值: $sales_value</td>
<tr> <tr>
</tbody> </tbody>
@ -174,16 +169,11 @@ class OrderController extends AdminController
$show->field('sn'); $show->field('sn');
$show->field('user.phone'); $show->field('user.phone');
$show->field('inviter.phone'); $show->field('inviter.phone');
$show->field('total_amount')->as(function ($value) {
return bcdiv($value, 100, 2);
});
$show->field('market_price')->as(function ($value) {
return bcdiv($value, 100, 2);
});
$show->field('cost_price')->as(function ($value) {
return bcdiv($value, 100, 2);
});
$show->field('products_total_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('¥'); $show->field('products_total_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('¥');
$show->field('total_amount')->as(fn ($value) => bcdiv($value, 100, 2));
$show->field('market_price')->as(fn ($value) => bcdiv($value, 100, 2));
$show->field('cost_price')->as(fn ($value) => bcdiv($value, 100, 2));
$show->field('profit_price')->as(fn () => round(($this->total_amount - $this->cost_price) / 100, 2, PHP_ROUND_HALF_DOWN));
$show->field('vip_discount_amount')->as(fn ($v) => bcdiv($v, 100, 2))->prepend('- ¥'); $show->field('vip_discount_amount')->as(fn ($v) => bcdiv($v, 100, 2))->prepend('- ¥');
$userCouponId = $show->model()->user_coupon_id; $userCouponId = $show->model()->user_coupon_id;

View File

@ -27,8 +27,8 @@ class StockBatchController extends AdminController
$modal->title('商品记录'); $modal->title('商品记录');
$data = $this->productSkus->map(fn($item) => [ $data = $this->productSkus->map(fn($item) => [
$item->name, $item->name,
round($item->sell_price, 2, PHP_ROUND_HALF_DOWN), round($item->sell_price / 100, 2, PHP_ROUND_HALF_DOWN),
round($item->cost_price, 2, PHP_ROUND_HALF_DOWN), round($item->cost_price / 100, 2, PHP_ROUND_HALF_DOWN),
$item->pivot?->amount $item->pivot?->amount
])->all(); ])->all();
return Table::make(['名称', '售价', '成本价', '数量'], $data); return Table::make(['名称', '售价', '成本价', '数量'], $data);

View File

@ -383,8 +383,8 @@ class OrderService
$cost_price = 0; $cost_price = 0;
foreach($mapProducts as $item) { foreach($mapProducts as $item) {
$sku = $item['sku']; $sku = $item['sku'];
$market_price += $sku->market_price; $market_price += $sku->market_price * $item['quantity'];
$cost_price += $sku->cost_price; $cost_price += $sku->cost_price * $item['quantity'];
} }
$attrs = [ $attrs = [

View File

@ -26,6 +26,7 @@ return [
'bargain_amount' => '砍价金额', 'bargain_amount' => '砍价金额',
'shipping_fee' => '运费', 'shipping_fee' => '运费',
'products_total_amount' => '商品总额', 'products_total_amount' => '商品总额',
'product_total_amount'=>'商品总额',
'total_amount' => '订单总额', 'total_amount' => '订单总额',
'weight' => '订单重量', 'weight' => '订单重量',
'note' => '客户备注', 'note' => '客户备注',
@ -48,7 +49,6 @@ return [
'sell_price'=>'价格', 'sell_price'=>'价格',
'quantity' => '数量', 'quantity' => '数量',
'after_sale_state'=>'售后状态', 'after_sale_state'=>'售后状态',
'product_total_amount'=>'总价',
'shipping_company' => '快递公司', 'shipping_company' => '快递公司',
'shipping_number' => '快递单号', 'shipping_number' => '快递单号',
'packages'=>'包裹内容', 'packages'=>'包裹内容',
@ -60,6 +60,7 @@ return [
'sales_value' => '成长值', 'sales_value' => '成长值',
'market_price' => '市场价', 'market_price' => '市场价',
'cost_price' => '成本价', 'cost_price' => '成本价',
'profit_price' => '毛利',
], ],
'options' => [ 'options' => [
], ],