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');