From a4ae19a64a3390e6e98ce8b2d6a7043c28e584bb Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 7 Jun 2024 14:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B4=A6=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/lists/StoreBillLists.php | 33 +++++++++++++++++-- .../store_finance_flow/StoreFinanceFlow.php | 15 +++++++-- .../finance/StoreBillController.php | 21 +----------- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/app/common/lists/StoreBillLists.php b/app/common/lists/StoreBillLists.php index 8109b6b1..a7f04c9b 100644 --- a/app/common/lists/StoreBillLists.php +++ b/app/common/lists/StoreBillLists.php @@ -3,10 +3,12 @@ namespace app\common\lists; use app\admin\lists\BaseAdminDataLists; +use app\common\enum\OrderEnum; +use app\common\enum\PayEnum; use app\common\model\store_finance_flow\StoreFinanceFlow; use think\db\Query; -class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface +class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface { public function setSearch(): array @@ -18,7 +20,7 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface public function lists(): array { $this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1; - return StoreFinanceFlow::where('1=1') + return StoreFinanceFlow::with(['user', 'staff']) ->when(!empty($this->request->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->request->adminInfo['store_id']); }) @@ -54,6 +56,13 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface ->order(['id' => 'desc']) ->select()->each(function ($item) { $item->month = date('m', strtotime($item->create_time)); + if (!empty($this->request->adminInfo['store_id'])) { + $item->pm_type = $item->financial_pm == 0 ? '收入' : '支出'; + } else { + $item->pm_type = $item->financial_pm == 0 ? '支出' : '收入'; + } + $item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']); + $item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']); }) ->toArray(); } @@ -95,4 +104,24 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface ->count(); } + public function setExcelFields(): array + { + return [ + 'financial_record_sn' => '交易单号', + 'order_sn' => '关联订单', + 'create_time' => '交易时间', + 'number' => '交易金额', + 'pm_type' => '支出收入', + 'nickname' => '交易人', + 'staff_name' => '关联店员', + 'financial_type_name' => '交易类型', + 'pay_type_name' => '支付方式', + ]; + } + + public function setFileName(): string + { + return '账单导出'; + } + } diff --git a/app/common/model/store_finance_flow/StoreFinanceFlow.php b/app/common/model/store_finance_flow/StoreFinanceFlow.php index 2dee7587..cbe88609 100644 --- a/app/common/model/store_finance_flow/StoreFinanceFlow.php +++ b/app/common/model/store_finance_flow/StoreFinanceFlow.php @@ -4,6 +4,8 @@ namespace app\common\model\store_finance_flow; use app\common\model\BaseModel; +use app\common\model\system_store\SystemStoreStaff; +use app\common\model\user\User; use think\model\concern\SoftDelete; @@ -18,5 +20,14 @@ class StoreFinanceFlow extends BaseModel protected $name = 'store_finance_flow'; protected $deleteTime = 'delete_time'; - -} \ No newline at end of file + public function user() + { + return $this->hasOne(User::class, 'id', 'user_id')->bind(['nickname']); + } + + public function staff() + { + return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']); + } + +} diff --git a/app/store/controller/finance/StoreBillController.php b/app/store/controller/finance/StoreBillController.php index f67b048c..426f7cdd 100644 --- a/app/store/controller/finance/StoreBillController.php +++ b/app/store/controller/finance/StoreBillController.php @@ -5,7 +5,6 @@ namespace app\store\controller\finance; use app\admin\lists\store_finance_flow\StoreFinanceFlowLists; use app\common\controller\Definitions; use app\common\lists\StoreBillLists; -use app\common\logic\StoreFinanceFlowLogic; use app\store\controller\BaseAdminController; use hg\apidoc\annotation as ApiDoc; @@ -22,6 +21,7 @@ class StoreBillController extends BaseAdminController ApiDoc\Query(name: 'type', type: 'int', require: false, desc: '类型:1日账单,2周账单,3月账单'), ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), + ApiDoc\Query(name: 'export', type: 'int', require: false, desc: '是否导出:2是'), ApiDoc\Header(ref: [Definitions::class, "token"]), ApiDoc\Query(ref: [Definitions::class, "page"]), ApiDoc\ResponseSuccess("data", type: "array"), @@ -51,23 +51,4 @@ class StoreBillController extends BaseAdminController return $this->dataLists(new StoreFinanceFlowLists()); } - #[ - ApiDoc\Title('下载'), - ApiDoc\url('/store/finance/storeBill/download'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\Param(name: 'remark', type: 'string', require: true, desc: '备注'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] - public function download(StoreFinanceFlowLogic $logic) - { - $id = $this->request->post('id'); - $remark = $this->request->post('remark'); - $logic->remark($id, $remark); - return $this->success('操作成功', [], 1, 1); - } - }