From 506e4db0b0561a98f9ad11bf102f2af930c648c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwanyongkang=E2=80=9D?= <“937888580@qq.com”> Date: Mon, 21 Mar 2022 17:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E8=B7=AF=E7=94=B1=E4=BA=A7=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/Alipay.php | 79 ++++++++++++++++++++++++++++++++++ app/ros/controller/Buyer.php | 48 +++++++++++++++++++++ app/ros/controller/Index.php | 16 +++++++ app/ros/controller/Product.php | 18 ++++++++ app/ros/model/Buyer.php | 9 ++++ app/ros/model/Product.php | 9 ++++ 6 files changed, 179 insertions(+) create mode 100644 app/common/Alipay.php create mode 100644 app/ros/controller/Buyer.php create mode 100644 app/ros/controller/Index.php create mode 100644 app/ros/controller/Product.php create mode 100644 app/ros/model/Buyer.php create mode 100644 app/ros/model/Product.php diff --git a/app/common/Alipay.php b/app/common/Alipay.php new file mode 100644 index 0000000..d6198b9 --- /dev/null +++ b/app/common/Alipay.php @@ -0,0 +1,79 @@ +payVerify($_POST); + + if($flag){ + + $status = $_POST['trade_status']; + + $flag = false; + + if ($status == 'TRADE_SUCCESS' && $_POST['auth_app_id'] == '2021002102631089' && $_POST['seller_id'] = '2088431603383955') { + $flag = true; + } + + if ($flag) { + + $invest_service = new InvestModel(); + $update_data = []; + $order_no=$_POST['out_trade_no']; + $alipay_no = $_POST['trade_no']; + + + + //获取充值信息 + $invest_info = $invest_service->getOne(['order_no'=>$order_no]); + + //更新余额 + $user_model = new UserModel(); + + $money = abs($invest_info['money']); + $userid = $invest_info['user_id']; + + $balance = $user_model->getOne(['id'=>$userid],'balance')['balance']; + $old_balance= $balance; + + $balance += $money; + + $data = [ + 'balance' => $balance + ]; + + $user_model->updateOne(['id'=>$userid,'balance'=>$old_balance],$data); + $balance_model = new BalanceModel(); + $balance_data = [ + 'user_id' => $userid, + 'money' => $money, + 'old_balance' => $old_balance, + 'new_balance' => $balance, + 'type' => 1, + ]; + $balance_model->add($balance_data); + //更新充值订单 + $update_data['alipay_no'] = $alipay_no; + $update_data['status'] = 1; + $update_data['old_money'] = $old_balance; + $update_data['new_money'] = $balance; + $invest_service->updateOne(['order_no'=>$order_no],$update_data); + } + } + + echo 'success'; + } +} \ No newline at end of file diff --git a/app/ros/controller/Buyer.php b/app/ros/controller/Buyer.php new file mode 100644 index 0000000..013fd08 --- /dev/null +++ b/app/ros/controller/Buyer.php @@ -0,0 +1,48 @@ +userinfo['UserId'])) { + die; + } + } + + //获取产品列表 + public function getBuyerInfo() { + $buyer_model = new BuyerModel(); + + $info = $buyer_model->getOne(['user_id'=>$this->userinfo['UserId']]); + echo json_encode($info); + } + + public function updateBuyerInfo() { + $userinfo = json_decode(file_get_contents("php://input"),true)['user_info']; + $userinfo['user_id'] = $this->userinfo['UserId']; + + if (empty($userinfo['name']) || empty($userinfo['phone']) || empty($userinfo['address'])) { + echo json_encode(['code' => -1]); + die; + } + + $buyer_model = new BuyerModel(); + + $info = $buyer_model->getOne(['user_id'=>$this->userinfo['UserId']]); + + $flag = false; + if (empty($info)) { + $flag = $buyer_model->add($userinfo); + } else { + $flag = $buyer_model->updateOne(['user_id'=>$this->userinfo['UserId']],$userinfo); + } + echo json_encode(['code' => 1]); + } +} \ No newline at end of file diff --git a/app/ros/controller/Index.php b/app/ros/controller/Index.php new file mode 100644 index 0000000..3053ad8 --- /dev/null +++ b/app/ros/controller/Index.php @@ -0,0 +1,16 @@ +getList([],'*','id asc'); + echo json_encode($list); + } +} \ No newline at end of file diff --git a/app/ros/controller/Product.php b/app/ros/controller/Product.php new file mode 100644 index 0000000..2baa254 --- /dev/null +++ b/app/ros/controller/Product.php @@ -0,0 +1,18 @@ +getOne(['user_id'=>$this->userinfo['UserId']]); + echo json_encode($info); + } +} \ No newline at end of file diff --git a/app/ros/model/Buyer.php b/app/ros/model/Buyer.php new file mode 100644 index 0000000..a4a13e8 --- /dev/null +++ b/app/ros/model/Buyer.php @@ -0,0 +1,9 @@ +