Browse Source

checkout bug

master
林一峰 7 years ago
parent
commit
0b6cff83cf
  1. 4
      app/Http/Controllers/Admin/WeixinMenuController.php
  2. 23
      app/Http/Controllers/Weixin/CartController.php
  3. 9
      app/Http/Model/Cart.php
  4. 2
      resources/views/admin/WeixinMenu/index.blade.php
  5. 8
      resources/views/weixin/cart/cartCheckout.blade.php
  6. 2
      resources/views/weixin/cart/index.blade.php

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

23
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);
}
}

9
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);
}

2
resources/views/admin/WeixinMenu/index.blade.php

@ -12,7 +12,7 @@
<tr id="cat-<?php echo $row["id"]; ?>">
<td><?php echo $row["id"]; ?></td>
<td><?php if($row["pid"]!=0){echo "";}echo $row["name"]; ?></td><td><?php echo $row["type"]; ?></td><td><?php if($row["is_show"]==0){echo '是';}else{echo '<font color="red">否</font>';} ?></td><td><?php echo date('Y-m-d',$row["addtime"]); ?></td>
<td><?php if($row["pid"]==0){ ?><a href="/fladmin/weixinmenu/add?reid=<?php echo $row["id"]; ?>">增加子类</a> | <?php } ?><a href="/fladmin/weixinmenu/edit?id=<?php echo $row["id"]; ?>">更改</a> | <a onclick="delconfirm('/fladmin/weixinmenu/del?id=<?php echo $row["id"]; ?>')" href="javascript:;">删除</a></td>
<td><a href="/fladmin/weixinmenu/edit?id=<?php echo $row["id"]; ?>">更改</a> | <a onclick="delconfirm('/fladmin/weixinmenu/del?id=<?php echo $row["id"]; ?>')" href="javascript:;">删除</a><?php if($row["pid"]==0){ ?> | <a href="/fladmin/weixinmenu/add?reid=<?php echo $row["id"]; ?>">增加子类</a><?php } ?></td>
</tr><?php }} ?>
</tbody></table></div><!-- 表格结束 --></form><!-- 表单结束 -->

8
resources/views/weixin/cart/cartCheckout.blade.php

@ -41,7 +41,7 @@ function selectaddress()
<!-- 选择收货地址-end -->
<!-- 订单商品列表-start -->
<ul class="goodslist">
<?php if($list){foreach($list as $k=>$v){ ?>
<?php if($checkout_goods['list']){foreach($checkout_goods['list'] as $k=>$v){ ?>
<li>
<img src="<?php echo $v['litpic']; ?>">
<p><b><?php echo $v['title']; ?></b><span>¥<?php echo $v['final_price']; ?><i>x<?php echo $v['goods_number']; ?></i></span></p>
@ -73,7 +73,7 @@ function selectaddress()
{
//询问框
layer.open({
content: '<div style="padding:15px;"><a style="margin-bottom:10px;background-color:#1aad19;border:1px solid #179e16;color:white;text-align:center;border-radius:2px;" class="bottoma" onclick="layer.closeAll();" href="javascript:update_pay_mode(1,\'余额支付\');">账户余额 <?php echo $user_info['money']; ?>元</a><a style="margin-bottom:10px;background-color:#ea5a3d;border:1px solid #dd2727;color:white;border-radius:2px;text-align:center;" class="bottoma" onclick="layer.closeAll();" href="javascript:update_pay_mode(2,\'微信支付\');">微信支付</a></div>'
content: '<div style="padding:15px;"><?php if($is_balance_enough){ ?><a style="margin-bottom:10px;background-color:#1aad19;border:1px solid #179e16;color:white;border-radius:2px;text-align:center;" class="bottoma" onclick="layer.closeAll();" href="javascript:update_pay_mode(1,\'余额支付\');">账户余额 <?php echo $user_info['money']; ?>元</a><?php }else{ ?><a style="margin-bottom:10px;background-color:#999;border:1px solid #999;color:white;border-radius:2px;text-align:center;" class="bottoma" href="javascript:;">余额不足 <?php echo $user_info['money']; ?>元</a><?php } ?><a style="background-color:#ea5a3d;border:1px solid #dd2727;color:white;border-radius:2px;text-align:center;" class="bottoma" onclick="layer.closeAll();" href="javascript:update_pay_mode(2,\'微信支付\');">微信支付</a></div>'
});
}
@ -98,10 +98,10 @@ function selectaddress()
<textarea name="message" rows="3" placeholder="给卖家留言"></textarea>
</div>
<div class="order_check_info">
<p>1件商品</p>
<p><?php echo $checkout_goods['total_goods']; ?>件商品</p>
<p>运费:¥0</p>
<p>满¥15.00减¥1.00</p>
<p>商品总价:¥99</span></p>
<p>商品总价:¥<?php echo $checkout_goods['total_price']; ?></span></p>
<p>应付款金额:<span class="red">¥<i id="totalamount">99</i></span></p>
</div>
</div>

2
resources/views/weixin/cart/index.blade.php

@ -156,7 +156,7 @@ function change_goods_number(type, id)
{
//提示
layer.open({
content: '姓名不能为空'
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});

Loading…
Cancel
Save