Esempio n. 1
0
 /**
  * 订单详情
  */
 public function order_detail()
 {
     $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;
     // 订单详情
     $order = model('Users')->get_order_detail($order_id, $this->user_id);
     if ($order['order_status'] == OS_UNCONFIRMED) {
         $order['handler'] = "<a class=\"btn btn-info ect-colorf\" href=\"" . url('user/cancel_order', array('order_id' => $order['order_id'])) . "\" onclick=\"if (!confirm('" . L('confirm_cancel') . "')) return false;\">" . L('cancel') . "</a>";
     } else {
         if ($order['order_status'] == OS_SPLITED) {
             /* 对配送状态的处理 */
             if ($order['shipping_status'] == SS_SHIPPED) {
                 @($order['handler'] = "<a class=\"btn btn-info ect-colorf\" href=\"" . url('user/affirm_received', array('order_id' => $order['order_id'])) . "\" onclick=\"if (!confirm('" . L('confirm_received') . "')) return false;\">" . L('received') . "</a>");
             } elseif ($order['shipping_status'] == SS_RECEIVED) {
                 @($order['handler'] = '<a class="btn btn-info ect-colorf" type="button" href="javascript:void(0);">' . L('ss_received') . '</a>');
             } else {
                 if ($order['pay_status'] == PS_UNPAYED) {
                     @($order['handler'] = "<a class=\"btn btn-infoect-colorf\" href=\"" . url('user/cancel_order', array('order_id' => $order['order_id'])) . "\">" . L('pay_money') . "</a>");
                 } else {
                     // @$order['handler'] = "<a class=\"btn btn-info ect-colorf\" href=\"javascript:void(0);\">" . L('view_order') . "</a>";
                 }
             }
         } else {
             $order['handler'] = '<a class="btn btn-info ect-colorf" type="button" href="javascript:void(0);">' . L('os.' . $order['order_status']) . '</a>';
         }
     }
     if ($order === false) {
         ECTouch::err()->show(L('back_home_lnk'), './');
         exit;
     }
     // 订单商品
     $goods_list = model('Order')->order_goods($order_id);
     foreach ($goods_list as $key => $value) {
         $goods_list[$key]['market_price'] = price_format($value['market_price'], false);
         $goods_list[$key]['goods_price'] = price_format($value['goods_price'], false);
         $goods_list[$key]['subtotal'] = price_format($value['subtotal'], false);
         $goods_list[$key]['tags'] = model('ClipsBase')->get_tags($value['goods_id']);
         $goods_list[$key]['goods_thumb'] = get_image_path($order_id, $value['goods_thumb']);
     }
     // 设置能否修改使用余额数
     if ($order['order_amount'] > 0) {
         if ($order['order_status'] == OS_UNCONFIRMED || $order['order_status'] == OS_CONFIRMED) {
             $user = model('Order')->user_info($order['user_id']);
             if ($user['user_money'] + $user['credit_line'] > 0) {
                 $this->assign('allow_edit_surplus', 1);
                 $this->assign('max_surplus', sprintf(L('max_surplus'), $user['user_money']));
             }
         }
     }
     // 未发货,未付款时允许更换支付方式
     if ($order['order_amount'] > 0 && $order['pay_status'] == PS_UNPAYED && $order['shipping_status'] == SS_UNSHIPPED) {
         $payment_list = model('Order')->available_payment_list(false, 0, true);
         // 过滤掉当前支付方式和余额支付方式
         if (is_array($payment_list)) {
             foreach ($payment_list as $key => $payment) {
                 // 如果不是微信浏览器访问并且不是微信会员 则不显示微信支付
                 if ($payment['pay_code'] == 'wxpay' && !is_wechat_browser() && empty($_SESSION['openid'])) {
                     unset($payment_list[$key]);
                 }
                 // 兼容过滤ecjia支付方式
                 if (substr($payment['pay_code'], 0, 4) == 'pay_') {
                     unset($payment_list[$key]);
                 }
                 if ($payment['pay_id'] == $order['pay_id'] || $payment['pay_code'] == 'balance') {
                     unset($payment_list[$key]);
                 }
             }
         }
         $this->assign('payment_list', $payment_list);
     }
     $order['pay_desc'] = html_out($order['pay_desc']);
     // 如果是银行汇款或货到付款 则显示支付描述
     $payment = model('Order')->payment_info($order['pay_id']);
     if ($payment['pay_code'] == 'bank' || $payment['pay_code'] == 'cod') {
         $this->assign('pay_desc', $payment['pay_desc']);
     }
     // 如果是微信支付 不允许再使用余额修改订单价格后支付
     if ($payment['pay_code'] == 'wxpay') {
         $this->assign('allow_edit_surplus', 0);
     }
     // 订单 支付 配送 状态语言项
     $order['order_status'] = L('os.' . $order['order_status']);
     $order['pay_status'] = L('ps.' . $order['pay_status']);
     $order['shipping_status'] = L('ss.' . $order['shipping_status']);
     $this->assign('title', L('order_detail'));
     $this->assign('order', $order);
     $this->assign('goods_list', $goods_list);
     $this->display('user_order_detail.dwt');
 }
Esempio n. 2
0
 /**
  *  提交订单
  */
 public function done()
 {
     /* 取得购物类型 */
     $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
     /* 检查购物车中是否有商品 */
     $condition = " session_id = '" . SESS_ID . "' " . "AND parent_id = 0 AND is_gift = 0 AND rec_type = '{$flow_type}'";
     $count = $this->model->table('cart')->field('COUNT(*)')->where($condition)->getOne();
     if ($count == 0) {
         show_message(L('no_goods_in_cart'), '', '', 'warning');
     }
     /* 如果使用库存,且下订单时减库存,则减少库存 */
     if (C('use_storage') == '1' && C('stock_dec_time') == SDT_PLACE) {
         $cart_goods_stock = model('Order')->get_cart_goods();
         $_cart_goods_stock = array();
         foreach ($cart_goods_stock['goods_list'] as $value) {
             $_cart_goods_stock[$value['rec_id']] = $value['goods_number'];
         }
         model('Flow')->flow_cart_stock($_cart_goods_stock);
         unset($cart_goods_stock, $_cart_goods_stock);
     }
     // 检查用户是否已经登录 如果用户已经登录了则检查是否有默认的收货地址 如果没有登录则跳转到登录和注册页面
     if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0) {
         /* 用户没有登录且没有选定匿名购物,转向到登录页面 */
         ecs_header("Location: " . url('user/login') . "\n");
     }
     // 获取收货人信息
     $consignee = model('Order')->get_consignee($_SESSION['user_id']);
     /* 检查收货人信息是否完整 */
     if (!model('Order')->check_consignee_info($consignee, $flow_type)) {
         /* 如果不完整则转向到收货人信息填写界面 */
         ecs_header("Location: " . url('flow/consignee') . "\n");
     }
     // 处理接收信息
     $how_oos = I('post.how_oos', 0);
     $inv_type = I('post.inv_type', '');
     $inv_payee = I('post.inv_payee', '');
     $inv_content = I('post.inv_content', '');
     $postscript = I('post.postscript', '');
     $oos = L('oos.' . $how_oos);
     // 订单信息
     $order = array('shipping_id' => I('post.shipping'), 'pay_id' => I('post.payment'), 'surplus' => isset($_POST['surplus']) ? floatval($_POST['surplus']) : 0.0, 'integral' => isset($_POST['integral']) ? intval($_POST['integral']) : 0, 'need_inv' => empty($_POST['need_inv']) ? 0 : 1, 'inv_type' => $_POST['inv_type'], 'inv_payee' => trim($_POST['inv_payee']), 'inv_content' => $_POST['inv_content'], 'postscript' => trim($_POST['postscript']), 'how_oos' => isset($oos) ? addslashes("{$oos}") : '', 'need_insure' => isset($_POST['need_insure']) ? intval($_POST['need_insure']) : 0, 'user_id' => $_SESSION['user_id'], 'add_time' => gmtime(), 'order_status' => OS_UNCONFIRMED, 'shipping_status' => SS_UNSHIPPED, 'pay_status' => PS_UNPAYED, 'agency_id' => model('Order')->get_agency_by_regions(array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district'])), 'mobile_order' => 1, 'mobile_pay' => 1);
     /* 扩展信息 */
     if (isset($_SESSION['flow_type']) && intval($_SESSION['flow_type']) != CART_GENERAL_GOODS) {
         $order['extension_code'] = $_SESSION['extension_code'];
         $order['extension_id'] = $_SESSION['extension_id'];
     } else {
         $order['extension_code'] = '';
         $order['extension_id'] = 0;
     }
     /* 检查积分余额是否合法 */
     $user_id = $_SESSION['user_id'];
     if ($user_id > 0) {
         $user_info = model('Order')->user_info($user_id);
         $order['surplus'] = min($order['surplus'], $user_info['user_money'] + $user_info['credit_line']);
         if ($order['surplus'] < 0) {
             $order['surplus'] = 0;
         }
         // 查询用户有多少积分
         $flow_points = model('Flow')->flow_available_points();
         // 该订单允许使用的积分
         $user_points = $user_info['pay_points'];
         // 用户的积分总数
         $order['integral'] = min($order['integral'], $user_points, $flow_points);
         if ($order['integral'] < 0) {
             $order['integral'] = 0;
         }
     } else {
         $order['surplus'] = 0;
         $order['integral'] = 0;
     }
     /* 订单中的商品 */
     $cart_goods = model('Order')->cart_goods($flow_type);
     if (empty($cart_goods)) {
         show_message(L('no_goods_in_cart'), L('back_home'), './', 'warning');
     }
     /* 检查商品总额是否达到最低限购金额 */
     if ($flow_type == CART_GENERAL_GOODS && model('Order')->cart_amount(true, CART_GENERAL_GOODS) < C('min_goods_amount')) {
         show_message(sprintf(L('goods_amount_not_enough'), price_format(C('min_goods_amount'), false)));
     }
     /* 收货人信息 */
     foreach ($consignee as $key => $value) {
         $order[$key] = addslashes($value);
     }
     /* 判断是不是实体商品 */
     foreach ($cart_goods as $val) {
         /* 统计实体商品的个数 */
         if ($val['is_real']) {
             $is_real_good = 1;
         }
     }
     if (isset($is_real_good)) {
         $res = $this->model->table('shipping')->field('shipping_id')->where("shipping_id=" . $order['shipping_id'] . " AND enabled =1")->getOne();
         if (!$res) {
             show_message(L('flow_no_shipping'));
         }
     }
     /* 订单中的总额 */
     $total = model('Users')->order_fee($order, $cart_goods, $consignee);
     $order['goods_amount'] = $total['goods_price'];
     $order['discount'] = $total['discount'];
     $order['surplus'] = $total['surplus'];
     $order['tax'] = $total['tax'];
     // 购物车中的商品能享受红包支付的总额
     $discount_amout = model('Order')->compute_discount_amount();
     // 红包和积分最多能支付的金额为商品总额
     $temp_amout = $order['goods_amount'] - $discount_amout;
     /* 配送方式 */
     if ($order['shipping_id'] > 0) {
         $shipping = model('Shipping')->shipping_info($order['shipping_id']);
         $order['shipping_name'] = addslashes($shipping['shipping_name']);
     }
     $order['shipping_fee'] = $total['shipping_fee'];
     $order['insure_fee'] = $total['shipping_insure'];
     /* 支付方式 */
     if ($order['pay_id'] > 0) {
         $payment = model('Order')->payment_info($order['pay_id']);
         $order['pay_name'] = addslashes($payment['pay_name']);
     }
     $order['pay_fee'] = $total['pay_fee'];
     $order['cod_fee'] = $total['cod_fee'];
     $order['order_amount'] = number_format($total['amount'], 2, '.', '');
     /* 如果全部使用余额支付,检查余额是否足够 */
     if ($payment['pay_code'] == 'balance' && $order['order_amount'] > 0) {
         if ($order['surplus'] > 0) {
             // 余额支付里如果输入了一个金额
             $order['order_amount'] = $order['order_amount'] + $order['surplus'];
             $order['surplus'] = 0;
         }
         if ($order['order_amount'] > $user_info['user_money'] + $user_info['credit_line']) {
             show_message(L('balance_not_enough'));
         } else {
             $order['surplus'] = $order['order_amount'];
             $order['order_amount'] = 0;
         }
     }
     /* 如果订单金额为0(使用余额或积分或红包支付),修改订单状态为已确认、已付款 */
     if ($order['order_amount'] <= 0) {
         $order['order_status'] = OS_CONFIRMED;
         $order['confirm_time'] = gmtime();
         $order['pay_status'] = PS_PAYED;
         $order['pay_time'] = gmtime();
         $order['order_amount'] = 0;
     }
     $order['integral_money'] = $total['integral_money'];
     $order['integral'] = $total['integral'];
     if ($order['extension_code'] == 'exchange_goods') {
         $order['integral_money'] = 0;
         $order['integral'] = $total['exchange_integral'];
     }
     $order['from_ad'] = !empty($_SESSION['from_ad']) ? $_SESSION['from_ad'] : '0';
     $order['referer'] = !empty($_SESSION['referer']) ? addslashes($_SESSION['referer']) : '';
     /* 记录扩展信息 */
     if ($flow_type != CART_GENERAL_GOODS) {
         $order['extension_code'] = $_SESSION['extension_code'];
         $order['extension_id'] = $_SESSION['extension_id'];
     }
     $affiliate = unserialize(C('affiliate'));
     if (isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 1) {
         // 推荐订单分成
         $parent_id = model('Users')->get_affiliate();
         if ($user_id == $parent_id) {
             $parent_id = 0;
         }
     } elseif (isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 0) {
         // 推荐注册分成
         $parent_id = 0;
     } else {
         // 分成功能关闭
         $parent_id = 0;
     }
     $order['parent_id'] = $parent_id;
     //分销 start
     $parent_id = model('Sale')->get_parent_id($parent_id);
     $order['parent_id'] = $parent_id;
     /* 插入订单表 */
     $error_no = 0;
     do {
         $order['order_sn'] = get_order_sn();
         // 获取新订单号
         $new_order = model('Common')->filter_field('order_info', $order);
         $this->model->table('order_info')->data($new_order)->insert();
         $error_no = M()->errno();
         if ($error_no > 0 && $error_no != 1062) {
             die(M()->errorMsg());
         }
     } while ($error_no == 1062);
     // 如果是订单号重复则重新提交数据
     $new_order_id = M()->insert_id();
     $order['order_id'] = $new_order_id;
     /* 插入订单商品 */
     $sql = "INSERT INTO " . $this->model->pre . "order_goods( " . "order_id, goods_id, goods_name, goods_sn, product_id, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id) " . " SELECT '{$new_order_id}', goods_id, goods_name, goods_sn, product_id, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id" . " FROM " . $this->model->pre . "cart WHERE session_id = '" . SESS_ID . "' AND rec_type = '{$flow_type}'";
     $this->model->query($sql);
     /* 处理余额、积分、红包 */
     if ($order['user_id'] > 0 && $order['surplus'] > 0) {
         model('ClipsBase')->log_account_change($order['user_id'], $order['surplus'] * -1, 0, 0, 0, sprintf(L('pay_order'), $order['order_sn']));
     }
     if ($order['user_id'] > 0 && $order['integral'] > 0) {
         model('ClipsBase')->log_account_change($order['user_id'], 0, 0, 0, $order['integral'] * -1, sprintf(L('pay_order'), $order['order_sn']));
     }
     /* 如果使用库存,且下订单时减库存,则减少库存 */
     if (C('use_storage') == '1' && C('stock_dec_time') == SDT_PLACE) {
         model('Order')->change_order_goods_storage($order['order_id'], true, SDT_PLACE);
     }
     /* 给商家发邮件 */
     /* 增加是否给客服发送邮件选项 */
     if (C('send_service_email') && C('service_email') != '') {
         $tpl = model('Base')->get_mail_template('remind_of_new_order');
         $this->assign('order', $order);
         $this->assign('goods_list', $cart_goods);
         $this->assign('shop_name', C('shop_name'));
         $this->assign('send_date', date(C('time_format')));
         $content = ECTouch::$view->fetch('str:' . $tpl['template_content']);
         send_mail(C('shop_name'), C('service_email'), $tpl['template_subject'], $content, $tpl['is_html']);
     }
     /* 如果需要,发短信 */
     if (C('sms_order_placed') == '1' && C('sms_shop_mobile') != '') {
         $sms = new EcsSms();
         $msg = $order['pay_status'] == PS_UNPAYED ? L('order_placed_sms') : L('order_placed_sms') . '[' . L('sms_paid') . ']';
         $sms->send(C('sms_shop_mobile'), sprintf($msg, $order['consignee'], $order['mobile']), '', 13, 1);
     }
     /* 如果需要,微信通知 by wanglu */
     if (method_exists('WechatController', 'do_oauth')) {
         $order_url = __HOST__ . url('user/order_detail', array('order_id' => $order['order_id']));
         $order_url = urlencode(base64_encode($order_url));
         send_wechat_message('order_remind', '', $order['order_sn'] . L('order_effective'), $order_url, $order['order_sn']);
     }
     /* 如果订单金额为0 处理虚拟卡 */
     if ($order['order_amount'] <= 0) {
         $sql = "SELECT goods_id, goods_name, goods_number AS num FROM " . $this->model->pre . "cart WHERE is_real = 0 AND extension_code = 'virtual_card'" . " AND session_id = '" . SESS_ID . "' AND rec_type = '{$flow_type}'";
         $res = $this->model->query($sql);
         $virtual_goods = array();
         foreach ($res as $row) {
             $virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']);
         }
         if ($virtual_goods) {
             /* 虚拟卡发货 */
             if (model('OrderBase')->virtual_goods_ship($virtual_goods, $msg, $order['order_sn'], true)) {
                 /* 如果没有实体商品,修改发货状态,送积分和红包 */
                 $count = $this->model->table('order_goods')->field('COUNT(*)')->where("order_id = '{$order['order_id']}' " . " AND is_real = 1")->getOne();
                 if ($count <= 0) {
                     /* 修改订单状态 */
                     model('Users')->update_order($order['order_id'], array('shipping_status' => SS_SHIPPED, 'shipping_time' => gmtime()));
                     /* 如果订单用户不为空,计算积分,并发给用户;发红包 */
                     if ($order['user_id'] > 0) {
                         /* 取得用户信息 */
                         $user = model('Order')->user_info($order['user_id']);
                         /* 计算并发放积分 */
                         $integral = model('Order')->integral_to_give($order);
                         model('ClipsBase')->log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf(L('order_gift_integral'), $order['order_sn']));
                     }
                 }
             }
         }
     }
     // 销量
     model('Flow')->add_touch_goods($flow_type, $order['extension_code']);
     /* 记录供应商信息 */
     $sql = "update " . $this->model->pre . "order_goods og , " . $this->model->pre . "goods g set og.suppliers_id=g.suppliers_id\r\n            where og.goods_id=g.goods_id and og.order_id='" . $order['order_id'] . "'";
     $this->model->query($sql);
     /* 清空购物车 */
     model('Order')->clear_cart($flow_type);
     /* 清除缓存,否则买了商品,但是前台页面读取缓存,商品数量不减少 */
     clear_all_files();
     /* 插入支付日志 */
     $order['log_id'] = model('ClipsBase')->insert_pay_log($new_order_id, $order['order_amount'], PAY_ORDER);
     /* 取得支付信息,生成支付代码 */
     if ($order['order_amount'] > 0) {
         $payment = model('Order')->payment_info($order['pay_id']);
         include_once ROOT_PATH . 'plugins/payment/' . $payment['pay_code'] . '.php';
         $pay_obj = new $payment['pay_code']();
         $pay_online = $pay_obj->get_code($order, unserialize_config($payment['pay_config']));
         $order['pay_desc'] = $payment['pay_desc'];
         $this->assign('pay_online', $pay_online);
     }
     if (!empty($order['shipping_name'])) {
         $order['shipping_name'] = trim(stripcslashes($order['shipping_name']));
     }
     // 货到付款不显示
     if ($payment['pay_code'] != 'balance') {
         /* 生成订单后,修改支付,配送方式 */
         // 支付方式
         $payment_list = model('Order')->available_payment_list(0);
         if (isset($payment_list)) {
             foreach ($payment_list as $key => $payment) {
                 /* 如果有易宝神州行支付 如果订单金额大于300 则不显示 */
                 if ($payment['pay_code'] == 'yeepayszx' && $total['amount'] > 300) {
                     unset($payment_list[$key]);
                 }
                 // 过滤掉当前的支付方式
                 if ($payment['pay_id'] == $order['pay_id']) {
                     unset($payment_list[$key]);
                 }
                 /* 如果有余额支付 */
                 if ($payment['pay_code'] == 'balance') {
                     /* 如果未登录,不显示 */
                     if ($_SESSION['user_id'] == 0) {
                         unset($payment_list[$key]);
                     } else {
                         if ($_SESSION['flow_order']['pay_id'] == $payment['pay_id']) {
                             $this->assign('disable_surplus', 1);
                         }
                     }
                 }
                 // 如果不是微信浏览器访问并且不是微信会员 则不显示微信支付
                 if ($payment['pay_code'] == 'wxpay' && !is_wechat_browser() && empty($_SESSION['openid'])) {
                     unset($payment_list[$key]);
                 }
                 // 兼容过滤ecjia支付方式
                 if (substr($payment['pay_code'], 0, 4) == 'pay_') {
                     unset($payment_list[$key]);
                 }
             }
         }
         $this->assign('payment_list', $payment_list);
         $this->assign('pay_code', 'no_balance');
     }
     // 如果是银行汇款或货到付款 则显示支付描述
     if ($payment['pay_code'] == 'bank' || $payment['pay_code'] == 'cod') {
         if (empty($order['pay_name'])) {
             $order['pay_name'] = trim(stripcslashes($payment['pay_name']));
         }
         $this->assign('pay_desc', $order['pay_desc']);
     }
     /* 订单信息 */
     $this->assign('order', $order);
     $this->assign('total', $total);
     $this->assign('goods_list', $cart_goods);
     $this->assign('order_submit_back', sprintf(L('order_submit_back'), L('back_home'), L('goto_user_center')));
     // 返回提示
     user_uc_call('add_feed', array($order['order_id'], BUY_GOODS));
     // 推送feed到uc
     unset($_SESSION['flow_consignee']);
     // 清除session中保存的收货人信息
     unset($_SESSION['flow_order']);
     unset($_SESSION['direct_shopping']);
     $this->assign('currency_format', C('currency_format'));
     $this->assign('integral_scale', C('integral_scale'));
     $this->assign('step', ACTION_NAME);
     $this->assign('title', L('order_submit'));
     $this->display('flow.dwt');
 }
Esempio n. 3
0
    $orders = get_pickup_orders($pids);
    if (!empty($orders)) {
        $status = array('shipping_status' => SS_RECEIVED, 'receive_time' => time());
        foreach ($orders as &$o) {
            update_order($o['order_id'], $status);
            order_action($o['order_sn'], OS_CONFIRMED, SS_RECEIVED, PS_PAYED, '门店取货');
        }
    }
    // Update package status
    $sql = "UPDATE " . $ecs->table('pickup_pack') . " SET status=3 WHERE id IN (" . implode(',', $pids) . ")";
    $db->query($sql);
    $response = array('errcode' => 0, 'mobile' => $orders[0]['mobile'], 'goods' => $goods, 'orders' => $orders, 'packs' => $packs);
    echo json_encode($response);
    exit;
}
$smarty->display(is_wechat_browser() ? 'pickup_wechat.htm' : 'pickup_wechat.htm');
/**
 * 检查取货码,返回对应的user_id
 * 
 * @param string $code 取货码
 * 
 * errcode:
 * 1 - 取货码不存
 * 2 - 该取货码已经取过货了
 * 3 - 取货码已过期
 */
function check_pickup_code($code)
{
    global $ecs, $db;
    $sql = "SELECT * FROM " . $ecs->table('pickup_code') . " WHERE code = '{$code}'";
    $qcode = $db->getRow($sql);
Esempio n. 4
0
         /* 如果有余额支付 */
         if ($payment['pay_code'] == 'balance') {
             /* 如果未登录,不显示 */
             if ($_SESSION['user_id'] == 0) {
                 unset($payment_list[$key]);
             } else {
                 if ($_SESSION['flow_order']['pay_id'] == $payment['pay_id']) {
                     $smarty->assign('disable_surplus', 1);
                 }
             }
         }
     }
 }
 foreach ($payment_list as $key => $value) {
     if ($value['pay_code'] == "wx_new_jspay") {
         $is_wechat = is_wechat_browser();
         if ($is_wechat == false) {
             unset($payment_list[$key]);
         }
     }
 }
 $smarty->assign('payment_list', $payment_list);
 /* 取得包装与贺卡 */
 if ($total['real_goods_count'] > 0) {
     /* 只有有实体商品,才要判断包装和贺卡 */
     if (!isset($_CFG['use_package']) || $_CFG['use_package'] == '1') {
         /* 如果使用包装,取得包装列表及用户选择的包装 */
         $smarty->assign('pack_list', pack_list());
     }
     /* 如果使用贺卡,取得贺卡列表及用户选择的贺卡 */
     if (!isset($_CFG['use_card']) || $_CFG['use_card'] == '1') {
Esempio n. 5
0
}
if ((DEBUG_MODE & 1) == 1) {
    error_reporting(E_ALL);
} else {
    error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
}
if ((DEBUG_MODE & 4) == 4) {
    include ROOT_PATH . 'include/lib.debug.php';
}
/* 判断是否支持 Gzip 模式 */
if (!defined('INIT_NO_SMARTY') && gzip_enabled()) {
    ob_start('ob_gzhandler');
} else {
    ob_start();
}
if (is_wechat_browser() && strpos($_CFG['site_url'], 'test.') === false) {
    if (empty($_SESSION['user_id'])) {
        include_once ROOT_PATH . 'include/lib_passport.php';
        include_once ROOT_PATH . 'weixin/login.php';
        $uri = str_replace('/mobile/', '/', $_SERVER['REQUEST_URI']);
        if (substr($uri, -1) == '/') {
            $uri .= 'index.php';
        }
        $callback = $_CFG['site_url'] . $uri;
        weixin_oauth($callback);
    } elseif (empty($_SESSION['openid'])) {
        $openid = $db->getOne("SELECT wxid FROM wxch_user WHERE uid={$_SESSION['user_id']}");
        $_SESSION['openid'] = $openid;
    }
}
/* 检查是否是微信浏览器访问 */
Esempio n. 6
0
function goto_login($clear_cookie = FALSE)
{
    global $_LANG, $_CFG;
    if (is_wechat_browser()) {
        // 微信登录
        $callback = $_CFG['site_url'] . $_SERVER['REQUEST_URI'];
        $user = weixin_oauth($callback);
    }
    if (empty($user)) {
        if ($clear_cookie) {
            setcookie($_COOKIE['ECSCP']['admin_id'], '', 1);
            setcookie($_COOKIE['ECSCP']['admin_pass'], '', 1);
        }
        if (!empty($_REQUEST['is_ajax'])) {
            make_json_error($_LANG['priv_error']);
        } else {
            ecs_header("Location: privilege.php?act=login\n");
        }
        exit;
    }
}
Esempio n. 7
0
     $user_bonus = user_bonus($_SESSION['user_id'], $total['goods_price']);
     if (!empty($user_bonus)) {
         foreach ($user_bonus as &$val) {
             $val['bonus_money_formated'] = price_format($val['type_money'], false);
         }
         $smarty->assign('bonus_list', $user_bonus);
         //默认使用第一个红包,重新计算费用
         $order['bonus_id'] = $user_bonus[0]['bonus_id'];
         $order['bonus'] = $user_bonus[0]['amount'];
         $total = order_fee($order, $cart_goods, $consignee);
     }
     // 能使用红包
     $smarty->assign('allow_use_bonus', 1);
 }
 // 取得支付列表
 $payment_list = available_payment_list(false, $cod_fee, true, is_wechat_browser());
 if (!empty($payment_list)) {
     $smarty->assign('default_payment', $payment_list[0]['pay_id']);
     foreach ($payment_list as $key => $payment) {
         if ($payment['is_cod'] == '1') {
             $payment_list[$key]['format_pay_fee'] = '<span id="ECS_CODFEE">' . $payment['format_pay_fee'] . '</span>';
         }
         // 如果有余额支付
         if ($payment['pay_code'] == 'balance') {
             // 如果未登录,不显示
             if ($_SESSION['user_id'] == 0) {
                 unset($payment_list[$key]);
             } else {
                 if ($_SESSION['flow_order']['pay_id'] == $payment['pay_id']) {
                     $smarty->assign('disable_surplus', 1);
                 }