public function getpriceInfo($pid, $count, $model)
 {
     $list = $this->where("id='{$pid}'")->find();
     if (empty($list)) {
         return false;
     }
     $model_price = $this->model_attr_price($model);
     $list['price'] = (double) (VipPrice($list['price']) + $model_price);
     $list['pricespe'] = (double) (VipPrice($list['pricespe']) + $model_price);
     $list['count'] = $count;
     $ginfo = get_members_group(session('memberID'));
     $list['discount'] = $ginfo['discount'] ? $ginfo['discount'] : 1;
     $list['price_total'] = $list['price'] * $count;
     $list['pricespe_total'] = $list['pricespe'] * $count;
     //优惠活动,1为批发
     if (in_array($list['activity'], array('1'))) {
         switch ($list['activity']) {
             case 1:
                 $PL_model = D('Products_lot');
                 $data = $PL_model->where(array('product_id' => $pid))->select();
                 $maxcount = $PL_model->where("product_id='{$pid}'")->order("maxcount desc")->find();
                 foreach ($data as $k => $v) {
                     if ($count >= $v['mincount'] && $count <= $v['maxcount']) {
                         $list['pricespe'] = $list['price'] = (double) $v['price'];
                         $list['price_total'] = $list['price'] * $count;
                         $list['pricespe_total'] = $list['pricespe'] * $count;
                         break 2;
                     } elseif ($count >= $maxcount['maxcount']) {
                         $list['pricespe'] = $list['price'] = (double) $maxcount['price'];
                         $list['price_total'] = $list['price'] * $count;
                         $list['pricespe_total'] = $list['pricespe'] * $count;
                         break 2;
                     }
                 }
                 break;
         }
     }
     if ($list['price_total'] <= $list['pricespe_total'] && $list['price_total']) {
         $list['total'] = $list['price_total'];
     } else {
         $list['total'] = $list['pricespe_total'];
     }
     if ($discount > 0) {
         $list['total'] = $list['total'] * $discount;
     }
     return $list;
 }
 public function _initialize()
 {
     header("Content-Type:text/html; charset=utf-8");
     //是否关闭网站
     if (GetValue('close_site') == 1) {
         header("HTTP/1.1 500 Internal Server Error");
         header("Status: 500 Internal Server Error");
         die('<div style="margin: 10px; text-align: center; font-size: 14px"><p>The temporary closure of this site, you can not access!</p><p>' . GetValue('close_site_content') . '</p></div>');
     }
     //IP封锁
     if (isset($_COOKIE['ipblock']) && $_COOKIE['ipblock'] == 0) {
     } elseif (isset($_COOKIE['ipblock']) && $_COOKIE["ipblock"] == 1 || GetValue('ipblock') == 1 && GetValue('ipblock_pwd') != '') {
         $ipblock = new Home\Controller\IpblockController();
         $ipblock->index();
     }
     //货币初始化
     $currencies = get_currencies_arr();
     if (!isset($_SESSION['currency'])) {
         for ($i = 0; $i < count($currencies); $i++) {
             if ($currencies[$i]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                 session('currency', $currencies[$i]);
             }
         }
     }
     $this->assign('currencies', $currencies);
     //生产一个唯一的session id
     $this->sessionID = cookie('sessionID');
     if (!$this->sessionID) {
         $this->sessionID = create_session_id();
         cookie('sessionID', $this->sessionID);
     }
     //读取用户id
     $auth_cookie = cookie('auth');
     if (empty($auth_cookie)) {
         $this->memberID = 0;
     } else {
         $auth = daddslashes(explode("\t", authcode($auth_cookie, 'DECODE', C('AUTHKEY'))));
         list($member_id, $member_email) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
         if (!empty($member_id)) {
             $this->memberID = $member_id;
         }
     }
     cookie('memberID', $this->memberID);
     if ($this->memberID) {
         //读取用户信息
         $this->mid = $this->memberID;
         $this->member_Info = D("Members")->where("id=" . $this->memberID)->find();
         $this->assign('member_Info', $this->member_Info);
         $this->member_ShippingAddress = D("Shippingaddress")->get_shippingaddress($this->memberID);
     }
     $this->assign('memberID', $this->memberID);
     $referer = '';
     if (isset($_GET['referer']) && $_GET['referer']) {
         $referer = $_GET['referer'];
     } else {
         if (cookie('referer')) {
             $referer = cookie('referer');
         }
     }
     $this->referer = $referer;
     //当前月份
     $today = getdate();
     $this->month = $today['month'];
     //会员等级
     $this->memberGropuInfo = get_members_group($this->memberID);
     $this->isVip = $this->memberGropuInfo ? 1 : 0;
     $this->ProModel = D('Products');
     $this->assign('catetree', get_catetree());
     $this->assign('itemCount', itemCount());
     $this->assign('copyright', GetValue('footer_content'));
     $this->assign('tongji', GetValue('footcode'));
 }
 function _initialize()
 {
     header("Content-Type:text/html; charset=utf-8");
     L('_OPERATION_SUCCESS_', "Operation Success");
     L('_OPERATION_FAIL_', 'Operation Fail');
     //是否关闭网站
     if (GetValue('close_site') == 1) {
         header("HTTP/1.1 500 Internal Server Error");
         header("Status: 500 Internal Server Error");
         die('<div style="margin: 10px; text-align: center; font-size: 14px"><p>The temporary closure of this site, you can not access!</p><p>' . GetValue('close_site_content') . '</p></div>');
     }
     //IP封锁
     if (isset($_COOKIE['ipblock']) && $_COOKIE['ipblock'] == 0) {
     } elseif (isset($_COOKIE['ipblock']) && $_COOKIE["ipblock"] == 1 || GetValue('ipblock') == 1 && GetValue('ipblock_pwd') != '') {
         import('@.Action.Home.IpblockAction');
         $ipblock = new IpblockAction();
         $ipblock->index();
     }
     $this->ProModel = D('Products');
     //多主题
     if ($this->theme = GetValue('theme')) {
         setcookie('think_template', $this->theme, time() + 3600, '/');
     } else {
         setcookie('think_template', 'default', time() + 3600, '/');
     }
     //多语言
     /*$lang=GetValue('lang');
     		if('auto'!=$lang){
     		setcookie('think_language',$lang?$lang:'en-us',time()+3600,'/');
     		}*/
     //浏览历史
     $this->product_history = product_history();
     //货币初始化
     $this->currencies = $currencies = get_currencies_arr();
     if (!isset($_SESSION['currency'])) {
         for ($row = 0; $row < count($currencies); $row++) {
             if ($currencies[$row]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                 $_SESSION['currency'] = $currencies[$row];
             }
         }
     }
     //生产一个唯一的session id
     $this->sessionID = Cookie::get('sessionID');
     if (!$this->sessionID) {
         $this->sessionID = create_session_id();
         Cookie::set('sessionID', $this->sessionID);
     }
     //读取用户id
     $auth_cookie = Cookie::get('auth');
     if (empty($auth_cookie)) {
         $this->memberID = 0;
     } else {
         $auth = daddslashes(explode("\t", authcode($auth_cookie, 'DECODE', C('AUTHKEY'))));
         list($member_id, $member_email) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
         if (!empty($member_id)) {
             $this->memberID = $member_id;
         }
     }
     Cookie::set('memberID', $this->memberID);
     if ($this->memberID) {
         //读取用户信息
         $this->mid = $this->memberID;
         self::$Model = D("Members");
         $this->memberInfo = self::$Model->where("id=" . $this->memberID)->find();
         $this->member_Info = $this->memberInfo;
         self::$Model = D("Shippingaddress");
         $this->memberShippingAddress = self::$Model->where("id=" . $this->memberID)->find();
         Cookie::set('memberShippingAddress', $this->memberShippingAddress);
         $this->member_ShippingAddress = $this->memberShippingAddress;
         /*$this->_365call="
         		<script type=\"text/javascript\">
         		//<![CDATA[
         		var _365call_memberID  = \"{$this->memberInfo['email']}\"; //  char(20)  账号(会员号)
         		var _365call_clientName= \"{$this->memberInfo['firstname']}{$this->memberInfo['lastname']}\"; //  char(50)  用户名(姓名)
         		var _365call_email     = \"{$this->memberInfo['email']}\"; //  char(50)  邮件地址
         		var _365call_phone     = \"{$this->memberShippingAddress['telphone']}\"; //  char(20)  联系电话
         		var _365call_msn       = \"\"; //  char(50)  MSN
         		var _365call_qq        = \"\"; //  char(20)  QQ
         		var _365call_note      = \"{$this->memberShippingAddress['address']}\"; //  char(100) 其他
         		//]]>
         		</script>";*/
     }
     //当前月份
     $today = getdate();
     $this->month = $today['month'];
     //总重量
     self::$Model = D("Cart");
     $this->Total_weight = self::$Model->cart_total_weight($this->sessionID);
     //购物车商品
     $this->cart_list = self::$Model->cart_list($this->sessionID);
     $this->item_count = itemCount();
     $this->total_count = TotalCount();
     //会员等级
     $this->memberGropuInfo = get_members_group($this->memberID);
     if (get_members_group($this->memberID)) {
         $this->isVip = 1;
     } else {
         $this->isVip = 0;
     }
     /**
      * bof缓存模板变量
      */
     //全局模板变量
     if (F('Common_Cache') == '') {
         F('Common_Cache', $this->_Common_Cache());
     }
     $this->assign(F('Common_Cache'));
     //产品缓存
     if (F('Products_Cache') == '') {
         F('Products_Cache', $this->_Products_Cache());
     }
     //打乱随机显示
     $Products_Cache = F('Products_Cache');
     //$Products_Cache['FeaturedProducts']=$this->ProModel->rand($Products_Cache['FeaturedProducts']);
     //$Products_Cache['HotProducts']=$this->ProModel->rand($Products_Cache['HotProducts']);
     //$Products_Cache['NewProducts']=$this->ProModel->rand($Products_Cache['NewProducts']);
     //$Products_Cache['SpeProducts']=$this->ProModel->rand($Products_Cache['SpeProducts']);
     $this->assign($Products_Cache);
     /**
      * eof缓存模板变量
      */
 }
Exemple #4
0
/**
 * 根据VIP会员等级取得VIP会员价
 *
 */
function VipPrice($price)
{
    $GroupInfo = get_members_group(Session::get('memberID'));
    if ($GroupInfo["discount"]) {
        $VipPrice = $GroupInfo["discount"] * $price;
    } else {
        $VipPrice = $price;
    }
    return $VipPrice;
}
Exemple #5
0
/**
 * 获取价格
 *
 * @param Integer $price 价格
 * @param Integer $spe 特价
 */
function getprice($price, $spe, $discount = true)
{
    //如果没有选择汇率,读取系统默认汇率
    $currencies = get_currencies_arr();
    if (!isset($_SESSION['currency'])) {
        for ($row = 0; $row < count($currencies); $row++) {
            if ($currencies[$row]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                session('currency', $currencies[$row]);
            }
        }
    }
    if ($spe >= $price) {
        //货币汇率
        $re = $_SESSION['currency']['code'] . sprintf("%01.2f", $spe * $_SESSION['currency']['rate']);
        $r_price = $price;
    } else {
        $price *= $_SESSION['currency']['rate'];
        $spe *= $_SESSION['currency']['rate'];
        $spe = sprintf("%01.2f", $spe);
        $price = sprintf("%01.2f", $price);
        if ($discount) {
            //$re=  '<span style="color:red;text-decoration: line-through;">'.$_SESSION ['currency'] ['code'] . $price . '</span>&nbsp;&nbsp;&nbsp;<span style="color:red;">' . $_SESSION ['currency'] ['code'] . $spe . '</span><br />Save:' . number_format ( (($price - $spe) / $price * 100), 0 ) . '% off';
            $re = '<span class="make-price">' . $_SESSION['currency']['code'] . $price . '</span><span class="shop-price">' . $_SESSION['currency']['code'] . $spe . '</span>';
        } else {
            $re = $_SESSION['currency']['code'] . $spe;
        }
        $r_price = $spe;
    }
    $memberID = session('memberID');
    //在价格里头显示vip价格
    if (!$memberID) {
        $memberID = 0;
    }
    $ginfo = get_members_group($memberID);
    if ($ginfo) {
        if ($discount) {
            return $re . " " . $ginfo["name"] . ":" . $_SESSION['currency']['code'] . $r_price * $ginfo["discount"];
        } else {
            return $re;
        }
    }
    return $re;
}
 function points()
 {
     if (empty($_POST["email"])) {
         $this->point = 0;
     } else {
         self::$Model = D("Members");
         $map["email"] = $_POST["email"];
         $list = self::$Model->where($map)->find();
         if ($list) {
             $this->group = get_members_group($list["id"]);
             $this->point = $list["points"];
             $this->email = $list["email"];
         } else {
             $this->error("没有找到该会员!");
         }
     }
     $this->display();
 }