From 4c224f31be8c5631a696f870f2bd805200e81e4c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 17:01:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8A=BC=E9=87=91=E7=BC=B4=E7=BA=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/server/StoreOrder.php | 66 +++++++++++++++++++ .../api/store/merchant/Merchant.php | 19 ++++++ route/api.php | 2 + 3 files changed, 87 insertions(+) diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index bc4960ea..f825e737 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -353,4 +353,70 @@ class StoreOrder extends BaseController return app('json')->success('订单核销成功'); } + /** + * 订单结算 + * @return mixed + * @throws \Psr\SimpleCache\InvalidArgumentException + */ + public function settle(StoreOrderRepository $repository) + { + $id = $this->request->param('id/d'); + $payType = $this->request->param('pay_type'); + if ($payType == 'creditBuy') { + return app('json')->fail('支付方式不支持'); + } + try { + $data = $repository->settle($id, $payType, $this->request->userInfo()); + return app('json')->success('success', $data); + } catch (\Exception $e) { + return app('json')->fail($e->getMessage()); + } + } + + /** + * 确认接单 + * @return mixed + */ + public function confirm(StoreOrderRepository $repository) + { + $id = $this->request->param('id/d'); + $type = $this->request->param('type/d'); + try { + $repository->confirm($id, $type); + return app('json')->success('success'); + } catch (\Exception $e) { + return app('json')->fail($e->getMessage()); + } + } + + /** + * 采购订单列表 + * @param $merId + * @param StoreOrderRepository $orderRepository + * @return \think\Collection + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function purchaseOrder($merId, StoreOrderRepository $orderRepository) + { + [$page, $limit] = $this->getPage(); + $keyword = $this->request->param('keyword'); + $list = $orderRepository->purchaseOrder(['mer_id' => $merId], $keyword, $page, $limit); + return app('json')->success($list); + } + + + /** + * 获取商户押金列表 + */ + public function getOrderAutoMarginList($merId){ + [$page, $limit] = $this->getPage(); + $select= Db::name('financial_record')->where('mer_id',$merId) + ->where('financial_type','auto_margin') + ->page($page)->limit($limit)->order('financial_record_id','desc')->select(); + return app('json')->success($select); + + } + } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index ebf147ea..0d0e9c16 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -365,6 +365,25 @@ class Merchant extends BaseController + public function marginInfo(MerchantTakeRepository $repository) + { + $id = $this->request->param('id'); + if (empty($id)) { + return app('json')->fail('参数不能为空'); + } + $merchantInfo = Db::name('merchant')->where('mer_id', $id)->field('uid,mer_id,type_id,mer_name,margin,paid_margin,is_margin')->find(); + if (empty($merchantInfo)) { + return app('json')->fail('参数错误'); + } + $merchantInfo['unpaid_margin'] = bcsub($merchantInfo['margin'], $merchantInfo['paid_margin'], 2); + if ($merchantInfo['margin'] <= 0) { + $merchantInfo['unpaid_margin'] = 0; + $merchantInfo['paid_margin'] = 0; + } + return app('json')->success($merchantInfo); + } + + diff --git a/route/api.php b/route/api.php index 0899daad..756a2ba3 100644 --- a/route/api.php +++ b/route/api.php @@ -308,6 +308,7 @@ Route::group('api/', function () { //管理员订单 Route::group('admin/:merId', function () { Route::get('/statistics', '/orderStatistics'); + Route::get('/auto_margin', '/getOrderAutoMarginList'); Route::get('/order_price', '/orderDetail'); Route::get('/order_list', '/orderList'); Route::get('/order/:id', '/order'); @@ -546,6 +547,7 @@ Route::group('api/', function () { //编辑商户信息 Route::post('update', 'Merchant/update'); Route::get('info', 'Merchant/info'); + Route::get('margin', 'Merchant/marginInfo'); })->prefix('api.store.merchant.'); Route::post('store/certificate/:merId', 'api.Auth/getMerCertificate'); 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 2/2] =?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'); //用户信息