From ec86c3b6b761297311d5ac32d8bfdc932d478546 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 21 Jun 2024 16:56:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=94=B6=E9=93=B6?= =?UTF-8?q?=E5=8F=B0=E7=8E=B0=E9=87=91=E6=B5=81=E6=B0=B4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CashFlowLogic.php | 18 +++-- .../StoreCashFinanceFlowController.php | 66 +++++++++++++++++ .../StoreCashFinanceFlowLists.php | 72 +++++++++++++++++++ 3 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php create mode 100644 app/store/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php diff --git a/app/common/logic/CashFlowLogic.php b/app/common/logic/CashFlowLogic.php index ffaf446fb..9b0e3c728 100644 --- a/app/common/logic/CashFlowLogic.php +++ b/app/common/logic/CashFlowLogic.php @@ -11,11 +11,17 @@ class CashFlowLogic extends BaseLogic public function insert($storeId, $amount) { $model = new StoreCashFinanceFlow(); - $model->store_id = $storeId; - $model->cash_price = $amount; - $model->receivable = $amount; - $model->status = YesNoEnum::NO;//收银台收了默认算完成了 - $model->save(); + $find = $model->where(['store_id' => $storeId])->whereDay('create_time')->where('status', 0)->find(); + if ($find) { + $find->cash_price = bcadd($find->cash_price, $amount, 2); + $find->receivable = bcadd($find->receivable, $amount, 2); + $find->save(); + } else { + $model->store_id = $storeId; + $model->cash_price = $amount; + $model->receivable = $amount; + $model->status = YesNoEnum::NO; //收银台收了默认算完成了 + $model->save(); + } } - } diff --git a/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php b/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php new file mode 100644 index 000000000..280425504 --- /dev/null +++ b/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php @@ -0,0 +1,66 @@ +dataLists(new StoreCashFinanceFlowLists()); + } + + /** + * @notes 编辑现金流水 + * @return \think\response\Json + * @author admin + * @date 2024/06/06 10:29 + */ + public function edit() + { + $id=$this->request->post('id'); + $res=StoreCashFinanceFlow::where(['store_id'=>$this->adminInfo['store_id'],'id'=>$id])->update(['store_status'=>1]); + if ($res) { + return $this->success('上交成功,等待财务审核', [], 1, 1); + } + return $this->fail('没有更新'); + } + + /** + * @notes 获取现金流水详情 + * @return \think\response\Json + * @author admin + * @date 2024/06/06 10:29 + */ + public function detail() + { + $params = (new StoreCashFinanceFlowValidate())->goCheck('detail'); + $result = StoreCashFinanceFlowLogic::detail($params); + $result['image']='https://lihaiim.oss-cn-chengdu.aliyuncs.com/public/uploads/images/20240619/20240619104553f7e108704.jpg'; + $result['bank_code']='456565656'; + $result['bank_name']='里海农科'; + $result['bank_address']='泸州支行'; + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/store/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php b/app/store/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php new file mode 100644 index 000000000..a1d1ff1a5 --- /dev/null +++ b/app/store/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php @@ -0,0 +1,72 @@ + 'create_time' + ]; + } + + + /** + * @notes 获取现金流水列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/06 10:29 + */ + public function lists(): array + { + $this->searchWhere[]=['store_id','=',$this->adminInfo['store_id']]; + return StoreCashFinanceFlow::where($this->searchWhere) + ->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($item) { + $item->store_name =SystemStore::where('id', $item->store_id)->value('name'); + if($item->admin_id>0){ + $item->admin_name =Admin::where('id', $item->admin_id)->value('name'); + } + }) + ->toArray(); + } + + + /** + * @notes 获取现金流水数量 + * @return int + * @author admin + * @date 2024/06/06 10:29 + */ + public function count(): int + { + return StoreCashFinanceFlow::where($this->searchWhere)->count(); + } + +} \ No newline at end of file