コード例 #1
0
ファイル: baseclass.php プロジェクト: snamper/xiaoshuhaochi
 function init()
 {
     //主要是检测权限
     $controller = Mysite::$app->getController();
     $this->mysql = new mysql_class();
     $this->memberCls = new memberclass($this->mysql);
     $this->member = $this->memberCls->getinfo();
     $this->pageCls = new page();
     $this->admin = $this->memberCls->getadmininfo();
     $this->digui = array();
     //递归处理数组
     $data['member'] = $this->member;
     $data['admininfo'] = $this->admin;
     $checkmodule = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "module  where name='" . $controller . "' and install=1 limit 0,20");
     if (empty($checkmodule) && !in_array($controller, array('site', 'market'))) {
         $this->message('未安装此模版');
     }
     $openid = IFilter::act(IReq::get('openid'));
     //openid='.$this->obj->FromUserName.'&='.$time.'&=
     $actime = IFilter::act(IReq::get('actime'));
     if (!empty($openid) && !empty($actime)) {
         if ($controller == 'wxsite') {
             $sign = IFilter::act(IReq::get('sign'));
             $mycode = Mysite::$app->config['wxtoken'];
             $checkstr = md5($mycode . $actime);
             $checkstr = substr($checkstr, 3, 15);
             if ($checkstr == $sign && !empty($openid)) {
                 $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "wxuser where openid ='" . $openid . "' ");
                 if (!empty($checkinfo)) {
                     ICookie::set('logintype', 'wx', 86400);
                     ICookie::set('wxopenid', $openid, 86400);
                     $backinfo = IFilter::act(IReq::get('backinfo'));
                     if (empty($backinfo)) {
                         $link = IUrl::creatUrl('wxsite/index');
                     } else {
                         $newtr = '';
                         $testinfo = explode(',', $backinfo);
                         foreach ($testinfo as $key => $value) {
                             if (!empty($value)) {
                                 $newtr .= chr($value);
                             }
                         }
                         $link = $newtr;
                         if (empty($link)) {
                             $link = IUrl::creatUrl('wxsite/index');
                         }
                     }
                     $this->message('', $link);
                 }
             }
         }
     }
     $action = Mysite::$app->getAction();
     $data['moduleid'] = $checkmodule['id'];
     $data['moduleparent'] = $checkmodule['parent_id'];
     $id = intval(IFilter::act(IReq::get('id')));
     $data['id'] = $id;
     Mysite::$app->setdata($data);
 }
コード例 #2
0
ファイル: smcart.php プロジェクト: snamper/xiaoshuhaochi
 public function setMyCart($goodsInfo)
 {
     $goodsInfo = str_replace(array('"', ','), array('&', '$'), JSON::encode($goodsInfo));
     $cartName = $this->getCartName();
     if ($this->saveType == 'session') {
         ISession::set($cartName, $goodsInfo);
     } else {
         ICookie::set($cartName, $goodsInfo, '7200');
     }
     return true;
 }
コード例 #3
0
ファイル: adminmethod.php プロジェクト: snamper/xiaoshuhaochi
 function wavecontrol()
 {
     $type = IReq::get('type');
     if ($type == 'closewave') {
         //关闭声音
         ICookie::set('playwave', 2, 2592000);
     } else {
         //开启声音
         ICookie::set('playwave', 0, 2592000);
     }
     $this->success('成功');
 }
コード例 #4
0
ファイル: site.php プロジェクト: xzdesk/iwebshop.com
 function search_list()
 {
     $this->word = IFilter::act(IReq::get('word'), 'text');
     $cat_id = IFilter::act(IReq::get('cat'), 'int');
     if (preg_match("|^[\\w\\s*-�*]+\$|", $this->word)) {
         //搜索关键字
         $tb_sear = new IModel('search');
         $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id');
         //如果是第一页,相应关键词的被搜索数量才加1
         if ($search_info && intval(IReq::get('page')) < 2) {
             //禁止刷新+1
             $allow_sep = "30";
             $flag = false;
             $time = ICookie::get('step');
             if (isset($time)) {
                 if (time() - $time > $allow_sep) {
                     ICookie::set('step', time());
                     $flag = true;
                 }
             } else {
                 ICookie::set('step', time());
                 $flag = true;
             }
             if ($flag) {
                 $tb_sear->setData(array('num' => 'num + 1'));
                 $tb_sear->update('id=' . $search_info['id'], 'num');
             }
         } elseif (!$search_info) {
             //如果数据库中没有这个词的信息,则新添
             $tb_sear->setData(array('keyword' => $this->word, 'num' => 1));
             $tb_sear->add();
         }
     } else {
         IError::show(403, '请输入正确的查询关键词');
     }
     $this->cat_id = $cat_id;
     $this->redirect('search_list');
 }
コード例 #5
0
 public function CreateImage(&$text = '')
 {
     $ini = microtime(true);
     /** Initialization */
     $this->ImageAllocate();
     /** Text insertion */
     $text = $this->GetCaptchaText();
     $fontcfg = $this->fonts[array_rand($this->fonts)];
     $this->WriteText($text, $fontcfg);
     ICookie::set('Captcha', $text, 2592000);
     /** Transformations */
     $this->WaveImage();
     if ($this->blur && function_exists('imagefilter')) {
         imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
     }
     $this->ReduceImage();
     if ($this->debug) {
         imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor);
     }
     /** Output */
     $this->WriteImage();
     $this->Cleanup();
 }
コード例 #6
0
ファイル: memberclass.php プロジェクト: snamper/xiaoshuhaochi
 function regester($email, $tname, $password, $phone, $group, $userlogo = '', $address = '', $cost = 0, $score = 0)
 {
     if (empty($email) && empty($phone)) {
         $this->error = '邮箱和手机不能同时为空';
         return false;
     }
     if (!empty($email)) {
         if (!IValidate::email($email)) {
             $this->error = '邮箱格式错误';
             return false;
         }
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where email='" . $email . "' ");
         if (!empty($userinfo)) {
             $this->error = '邮箱已存在,不可注册';
             return false;
         }
     }
     if (!empty($phone)) {
         if (!IValidate::suremobi($phone)) {
             $this->error = '手机格式错误';
             return false;
         }
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $phone . "' ");
         if (!empty($userinfo)) {
             $this->error = '手机已存在,不可注册';
             return false;
         }
     }
     if (!IValidate::len($tname, 3, 20)) {
         //$this->error = '用户名长度大于3小于20'.$tname;
         //return false;
     }
     if (!IValidate::len($password, 6, 20)) {
         $this->error = '密码长度大于6小于20';
         return false;
     }
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where username='******' ");
     if (!empty($userinfo)) {
         //$this->error = '用户名已存在,不可注册';
         //return false;
     }
     $arr['username'] = $tname;
     $arr['phone'] = $phone;
     $arr['address'] = $address;
     $arr['password'] = md5($password);
     $arr['email'] = $email;
     $arr['creattime'] = time();
     $arr['score'] = $score == 0 ? Mysite::$app->config['regesterscore'] : $score;
     $arr['logintime'] = time();
     $arr['logo'] = $userlogo;
     $arr['loginip'] = IClient::getIp();
     $arr['group'] = $group;
     $arr['cost'] = $cost;
     $arr['parent_id'] = intval(ICookie::get('logincode'));
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'member', $arr);
     $this->uid = $this->mysql->insertid();
     if ($arr['score'] > 0) {
         $this->addlog($this->uid, 1, 1, $arr['score'], '注册送积分', '注册送积分' . $arr['score'], $arr['score']);
     }
     $logintype = ICookie::get('adlogintype');
     $token = ICookie::get('adtoken');
     $openid = ICookie::get('adopenid');
     if (!empty($logintype)) {
         $apiinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "otherlogin where loginname='" . $logintype . "'  ");
         if (!empty($apiinfo)) {
             //更新
             $tempuid = $this->uid;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'oauth', array('uid' => $tempuid), "openid='" . $openid . "' and type = '" . $logintype . "'");
             ICookie::set('logintype', $logintype, 86400);
         }
     }
     if (Mysite::$app->config['regester_juan'] == 1) {
         //注册送优惠券
         $nowtime = time();
         $endtime = $nowtime + Mysite::$app->config['regester_juanday'] * 24 * 60 * 60;
         $juandata['card'] = $nowtime . rand(100, 999);
         $juandata['card_password'] = substr(md5($juandata['card']), 0, 5);
         $juandata['status'] = 1;
         // 状态,0未使用,1已绑定,2已使用,3无效
         $juandata['creattime'] = $nowtime;
         // 制造时间
         $juandata['cost'] = Mysite::$app->config['regester_juancost'];
         // 优惠金额
         $juandata['limitcost'] = Mysite::$app->config['regester_juanlimit'];
         // 购物车限制金额下限
         $juandata['endtime'] = $endtime;
         // 失效时间
         $juandata['uid'] = $this->uid;
         // 用户ID
         $juandata['username'] = $arr['username'];
         // 用户名
         $juandata['name'] = '注册账号赠送优惠券';
         //  优惠券名称
         $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata);
     }
     return true;
 }
コード例 #7
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function loginbycode()
 {
     $uname = IFilter::act(IReq::get('uname'));
     $code = IFilter::act(IReq::get('code'));
     $link = IUrl::creatUrl('member/login');
     $logincode = intval(IFilter::act(IReq::get('logincode')));
     if (!empty($logincode)) {
         ICookie::set('logincode', $logincode, 86400 * 365);
     }
     if (empty($uname)) {
         $this->message('手机不能为空', $link);
         exit;
     }
     if (empty($code)) {
         $this->message('验证码不能为空', $link);
         exit;
     }
     $logintype = IFilter::act(IReq::get('logintype'));
     if (!IValidate::suremobi($uname)) {
         $this->message('联系手机格式错误');
     }
     //$checkcode =    ICookie::get('regphonecode');
     $res = $this->mobilecodecheck($uname, $code);
     if ($res['success'] == 'no') {
         $this->message($res['msg']);
     }
     //if($code != $checkcode) $this->message('手机验证码错误');
     if (!$this->memberCls->login($uname, $pwd = "", $code = true)) {
         $this->message($this->memberCls->ero(), $link);
     }
     $link = IUrl::creatUrl('member/base');
     $this->success('', $link);
 }
コード例 #8
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function mangeshop()
 {
     $this->checkmemberlogin();
     $id = intval(IFilter::act(IReq::get('id')));
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id='" . $id . "' and is_pass=1 and uid=" . $this->member['uid'] . " ");
     $link = IUrl::creatUrl('member/index');
     if (empty($userinfo)) {
         $this->message('未开店或者店铺审核未通过', $link);
     }
     $link = IUrl::creatUrl('shop/useredit');
     ///http://192.168.0.104/index.php?controller=&action=;
     ICookie::set('adminshopid', $id, 86400);
     $this->success('', $link);
 }
コード例 #9
0
ファイル: back.php プロジェクト: snamper/xiaoshuhaochi
        }
    } else {
        if ($uid > 0) {
            $link = IUrl::creatUrl('member/base');
            /*跳转到用户中心*/
        } else {
            $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where  uid  = '" . $oauthinfo['uid'] . "'");
            if (empty($userinfo)) {
                $this->message('账号未查找到,关联账号是否被删除');
            }
            $data['loginip'] = IClient::getIp();
            $data['logintime'] = time();
            $checktime = date('Y-m-d', time());
            $checktime = strtotime($checktime);
            if ($userinfo['logintime'] < $checktime) {
                if (Mysite::$app->config['loginscore'] > 0) {
                    $data['score'] = $userinfo['score'] + Mysite::$app->config['loginscore'];
                    $mess['content'] = '用户登陆赠送积分' . Mysite::$app->config['loginscore'] . '总积分' . $data['score'];
                    $this->memberCls->addlog($userinfo['uid'], 1, 1, Mysite::$app->config['loginscore'], '每天登陆', $mess['content'], $data['score']);
                    // $this->mysql->insert(Mysite::$app->config['tablepre']."message",$mess);
                }
            }
            $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $data, "uid='" . $userinfo['uid'] . "'");
            ICookie::set('logintype', $logintype, 86400);
            ICookie::set('uid', $userinfo['uid'], 86400);
            $link = IUrl::creatUrl('member/base');
            /*跳转到用户中心*/
        }
    }
}
$this->message('', $link);
コード例 #10
0
ファイル: simple -6-29.php プロジェクト: yongge666/sunupedu
 function login_act()
 {
     $login_info = IFilter::act(IReq::get('login_info', 'post'));
     $password = IReq::get('password', 'post');
     $remember = IFilter::act(IReq::get('remember', 'post'));
     $autoLogin = IFilter::act(IReq::get('autoLogin', 'post'));
     $callback = IFilter::act(IReq::get('callback'), 'text');
     $message = '';
     $password = md5($password);
     if ($login_info == '') {
         $message = '请填写用户名或者邮箱';
     } else {
         if (!preg_match('|\\S{6,32}|', $password)) {
             $message = '密码格式不正确,请输入6-32个字符';
         } else {
             if ($userRow = CheckRights::isValidUser($login_info, $password)) {
                 CheckRights::loginAfter($userRow);
                 //记住帐号
                 if ($remember == 1) {
                     ICookie::set('loginName', $login_info);
                 }
                 //自动登录
                 if ($autoLogin == 1) {
                     ICookie::set('autoLogin', $autoLogin);
                 }
                 //自定义跳转页面
                 if ($callback && !strpos($callback, 'reg') && !strpos($callback, 'login')) {
                     $this->redirect($callback);
                 } else {
                     $this->redirect('/ucenter/index');
                 }
             } else {
                 //邮箱未验证
                 $userDB = new IModel('user as u,member as m');
                 $userRow = $userDB->getObj(" (u.email = '{$login_info}' or u.username = '******') and password = '******' ");
                 if ($userRow) {
                     $siteConfig = new Config('site_config');
                     if ($userRow['status'] == 3) {
                         if ($siteConfig->reg_option == 1) {
                             $message = "您的邮箱还未验证,请点击下面的链接发送您的邮箱验证邮件!";
                             $this->redirect('/site/success?message=' . urlencode($message) . '&email=' . $userRow['email']);
                         } else {
                             $message = '您的账号已经被锁定';
                         }
                     }
                 } else {
                     $message = '用户名和密码不匹配';
                 }
             }
         }
     }
     //错误信息
     if ($message) {
         $this->message = $message;
         $_GET['callback'] = $callback;
         $this->redirect('login', false);
     }
 }
コード例 #11
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function selfpayment()
 {
     $data['shopid'] = intval(IReq::get('shopid'));
     //店铺ID
     $data['content'] = '到店自助付款';
     //备注
     $data['paytype'] = IFilter::act(IReq::get('paytype'));
     //支付方式
     $data['dno'] = time() . rand(1000, 9999);
     //订单编号
     $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id = '" . $data['shopid'] . "'    ");
     $data['shopuid'] = $shopinfo['uid'];
     $data['shopaddress'] = $shopinfo['address'];
     $data['shopphone'] = $shopinfo['phone'];
     $data['shopname'] = $shopinfo['shopname'];
     $data['buycode'] = substr(md5(time()), 9, 6);
     $minitime = strtotime(date('Y-m-d', time()));
     $tj = $this->mysql->select_one("select count(id) as shuliang from " . Mysite::$app->config['tablepre'] . "order where shopid='" . $data['shopid'] . "' and addtime > " . $minitime . " limit 0,1000");
     $data['daycode'] = $tj['shuliang'] + 1;
     $data['buyeraddress'] = "in_shop";
     //到店支付
     $panduan = Mysite::$app->config['man_ispass'];
     $data['status'] = $panduan == 1 ? '0' : 1;
     $data['paystatus'] = 0;
     $data['ordertype'] = 5;
     //订单类型
     $data['cxcost'] = 0;
     $data['yhjcost'] = 0;
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress["area1"])) {
         $info_ipaddress = $ipaddress['ip'] . mb_convert_encoding($ipaddress["area1"], 'UTF-8', 'GB2312');
         //('GB2312','ansi',);
         $data['ipaddress'] = $info_ipaddress;
     }
     $data['shopcost'] = IReq::get('shopcost');
     //
     $data['allcost'] = $data['shopcost'];
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'order', $data);
     //写主订单
     $orderid = $this->mysql->insertid();
     $cmd['order_id'] = $orderid;
     $cmd['goodsid'] = '-1';
     $cmd['goodsname'] = '到店自助付款';
     $cmd['goodscost'] = $data['shopcost'];
     $cmd['goodscount'] = 1;
     $cmd['shopid'] = $data['shopid'];
     $cmd['status'] = 0;
     $cmd['is_send'] = 0;
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $cmd);
     ICookie::set('orderid', $orderid, 86400);
     echo json_encode(array('success' => 'yes', 'msg' => $orderid));
     exit;
 }
コード例 #12
0
ファイル: adminmethod.php プロジェクト: snamper/xiaoshuhaochi
 function resetdefualt()
 {
     $shopid = IReq::get('shopid');
     ICookie::set('adminshopid', $shopid, 86400);
     $link = IUrl::creatUrl('shop/useredit');
     $this->refunction('', $link);
 }
コード例 #13
0
ファイル: site.php プロジェクト: Wen1750686723/utao
 function search_list()
 {
     $return = $this->goodsListFilter();
     $this->show_type = $return['show_type'];
     $this->listImageWidth = $return['listImageWidth'];
     $this->listImageHeight = $return['listImageHeight'];
     $this->order = $return['order'];
     $this->orderArray = $return['orderArray'];
     $this->word = IFilter::act(IReq::get('word'));
     $cat_id = intval(IReq::get('cat'));
     if ($this->word != '' && $this->word != '%' && $this->word != '_') {
         if ($cat_id > 0) {
             $tb_goods = new IQuery('goods as go');
             $tb_goods->join = "left join category_extend as ca on go.id = ca.goods_id";
             $tb_goods->where = "go.name like '%{$this->word}%' and go.is_del = 0 and ca.category_id = {$cat_id}";
             $tb_goods->fields = "count(*) as num";
             $goodsNum = $tb_goods->find();
             $this->findSum = $goodsNum[0]['num'];
         } else {
             $goodsObj = new IModel('goods');
             $goodsNum = $goodsObj->getObj('name like "%' . $this->word . '%" and is_del=0', 'count(*) as num');
             $this->findSum = $goodsNum['num'];
         }
         //搜索关键字
         $tb_sear = new IModel('search');
         $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id');
         //如果是第一页,相应关键词的被搜索数量才加1
         if ($search_info && intval(IReq::get('page')) < 2) {
             //禁止刷新+1
             $allow_sep = "30";
             $flag = false;
             $time = ICookie::get('step');
             if (isset($time)) {
                 if (time() - $time > $allow_sep) {
                     ICookie::set('step', time());
                     $flag = true;
                 }
             } else {
                 ICookie::set('step', time());
                 $flag = true;
             }
             if ($flag) {
                 $tb_sear->setData(array('num' => 'num + 1'));
                 $tb_sear->update('id=' . $search_info['id'], 'num');
             }
         } elseif (!$search_info) {
             //如果数据库中没有这个词的信息,则新添
             $tb_sear->setData(array('keyword' => $this->word, 'num' => 1));
             $tb_sear->add();
         }
     } else {
         IError::show(403, '请输入正确的查询关键词');
     }
     $this->cat_id = $cat_id;
     $this->redirect('search_list');
 }
コード例 #14
0
ファイル: frontend.php プロジェクト: Wen1750686723/utao
 /**
  *	列表展示
  *	@author keenhome@126.com
  *	@date 2013-4-30
  */
 public function glist()
 {
     $word = IFilter::act(IReq::get('kw'));
     $ids = IFilter::act(IReq::get('ids'), 'string');
     $arr_ids = $ids ? explode('_', $ids) : array();
     $top_cid = isset($arr_ids[0]) ? intval($arr_ids[0]) : 0;
     $second_cid = isset($arr_ids[1]) ? intval($arr_ids[1]) : 0;
     $third_cid = isset($arr_ids[2]) ? intval($arr_ids[2]) : 0;
     $forth_cid = isset($arr_ids[3]) ? intval($arr_ids[3]) : 0;
     $bid = isset($arr_ids[4]) ? intval($arr_ids[4]) : 0;
     $prid = isset($arr_ids[5]) ? intval($arr_ids[5]) : 0;
     $prid = $prid > count($this->site_config['price_range']) - 1 ? count($this->site_config['price_range']) - 1 : $prid;
     $sort = isset($arr_ids[6]) ? intval($arr_ids[6]) : 0;
     $sort = $sort > count($this->sort_type_map) - 1 ? count($this->sort_type_map) - 1 : $sort;
     $page = isset($arr_ids[7]) ? intval($arr_ids[7]) : 0;
     $pagesize = $this->site_config['list_num'];
     $order_by = $this->sort_type_map[$sort] ? $this->sort_type_map[$sort] : "{$this->tablePre}goods.sort ASC";
     $start = $page * $pagesize;
     $all_goods_list = array();
     $total_num = array();
     $goods_list = array();
     $data = array();
     $brands = array();
     $subcat = array();
     $cname = '';
     $title = '';
     $description = '';
     $keywords = '';
     if ($top_cid || $second_cid || $word) {
         $categoryObj = new IModel('category');
         $where = "{$this->tablePre}goods.is_del=0";
         $cids = '';
         if ($third_cid) {
             $cids = Block::getCategroy($third_cid);
         } elseif ($second_cid) {
             $cids = Block::getCategroy($second_cid);
         } elseif ($top_cid) {
             $cids = Block::getCategroy($top_cid);
         }
         if ($cids) {
             $cids = substr($cids, 0, -1);
             $where .= " AND {$this->tablePre}category_extend.category_id IN ({$cids})";
         }
         if ($word && $word != '%' && $word != '_') {
             $where .= " AND ( {$this->tablePre}goods.name LIKE '%{$word}%' OR {$this->tablePre}goods.sellernick\n LIKE '%{$word}%' ) ";
             // 记录搜索词频
             //搜索关键字
             $tb_sear = new IModel('search');
             $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id');
             //如果是第一页,相应关键词的被搜索数量才加1
             if ($search_info && $page < 2) {
                 //禁止刷新+1
                 $allow_sep = "30";
                 $flag = false;
                 $time = ICookie::get('step');
                 if (isset($time)) {
                     if (time() - $time > $allow_sep) {
                         ICookie::set('step', time());
                         $flag = true;
                     }
                 } else {
                     ICookie::set('step', time());
                     $flag = true;
                 }
                 if ($flag) {
                     $tb_sear->setData(array('num' => 'num + 1'));
                     $tb_sear->update('id=' . $search_info['id'], 'num');
                 }
             } elseif (!$search_info) {
                 //如果数据库中没有这个词的信息,则新添
                 $tb_sear->setData(array('keyword' => $this->word, 'num' => 1));
                 $tb_sear->add();
             }
         }
         $all_where = $where;
         if ($bid > 0) {
             $where .= " AND {$this->tablePre}goods.brand_id={$bid}";
         }
         if ($prid > 0) {
             $where .= " AND {$this->tablePre}goods.sell_price>=" . $this->site_config['price_range'][$prid - 1] . " AND  {$this->tablePre}goods.sell_price<=" . $this->site_config['price_range'][$prid];
         }
         // 取所有商品基本信息
         $sql = "SELECT DISTINCT({$this->tablePre}goods.id),{$this->tablePre}goods.brand_id,{$this->tablePre}category.parent_id,{$this->tablePre}category.name as cname,{$this->tablePre}category.id as cid FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$all_where}";
         $all_goods_list = $categoryObj->query_sql($sql);
         // 取分页总数
         $sql = "SELECT DISTINCT({$this->tablePre}goods.id) FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$where}";
         $total_num = $categoryObj->query_sql($sql);
         $fields = " DISTINCT({$this->tablePre}goods.id),\n\t\t\t\t\t\t{$this->tablePre}category.parent_id,\n\t\t\t\t\t\t{$this->tablePre}goods.*,\n\t\t\t\t\t\t{$this->tablePre}category.id as cid,\n\t\t\t\t\t\t{$this->tablePre}brand.name as bname ";
         if ($word && !$cids) {
             $fields .= ",{$this->tablePre}category.name as cname";
         }
         if (!$cids && $third_cid) {
             $where .= " AND {$this->tablePre}category_extend.category_id=({$third_cid})";
         }
         // 获取商品列表
         $sql = "SELECT {$fields} FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}brand ON {$this->tablePre}brand.id={$this->tablePre}goods.brand_id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tORDER BY {$order_by}\n\t\t\t\t\tLIMIT {$start},{$pagesize}";
         $goods_list = $categoryObj->query_sql($sql);
         // 获取二级类的名称
         if ($second_cid) {
             $sql = "SELECT id,name,title,keywords,descript \n\t\t\t\t\t\tFROM {$this->tablePre}category \n\t\t\t\t\t\tWHERE id={$second_cid} \n\t\t\t\t\t\tORDER BY {$this->tablePre}category.sort ASC";
             $second_catinfo = $categoryObj->query_sql($sql);
             if (count($second_catinfo) > 0) {
                 $cname = $second_catinfo[0]['name'];
                 $title = $second_catinfo[0]['title'] ? '【' . $cname . '】' . $second_catinfo[0]['title'] : '';
                 $description = $second_catinfo[0]['descript'];
                 $keywords = $second_catinfo[0]['keywords'];
             }
             // 获取3级类
             $sql = "SELECT id,name FROM {$this->tablePre}category WHERE parent_id={$second_cid} ORDER BY {$this->tablePre}category.sort ASC";
             $subcat = $categoryObj->query_sql($sql);
         }
         if (!$cids && count($all_goods_list) > 0) {
             $top_cids = array();
             $top_cat_info = array();
             $second_cids = array();
             $second_cat_info = array();
             $third_cids = array();
             $third_cat_info = array();
             // 取顶级类
             foreach ($all_goods_list as $key => $item) {
                 if ($item['parent_id'] == -1) {
                     $top_cids[$item['cid']] = $item['cid'];
                     $top_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']);
                 }
             }
             foreach ($all_goods_list as $key => $item) {
                 if (!$item['cid']) {
                     continue;
                 }
                 // 取2级类
                 if (in_array($item['parent_id'], $top_cids)) {
                     $second_cids[$item['cid']] = $item['cid'];
                     $second_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']);
                 } else {
                     $third_cids[$item['cid']] = $item['cid'];
                     $third_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']);
                 }
             }
             if (count($third_cids) > 0) {
                 $cids = implode(',', $third_cids);
                 $subcat = $third_cat_info;
             } elseif (count($second_cids) > 0) {
                 $cids = implode(',', $second_cids);
                 $subcat = $second_cat_info;
             } elseif (count($top_cids) > 0) {
                 $cids = implode(',', $top_cids);
                 $subcat = $top_cat_info;
             }
         }
         $bids = array();
         if (count($all_goods_list) > 0) {
             // 取品牌id
             foreach ($all_goods_list as $key => $item) {
                 if ($item['brand_id']) {
                     $bids[$item['brand_id']] = $item['brand_id'];
                 }
             }
         }
         // 获取所有品牌
         if (count($bids) > 0) {
             $bids_string = implode(',', $bids);
             $sql = "SELECT * FROM {$this->tablePre}brand WHERE id IN({$bids_string}) ORDER BY {$this->tablePre}brand.sort ASC";
             $brands = $categoryObj->query_sql($sql);
         }
     }
     $data['goods_list'] = $goods_list;
     $data['cname'] = $cname;
     $data['top_cid'] = $top_cid;
     $data['second_cid'] = $second_cid;
     $data['third_cid'] = $third_cid;
     $data['forth_cid'] = $forth_cid;
     $data['bid'] = $bid;
     $data['prid'] = $prid;
     $data['kw'] = $word;
     $data['sort'] = $sort;
     $data['brands'] = count($brands) > 0 ? $brands : '';
     $data['price_range'] = count($this->site_config['price_range']) > 0 ? $this->site_config['price_range'] : '';
     $data['subcat'] = count($subcat) > 0 ? $subcat : '';
     $data['page'] = $page;
     $data['pagesize'] = $pagesize;
     $data['goodsNum'] = count($total_num);
     $data['title'] = $title ? $title : '【' . $cname . '】' . '商品列表-优加网(ujia.info)';
     $data['description'] = $description;
     $data['keywords'] = $keywords;
     $this->setRenderData($data);
     $this->redirect('glist');
 }
コード例 #15
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function makeorder()
 {
     $info['shopid'] = intval(IReq::get('shopid'));
     //店铺ID
     $info['remark'] = IFilter::act(IReq::get('remark'));
     //备注
     $info['paytype'] = IFilter::act(IReq::get('paytype'));
     //支付方式IFilter::act(IReq::get('paytype'));//支付方式
     $info['dikou'] = 0;
     //intval(IReq::get('dikou'));//抵扣金额
     $info['username'] = IFilter::act(IReq::get('username'));
     $info['mobile'] = IFilter::act(IReq::get('mobile'));
     $info['addressdet'] = IFilter::act(IReq::get('addressdet'));
     $info['senddate'] = date('Y-m-d', time());
     // IFilter::act(IReq::get('senddate'));
     $info['minit'] = IFilter::act(IReq::get('minit'));
     $info['juanid'] = 0;
     //intval(IReq::get('juanid'));//优惠劵ID
     $info['ordertype'] = 5;
     //订单类型
     $peopleNum = IFilter::act(IReq::get('peopleNum'));
     $info['othercontent'] = '';
     //empty($peopleNum)?'':serialize(array('人数'=>$peopleNum));
     if (empty($info['shopid'])) {
         $this->message('店铺ID错误');
     }
     $Cart = new smCart();
     $carinfo = $Cart->getMyCart();
     if (!isset($carinfo['list'][$info['shopid']]['data'])) {
         $this->message('对应店铺购物车商品为空');
     }
     if ($carinfo['list'][$info['shopid']]['shopinfo']['shoptype'] == 1) {
         $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopmarket as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     } else {
         $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     }
     if (empty($shopinfo)) {
         $this->message('店铺获取失败');
     }
     $checkps = $this->pscost($shopinfo, $carinfo['list'][$info['shopid']]['count']);
     if ($checkps['canps'] != 1) {
         $this->message('该店铺不在配送范围内');
     }
     $info['cattype'] = 0;
     //
     if (empty($info['username'])) {
         $this->message('联系人不能为空');
     }
     if (!IValidate::suremobi($info['mobile'])) {
         $this->message('请输入正确的手机号');
     }
     if (empty($info['addressdet'])) {
         $this->message('详细地址为空');
     }
     $info['userid'] = !isset($this->member['score']) ? '0' : $this->member['uid'];
     if (Mysite::$app->config['allowedguestbuy'] != 1) {
         if ($info['userid'] == 0) {
             $this->message('禁止游客下单');
         }
     }
     //判断库存
     $senddate = $info['senddate'];
     $minit = $info['minit'];
     $nowpost = strtotime($senddate . ' ' . $minit . ':00');
     $day = strtotime(date('Y-m-d', $nowpost));
     $goods_id_list = [];
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         $goods_id_list[] = $value['id'];
     }
     $goods_ids = implode(',', $goods_id_list);
     $stock_info_list = $this->mysql->getarr("SELECT goods_id,stock FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id in ({$goods_ids}) AND day={$day}");
     $stock_list = [];
     foreach ($stock_info_list as $key => $value) {
         $stock_list[$value['goods_id']] = $value['stock'];
     }
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         if ($value['daycount'] - $stock_list[$value['id']] - $value['count'] < 0) {
             $this->message($valeu['name'] . '库存不足');
             exit;
         }
     }
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress["area1"])) {
         $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress["area1"], 'UTF-8', 'GB2312');
         //('GB2312','ansi',);
     }
     //area1 二级地址名称	area2 三级地址名称	area3
     $nowID = intval(ICookie::get('myaddress'));
     if (empty($nowID)) {
         $this->message('未选择配送区域');
     }
     $checkareaid = $nowID;
     $dataareaids = array();
     while ($checkareaid > 0) {
         $temp_check = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id ='" . $checkareaid . "'   order by id desc limit 0,50");
         if (empty($temp_check)) {
             break;
         }
         if (in_array($checkareaid, $dataareaids)) {
             break;
         }
         $dataareaids[] = $checkareaid;
         $checkareaid = $temp_check['parent_id'];
     }
     $data['areaids'] = join(',', $dataareaids);
     /*
     	  $checksend = Mysite::$app->config['ordercheckphone'];
         if($checksend == 1){
         	  if(empty($this->member['uid'])){
         	  	  $checkphone = $this->mysql->select_one("select * from ".Mysite::$app->config['tablepre']."mobile where phone ='".$info['mobile']."'   order by addtime desc limit 0,50");
         	  	  if(empty($checkphone)) $this->message('短信验证码不能为空');
         	  	  if(empty($checkphone['is_send'])){
         	  	    $mycode = IFilter::act(IReq::get('phonecode'));
         	  	    if($mycode == $checkphone['code']){
         	  	       $this->mysql->update(Mysite::$app->config['tablepre'].'mobile',array('is_send'=>1),"phone='".$info['mobile']."'");
         	  	    }else{
         	  	       $this->message('验证码不一致');
         	  	    }
         	  	  }
         	  }
         }*/
     $data['shopcost'] = 0;
     //:店铺商品总价
     $data['shopps'] = 0;
     //店铺配送费
     $data['bagcost'] = 0;
     //:打包费
     //获取店铺商品总价  获取超市商品总价
     $data['shopcost'] = $carinfo['list'][$info['shopid']]['sum'];
     $data['shopps'] = $checkps['pscost'];
     $data['bagcost'] = $carinfo['list'][$info['shopid']]['bagcost'];
     //支付方式检测
     $data['paytype'] = $info['paytype'];
     $paytype = $info['paytype'];
     if ($paytype != 'outpay') {
         if ($paytype == 'open_acout') {
             /*  if(Mysite::$app->config['open_acout'] != 1 || $userid == 0){
              	    $data['paytype'] = 'outpay';
                 }*/
         } else {
             $paylist = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "paylist where loginname='" . $paytype . "'  order by id desc  ");
             if ($paylist < 1) {
                 $data['paytype'] = 'outpay';
             }
         }
     }
     //判断促销
     $data['cxids'] = '';
     $data['cxcost'] = 0;
     $zpin = array();
     $cattype = $info['cattype'];
     if ($data['shopcost'] > 0) {
         $sellrule = new sellrule();
         $cxtypeid = $cattype + 1;
         $sellrule->setdata($info['shopid'], $data['shopcost'], $shopinfo['shoptype']);
         $ruleinfo = $sellrule->getdata();
         $data['cxcost'] = $ruleinfo['downcost'];
         $data['cxids'] = $ruleinfo['cxids'];
         $zpin = $ruleinfo['zid'];
         //赠品
         $data['shopps'] = $ruleinfo['nops'] == true ? 0 : $data['shopps'];
     }
     //判断优惠劵
     $allcost = $data['shopcost'];
     $data['yhjcost'] = 0;
     $data['yhjids'] = '';
     $juanid = $info['juanid'];
     $userid = $info['userid'];
     if ($juanid > 0 && $userid > 0) {
         $juaninfo = $this->mysql->select_one("select *  from " . Mysite::$app->config['tablepre'] . "juan  where id= '" . $juanid . "' and uid='" . $userid . "'  and status = 1 and endtime > " . time() . " ");
         if (!empty($juaninfo)) {
             if ($allcost >= $juaninfo['limitcost']) {
                 $data['yhjcost'] = $juaninfo['cost'];
                 $juandata['status'] = 2;
                 $juandata['usetime'] = time();
                 $this->mysql->update(Mysite::$app->config['tablepre'] . 'juan', $juandata, "id='" . $juanid . "'");
                 $data['yhjids'] = $juanid;
             }
         }
     }
     //积分抵扣
     $allcost = $allcost - $data['cxcost'] - $data['yhjcost'];
     $data['scoredown'] = 0;
     $dikou = $info['dikou'];
     if (!empty($userid) && $dikou > 0 && Mysite::$app->config['scoretocost'] > 0 && $allcost > $dikou) {
         $checkuser = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $userid . "'  ");
         if (is_array($checkuser)) {
             $checkscore = $dikou * intval(Mysite::$app->config['scoretocost']);
             if ($checkuser['score'] >= $checkscore) {
                 $data['scoredown'] = $checkscore;
                 $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`score`=`score`-' . $checkscore, "uid ='" . $userid . "' ");
             }
         }
     }
     $dikou = $data['scoredown'] > 0 ? $dikou : 0;
     $allcost = $allcost - $dikou;
     $data['allcost'] = $allcost + $data['shopps'] + $data['bagcost'];
     //订单应收费用
     $data['shopuid'] = 0;
     // 店铺UID
     $data['shopid'] = 0;
     //店铺ID
     $data['shopname'] = '商城';
     //店铺名称
     $data['shopphone'] = Mysite::$app->config['marketphone'];
     //店铺电话
     $data['shopaddress'] = '';
     // 店铺地址
     $data['pstype'] = $checkps['pstype'];
     $data['shoptype'] = $shopinfo['shoptype'];
     //检测店铺
     //$senddate = $info['senddate'];
     //$minit = $info['minit'];
     //$nowpost = strtotime($senddate.' '.$minit.':00');
     $settime = time() - 10 * 60;
     // if($settime > $nowpost)  $this->message('提交配送时间和服务器时间相差超过10分钟下单失败');
     $temp = strtotime($minit . ':00');
     $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime'];
     $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']);
     if (!$tempinfo) {
         $this->message('配送时间不在有效配送时间范围');
     }
     if ($shopinfo['is_open'] != 1) {
         $this->message('店铺暂停营业');
     }
     if ($shopinfo['limitcost'] > $allcost) {
         $this->message('商品总价低于最小起送价' . $shopinfo['limitcost']);
     }
     $data['shopuid'] = $shopinfo['uid'];
     // 店铺UID
     $data['shopid'] = $shopinfo['id'];
     //店铺ID
     $data['shopname'] = $shopinfo['shopname'];
     //店铺名称
     $data['shopphone'] = $shopinfo['phone'];
     //店铺电话
     $data['shopaddress'] = $shopinfo['address'];
     // 店铺地址
     $data['buyeraddress'] = $info['addressdet'];
     $data['ordertype'] = $info['ordertype'];
     //来源方式;
     $data['buyeruid'] = $userid;
     // 购买用户ID,0未注册用户
     $data['buyername'] = $info['username'];
     //购买热名称
     $data['buyerphone'] = $info['mobile'];
     // 联系电话
     $panduan = Mysite::$app->config['man_ispass'];
     $data['status'] = $panduan == 1 ? '0' : 1;
     $data['paystatus'] = 0;
     // 支付状态1已支付
     $data['content'] = $info['remark'];
     // 订单备注
     $data['is_make'] = Mysite::$app->config['allowed_is_make'] == 1 ? 0 : 1;
     //  daycode 当天订单序号
     $data['ipaddress'] = $info['ipaddress'];
     $data['is_ping'] = 0;
     // 是否评价字段 1已评完 0未评
     $data['addtime'] = time();
     $data['posttime'] = $nowpost;
     //: 配送时间
     $data['othertext'] = $info['othercontent'];
     //其他说明
     //  :审核时间
     $data['passtime'] = time();
     if ($data['status'] == 1) {
         $data['passtime'] == 0;
     }
     $data['buycode'] = substr(md5(time()), 9, 6);
     $data['dno'] = time() . rand(1000, 9999);
     $minitime = strtotime(date('Y-m-d', time()));
     $tj = $this->mysql->select_one("select count(id) as shuliang from " . Mysite::$app->config['tablepre'] . "order where shopid='" . $info['shopid'] . "' and addtime > " . $minitime . " limit 0,1000");
     $data['daycode'] = $tj['shuliang'] + 1;
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'order', $data);
     //写主订单
     $orderid = $this->mysql->insertid();
     $this->orderid = $orderid;
     //$day = strtotime(date('Y-m-d',$nowpost));
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         $cmd['order_id'] = $orderid;
         $cmd['goodsid'] = $value['id'];
         $cmd['goodsname'] = $value['name'];
         $cmd['goodscost'] = $value['cost'];
         $cmd['goodscount'] = $value['count'];
         $cmd['shopid'] = $value['shopid'];
         $cmd['status'] = 0;
         $cmd['is_send'] = 0;
         $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $cmd);
         //减库存pinkky
         $daystock = $this->mysql->select_one("SELECT * FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id=" . $value['id'] . " and day=" . $day);
         if ($daystock) {
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'daystock', '`stock`=`stock`+1', "id=" . $daystock['id']);
         } else {
             $stockdata['goods_id'] = $value['id'];
             $stockdata['day'] = $day;
             $stockdata['stock'] = 1;
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'daystock', $stockdata);
         }
         //$this->mysql->update(Mysite::$app->config['tablepre'].'goods','`count`=`count`-'.$cmd['goodscount'].' ,`sellcount`=`sellcount`+'.$cmd['goodscount'],"id='".$cmd['goodsid']."'");
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', '`sellcount`=`sellcount`+' . $cmd['goodscount'], "id='" . $cmd['goodsid'] . "'");
     }
     if (is_array($zpin)) {
         foreach ($zpin as $key => $value) {
             $datadet['order_id'] = $orderid;
             $datadet['goodsid'] = $key;
             $datadet['goodsname'] = $value['presenttitle'];
             $datadet['goodscost'] = 0;
             $datadet['goodscount'] = 1;
             $datadet['shopid'] = $checkshopid;
             $datadet['status'] = 0;
             $datadet['is_send'] = 1;
             //更新促销规则中 此赠品的数量
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $datadet);
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'rule', '`controlcontent`=`controlcontent`-1', "id='" . $key . "'");
         }
     }
     $checkbuyer = Mysite::$app->config['allowedsendbuyer'];
     if (Mysite::$app->config['man_ispass'] != 1) {
         $orderCLs = new orderclass($this->mysql);
         $orderCLs->sendmess($orderid);
     }
     if ($userid == 0) {
         ICookie::set('orderid', $orderid, 86400);
     } else {
         //保持地址数据
         $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address where userid='" . $userid . "'  ");
         if (empty($checkinfo)) {
             $addata['userid'] = $this->member['uid'];
             $addata['username'] = $this->member['username'];
             $addata['address'] = $data['buyeraddress'];
             $addata['phone'] = $data['buyerphone'];
             $addata['contactname'] = $data['buyername'];
             $addata['default'] = 1;
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'address', $addata);
         }
     }
     $Cart->delshop($info['shopid']);
     $this->success($orderid);
 }
コード例 #16
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 public function makeorder()
 {
     $subtype = intval(IReq::get("subtype"));
     $info['shopid'] = intval(IReq::get("shopid"));
     $info['remark'] = IFilter::act(IReq::get("content"));
     $info['paytype'] = IFilter::act(IReq::get("paytype"));
     $info['username'] = IFilter::act(IReq::get("contactname"));
     $info['mobile'] = IFilter::act(IReq::get("phone"));
     $info['addressdet'] = IFilter::act(IReq::get("addressdet"));
     $info['senddate'] = IFilter::act(IReq::get("senddate"));
     $info['minit'] = IFilter::act(IReq::get("orderTime"));
     $info['juanid'] = intval(IReq::get("juanid"));
     $info['ordertype'] = 1;
     $peopleNum = IFilter::act(IReq::get("personcount"));
     $info['othercontent'] = empty($peopleNum) ? "" : serialize(array("人数" => $peopleNum));
     $info['userid'] = !isset($this->member['score']) ? "0" : $this->member['uid'];
     if (Mysite::$app->config['allowedguestbuy'] != 1 && $info['userid'] == 0) {
         $this->message("member_nologin");
     }
     $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     if (empty($shopinfo)) {
         $this->message("店铺不存在");
     }
     $checksend = Mysite::$app->config['ordercheckphone'];
     if ($checksend == 1 && empty($this->member['uid'])) {
         $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $info['mobile'] . "'   order by addtime desc limit 0,50");
         if (empty($checkphone)) {
             $this->message("member_emailyan");
         }
         if (empty($checkphone['is_send'])) {
             $mycode = IFilter::act(IReq::get("phonecode"));
             if ($mycode == $checkphone['code']) {
                 $this->mysql->update(Mysite::$app->config['tablepre'] . "mobile", array("is_send" => 1), "phone='" . $info['mobile'] . "'");
             } else {
                 $this->message("member_emailyan");
             }
         }
     }
     if (empty($info['username'])) {
         $this->message("emptycontact");
     }
     if (!IValidate::suremobi($info['mobile'])) {
         $this->message("errphone");
     }
     $info['ipaddress'] = "";
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress['area1'])) {
         $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress['area1'], "UTF-8", "GB2312");
     }
     $info['cattype'] = 0;
     $senddate = $info['senddate'];
     $minit = $info['minit'];
     $nowpost = strtotime($senddate . " " . $minit . ":00");
     $settime = time() - 600;
     if ($nowpost < $settime) {
         $this->message("提交配送时间和服务器时间相差超过10分钟下单失败");
     }
     $temp = strtotime($minit . ":00");
     $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime'];
     $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']);
     if (!$tempinfo) {
         $this->message("配送时间不在有效配送时间范围");
     }
     if ($shopinfo['is_open'] != 1) {
         $this->message("店铺暂停营业");
     }
     $info['paytype'] = $info['paytype'] == 1 ? 1 : 0;
     $info['areaids'] = "";
     $info['shopinfo'] = $shopinfo;
     if ($subtype == 1) {
         $info['allcost'] = 0;
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
         $info['goodslist'] = array();
     } else {
         if (empty($info['shopid'])) {
             $this->message("shop_noexit");
         }
         $Cart = new smCart();
         $Cart->cartName = 'platesmcart';
         $carinfo = $Cart->getMyCart();
         if (!isset($carinfo['list'][$info['shopid']]['data'])) {
             $this->message("shop_emptycart");
         }
         $info['allcost'] = $carinfo['list'][$info['shopid']]['sum'];
         $info['goodslist'] = $carinfo['list'][$info['shopid']]['data'];
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
     }
     $info['shopps'] = 0;
     $info['pstype'] = 0;
     $info['cattype'] = 1;
     $info['is_goshop'] = 1;
     $info['subtype'] = $subtype;
     $info['sendtime'] = $nowpost;
     $orderclass = new orderclass($this->mysql);
     $orderclass->orderyuding($info);
     $orderid = $orderclass->getorder();
     if ($info['userid'] == 0) {
         ICookie::set("orderid", $orderid, 86400);
     }
     if ($subtype == 2) {
         $Cart->delshop($info['shopid']);
     }
     $this->success($orderid);
     exit;
 }
コード例 #17
0
ファイル: regiment.php プロジェクト: chenyongze/iwebshop
 /**
  * 用户报名参加团购
  *
  * 用户可以参加本次团购的条件:
  * 1.本次团购还没有满员
  * 2.一小时二十五分钟内,用户在本次团购中没有未完成的交易
  *
  * regiment_user_relation表中的is_over:0代表着还没有完成,1代表着已经完成交易了
  * 如果用户没有登录便参加团购,会生成一个hash存在cookie里,名字为regiment_100,其中100是相应团购的id
  * 并将此hash保存在regiment_user_relation表的hash字段里。在用户付账需要登录的时候应该查询这个hash并更新相应的user_id
  *
  * @static
  */
 public static function join($id, $user_id = null)
 {
     $id = intval($id);
     $now = time();
     $regiment = self::getRegimentById($id);
     $time_limit = self::time_limit();
     if ($regiment === false || 0 != $regiment['store_nums'] && $regiment['user_num'] >= $regiment['store_nums'] || strtotime($regiment['end_time']) < $now || strtotime($regiment['start_time']) > $now) {
         return array('flag' => 'msg', 'data' => '本次团购已过期或者人满');
     }
     $tb = new IModel("regiment_user_relation");
     $data = array('user_id' => "", 'hash' => "", 'regiment_id' => $id, 'join_time' => date("Y-m-d H:i:s", $now), 'is_over' => 0);
     if ($user_id !== null) {
         $user_id = intval($user_id);
         $re = $tb->query("regiment_id={$id} AND user_id={$user_id} AND is_over=0");
         $data['user_id'] = $user_id;
     } else {
         $hash = ICookie::get("regiment_{$id}");
         if ($hash === null) {
             $hash = IHash::md5(serialize($_SERVER) . microtime(1));
             ICookie::set("regiment_{$id}", $hash, $time = $time_limit * 60);
         }
         $re = $tb->query("regiment_id={$id} AND hash='{$hash}' AND is_over=0");
         $data['hash'] = $hash;
     }
     if ($re) {
         $re = end($re);
     }
     if (count($re) == 0 || strtotime($re['join_time']) < $now - $time_limit * 60) {
         $tb->setData($data);
         //$relation_id是关系表的主键
         if ($re) {
             $tb->update("id={$re['id']}");
             $relation_id = $re['id'];
         } else {
             $relation_id = $tb->add();
         }
         return array('flag' => true, 'data' => '参与成功', 'relation_id' => $relation_id);
     } else {
         return array('flag' => false, 'data' => '本次团购您存在未完成交易');
     }
 }
コード例 #18
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function changeshop()
 {
     $id = intval(IFilter::act(IReq::get('id')));
     $link = IUrl::creatUrl('site/index/');
     if ($id < 1) {
         $this->message('获取店铺ID失败', $link);
     }
     $grade = Mysite::$app->config['area_grade'];
     $temp_where = '';
     $doarea = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "area where parent_id in(select id from " . Mysite::$app->config['tablepre'] . "area where parent_id =0) ");
     if ($grade == 1) {
         $where = ' and areaid  in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0)';
     } elseif ($grade == 2) {
         $where = ' and areaid  in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0)) ';
     } elseif ($grade == 3) {
         $where = ' and areaid   in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0))) ';
     }
     $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatoadd where shopid=" . $id . " " . $where . "");
     if (empty($checkinfo)) {
         $this->message('获取店铺区域信息失败', $link);
     }
     $arealist = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id = " . $checkinfo['areaid'] . " order by orderid asc ");
     if (empty($arealist)) {
         $this->message('获取店铺区域信息失败', $link);
     }
     ICookie::set('lng', $arealist['lng'], 2592000);
     ICookie::set('lat', $arealist['lat'], 2592000);
     ICookie::set('mapname', $arealist['name'], 2592000);
     ICookie::set('myaddress', $checkinfo['areaid'], 2592000);
     $cookmalist = ICookie::get('cookmalist');
     $cooklnglist = ICookie::get('cooklnglist');
     $cooklatlist = ICookie::get('cooklatlist');
     $check = explode(',', $cookmalist);
     if (!in_array($arealist['name'], $check)) {
         $cookmalist = empty($cookmalist) ? $arealist['name'] . ',' : $arealist['name'] . ',' . $cookmalist;
         $cooklatlist = empty($cooklatlist) ? $arealist['lat'] . ',' : $arealist['lat'] . ',' . $cooklatlist;
         $cooklnglist = empty($cooklnglist) ? $arealist['lng'] . ',' : $arealist['lng'] . ',' . $cooklnglist;
         ICookie::set('cookmalist', $cookmalist, 2592000);
         ICookie::set('cooklatlist', $cooklatlist, 2592000);
         ICookie::set('cooklnglist', $cooklnglist, 2592000);
     }
     $link = IUrl::creatUrl('shop/index/id/' . $id);
     $this->message('', $link);
 }
コード例 #19
0
ファイル: method.php プロジェクト: snamper/xiaoshuhaochi
 function giftlog()
 {
     $backinfo = $this->checkappMem();
     if (empty($backinfo['uid'])) {
         $this->message('nologin');
     } else {
         if ($this->member['uid'] == 0) {
             ICookie::set('email', $backinfo['email'], 86400);
             ICookie::set('memberpwd', ICookie::get('apppwd'), 86400);
             ICookie::set('membername', $backinfo['username'], 86400);
             ICookie::set('uid', $backinfo['uid'], 86400);
         }
     }
     echo '获取礼品记录';
     exit;
 }
コード例 #20
0
ファイル: simple.php プロジェクト: Wen1750686723/utao
 function login_act()
 {
     $login_info = IFilter::act(IReq::get('login_info', 'post'));
     $password = IReq::get('password', 'post');
     $remember = IFilter::act(IReq::get('remember', 'post'));
     $autoLogin = IFilter::act(IReq::get('autoLogin', 'post'));
     $callback = IReq::get('callback');
     $message = '';
     if ($login_info == '') {
         $message = '请填写用户名或者邮箱';
     } else {
         if (!preg_match('|\\S{6,32}|', $password)) {
             $message = '密码格式不正确,请输入6-32个字符';
         } else {
             if ($userRow = CheckRights::isValidUser($login_info, md5($password))) {
                 $this->loginAfter($userRow);
                 //记住帐号
                 if ($remember == 1) {
                     ICookie::set('loginName', $login_info);
                 }
                 //自动登录
                 if ($autoLogin == 1) {
                     ICookie::set('autoLogin', $autoLogin);
                 }
                 //自定义跳转页面
                 if ($callback != null && $callback != '' && $callback != "/simple/reg" && $callback != "/simple/login") {
                     $this->redirect($callback);
                 } else {
                     $this->redirect('/ucenter/index');
                 }
             } else {
                 $message = '用户名和密码不匹配';
             }
         }
     }
     //错误信息
     if ($message != '') {
         $this->message = $message;
         $_GET['callback'] = $callback;
         $this->redirect('login', false);
     }
 }