账单导出
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Recon;
|
||||
|
||||
use App\Exceptions\RepositoryException;
|
||||
use App\Exports\BillBatchExport;
|
||||
use App\Exports\BillExport;
|
||||
use App\Models\BillModel;
|
||||
use App\Models\StoreModel;
|
||||
@@ -60,6 +61,27 @@ class BillController extends BaseController
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出账单:同一门店的账单合并在一张工作表,不同门店拆分为多个工作表
|
||||
*/
|
||||
#[GetRoute(route: '/batch-export', authorize: 'export')]
|
||||
public function batchExport(Request $request): Response
|
||||
{
|
||||
$data = $request->validate([
|
||||
'ids' => 'required|array|min:1|max:100',
|
||||
'ids.*' => 'required|integer|distinct|exists:bill,id',
|
||||
]);
|
||||
|
||||
$bills = BillModel::query()
|
||||
->with('store:id,name')
|
||||
->whereIn('id', $data['ids'])
|
||||
->orderBy('bill_date')
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
return Excel::download(new BillBatchExport($bills), '门店账单_批量导出.xlsx');
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独导出账单:账单内明细按商品合并(可按一级分类过滤),
|
||||
* 表尾汇总商品金额/配送费/附加金额/售后金额/总金额
|
||||
|
||||
Reference in New Issue
Block a user