From 0b6cff83cfc514f23dd62ef46e2ee12ab66b7751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E5=B3=B0?= <1feng.0595@gmail.com> Date: Fri, 17 Nov 2017 00:15:17 +0800 Subject: [PATCH] checkout bug --- .../Admin/WeixinMenuController.php | 4 ++-- .../Controllers/Weixin/CartController.php | 23 +++++++++++-------- app/Http/Model/Cart.php | 9 +++++--- .../views/admin/WeixinMenu/index.blade.php | 2 +- .../views/weixin/cart/cartCheckout.blade.php | 8 +++---- resources/views/weixin/cart/index.blade.php | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/Admin/WeixinMenuController.php b/app/Http/Controllers/Admin/WeixinMenuController.php index c110d0d..6c94cfe 100644 --- a/app/Http/Controllers/Admin/WeixinMenuController.php +++ b/app/Http/Controllers/Admin/WeixinMenuController.php @@ -49,7 +49,7 @@ class WeixinMenuController extends CommonController unset($_POST["prid"]); unset($_POST["_token"]); - if(DB::table('weixin_menu')->insert(array_filter($_POST))) + if(DB::table('weixin_menu')->insert($_POST)) { success_jump('添加成功!'); } @@ -79,7 +79,7 @@ class WeixinMenuController extends CommonController $_POST['addtime'] = time(); //添加时间 unset($_POST["_token"]); - if(DB::table('weixin_menu')->where('id', $id)->update(array_filter($_POST))) + if(DB::table('weixin_menu')->where('id', $id)->update($_POST)) { success_jump('修改成功!', route('admin_weixinmenu')); } diff --git a/app/Http/Controllers/Weixin/CartController.php b/app/Http/Controllers/Weixin/CartController.php index 9a4a674..910979c 100644 --- a/app/Http/Controllers/Weixin/CartController.php +++ b/app/Http/Controllers/Weixin/CartController.php @@ -38,15 +38,6 @@ class CartController extends CommonController //购物车结算 public function cartCheckout($ids) { - //购物车结算商品列表 - $postdata = array( - 'ids' => $ids, - 'access_token' => $_SESSION['weixin_user_info']['access_token'] - ); - $url = env('APP_API_URL')."/cart_checkout_goods_list"; - $res = curl_request($url,$postdata,'GET'); - $data['list'] = $res['data']['list']; - //支付方式列表 $postdata = array( 'status' => 1, @@ -82,6 +73,20 @@ class CartController extends CommonController $res = curl_request($url,$postdata,'GET'); $data['user_info'] = $res['data']; + //购物车结算商品列表 + $postdata = array( + 'ids' => $ids, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/cart_checkout_goods_list"; + $res = curl_request($url,$postdata,'GET'); + $data['checkout_goods'] = $res['data']; + + //判断余额是否足够 + $is_balance_enough = 1; //足够 + if($data['checkout_goods']['total_price']>$data['user_info']['money']){$is_balance_enough = 0;} + $data['is_balance_enough'] = $is_balance_enough; + return view('weixin.cart.cartCheckout', $data); } } \ No newline at end of file diff --git a/app/Http/Model/Cart.php b/app/Http/Model/Cart.php index db049ce..138e760 100644 --- a/app/Http/Model/Cart.php +++ b/app/Http/Model/Cart.php @@ -198,7 +198,8 @@ class Cart extends BaseModel // 获取购物车列表 $cartList = self::where(array('user_id'=>$user_id))->whereIn('id', $cartIds)->get(); - $total_price = 0;//总金额 + $total_price = 0; //商品总金额 + $total_goods = 0; //商品总数量 if(!empty($cartList)) { @@ -217,12 +218,14 @@ class Cart extends BaseModel $cartList[$k]->title = $goods->title; $cartList[$k]->litpic = $goods->litpic; - $total_price += $cartList[$k]->final_price*$tempInfo['price']; + $total_price = $total_price + $cartList[$k]->final_price*$cartList[$k]->goods_number; + $total_goods = $total_goods + $cartList[$k]->goods_number; } } $res['list'] = $cartList; - $res['list'] = $cartList; + $res['total_price'] = $total_price; + $res['total_goods'] = $total_goods; return ReturnData::create(ReturnData::SUCCESS,$res); } diff --git a/resources/views/admin/WeixinMenu/index.blade.php b/resources/views/admin/WeixinMenu/index.blade.php index f7c635f..59da6d1 100644 --- a/resources/views/admin/WeixinMenu/index.blade.php +++ b/resources/views/admin/WeixinMenu/index.blade.php @@ -12,7 +12,7 @@ "> 否';} ?> -">增加子类 | ">更改 | ')" href="javascript:;">删除 +">更改 | ')" href="javascript:;">删除 | ">增加子类 diff --git a/resources/views/weixin/cart/cartCheckout.blade.php b/resources/views/weixin/cart/cartCheckout.blade.php index e652b94..423eea4 100644 --- a/resources/views/weixin/cart/cartCheckout.blade.php +++ b/resources/views/weixin/cart/cartCheckout.blade.php @@ -41,7 +41,7 @@ function selectaddress()