예제 #1
0
 public function done()
 {
     require_once APP_ROOT_PATH . "system/model/cart.php";
     require_once APP_ROOT_PATH . "system/model/deal.php";
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     global_run();
     $ajax = 1;
     $region4_id = intval($_REQUEST['region_lv4']);
     $region3_id = intval($_REQUEST['region_lv3']);
     $region2_id = intval($_REQUEST['region_lv2']);
     $region1_id = intval($_REQUEST['region_lv1']);
     if ($region4_id == 0) {
         if ($region3_id == 0) {
             if ($region2_id == 0) {
                 $region_id = $region1_id;
             } else {
                 $region_id = $region2_id;
             }
         } else {
             $region_id = $region3_id;
         }
     } else {
         $region_id = $region4_id;
     }
     $delivery_id = intval($_REQUEST['delivery']);
     $payment = intval($_REQUEST['payment']);
     $account_money = floatval($_REQUEST['account_money']);
     $all_account_money = intval($_REQUEST['all_account_money']);
     $ecvsn = $_REQUEST['ecvsn'] ? strim($_REQUEST['ecvsn']) : '';
     $ecvpassword = $_REQUEST['ecvpassword'] ? strim($_REQUEST['ecvpassword']) : '';
     $user_id = intval($GLOBALS['user_info']['id']);
     $session_id = es_session::id();
     $cart_result = load_cart_list();
     $goods_list = $cart_result['cart_list'];
     if (!$goods_list) {
         showErr($GLOBALS['lang']['CART_EMPTY_TIP'], $ajax);
     }
     //验证购物车
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax, url("index", "user#login"));
     }
     $deal_ids = array();
     foreach ($goods_list as $k => $v) {
         $data = check_cart($v['id'], $v['number']);
         if (!$data['status']) {
             showErr($data['info'], $ajax, url("index", "cart#index"));
         }
         $deal_ids[$v['deal_id']]['deal_id'] = $v['deal_id'];
     }
     foreach ($deal_ids as $row) {
         //验证支付方式的支持
         if ($GLOBALS['db']->getOne("select define_payment from " . DB_PREFIX . "deal where id = " . $row['deal_id']) == 1) {
             if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where deal_id = " . $row['deal_id'] . " and payment_id = " . $payment)) {
                 showErr($GLOBALS['lang']['INVALID_PAYMENT'], $ajax, url("index", "cart#index"));
             }
         }
     }
     //结束验证购物车
     //开始验证订单接交信息
     $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
     if ($data['is_delivery'] == 1) {
         //配送验证
         if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['consignee']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'], $ajax);
         }
         if (trim($_REQUEST['address']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['zip']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ZIP'], $ajax);
         }
         if (trim($_REQUEST['mobile']) == '') {
             showErr($GLOBALS['lang']['FILL_MOBILE_PHONE'], $ajax);
         }
         if (!check_mobile(trim($_REQUEST['mobile']))) {
             showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], $ajax);
         }
         if (!$data['delivery_info']) {
             showErr($GLOBALS['lang']['PLEASE_SELECT_DELIVERY'], $ajax);
         }
     }
     if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
         showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT'], $ajax);
     }
     //结束验证订单接交信息
     //开始生成订单
     $now = NOW_TIME;
     $order['type'] = 0;
     //普通订单
     $order['user_id'] = $user_id;
     $order['create_time'] = $now;
     $order['total_price'] = $data['pay_total_price'];
     //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
     $order['pay_amount'] = 0;
     $order['pay_status'] = 0;
     //新单都为零, 等下面的流程同步订单状态
     $order['delivery_status'] = $data['is_delivery'] == 0 ? 5 : 0;
     $order['order_status'] = 0;
     //新单都为零, 等下面的流程同步订单状态
     $order['return_total_score'] = $data['return_total_score'];
     //结单后送的积分
     $order['return_total_money'] = $data['return_total_money'];
     //结单后送的现金
     $order['memo'] = strim($_REQUEST['memo']);
     $order['region_lv1'] = intval($_REQUEST['region_lv1']);
     $order['region_lv2'] = intval($_REQUEST['region_lv2']);
     $order['region_lv3'] = intval($_REQUEST['region_lv3']);
     $order['region_lv4'] = intval($_REQUEST['region_lv4']);
     $order['address'] = strim($_REQUEST['address']);
     $order['mobile'] = strim($_REQUEST['mobile']);
     $order['consignee'] = strim($_REQUEST['consignee']);
     $order['zip'] = strim($_REQUEST['zip']);
     $order['deal_total_price'] = $data['total_price'];
     //团购商品总价
     $order['discount_price'] = $data['user_discount'];
     $order['delivery_fee'] = $data['delivery_fee'];
     $order['ecv_money'] = 0;
     $order['account_money'] = 0;
     $order['ecv_sn'] = '';
     $order['delivery_id'] = $data['delivery_info']['id'];
     $order['payment_id'] = $data['payment_info']['id'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['bank_id'] = strim($_REQUEST['bank_id']);
     foreach ($data['promote_description'] as $promote_item) {
         $order['promote_description'] .= $promote_item . "<br />";
     }
     //更新来路
     $order['referer'] = $GLOBALS['referer'];
     $user_info = es_session::get("user_info");
     $order['user_name'] = $user_info['user_name'];
     /** 更新会员手机号
     		$coupon_mobile = htmlspecialchars(addslashes(trim($_REQUEST['coupon_mobile'])));
     		if($coupon_mobile!='')
     			$GLOBALS['db']->query("update ".DB_PREFIX."user set mobile = '".$coupon_mobile."' where id = ".intval($user_info['id']));
     		*/
     if ($user_info['mobile'] == "") {
         $user_mobile = strim($_REQUEST['user_mobile']);
         if ($user_mobile == "") {
             $data = array();
             $data['status'] = false;
             $data['info'] = "请输入手机号";
             $data['jump'] = "";
             ajax_return($data);
         }
         if (!check_mobile($user_mobile)) {
             $data = array();
             $data['status'] = false;
             $data['info'] = "手机号格式不正确";
             $data['jump'] = "";
             ajax_return($data);
         }
         if (app_conf("SMS_ON") == 1) {
             $mobile_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '" . $user_mobile . "'");
             $sms_verify = strim($_POST['sms_verify']);
             if (empty($mobile_data) || $mobile_data['code'] != $sms_verify) {
                 $data = array();
                 $data['status'] = false;
                 $data['info'] = "手机验证码错误";
                 $data['jump'] = "";
                 ajax_return($data);
             }
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $user_mobile . "' where id = " . $user_info['id'], "SILENT");
         if ($GLOBALS['db']->affected_rows() > 0) {
             $GLOBALS['db']->query("delete from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '" . $user_mobile . "'");
             //删除验证码
         } else {
             $data = array();
             $data['status'] = false;
             $data['info'] = "手机号已被注册";
             $data['jump'] = "";
             ajax_return($data);
         }
     }
     do {
         $order['order_sn'] = to_date(NOW_TIME, "Ymdhis") . rand(10, 99);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
         $order_id = intval($GLOBALS['db']->insert_id());
     } while ($order_id == 0);
     //生成订单商品
     foreach ($goods_list as $k => $v) {
         $deal_info = load_auto_cache("deal", array("id" => $v['deal_id']));
         $goods_item = array();
         $goods_item['deal_id'] = $v['deal_id'];
         $goods_item['number'] = $v['number'];
         $goods_item['unit_price'] = $v['unit_price'];
         $goods_item['total_price'] = $v['total_price'];
         $goods_item['name'] = $v['name'];
         $goods_item['sub_name'] = $v['sub_name'];
         $goods_item['attr'] = $v['attr'];
         $goods_item['verify_code'] = $v['verify_code'];
         $goods_item['order_id'] = $order_id;
         $goods_item['return_score'] = $v['return_score'];
         $goods_item['return_total_score'] = $v['return_total_score'];
         $goods_item['return_money'] = $v['return_money'];
         $goods_item['return_total_money'] = $v['return_total_money'];
         $goods_item['buy_type'] = $v['buy_type'];
         $goods_item['attr_str'] = $v['attr_str'];
         $goods_item['add_balance_price'] = $v['add_balance_price'];
         $goods_item['add_balance_price_total'] = $v['add_balance_price'] * $v['number'];
         $goods_item['balance_unit_price'] = $deal_info['balance_price'];
         $goods_item['balance_total_price'] = $deal_info['balance_price'] * $v['number'];
         $goods_item['delivery_status'] = $deal_info['is_delivery'] == 1 ? 0 : 5;
         $goods_item['is_coupon'] = $deal_info['is_coupon'];
         $goods_item['deal_icon'] = $deal_info['icon'];
         $goods_item['supplier_id'] = $deal_info['supplier_id'];
         $goods_item['is_refund'] = $deal_info['is_refund'];
         $goods_item['user_id'] = $user_id;
         $goods_item['order_sn'] = $order['order_sn'];
         $goods_item['is_shop'] = $deal_info['is_shop'];
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT');
     }
     //开始更新订单表的deal_ids
     $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
     $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set deal_ids = '" . $deal_ids . "' where id = " . $order_id);
     $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "'");
     load_cart_list(true);
     if ($data['is_delivery'] == 1) {
         //保存收款人
         $consignee_id = intval($_REQUEST['consignee_id']);
         $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $order['user_id'] . " and id = " . $consignee_id);
         $user_consignee['region_lv1'] = intval($_REQUEST['region_lv1']);
         $user_consignee['region_lv2'] = intval($_REQUEST['region_lv2']);
         $user_consignee['region_lv3'] = intval($_REQUEST['region_lv3']);
         $user_consignee['region_lv4'] = intval($_REQUEST['region_lv4']);
         $user_consignee['address'] = strim($_REQUEST['address']);
         $user_consignee['mobile'] = strim($_REQUEST['mobile']);
         $user_consignee['consignee'] = strim($_REQUEST['consignee']);
         $user_consignee['zip'] = strim($_REQUEST['zip']);
         $user_consignee['user_id'] = $order['user_id'];
         if (intval($user_consignee['id']) == 0) {
             //新增
             $user_consignee['is_default'] = 1;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'INSERT', '', 'SILENT');
         } else {
             //更新
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT');
             rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id'])));
         }
     }
     //生成order_id 后
     //1. 代金券支付
     $ecv_data = $data['ecv_data'];
     if ($ecv_data) {
         $ecv_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'");
         if ($ecv_data['money'] > $order['total_price']) {
             $ecv_data['money'] = $order['total_price'];
         }
         $payment_notice_id = make_payment_notice($ecv_data['money'], $order_id, $ecv_payment_id);
         require_once APP_ROOT_PATH . "system/payment/Voucher_payment.php";
         $voucher_payment = new Voucher_payment();
         $voucher_payment->direct_pay($ecv_data['sn'], $ecv_data['password'], $payment_notice_id);
     }
     //2. 余额支付
     $account_money = $data['account_money'];
     if (floatval($account_money) > 0) {
         $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'");
         $payment_notice_id = make_payment_notice($account_money, $order_id, $account_payment_id);
         require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
         $account_payment = new Account_payment();
         $account_payment->get_payment_code($payment_notice_id);
     }
     //3. 相应的支付接口
     $payment_info = $data['payment_info'];
     if ($payment_info && $data['pay_price'] > 0) {
         $payment_notice_id = make_payment_notice($data['pay_price'], $order_id, $payment_info['id']);
         //创建支付接口的付款单
     }
     $rs = order_paid($order_id);
     update_order_cache($order_id);
     if ($rs) {
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#done", array("id" => $order_id));
         ajax_return($data);
         //支付成功
     } else {
         distribute_order($order_id);
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#pay", array("id" => $payment_notice_id));
         ajax_return($data);
     }
 }
예제 #2
0
파일: deal.php 프로젝트: macall/jsd
/**
 * 检测团购的属性数量状态
 * $id 团购ID
 * $attr_setting 属性组合的字符串
 * $number 数量
 */
function check_deal_number_attr($id, $attr_setting, $number = 0)
{
    require_once APP_ROOT_PATH . "system/model/cart.php";
    $cart_result = load_cart_list();
    $id = intval($id);
    $deal_info = get_deal($id);
    $attr_stock_cfg = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "attr_stock where deal_id = " . $id . " and locate(attr_str,'" . $attr_setting . "') > 0 ");
    $stock_setting = intval($attr_stock_cfg['stock_cfg']);
    $stock_attr_setting = $attr_stock_cfg['attr_str'];
    // 获取到当前规格的库存
    /*验证数量*/
    //定义几组需要的数据
    //1. 本团购记录下的购买量
    $deal_buy_count = intval($attr_stock_cfg['buy_count']);
    //2. 本团购当前会员的购物车中数量
    $deal_user_cart_count = 0;
    foreach ($cart_result['cart_list'] as $k => $v) {
        if ($v['deal_id'] == $id && strpos($v['attr_str'], $stock_attr_setting) !== false) {
            $deal_user_cart_count += intval($v['number']);
        }
    }
    //3. 本团购当前会员未付款的数量
    $deal_user_unpaid_count = intval($GLOBALS['db']->getOne("select sum(oi.number) from " . DB_PREFIX . "deal_order_item as oi left join " . DB_PREFIX . "deal_order as o on oi.order_id = o.id where o.user_id = " . intval($GLOBALS['user_info']['id']) . " and o.pay_status <> 2 and o.order_status = 0 and oi.deal_id = " . $id . " and o.is_delete = 0 and oi.attr_str like '%" . $stock_attr_setting . "%'"));
    if ($deal_user_cart_count + $deal_buy_count + $deal_user_unpaid_count + $number > $stock_setting && $stock_setting > 0) {
        $result['status'] = 0;
        $result['data'] = DEAL_OUT_OF_STOCK;
        //库存不足
        $result['info'] = $deal_info['sub_name'] . $stock_attr_setting . " " . sprintf($GLOBALS['lang']['DEAL_MAX_BOUGHT'], $stock_setting);
        $result['attr'] = $stock_attr_setting;
        return $result;
    }
    /*验证数量*/
    $result['status'] = 1;
    $result['info'] = $deal_info['sub_name'];
    return $result;
}
예제 #3
0
파일: user.php 프로젝트: macall/baikec_jsd
/**
 * 处理会员登录
 * @param $user_name_or_email 用户名或邮箱地址
 * @param $user_pwd 密码
 * 
 */
function do_login_user($user_name_or_email, $user_pwd)
{
    $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where (user_name='" . $user_name_or_email . "' or email = '" . $user_name_or_email . "' or mobile = '" . $user_name_or_email . "') and is_delete = 0");
    //载入会员整合
    $integrate_code = strim(app_conf("INTEGRATE_CODE"));
    if ($integrate_code != '' && $GLOBALS['request']['from'] != 'wap') {
        $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php";
        if (file_exists($integrate_file)) {
            require_once $integrate_file;
            $integrate_class = $integrate_code . "_integrate";
            $integrate_obj = new $integrate_class();
        }
    }
    if ($integrate_obj) {
        $result = $integrate_obj->login($user_name_or_email, $user_pwd);
    }
    $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where (user_name='" . $user_name_or_email . "' or email = '" . $user_name_or_email . "' or mobile = '" . $user_name_or_email . "') and is_delete = 0");
    if (!$user_data) {
        $result['status'] = 0;
        $result['data'] = ACCOUNT_NO_EXIST_ERROR;
        return $result;
    } else {
        $result['user'] = $user_data;
        if ($user_data['user_pwd'] != md5($user_pwd . $user_data['code']) && $user_data['user_pwd'] != $user_pwd) {
            $result['status'] = 0;
            $result['data'] = ACCOUNT_PASSWORD_ERROR;
            return $result;
        } elseif ($user_data['is_effect'] != 1) {
            $result['status'] = 0;
            $result['data'] = ACCOUNT_NO_VERIFY_ERROR;
            return $result;
        } else {
            if (intval($result['status']) == 0) {
                $result['status'] = 1;
            }
            //登录成功自动检测关于会员等级以及自动登录商家
            $account_name = $user_data['merchant_name'];
            $account = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_account where account_name = '" . $account_name . "' and is_effect = 1 and is_delete = 0");
            if ($account) {
                $account_locations = $GLOBALS['db']->getAll("select location_id from " . DB_PREFIX . "supplier_account_location_link where account_id = " . $account['id']);
                $account_location_ids = array(0);
                foreach ($account_locations as $row) {
                    $account_location_ids[] = $row['location_id'];
                }
                $account['location_ids'] = $account_location_ids;
                es_session::set("account_info", $account);
                $GLOBALS['db']->query("update " . DB_PREFIX . "supplier_account set login_ip = '" . CLIENT_IP . "' where id=" . $account['id']);
            }
            $user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
            $user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['total_score']) . " order by score desc");
            if ($user_current_group['score'] < $user_group['score']) {
                $user_data['group_id'] = intval($user_group['id']);
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set group_id = " . $user_data['group_id'] . " where id = " . $user_data['id']);
                $pm_content = "恭喜您,您已经成为" . $user_group['name'] . "。";
                if ($user_group['discount'] < 1) {
                    $pm_content .= "您将享有" . $user_group['discount'] * 10 . "折的购物优惠";
                }
                send_msg($user_data['id'], $pm_content, "notify", 0);
            }
            $user_current_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where id = " . intval($user_data['level_id']));
            $user_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where point <=" . intval($user_data['point']) . " order by point desc");
            if ($user_current_level['point'] < $user_level['point']) {
                $user_data['level_id'] = intval($user_level['id']);
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set level_id = " . $user_data['level_id'] . " where id = " . $user_data['id']);
                $pm_content = "恭喜您,您已经成为" . $user_level['name'] . "。";
                send_msg($user_data['id'], $pm_content, "notify", 0);
            }
            if ($user_current_level['point'] > $user_level['point']) {
                $user_data['level_id'] = intval($user_level['id']);
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set level_id = " . $user_data['level_id'] . " where id = " . $user_data['id']);
                $pm_content = "很报歉,您已经降为" . $user_level['name'] . "。";
                send_msg($user_data['id'], $pm_content, "notify", 0);
            }
            send_system_msg($user_data['id']);
            $user_data = load_user($user_data['id'], true);
            es_session::set("user_info", $user_data);
            $GLOBALS['user_info'] = $user_data;
            es_session::set("user_logined", true);
            $GLOBALS['user_logined'] = true;
            es_session::set("user_logined_time", NOW_TIME);
            $GLOBALS['db']->query("update " . DB_PREFIX . "deal_cart set user_id = " . $GLOBALS['user_info']['id'] . " where session_id = '" . es_session::id() . "'");
            require_once APP_ROOT_PATH . "system/model/cart.php";
            load_cart_list(true);
            //检测勋章
            $medal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "medal where is_effect = 1 and allow_check = 1");
            foreach ($medal_list as $medal) {
                $file = APP_ROOT_PATH . "system/medal/" . $medal['class_name'] . "_medal.php";
                $cls = $medal['class_name'] . "_medal";
                if (file_exists($file)) {
                    require_once $file;
                    if (class_exists($cls)) {
                        $o = new $cls();
                        $check_result = $o->check_medal();
                        if ($check_result['status'] == 0) {
                            send_msg($user_data['id'], $check_result['info'], "notify", 0);
                        }
                    }
                }
            }
            //签到
            $signin_result = signin($GLOBALS['user_info']['id']);
            if ($signin_result['status']) {
                es_session::set("signin_result", $signin_result);
            }
            $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
            $s_api_user_info = es_session::get("api_user_info");
            if ($s_api_user_info) {
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set " . $s_api_user_info['field'] . " = '" . $s_api_user_info['id'] . "' where id = " . $user_data['id'] . " and (" . $s_api_user_info['field'] . " = 0 or " . $s_api_user_info['field'] . "='')");
                es_session::delete("api_user_info");
            }
            $result['step'] = intval($user_data["step"]);
            return $result;
        }
    }
}
예제 #4
0
파일: cart.php 프로젝트: macall/jsd
/**
 * 验证购物车
 */
function check_cart($id, $number)
{
    $cart_result = load_cart_list();
    $cart_item = $cart_result['cart_list'][$id];
    if (empty($cart_item)) {
        $result['info'] = "非法的数据";
        $result['status'] = 0;
        return $result;
    }
    if ($number <= 0) {
        $result['info'] = "数量不能为0";
        $result['status'] = 0;
        return $result;
    }
    $add_number = $number - $cart_item['number'];
    require_once APP_ROOT_PATH . "system/model/deal.php";
    $check = check_deal_number($cart_item['deal_id'], $add_number);
    if ($check['status'] == 0) {
        $result['info'] = $check['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $check['data']];
        $result['status'] = 0;
        return $result;
    }
    //属性库存的验证
    $attr_setting_str = '';
    if ($cart_item['attr'] != '') {
        $attr_setting_str = $cart_item['attr_str'];
    }
    if ($attr_setting_str != '') {
        $check = check_deal_number_attr($cart_item['deal_id'], $attr_setting_str, $add_number);
        if ($check['status'] == 0) {
            $result['info'] = $check['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $check['data']];
            $result['status'] = 0;
            return $result;
        }
    }
    //属性库存的验证
    //验证时间
    $checker = check_deal_time($cart_item['deal_id']);
    if ($checker['status'] == 0) {
        $result['info'] = $checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']];
        $result['status'] = 0;
        return $result;
    }
    //验证时间
    $result['status'] = 1;
    return $result;
}
예제 #5
0
파일: main_lib.php 프로젝트: macall/jsd
function load_cart_tip()
{
    require_once APP_ROOT_PATH . "system/model/cart.php";
    $cart_result = load_cart_list();
    $count = 0;
    foreach ($cart_result['cart_list'] as $k => $v) {
        $count += intval($v['number']);
    }
    $GLOBALS['tmpl']->assign("cart_count", $count);
    $GLOBALS['tmpl']->assign("head_cart_data", load_cart_list());
    return $GLOBALS['tmpl']->fetch("inc/cart_tip.html");
}
예제 #6
0
 /**
  * 计算购物车总价
  */
 public function count_buy_total()
 {
     global_run();
     require_once APP_ROOT_PATH . "system/model/cart.php";
     $region_id = intval($_REQUEST['region_id']);
     //配送地区
     $delivery_id = intval($_REQUEST['delivery_id']);
     //配送方式
     $account_money = floatval($_REQUEST['account_money']);
     //余额
     $ecvsn = $_REQUEST['ecvsn'] ? addslashes(trim($_REQUEST['ecvsn'])) : '';
     $ecvpassword = $_REQUEST['ecvpassword'] ? addslashes(trim($_REQUEST['ecvpassword'])) : '';
     $payment = intval($_REQUEST['payment']);
     $all_account_money = intval($_REQUEST['all_account_money']);
     $bank_id = strim(trim($_REQUEST['bank_id']));
     $user_id = intval($GLOBALS['user_info']['id']);
     $session_id = es_session::id();
     $cart_result = load_cart_list();
     $goods_list = $cart_result['cart_list'];
     $result = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list, 0, 0, $bank_id);
     $GLOBALS['tmpl']->assign("result", $result);
     $html = $GLOBALS['tmpl']->fetch("inc/cart_total.html");
     $data = $result;
     $data['html'] = $html;
     $data['expire'] = empty($goods_list) ? true : false;
     if ($data['expire']) {
         $data['jump'] = url("index", "cart");
     }
     ajax_return($data);
 }