From 875bb256fd3a11cd90b9344d2020602a6a102322 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 29 Nov 2023 09:44:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PayOrderController.php | 108 +++++++++++++++ app/adminapi/lists/PayOrderLists.php | 78 +++++++++++ app/adminapi/logic/PayOrderLogic.php | 130 ++++++++++++++++++ app/adminapi/validate/PayOrderValidate.php | 116 ++++++++++++++++ app/common/model/PayOrder.php | 34 +++++ 5 files changed, 466 insertions(+) create mode 100644 app/adminapi/controller/PayOrderController.php create mode 100644 app/adminapi/lists/PayOrderLists.php create mode 100644 app/adminapi/logic/PayOrderLogic.php create mode 100644 app/adminapi/validate/PayOrderValidate.php create mode 100644 app/common/model/PayOrder.php diff --git a/app/adminapi/controller/PayOrderController.php b/app/adminapi/controller/PayOrderController.php new file mode 100644 index 0000000..8991b87 --- /dev/null +++ b/app/adminapi/controller/PayOrderController.php @@ -0,0 +1,108 @@ +dataLists(new PayOrderLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function add() + { + $params = (new PayOrderValidate())->post()->goCheck('add'); + $result = PayOrderLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(PayOrderLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function edit() + { + $params = (new PayOrderValidate())->post()->goCheck('edit'); + $result = PayOrderLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(PayOrderLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function delete() + { + $params = (new PayOrderValidate())->post()->goCheck('delete'); + PayOrderLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function detail() + { + $params = (new PayOrderValidate())->goCheck('detail'); + $result = PayOrderLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/PayOrderLists.php b/app/adminapi/lists/PayOrderLists.php new file mode 100644 index 0000000..6e779d2 --- /dev/null +++ b/app/adminapi/lists/PayOrderLists.php @@ -0,0 +1,78 @@ + ['collection_account', 'order_no', 'business_order_no', 'pay_type', 'pay_status', 'transaction_id', 'finish_time'], + 'between' => ['order_from', 'order_type'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function lists(): array + { + return PayOrder::where($this->searchWhere) + ->field(['id', 'order_from', 'order_type', 'collection_account', 'pay_user_role', 'pay_user_info', 'order_no', 'business_order_no', 'total_fee', 'pay_type', 'pay_status', 'transaction_id', 'finish_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function count(): int + { + return PayOrder::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/PayOrderLogic.php b/app/adminapi/logic/PayOrderLogic.php new file mode 100644 index 0000000..2a6356d --- /dev/null +++ b/app/adminapi/logic/PayOrderLogic.php @@ -0,0 +1,130 @@ + $params['order_from'], + 'order_type' => $params['order_type'], + 'collection_account' => $params['collection_account'], + 'pay_user_role' => $params['pay_user_role'], + 'pay_user_info' => $params['pay_user_info'], + 'order_no' => $params['order_no'], + 'business_order_no' => $params['business_order_no'], + 'total_fee' => $params['total_fee'], + 'pay_type' => $params['pay_type'], + 'pay_status' => $params['pay_status'], + 'business_callback_url' => $params['business_callback_url'], + 'transaction_id' => $params['transaction_id'], + 'finish_time' => $params['finish_time'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + PayOrder::where('id', $params['id'])->update([ + 'order_from' => $params['order_from'], + 'order_type' => $params['order_type'], + 'collection_account' => $params['collection_account'], + 'pay_user_role' => $params['pay_user_role'], + 'pay_user_info' => $params['pay_user_info'], + 'order_no' => $params['order_no'], + 'business_order_no' => $params['business_order_no'], + 'total_fee' => $params['total_fee'], + 'pay_type' => $params['pay_type'], + 'pay_status' => $params['pay_status'], + 'business_callback_url' => $params['business_callback_url'], + 'transaction_id' => $params['transaction_id'], + 'finish_time' => $params['finish_time'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public static function delete(array $params): bool + { + return PayOrder::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public static function detail($params): array + { + return PayOrder::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/PayOrderValidate.php b/app/adminapi/validate/PayOrderValidate.php new file mode 100644 index 0000000..ea8820c --- /dev/null +++ b/app/adminapi/validate/PayOrderValidate.php @@ -0,0 +1,116 @@ + 'require', + 'order_from' => 'require', + 'order_type' => 'require', + 'collection_account' => 'require', + 'pay_user_role' => 'require', + 'pay_user_info' => 'require', + 'order_no' => 'require', + 'business_order_no' => 'require', + 'total_fee' => 'require', + 'pay_type' => 'require', + 'pay_status' => 'require', + 'business_callback_url' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'order_from' => '订单来源1商城2供销', + 'order_type' => '订单类型', + 'collection_account' => '收款账户', + 'pay_user_role' => '付款角色', + 'pay_user_info' => '付款方信息', + 'order_no' => '支付订单编号', + 'business_order_no' => '业务系统订单编号', + 'total_fee' => '总金额', + 'pay_type' => '支付方式', + 'pay_status' => '支付状态', + 'business_callback_url' => '业务系统异步通知地址', + ]; + + + /** + * @notes 添加场景 + * @return PayOrderValidate + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function sceneAdd() + { + return $this->only(['order_from','order_type','collection_account','pay_user_role','pay_user_info','order_no','business_order_no','total_fee','pay_type','pay_status','business_callback_url']); + } + + + /** + * @notes 编辑场景 + * @return PayOrderValidate + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function sceneEdit() + { + return $this->only(['id','order_from','order_type','collection_account','pay_user_role','pay_user_info','order_no','business_order_no','total_fee','pay_type','pay_status','business_callback_url']); + } + + + /** + * @notes 删除场景 + * @return PayOrderValidate + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return PayOrderValidate + * @author likeadmin + * @date 2023/11/24 18:08 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/PayOrder.php b/app/common/model/PayOrder.php new file mode 100644 index 0000000..1d38067 --- /dev/null +++ b/app/common/model/PayOrder.php @@ -0,0 +1,34 @@ +