优化订单统计
parent
eb6bf66970
commit
85a616282e
|
|
@ -152,6 +152,9 @@ class OrderController extends AdminController
|
|||
<span class="label bg-success">{$phone}</span>
|
||||
HTML;
|
||||
});
|
||||
$grid->column('order_total_amount')->display(function () {
|
||||
return bcdiv($this->point_discount_amount + $this->total_amount, 100, 2);
|
||||
})->prepend('¥');
|
||||
$grid->column('point_discount_amount')->display(function ($value) {
|
||||
return bcdiv($value, 100, 2);
|
||||
})->prepend('¥');
|
||||
|
|
@ -296,19 +299,21 @@ class OrderController extends AdminController
|
|||
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
||||
});
|
||||
$count = $query->count();
|
||||
$total_amount = number_format($query->sum('total_amount') / 100, 2);
|
||||
$payment_amount = bcdiv($query->sum('total_amount'), 100, 2);
|
||||
$market_price = number_format($query->sum('market_price') / 100, 2);
|
||||
$cost_price = number_format($query->sum('cost_price') / 100, 2);
|
||||
$sales_value = number_format($query->sum('sales_value'));
|
||||
$point_discount_amount = bcdiv($query->sum('point_discount_amount'), 100, 2);
|
||||
$total_amount = bcadd($payment_amount, $point_discount_amount, 2);
|
||||
return <<<HTML
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>统计</td>
|
||||
<td>订单数: $count</td>
|
||||
<td>积分: $point_discount_amount</td>
|
||||
<td>订单总额: $total_amount</td>
|
||||
<td>积分抵扣: $point_discount_amount</td>
|
||||
<td>实付金额: $payment_amount</td>
|
||||
<td>市场价: $market_price</td>
|
||||
<td>成本价: $cost_price</td>
|
||||
<td>成长值: $sales_value</td>
|
||||
|
|
@ -395,13 +400,16 @@ class OrderController extends AdminController
|
|||
$show->field('reduced_amount')->as(function ($v) {
|
||||
return bcdiv($v, 100, 2);
|
||||
})->prepend('- ¥');
|
||||
$show->field('order_total_amount')->as(function ($v) {
|
||||
return bcdiv($this->point_discount_amount + $this->total_amount, 100, 2);
|
||||
})->prepend('- ¥');
|
||||
$show->field('point_discount_amount')->as(function ($v) {
|
||||
return bcdiv($v, 100, 2);
|
||||
})->prepend('- ¥');
|
||||
$show->field('profit');
|
||||
$show->field('total_amount')->as(function ($v) {
|
||||
return bcdiv($v, 100, 2);
|
||||
})->prepend('¥');
|
||||
$show->field('profit');
|
||||
});
|
||||
$show->row(function (Show\Row $show) use ($userCouponId) {
|
||||
$show->width(6)->field('sales_value');
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Admin\Controllers\Store;
|
||||
|
||||
use Dcat\Admin\{Form, Grid, Admin, Show};
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\{Order, OrderProduct, OrderPackage};
|
||||
use App\Constants\OrderStatus;
|
||||
use App\Enums\PayWay;
|
||||
use App\Models\Store\{Store, Desk};
|
||||
use App\Models\{Order, OrderProduct, OrderPackage};
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Layout\Row;
|
||||
use Dcat\Admin\Widgets\{Box, Tab, Card};
|
||||
use App\Constants\OrderStatus;
|
||||
use App\Models\Store\{Store, Desk};
|
||||
use Dcat\Admin\{Form, Grid, Admin, Show};
|
||||
|
||||
class OrderController extends AdminController
|
||||
{
|
||||
|
|
@ -66,10 +66,12 @@ class OrderController extends AdminController
|
|||
<span class="label bg-success">{$phone}</span>
|
||||
HTML;
|
||||
});
|
||||
$grid->column('total_amount')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$grid->column('order_total_amount')->display(fn ($v) => bcdiv($this->point_discount_amount + $this->total_amount, 100, 2))->prepend('¥');
|
||||
$grid->column('point_discount_amount')->display(fn ($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
$grid->column('total_amount')->display(fn ($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
$grid->column('market_price')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$grid->column('cost_price')->display(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$grid->column('profit_price')->display(fn () => round(($this->total_amount - $this->cost_price) / 100, 2, PHP_ROUND_HALF_DOWN));
|
||||
$grid->column('profit_price')->display(fn () => bcdiv($this->total_amount + $this->point_discount_amount - $this->cost_price, 100, 2));
|
||||
$grid->column('user_coupon_id')->display(fn ($value) => $value ? data_get($this->userCoupon, 'coupon_name') . '(¥'.round($this->coupon_discount_amount/100, 2, PHP_ROUND_HALF_DOWN).')' : '');
|
||||
$grid->column('sales_value');
|
||||
$grid->column('order_status')->using($this->statusMap)->dot($this->statusColor);
|
||||
|
|
@ -154,18 +156,21 @@ class OrderController extends AdminController
|
|||
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
||||
});
|
||||
$count = $query->count();
|
||||
$total_amount = round($query->sum('total_amount') / 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);
|
||||
$paymentAmount = bcdiv($query->sum('total_amount'), 100, 2);
|
||||
$pointDiscountAmount = bcdiv($query->sum('point_discount_amount'), 100, 2);
|
||||
$totalAmount = bcadd($paymentAmount, $pointDiscountAmount, 2);
|
||||
$cost_price = bcdiv($query->sum('cost_price'), 100, 2);
|
||||
$sales_value = round($query->sum('sales_value'), 2, PHP_ROUND_HALF_DOWN);
|
||||
$profit_price = round($total_amount - $cost_price, 2, PHP_ROUND_HALF_DOWN);
|
||||
$profit_price = bcsub($totalAmount, $cost_price, 2);
|
||||
return <<<HTML
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>统计</td>
|
||||
<td>订单数: $count</td>
|
||||
<td>订单总额: $total_amount</td>
|
||||
<td>订单总额: $totalAmount</td>
|
||||
<td>积分抵扣: $pointDiscountAmount</td>
|
||||
<td>实付金额: $paymentAmount</td>
|
||||
<td>总毛利: $profit_price</td>
|
||||
<td>成长值: $sales_value</td>
|
||||
<tr>
|
||||
|
|
@ -187,7 +192,7 @@ class OrderController extends AdminController
|
|||
$show->field('products_total_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$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('profit_price')->as(fn () => round(($this->total_amount + $this->point_discount_amount - $this->cost_price) / 100, 2, PHP_ROUND_HALF_DOWN));
|
||||
$show->field('vip_discount_amount')->as(fn ($v) => bcdiv($v, 100, 2))->prepend('- ¥');
|
||||
|
||||
// 优惠券
|
||||
|
|
@ -196,6 +201,8 @@ class OrderController extends AdminController
|
|||
|
||||
$show->field('shipping_fee')->as(fn ($v) => bcdiv($v, 100, 2))->prepend('+ ¥');
|
||||
$show->field('reduced_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('- ¥');
|
||||
$show->field('order_total_amount')->as(fn($value) => bcdiv($this->point_discount_amount + $this->total_amount, 100, 2))->prepend('¥');
|
||||
$show->field('point_discount_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$show->field('total_amount')->as(fn($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||
$show->field('sales_value');
|
||||
$show->field('order_status')->as(fn() => $this->order_status)->using($this->statusMap)->dot($this->statusColor);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ return [
|
|||
'bargain_amount' => '砍价金额',
|
||||
'shipping_fee' => '运费',
|
||||
'products_total_amount' => '商品总额',
|
||||
'total_amount' => '订单总额',
|
||||
'order_total_amount' => '订单总额',
|
||||
'total_amount' => '实付金额',
|
||||
'weight' => '订单重量',
|
||||
'note' => '客户备注',
|
||||
'remark' => '订单备注',
|
||||
|
|
@ -58,7 +59,7 @@ return [
|
|||
'market_price' => '市场价',
|
||||
'cost_price' => '成本价',
|
||||
'out_trade_no' => '支付流水号',
|
||||
'point_discount_amount' => '积分',
|
||||
'point_discount_amount' => '积分抵扣',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ return [
|
|||
'shipping_fee' => '运费',
|
||||
'products_total_amount' => '商品总额',
|
||||
'product_total_amount'=>'商品总额',
|
||||
'total_amount' => '订单总额',
|
||||
'total_amount' => '实付金额',
|
||||
'weight' => '订单重量',
|
||||
'note' => '客户备注',
|
||||
'remark' => '订单备注',
|
||||
|
|
@ -62,6 +62,8 @@ return [
|
|||
'cost_price' => '成本价',
|
||||
'profit_price' => '毛利',
|
||||
'desk_id' => '桌号',
|
||||
'order_total_amount' => '订单总额',
|
||||
'point_discount_amount' => '积分抵扣',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue