diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 3a5d00df..ad92412a 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -275,6 +275,31 @@ class Auth extends BaseController return app('json')->success('退出登录'); } + 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('用户店铺异常'); + } + $repository = app()->make(StoreOrderRepository::class); + $param = [ + "status" => 0, + "is_del" => 0, + "mer_id" => $merchant['mer_id'], + "pay_type" => 1, + "attach" => "meal", + "order_info" => '{"is_margin":1,"margin":"' . $merchant['margin'] . '"}', + "pay_price" => $merchant['margin'], + "order_sn" => "bzj" . date('YmdHis') . uniqid(), + "body" => $merchant['mer_name'] . ' - ' . $merchant['margin'], + ]; + $payType = 'weixinApp'; + $service = new PayService($payType, $param); + $payInfo = $service->pay(User::where(['uid'=>$user['uid']])->find()); + return app('json')->success($payInfo); + } + /** * @return mixed * @throws DataNotFoundException diff --git a/route/api.php b/route/api.php index 4516b79b..b799d9c0 100644 --- a/route/api.php +++ b/route/api.php @@ -67,7 +67,9 @@ Route::group('api/', function () { //绑定推荐人 Route::post('user/spread', 'api.Auth/spread'); - + //用户缴纳保证金 + Route::post('user/margin', 'api.Auth/doMargin'); + //优惠券 Route::group('coupon', function () { Route::post('receive/:id', 'api.store.product.StoreCoupon/receiveCoupon');