From defd8b9e51b001c870e4af72ce17c61997d54adc Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 17:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 59 +++++++++++++++++++++++++++++++++++++ route/api.php | 5 ++++ 2 files changed, 64 insertions(+) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index d888a167..5a329951 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -23,6 +23,7 @@ use app\common\model\store\order\StoreOrderStatus; use app\common\model\store\order\StoreRefundOrder; use app\common\model\system\merchant\FinancialRecord; use app\common\model\system\merchant\Merchant; +use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserBill; use app\common\model\user\UserRecharge; @@ -38,6 +39,7 @@ use app\validate\api\ChangePasswordValidate; use app\validate\api\UserAuthValidate; use crmeb\basic\BaseController; use crmeb\services\MiniProgramService; +use crmeb\services\PayService; use crmeb\services\SmsService; use crmeb\services\WechatService; use Exception; @@ -921,4 +923,61 @@ class Auth extends BaseController return app('json')->success($data); } + public function marginList() + { + $user = $this->request->userInfo(); + [$page, $limit] = $this->getPage(); + $count = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->count(); + $list = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->page($page, $limit)->order('order_id', 'desc')->select()->toArray(); + return app('json')->success(compact('count', 'list')); + } + + + public function doMargin() + { + $user = $this->request->userInfo(); + $merchant = Db::name('merchant')->where('uid', $user['uid'])->where('status', 1)->find(); + if (!$merchant) { + return app('json')->fail('没有店铺'); + } + if ($merchant['is_margin'] == 10) { + return app('json')->fail('押金已缴纳'); + } + if ($merchant['margin'] == 0) { + $margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin'); + $margin = bcsub($margin, $merchant['paid_margin'], 2); + } else { + $margin = $merchant['margin']; + } + if ($margin == 0) { + return app('json')->fail('当前金额为0,不能进行充值'); + } + $orderSn = "bzj" . date('YmdHis') . uniqid(); + Db::name('margin_order')->insert([ + 'uid' => $user['uid'], + 'mer_id' => $merchant['mer_id'], + 'order_sn' => $orderSn, + 'total_price' => $margin, + 'pay_type' => 1, + 'create_time' => date('Y-m-d H:i:s') + ]); + $param = [ + "status" => 0, + "is_del" => 0, + "mer_id" => $merchant['mer_id'], + "pay_type" => 1, + "attach" => "margin", + "order_info" => '{"is_margin":1,"margin":"' . $margin . '"}', + "pay_price" => $margin, + "order_sn" => $orderSn, + "body" => $merchant['mer_name'] . ' - ' . $margin, + ]; + $payType = 'weixinApp'; + $service = new PayService($payType, $param); + $payInfo = $service->pay(User::where(['uid' => $user['uid']])->find()); + return app('json')->success($payInfo); + } + + + } diff --git a/route/api.php b/route/api.php index 756a2ba3..c89ea11e 100644 --- a/route/api.php +++ b/route/api.php @@ -40,6 +40,11 @@ Route::group('api/', function () { })->prefix('api.store.order.StoreOrder'); }); + //用户缴纳押金 + Route::post('user/margin', 'api.Auth/doMargin'); + Route::get('user/margin/list', 'api.Auth/marginList'); + + //退出登录 Route::post('logout', 'api.Auth/logout'); //用户信息