예제 #1
0
파일: Cart.class.php 프로젝트: lughong/shop
 public static function addOrder($uid = 0, $username = '', $pay_name = '货到付款', $default_address_id = 0)
 {
     if ($uid) {
         //从购物车里获取到商品列表
         $cart_goods_list = Cart::select($uid);
         if ($cart_goods_list) {
             //计算订单总金额
             $order_total_data = self::getOrderTotal($cart_goods_list);
             $total = $order_total_data['total'];
             //运费
             $shipping_fee = self::getOrderShippingFee($total);
             //优惠
             $bonus = 0;
             //使用优惠券...
             //收货地址
             $address_info = UserAddress::getAddrByAddressId($uid, $default_address_id);
             if (!$address_info) {
                 $address_info = UserAddress::getDefaultAddress($uid);
             }
             $data['sn'] = self::createOrderSn();
             //订单号
             $data['uid'] = $uid;
             //用户id
             $data['username'] = $username;
             //用户名
             $data['order_status'] = 'yes';
             //订单有效
             $data['consignee'] = $address_info['consignee'];
             //联系人
             $data['province'] = $address_info['province'];
             //省
             $data['city'] = $address_info['city'];
             //市
             $data['district'] = $address_info['district'];
             //区
             $data['address'] = $address_info['address'];
             //详细地址
             $data['mobile'] = $address_info['mobile'];
             //手机或电话
             $data['shipping_fee'] = $shipping_fee;
             //运费
             $data['bonus'] = $bonus;
             //优惠
             $data['order_money'] = $total;
             //货物总金额
             $data['money_paid'] = $total + $shipping_fee + $bonus;
             //应付款金额
             $data['pay_name'] = $pay_name;
             //付款方式
             //非货到付款操作
             if ($pay_name !== '货到付款') {
                 $data['pay_time'] = time();
                 //支付时间
                 $data['confirm_status'] = 'yes';
                 //确认订单状态(非货到付款自动确认)
                 $data['confirm_time'] = time();
                 //确认订单时间
             }
             $rs = OrderInfo::addOrder($data);
             if ($rs) {
                 //下单成功,减少库存
                 AdminGoodsM::minusStock($cart_goods_list);
                 //添加到订单商品表
                 OrderGoodsInfo::addGoods($rs, $cart_goods_list);
                 //删除购物车里面的商品信息
                 $where = self::_where($uid);
                 Cart::delete($where);
             }
             //下单成功
             return $rs;
         }
     }
     //下单失败
     return false;
 }
예제 #2
0
파일: test.php 프로젝트: lughong/shop
 public function cart($goods_id, $goods_num)
 {
     if ($goods_id) {
         $uid = LuS::get('uid');
         $data['goods_id'] = $goods_id;
         $data['goods_num'] = $goods_num;
         // $data = $goods_id;
         //添加
         $rs_add = Cart::add($uid, $data);
         var_dump($rs_add);
         // //查询
         // $rs_select = Cart::getCartGoodsInfoByGoodsId( $uid, $goods_id );
         // var_dump( $rs_select );
         //数量减1
         $rs_decr = Cart::decr($uid, $goods_id, 1);
         var_dump($rs_decr);
         // //查询
         $rs_select = Cart::select($uid);
         var_dump($rs_select);
         //数量减1
         $rs_incr = Cart::incr($uid, $goods_id, 1);
         var_dump($rs_incr);
         // //查询
         $rs_select = Cart::select($uid);
         var_dump($rs_select);
     }
 }
예제 #3
0
 public function getSummary()
 {
     $this->_carts = Cart::select('carts.*')->join('orders', function ($q) {
         $q->on('carts.o_id', '=', 'orders.o_id')->where('orders.o_group_number', '=', $this->o_group_number);
     })->where('carts.c_status', '<>', -1)->get();
     foreach ($this->_carts as $key => $cart) {
         if (empty($this->_bills[$cart->b_id])) {
             if ($cart->c_status == 3) {
                 $this->_bills[$cart->b_id]['total']['paied'] = $cart->c_amount;
                 $this->_bills[$cart->b_id]['total_origin']['paied'] = $cart->c_amount_origin;
             } else {
                 $this->_bills[$cart->b_id]['total']['pending'] = $cart->c_amount;
                 $this->_bills[$cart->b_id]['total_origin']['pending'] = $cart->c_amount_origin;
             }
         } else {
             if ($cart->c_status == 3) {
                 $this->_bills[$cart->b_id]['total']['paied'] += $cart->c_amount;
                 $this->_bills[$cart->b_id]['total_origin']['paied'] += $cart->c_amount_origin;
             } else {
                 $this->_bills[$cart->b_id]['total']['pending'] += $cart->c_amount;
                 $this->_bills[$cart->b_id]['total_origin']['pending'] += $cart->c_amount_origin;
             }
         }
     }
 }
예제 #4
0
파일: goods.php 프로젝트: lughong/shop
 public function balance()
 {
     //是否已经登录
     User::isLogin();
     $uid = LuS::get('uid');
     //取出默认地址,没有默认地址默认为第一条
     $default_address = UserAddress::getDefaultAddress($uid);
     if ($default_address) {
         $default_address_id = $default_address['address_id'];
         //地址详情
         $address_detail = RegionM::getAddressDetail($default_address['province'], $default_address['city'], $default_address['district']);
         $default_address['address_detail'] = $address_detail . $default_address['address'];
         //电话
         $call = UserAddress::getDefaultCall($default_address);
         $default_address['call'] = $call;
     } else {
         $default_address = null;
         $default_address_id = 0;
     }
     //取出购物车信息
     $cart_goods_list = Cart::select($uid);
     if (!$cart_goods_list) {
         //购物车空空如也
         $url = HOMEURL;
         header('Location:' . $url);
         throw new Exception('exit');
     }
     $data = Cart::getOrderTotal($cart_goods_list);
     $total = $data['total'];
     $shipping_fee = Cart::getOrderShippingFee($total);
     $money_paid = $total + $shipping_fee;
     //下单链接
     $add_order_url = url('goods', 'goods::addtoorder');
     //详情链接,不带订单号,在页面上拼接上
     $order_detail_url = url('usercenter', 'usercenter::detail');
     //添加地址链接
     $add_addr_url = url('usercenter', 'usercenter::addaddr');
     //地址链接
     $addr_url = url('usercenter', 'usercenter::addr');
     //填写完地址后回跳
     $addr_jump_url = url('goods', 'goods::balance');
     LuS::set('addr_jump_url', $addr_jump_url);
     $smarty = get_smarty();
     $smarty->assign('total', $total);
     $smarty->assign('amount', $money_paid);
     $smarty->assign('shipping_fee', $shipping_fee);
     $smarty->assign('default_address_id', $default_address_id);
     $smarty->assign('default_address', $default_address);
     $smarty->assign('goods_list', $cart_goods_list);
     $smarty->assign('add_order_url', $add_order_url);
     $smarty->assign('order_detail_url', $order_detail_url);
     $smarty->assign('add_addr_url', $add_addr_url);
     $smarty->assign('addr_url', $addr_url);
     $smarty->display('goods/order.html');
 }
예제 #5
0
파일: cart.php 프로젝트: Torredo/autozip
<?php

require_once 'config.php';
$records = Cart::select(Config::sessionId());
$meta = Meta::select('section', 'cart');
include 'view/tpl_top.php';
include 'view/tpl_header.php';
include 'view/tpl_popup_zakaz.php';
include 'view/tpl_nav.php';
?>
<div class="container main-container">
    <div class="row">
        <div class="col-lg-3 col-md-3 col-sm-12">
            <?php 
include 'view/tpl_catalog.php';
?>
        </div>
        <div class="clearfix visible-sm"></div>
        <div class="col-lg-9 col-md-9 col-sm-12">
            <div class="col-lg-12 col-sm-12">
                <span class="title text-uppercase cart"><?php 
echo $records != false ? "Корзина товаров" : "Ваша корзина пуста";
?>
</span>
            </div>
            <?php 
if ($records != false) {
    ?>
            <div class="col-lg-12 col-sm-12 hero-feature body-cart">
                <div class="table-responsive">
                    <table class="table table-bordered tbl-cart">