From b185b74f6bacdffb53cd6e7a98fbcdbf30aa9dba Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sun, 28 Jun 2026 20:33:14 +0800 Subject: [PATCH] admin offline-order export --- .../OfflineOrderItemStatisticController.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/Admin/Controllers/OfflineOrderItemStatisticController.php b/app/Admin/Controllers/OfflineOrderItemStatisticController.php index e24f17af..a49f9078 100644 --- a/app/Admin/Controllers/OfflineOrderItemStatisticController.php +++ b/app/Admin/Controllers/OfflineOrderItemStatisticController.php @@ -118,7 +118,7 @@ class OfflineOrderItemStatisticController extends AdminController public function staff(Content $content) { $table = (new OfflineOrder())->getTable(); - $stores = Store::pluck('title', 'id'); + $stores = Store::query()->effective()->sort()->pluck('title', 'id'); $builder = OfflineOrder::query()->with(['staff', 'store'])->select([ "{$table}.staff_id", @@ -151,6 +151,30 @@ class OfflineOrderItemStatisticController extends AdminController $grid->disableFilterButton(); $grid->disableActions(); + $grid->export() + ->titles([ + 'staff_id' => '员工', + 'store_id' => '门店', + 'count' => '订单数', + 'products_total_amount' => '订单总额', + 'discount_reduction_amount' => '折扣优惠', + 'points_deduction_amount' => '积分抵扣', + 'coupon_discount_amount' => '优惠券抵扣', + 'payment_amount' => '实付金额', + ])->rows(function ($rows) { + foreach ($rows as $index => &$row) { + $row['staff_id'] = data_get($row, 'staff.phone'); + $row['store_id'] = data_get($row, 'store.title'); + $row['count'] = data_get($row, 'count'); + $row['products_total_amount'] = bcdiv(data_get($row, 'products_total_amount', 0), 100, 2); + $row['discount_reduction_amount'] = bcdiv(data_get($row, 'discount_reduction_amount', 0), 100, 2); + $row['points_deduction_amount'] = bcdiv(data_get($row, 'points_deduction_amount', 0), 100, 2); + $row['coupon_discount_amount'] = bcdiv(data_get($row, 'coupon_discount_amount', 0), 100, 2); + $row['payment_amount'] = bcdiv(data_get($row, 'payment_amount', 0), 100, 2); + } + return $rows; + })->filename("员工业绩统计"); + return $content ->translation($this->translation()) ->title("员工业绩统计")