Example #1
0
 function delask()
 {
     $id = IFilter::act(IReq::get('id'));
     if (empty($id)) {
         $this->message('留言ID不能为空');
     }
     $ids = is_array($id) ? join(',', $id) : $id;
     $adminuid = ICookie::get('adminuid');
     $where = " id in({$ids})";
     $this->mysql->delete(Mysite::$app->config['tablepre'] . 'ask', $where);
     $this->success('操作成功');
 }
Example #2
0
 public function singlelist()
 {
     $this->checkshoplogin();
     $shopid = ICookie::get('adminshopid');
     if ($shopid <= 0) {
         $this->message('获取失败');
     }
     $pageinfo = new page();
     $pageinfo->setpage(IReq::get('page'));
     $data['list'] = $this->mysql->getarr("SELECT * FROM " . Mysite::$app->config['tablepre'] . "shop_single WHERE shop_id={$shopid} ORDER BY single_id DESC LIMIT " . $pageinfo->startnum() . ", " . $pageinfo->getsize() . " ");
     $shuliang = $this->mysql->counts("SELECT * FROM " . Mysite::$app->config['tablepre'] . "shop_single WHERE shop_id={$shopid}");
     $pageinfo->setnum($shuliang);
     $data['pagecontent'] = $pageinfo->getpagebar();
     Mysite::$app->setdata($data);
 }
Example #3
0
 public function getMyCart()
 {
     $cartName = $this->getCartName();
     if ($this->saveType == 'session') {
         $cartValue = ISession::get($cartName);
     } else {
         $cartValue = ICookie::get($cartName);
     }
     if ($cartValue == null) {
         return $this->cartExeStruct;
     } else {
         $cartValue = JSON::decode(str_replace(array('&', '$'), array('"', ','), $cartValue));
         if (is_array($cartValue)) {
             return $this->cartFormat($cartValue);
         } else {
             return $this->cartExeStruct;
         }
     }
 }
Example #4
0
 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');
 }
Example #5
0
 function goodsupload()
 {
     $link = IUrl::creatUrl('member/login');
     if ($this->member['uid'] == 0 && $this->admin['uid'] == 0) {
         $this->message('未登陆', $link);
     }
     $type = IReq::get('type');
     $goodsid = intval(IReq::get('goodsid'));
     $shopid = ICookie::get('adminshopid');
     if ($shopid < 0) {
         echo '无权限操作';
         exit;
     }
     if (is_array($_FILES) && isset($_FILES['imgFile'])) {
         $json = new Services_JSON();
         $uploadpath = 'upload/shop/';
         $filepath = '/upload/shop/';
         $upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'doc', 'png'));
         //upload
         $file = $upload->getfile();
         if ($upload->errno != 15 && $upload->errno != 0) {
             echo "<script>parent.uploaderror('" . json_encode($upload->errmsg()) . "');</script>";
         } else {
             if ($goodsid > 0 && $shopid > 0) {
                 $data['img'] = $filepath . $file[0]['saveName'];
                 $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', $data, "id='" . $goodsid . "' and shopid='" . $shopid . "'");
             }
             echo "<script>parent.uploadsucess('" . $filepath . $file[0]['saveName'] . "');</script>";
         }
         exit;
     }
     $imgurl = '';
     if ($goodsid > 0 && $type == 'goods') {
         $temp = $this->mysql->select_one("select img from " . Mysite::$app->config['tablepre'] . "goods where id='" . $goodsid . "' and shopid='" . $shopid . "'");
         $imgurl = $temp['img'];
     }
     Mysite::$app->setdata(array('type' => $type, 'goodsid' => $goodsid, 'imgurl' => $imgurl));
 }
Example #6
0
 function platecart()
 {
     //购物车
     $nowID = intval(ICookie::get('myaddress'));
     if (empty($nowID)) {
         $link = IUrl::creatUrl('wxsite/index');
         $this->message('', $link);
     }
     $id = IFilter::act(IReq::get('id'));
     $data['scoretocost'] = Mysite::$app->config['scoretocost'];
     //	id	card 优惠劵卡号	card_password 优惠劵密码	status 状态,0未使用,1已绑定,2已使用,3无效	creattime 制造时间	cost 优惠金额	limitcost 购物车限制金额下限	endtime 失效时间	uid 用户ID	username 用户名	usetime 使用时间	name
     $data['juanlist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "juan  where uid='" . $this->member['uid'] . "' and endtime > " . time() . " and status = 1   ");
     $data['shoptime'] = $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  id='" . $id . "' ");
     $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 shopid = " . $id . "   ");
     // $data['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 = '".$id."'    ");
     $data['shopinfo'] = $shopinfo;
     //计算时间间隔
     $morning_offer = $shopinfo['morning_offer'] ? $shopinfo['morning_offer'] : "";
     $afternoon_offer = $shopinfo['afternoon_offer'] ? $shopinfo['afternoon_offer'] : "";
     if ($morning_offer) {
         $morninginfo = explode("-", $morning_offer);
     }
     $data['morning'] = $morninginfo;
     if (isset($afternoon_offer)) {
         $afternooninfo = explode("-", $afternoon_offer);
         $data['afternoon'] = $afternooninfo;
     } else {
         $afternooninfo = "";
     }
     $interval = $shopinfo['interval'];
     //送餐间隔时间
     // $fulldate = IFilter::act(IReq::get('fulldate'));
     // $restime = $this->timecount($morninginfo, $afternooninfo, $interval, $fulldate);//通过timecount方法计算时间段
     // $data['restime'] = $restime;
     if (!$morning_offer && !$afternoon_offer) {
         $support_time = $shopinfo['starttime'];
     }
     //
     if (empty($shopinfo)) {
         $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 shopid = " . $id . "   ");
     }
     $nowtime = time();
     $timelist = array();
     $info = explode('|', $shopinfo['starttime']);
     $info = is_array($info) ? $info : array($info);
     $data['is_open'] = 0;
     $dototime = time() + $shopinfo['maketime'] * 60;
     foreach ($info as $key => $value) {
         if (!empty($value)) {
             $temptime = explode('-', $value);
             if (count($temptime) == 2) {
                 //开始转换
                 $btime = strtotime($temptime[0] . ':00');
                 $etime = strtotime($temptime[1] . ':00');
                 $whtime = $btime;
                 while ($whtime < $etime) {
                     if ($whtime < $etime && $whtime >= $nowtime && $whtime > $dototime) {
                         $timelist[] = date('H:i', $whtime);
                         $data['is_open'] = 1;
                     }
                     $whtime += 900;
                 }
             }
         }
     }
     if ($shopinfo['is_open'] == 0 || $shopinfo['is_pass'] == 0) {
         $data['is_open'] = 0;
     }
     $data['timelist'] = $timelist;
     $data['deaddress'] = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address  where userid = " . $this->member['uid'] . " and `default`=1   ");
     $checkareaid = $nowID;
     $dataareaids = array();
     $areadata = 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'];
         $areadata[] = $temp_check['name'];
     }
     $areadata = array_reverse($areadata);
     $data['areainfo'] = join('', $areadata);
     //$data['gustinfo'] = unserialize(ICookie::get('gustAddress'));
     if (isset($_COOKIE['gustAddress'])) {
         $data['gustinfo'] = unserialize($_COOKIE['gustAddress']);
     } else {
         $data['gustinfo'] = "";
     }
     $now_time = time();
     if ($now_time >= strtotime($shopinfo['asoftime'] . ":00")) {
         $now_time = strtotime("+1 day");
     }
     $data['now_time'] = $now_time;
     Mysite::$app->setdata($data);
 }
Example #7
0
 function savelunadv()
 {
     $shopid = ICookie::get('adminshopid');
     $imglist = IFilter::act(IReq::get('imglist'));
     $links = IUrl::creatUrl('shop/shoplunadv');
     if (empty($imglist)) {
         $this->message('图片不能为空', $links);
     }
     $data['imglist'] = join(',', $imglist);
     $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop', $data, "id='" . $shopid . "'");
     $this->success('操作成功', $links);
 }
Example #8
0
 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');
 }
Example #9
0
 /**
  *	列表展示
  *	@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');
 }
Example #10
0
 function gotopay()
 {
     $orderid = intval(IReq::get('orderid'));
     if (empty($orderid)) {
         $this->error('订单获取失败');
     }
     $userid = empty($this->member['uid']) ? 0 : $this->member['uid'];
     if ($userid == 0) {
         $neworderid = ICookie::get('orderid');
         if ($orderid != $neworderid) {
             $this->error('订单无查看权限');
         }
     }
     $orderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id=" . $orderid . "  ");
     //获取主单
     if (empty($orderinfo)) {
         $this->error('订单数据获取失败');
     }
     if ($userid > 0) {
         if ($orderinfo['buyeruid'] != $userid) {
             $this->error('无查看权限');
         }
     }
     if ($orderinfo['paytype'] == 'outpay') {
         $this->message('此订单是货到支付订单不可操作');
     }
     if ($orderinfo['status'] > 2) {
         $this->message('此订单已发货或者其他状态不可操作');
     }
     $paytypelist = array('open_acout');
     $paylist = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "paylist   order by id asc limit 0,50");
     if (is_array($paylist)) {
         foreach ($paylist as $key => $value) {
             $paytypelist[] = $value['loginname'];
         }
     }
     if (!in_array($orderinfo['paytype'], $paytypelist)) {
         $this->message('未定义的支付方式');
     }
     if ($orderinfo['paystatus'] == 1) {
         $this->message('此订单已支付');
     }
     $paytype = $orderinfo['paytype'];
     if ($orderinfo['paytype'] == "alipay") {
         $paytype = "alipay/html5";
     }
     $paydir = hopedir . '/plug/pay/' . $paytype;
     if (!file_exists($paydir . '/pay.php')) {
         $this->message('支付方式文件不存在');
     }
     $dopaydata = array('type' => 'order', 'upid' => $orderid, 'cost' => $orderinfo['allcost']);
     //支付数据
     if ($orderinfo['paytype'] == "weixin") {
         //echo $paydir.'/wxsite/pay.php';
         ///data/www/xshc/wmr//plug/pay/weixin/wxsite/pay.php
         include_once $paydir . '/wxsite/pay.php';
     } else {
         include_once $paydir . '/pay.php';
     }
     //调用方式  直接调用支付方式
 }
 public function run($setindex = '')
 {
     IUrl::beginUrl();
     $controller = IUrl::getInfo('controller');
     $action = IUrl::getInfo('action');
     $Taction = empty($action) ? $this->defaultAction : $action;
     $info = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
     $sitekey = isset($this->config['sitekey']) ? $this->config['sitekey'] : '';
     //if ($this->getkey() != $sitekey) {
     //	echo 'error! 关注好资源222-www.mx800.com';
     //	exit();
     //}
     /*
     		$hostcheck = array('wmr.xiaoshuhaochi.com', 'wmr.xiaoshuhaochi.com', 'xiaoshuhaochi.com');
     
     		if (!in_array($info, $hostcheck)) {
     			echo 'error! 关注好资源111-www.mx800.com';
     			exit();
     		}*/
     if ($controller === NULL) {
         $controller = $this->defaultController;
     }
     $this->controller = $controller;
     $this->Taction = $Taction;
     if ($controller == 'site' && $Taction == 'index') {
         if (is_mobile_request()) {
             $this->controller = 'html5';
         }
     }
     spl_autoload_register('Mysite::autoload');
     $filePath = hopedir . '/lib/Smarty/libs/Smarty.class.php';
     if (!class_exists('smarty')) {
         include_once $filePath;
     }
     if ($controller == 'adminpage') {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates/';
         $smarty->compile_dir = hopedir . '/templates_c/adminpage';
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $module = IUrl::getInfo('module');
         $module = empty($module) ? 'index' : $module;
         $doaction = Mysite::$app->getAction() == 'index' ? 'system' : Mysite::$app->getAction();
         $this->Taction = $doaction;
         $this->siteset();
         if (!file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php')) {
         } else {
             include hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $module)) {
                 call_user_func(array($method, $module));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/adminpage/' . Mysite::$app->getAction() . '/' . $module . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/adminpage/' . Mysite::$app->getAction();
                 $templtepach = hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/adminpage/public/error.html';
             }
         }
         $smarty->assign('tmodule', $module);
         $smarty->assign('tempdir', 'adminpage');
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
         exit;
     } else {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates';
         $smarty->compile_dir = hopedir . '/templates_c/' . Mysite::$app->config['sitetemp'];
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $this->siteset();
         if (!file_exists(hopedir . 'module/' . Mysite::$app->getController() . '/method.php')) {
             $this->setController = 'site';
             $this->setAction = 'error';
         } else {
             include hopedir . 'module/' . Mysite::$app->getController() . '/method.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $Taction)) {
                 call_user_func(array($method, $Taction));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/' . Mysite::$app->getController() . '/' . Mysite::$app->getAction() . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/system';
                 $templtepach = hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/public/error.html';
             }
         }
         $smarty->assign('tempdir', Mysite::$app->config['sitetemp']);
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
     }
 }
Example #12
0
 function getadmininfo()
 {
     $adminname = ICookie::get('adminname');
     $adminpwd = ICookie::get('adminpwd');
     $adminuid = ICookie::get('adminuid');
     $userinfo = array();
     if (!empty($adminuid)) {
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "admin where uid='" . $adminuid . "' and password  = '******'");
         $userinfo['group'] = $userinfo['groupid'];
     }
     if (empty($userinfo) || !isset($userinfo['uid'])) {
         $userinfo = array('uid' => 0, 'username' => 'guest', 'group' => '2');
     }
     return $userinfo;
 }
Example #13
0
 function goodsstock()
 {
     $this->checkshoplogin();
     $shopid = ICookie::get('adminshopid');
     if ($shopid <= 0) {
         $this->message("请重新登陆");
     }
     $gid = (int) IReq::get('gid');
     $startdate = IReq::get('start_date');
     $enddate = IReq::get('end_date');
     //print_r($startdate);exit;
     $startdate = empty($startdate) ? date('Y-m-d') : $startdate;
     $enddate = empty($enddate) ? date('Y-m-d', strtotime("+7 day")) : $enddate;
     if (!($sd = @strtotime($startdate))) {
         $this->message("开始日期格式不正确");
     }
     if (!($ed = @strtotime($enddate))) {
         $this->message("结束日期格式不正确");
     }
     $temp_list = [];
     do {
         $temp_list[date('Y-m-d', $sd)] = 0;
     } while (($sd += 86400) <= $ed);
     $info = $this->mysql->select_one("SELECT daycount FROM " . Mysite::$app->config['tablepre'] . "goods WHERE id=" . $gid);
     $daycount = $info['daycount'];
     $daystock = $this->mysql->getarr("SELECT day, stock FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id={$gid} AND day BETWEEN {$sd} AND {$ed}");
     $buynum_list = [];
     $stock_list = [];
     foreach ($daystock as $v) {
         $buynum_list[date('Y-m-d', $v['day'])] = $v['stock'];
     }
     $buynum_list = array_merge($temp_list, $buynum_list);
     //print_r($buynum_list);exit;
     foreach ($buynum_list as $k => $buy) {
         $stock_list[$k] = $daycount - $buy;
     }
     $data['stock_list'] = $stock_list;
     $data['start_date'] = $startdate;
     $data['end_date'] = $enddate;
     $data['gid'] = $gid;
     Mysite::$app->setdata($data);
 }
Example #14
0
 function savemapshoplocation()
 {
     $this->checkshoplogin();
     $data['lng'] = IReq::get('lng');
     $data['lat'] = IReq::get('lat');
     $shopid = ICookie::get('adminshopid');
     if (empty($data['lng'])) {
         $this->message('百度地图坐标不能为空');
     }
     if (empty($data['lat'])) {
         $this->message('百度坐标不能为空');
     }
     if (empty($shopid)) {
         $this->message('cookies失效,请重新登陆');
     }
     $shopid = ICookie::get('adminshopid');
     $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop', $data, "id='" . $shopid . "'");
     $this->success('操作成功');
 }
Example #15
0
 public function sendwxmsg()
 {
     $this->checkshoplogin();
     $shopid = ICookie::get('adminshopid');
     if ($shopid <= 0) {
         $this->message('操作失败');
     }
     $openid = trim(IReq::get('openid'));
     $content = trim(IReq::get('content'));
     if (empty($content)) {
         $this->message('发送内容不能为空');
     }
     $wechat = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop_wechat where shopid={$shopid}");
     if (empty($wechat)) {
         $this->message('未设置微信基本信息');
     }
     $wx_s = new wx_s($wechat['token'], $wechat['appid'], $wechat['secret'], $shopid);
     if ($wx_s->sendmsg($content, $openid)) {
         $this->success('操作成功');
     } else {
         $this->message($wx_s->err());
     }
 }
Example #16
0
 /**
  * 生成订单
  */
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $taxes = IFilter::act(IReq::get('taxes'), 'float');
     $insured = IFilter::act(IReq::get('insured'), 'float');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = IFilter::act(IReq::get('direct_gid'), 'int');
     $num = IFilter::act(IReq::get('direct_num'), 'int');
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = IFilter::act(IReq::get('direct_active_id'), 'int');
     $order_no = Order_Class::createOrderNum();
     $order_type = 0;
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //活动特殊处理
     if ($promo != '' && $active_id != '') {
         //团购
         if ($promo == 'groupon') {
             $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}");
             //此团购还存在已经报名但是未付款的情况
             if (regiment::hasJoined($active_id, $hashId) == true) {
                 IError::show(403, '您已经参加过此次团购,请先完成支付');
                 exit;
             }
             //团购已经达到限定的人数
             if (regiment::isFull($active_id) == true) {
                 IError::show(403, '此团购的参加人数已满');
                 exit;
             }
             $order_type = 1;
             //团购开始报名
             $joinUserId = $user_id ? $user_id : null;
             $resultData = regiment::join($active_id, $joinUserId);
             $is_success = '';
             if ($resultData['flag'] == true) {
                 $regimentRelationObj = new IModel('regiment_user_relation');
                 $regimentRelationObj->setData(array('order_no' => $order_no));
                 $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
             }
             if ($is_success == '' || $resultData['flag'] == false) {
                 $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
                 IError::show(403, $errorMsg);
                 exit;
             }
         } else {
             if ($promo == 'time') {
                 $order_type = 2;
             }
         }
     }
     //付款方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id);
     if ($deliveryRow['type'] == 0 && $payment == 0) {
         IError::show(403, '请选择支付方式');
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         }
     }
     //计算费用
     $countSumObj = new CountSum();
     //直接购买商品方式
     if ($type != '' && $gid != 0) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $paymentType = 0;
     } else {
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
     }
     //最终订单金额计算
     $orderData = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $province, $delivery_id, $payment, $goodsResult['freeFreight'], $insured, $taxes);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $orderData['deliveryOrigPrice'], 'real_freight' => $orderData['deliveryPrice'], 'pay_fee' => $orderData['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $taxes, 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'] + (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'order_amount' => $orderData['orderAmountPrice'] - (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'if_insured' => $insured ? 1 : 0, 'insured' => $insured);
     $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount'];
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderInstance = new Order_Class();
     $orderInstance->insertOrderGoods($this->order_id, $goodsResult);
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
         $addressRow = $addressObj->getObj('user_id = ' . $user_id);
         if (empty($addressRow)) {
             $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile);
             $addressObj->setData($addressData);
             $addressObj->add();
         } else {
             //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
             $radio_address = intval(IReq::get('radio_address'));
             if ($radio_address != 0) {
                 $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
                 if (empty($addressDefRow)) {
                     $addressData = array('default' => 1);
                     $addressObj->setData($addressData);
                     $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
                 }
             }
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment = $paymentName;
     $this->paymentType = $paymentType;
     $this->delivery = $deliveryRow['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = Order_Class::updateOrderStatus($dataArray['order_no']);
         if ($order_id != '') {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->setRenderData($dataArray);
         $this->redirect('cart3');
     }
 }
Example #17
0
 function shoploginin()
 {
     $uname = IFilter::act(IReq::get('uname'));
     $pwd = IFilter::act(IReq::get('pwd'));
     if (empty($uname)) {
         $this->message('帐号不能为空');
     }
     if (empty($pwd)) {
         $this->message('密码不能为空');
     }
     if (Mysite::$app->config['allowedcode'] == 1) {
         $Captcha = IFilter::act(IReq::get('Captcha'));
         if ($Captcha != ICookie::get('Captcha')) {
             $this->message('验证码错误');
         }
     }
     if (!$this->memberCls->login($uname, $pwd)) {
         $this->message($this->memberCls->ero());
     }
     $checkuid = $this->memberCls->getuid();
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where    is_pass=1 and uid=" . $checkuid . " ");
     if (empty($userinfo)) {
         $this->message('未开店或者店铺审核未通过');
     }
     ICookie::set('adminshopid', $userinfo['id'], 86400);
     $this->success('操作成功');
 }
Example #18
0
 function guestorderlist()
 {
     $this->setstatus();
     $phone = IFilter::act(IReq::get('phone'));
     $link = IUrl::creatUrl('order/guestorder');
     $Captcha = IFilter::act(IReq::get('Captcha'));
     $type = IFilter::act(IReq::get('type'));
     if (Mysite::$app->config['allowedcode'] == 1) {
         if ($Captcha != ICookie::get('Captcha')) {
             $this->message('验证码错误', $link);
         }
     }
     if (!IValidate::suremobi($phone)) {
         $this->message('请录入正确的手机号码');
     }
     $data['phone'] = $phone;
     $data['Captcha'] = $Captcha;
     $data['where'] = ' buyerphone = \'' . $phone . '\'';
     $data['where'] .= empty($type) ? ' and shoptype=0' : ' and shoptype=1';
     $data['type'] = $type;
     Mysite::$app->setdata($data);
 }
Example #19
0
 public function pscost($shopinfo, $goodsnum)
 {
     $backdata = array('pscost' => 0, 'pstype' => 0, 'canps' => 0);
     $sendtype = 0;
     //网站配送
     if (isset($shopinfo['sendtype']) && $shopinfo['sendtype'] == 1) {
         $sendtype = 1;
         //店铺配送
         $backdata['pstype'] = 1;
     }
     // 'psset' => 'a:5:{s:12:"locationtype";i:2;s:6:"pstype";i:1;s:8:"psvalue1";s:1:"3";s:8:"psvalue2";s:1:"6";s:8:"psvalue3";s:2:"10";}',
     $psinfo = Mysite::$app->config['psset'];
     if (empty($psinfo)) {
         return $backdata;
         //无配送设置则配送费为 0;
     }
     $siteps = unserialize($psinfo);
     $locationtype = $siteps['locationtype'] == 1 ? 1 : 2;
     //定位方式
     if ($sendtype == 0) {
         //网站配送费计算规则;
         switch ($siteps['pstype']) {
             case '1':
                 $backdata['pscost'] = empty($siteps['psvalue1']) ? 0 : $siteps['psvalue1'];
                 $backdata['canps'] = 1;
                 break;
             case '2':
                 //根据不同区域设置不同配送费
                 $areaid = ICookie::get('myaddress');
                 if (!empty($areaid)) {
                     if ($shopinfo['shoptype'] == 1) {
                         $areainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatomar where areaid = " . $areaid . " and shopid = 0");
                     } else {
                         $areainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatoadd where areaid = " . $areaid . " and shopid = 0");
                     }
                     $backdata['pscost'] = isset($areainfo['cost']) ? $areainfo['cost'] : 0;
                     $backdata['canps'] = 1;
                 } else {
                     $backdata['canps'] = 0;
                 }
                 break;
             case '3':
                 //不计算
                 $backdata['pscost'] = 0;
                 $backdata['canps'] = 1;
                 break;
             case '4':
                 //地图
                 if ($locationtype == 1) {
                     $lat = ICookie::get('lat');
                     $lng = ICookie::get('lng');
                     $lat = empty($lat) ? 0 : $lat;
                     $lng = empty($lng) ? 0 : $lng;
                     $shoplat = isset($shopinfo['lat']) ? $shopinfo['lat'] : 0;
                     $shoplng = isset($shopinfo['lng']) ? $shopinfo['lng'] : 0;
                     $juli = $this->GetDistance($lat, $lng, $shoplat, $shoplng, 1);
                     if ($juli < 1001) {
                         $backdata['pscost'] = $siteps['psvalue1'];
                         $backdata['canps'] = 1;
                     } elseif ($juli < 3001) {
                         $backdata['pscost'] = $siteps['psvalue2'];
                         $backdata['canps'] = 1;
                     } elseif ($juli < 6001) {
                         $backdata['pscost'] = $siteps['psvalue3'];
                         $backdata['canps'] = 1;
                     } else {
                         $backdata['pscost'] = 100;
                         $backdata['canps'] = 0;
                     }
                 } else {
                     $backdata['pscost'] = 0;
                     $backdata['canps'] = 0;
                 }
                 break;
             case '5':
                 //菜品计算
                 $tempstart = $siteps['psvalue1'];
                 $stepcost = $goodsnum * $siteps['psvalue2'];
                 $backdata['pscost'] = $tempstart + $stepcost - $siteps['psvalue2'];
                 $backdata['pscost'] = 0;
                 $backdata['canps'] = 1;
                 break;
             default:
                 //不在 所列举 范围内则为0;
                 $backdata['pscost'] = 0;
                 $backdata['canps'] = 0;
                 break;
         }
     } elseif ($sendtype == 1) {
         //店铺配送费计算规则
         if (empty($shopinfo['sendset'])) {
             //无店铺设置返回0;
             return $backdata;
         }
         $shopps = unserialize($shopinfo['sendset']);
         switch ($shopps['pstype']) {
             case '1':
                 //同意配送费
                 $backdata['pscost'] = empty($shopps['psvalue1']) ? 0 : $shopps['psvalue1'];
                 $backdata['canps'] = 1;
                 break;
             case '2':
                 //根据不同区域设置不同配送费
                 $areaid = ICookie::get('myaddress');
                 if (!empty($areaid)) {
                     if ($shopinfo['shoptype'] == 1) {
                         $areainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatomar where areaid = " . $areaid . " and shopid = " . $shopinfo['id'] . "");
                         $backdata['pscost'] = isset($areainfo['cost']) ? $areainfo['cost'] : 0;
                         $checkareainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areamarket where areaid = " . $areaid . " and shopid = " . $shopinfo['id'] . "");
                     } else {
                         $areainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatoadd where areaid = " . $areaid . " and shopid = " . $shopinfo['id'] . "");
                         $backdata['pscost'] = isset($areainfo['cost']) ? $areainfo['cost'] : 0;
                         $checkareainfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areashop where areaid = " . $areaid . " and shopid = " . $shopinfo['id'] . "");
                     }
                     if (empty($checkareainfo)) {
                         $backdata['canps'] = 0;
                     } else {
                         $backdata['canps'] = 1;
                     }
                 } else {
                     $backdata['canps'] = 0;
                 }
                 break;
             case '3':
                 //不计算
                 $backdata['pscost'] = 0;
                 $backdata['canps'] = 1;
                 break;
             case '4':
                 //地图
                 if ($locationtype == 1) {
                     $lat = ICookie::get('lat');
                     $lng = ICookie::get('lng');
                     $lat = empty($lat) ? 0 : $lat;
                     $lng = empty($lng) ? 0 : $lng;
                     $juli = $this->GetDistance($lat, $lng, $shopinfo['lat'], $shopinfo['lng'], 1);
                     if ($juli < 1001) {
                         $backdata['pscost'] = $shopps['psvalue1'];
                         $backdata['canps'] = 1;
                     } elseif ($juli < 3001) {
                         $backdata['pscost'] = $shopps['psvalue2'];
                         $backdata['canps'] = 1;
                     } elseif ($juli < 6001) {
                         $backdata['pscost'] = $shopps['psvalue3'];
                         $backdata['canps'] = 1;
                     } else {
                         $backdata['canps'] = 0;
                         $backdata['pscost'] = 100;
                     }
                 } else {
                     $backdata['canps'] = 0;
                     $backdata['pscost'] = 0;
                 }
                 break;
             case '5':
                 //菜品计算
                 $tempstart = $shopps['psvalue1'];
                 $stepcost = $goodsnum * $shopps['psvalue2'];
                 $backdata['pscost'] = $tempstart + $stepcost - $shopps['psvalue2'];
                 $backdata['canps'] = 1;
                 break;
             default:
                 //不在 所列举 范围内则为0;
                 $backdata['pscost'] = 0;
                 $backdata['canps'] = 0;
                 break;
         }
     }
     return $backdata;
 }
Example #20
0
 function cart()
 {
     $data['sitetitle'] = '购物车';
     $gooids = $_COOKIE["market_id"];
     $market_count = $_COOKIE["market_count"];
     if (empty($gooids)) {
         $this->message('购物车商品为空');
     }
     $gidinfo = explode(',', $gooids);
     $gidconut = explode(',', $market_count);
     $tempids = array();
     foreach ($gidinfo as $key => $value) {
         if (intval($value) > 0) {
             $tempids[$value] = $gidconut[$key];
         }
     }
     $cartlist = array();
     $goodsshu = 0;
     $query = join(',', array_keys($tempids));
     if (!empty($query)) {
         $goodsinfo = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "goods where id in(" . $query . ") and shopid =0");
         foreach ($goodsinfo as $key => $value) {
             $value['buycount'] = $tempids[$value['id']];
             $value['sum'] = $value['buycount'] * $value['cost'];
             $cartlist[] = $value;
             $goodsshu += $value['buycount'];
         }
     }
     $data['cartlist'] = $cartlist;
     //获取配送费
     $checkps = $this->pscost(array('shopid' => 0), $goodsshu);
     if ($checkps['canps'] != 1) {
         $link = IUrl::creatUrl('site/guide');
         $this->message('该店铺不在配送范围内', $link);
     }
     $data['pscost'] = $checkps['pscost'];
     $psinfo = unserialize(Mysite::$app->config['psset']);
     $data['areainfo'] = '';
     $nowID = ICookie::get('myaddress');
     $data['locationtype'] = $psinfo['locationtype'];
     if ($psinfo['locationtype'] == 1) {
         //百度地图
         $data['areainfo'] = ICookie::get('mapname');
         if (empty($data['areainfo'])) {
             $link = IUrl::creatUrl('site/guide');
             $this->message('请先选择您所在区域在进行下单', $link);
         }
     } else {
         $data['areainfo'] = ICookie::get('mapname');
         if (empty($nowID)) {
             $link = IUrl::creatUrl('site/guide');
             $this->message('请先选择您所在区域在进行下单', $link);
         }
     }
     $data['myaddressslist'] = array();
     $tempre = '';
     if (!empty($nowID)) {
         $area_grade = Mysite::$app->config['area_grade'];
         $temp_areainfo = '';
         if ($area_grade > 1) {
             $areainfocheck = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $nowID . "");
             if (!empty($areainfocheck)) {
                 $areainfocheck1 = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $areainfocheck['parent_id'] . "");
                 if (!empty($areainfocheck1)) {
                     $temp_areainfo = $areainfocheck1['name'];
                     if ($area_grade > 2) {
                         $areainfocheck2 = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $areainfocheck1['parent_id'] . "");
                         if (!empty($areainfocheck2)) {
                             $temp_areainfo = $areainfocheck2['name'] . $temp_areainfo;
                         }
                     }
                 }
                 $tempre = $temp_areainfo . $tempre;
             }
         }
         if ($this->member['uid'] > 0) {
             $data['myaddressslist'] = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address  where areaid" . $area_grade . "=" . $nowID . "");
         }
     }
     if (isset($data['myaddressslist']['address'])) {
         $data['areainfo'] = $tempre . $data['myaddressslist']['address'];
     } else {
         $data['areainfo'] = $tempre . $data['areainfo'];
     }
     //获取默认配送所有地址
     $data['open_acout'] = Mysite::$app->config['open_acout'];
     $data['paylist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "paylist   order by id desc  ");
     //
     $data['starttime'] = Mysite::$app->config['marketstarttime'];
     $data['marketlong'] = Mysite::$app->config['marketlong'];
     $data['juanlist'] = array();
     if (!empty($this->member['uid'])) {
         $data['juanlist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "juan  where uid ='" . $this->member['uid'] . "'  and status = 1 and endtime > " . time() . "  order by id desc limit 0,20");
     }
     Mysite::$app->setdata($data);
 }
Example #21
0
 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;
 }
Example #22
0
$opid = $qc->get_openid();
$qc = new QC($acs, $opid);
$arr = $qc->get_user_info();
if (empty($opid)) {
    $this->message($logintype . '登录接口获取信息失败noopid,请联系管理员');
}
if (!is_array($arr)) {
    $this->message($logintype . '接口获取信息失败noinfo,请联系管理员');
}
/**判断信息是否写到数据库中***/
//第三方登录表 结构:oauth   id uid  token openid type addtime
//31天  *24 * 60 *60  26784400
$nowtime = time() - 26784400;
$oauthinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "oauth where openid='" . $opid . "' and addtime > " . $nowtime . " and type = '" . $logintype . "' ");
$link = IUrl::creatUrl('member/bandaout');
$uid = ICookie::get('uid');
if (empty($oauthinfo)) {
    $data['uid'] = $this->member['uid'];
    $data['token'] = $acs;
    $data['openid'] = $opid;
    $data['type'] = $logintype;
    $data['addtime'] = time();
    $this->mysql->insert(Mysite::$app->config['tablepre'] . 'oauth', $data);
    if (!empty($this->member['uid'])) {
        $link = IUrl::creatUrl('member/base');
    } else {
        ICookie::set('adlogintype', $logintype, 86400);
        ICookie::set('adtoken', $acs, 86400);
        ICookie::set('adopenid', $opid, 86400);
        ICookie::set('nickname', $opid, 86400);
    }
Example #23
0
 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);
 }
Example #24
0
 function ordertoday()
 {
     $firstareain = IReq::get('firstarea');
     $secareain = IReq::get('secarea');
     $statustype = intval(IReq::get('statustype'));
     $dno = IReq::get('dno');
     $data['dno'] = $dno;
     $data['statustype'] = $statustype;
     $statustype = in_array($statustype, array(1, 2, 3, 4, 5)) ? $statustype : 0;
     $statustypearr = array('0' => '', '1' => ' and ord.status = 0 ', '2' => ' and ord.status = 1  ', '3' => ' and ord.status > 1 and ord.status < 4 ', '4' => ' and ord.is_reback in(1,2)  ');
     ///statustype  1   待审核
     //statustype  2   待发货
     //statustype  3   已发货
     //statustype  4   退款处理
     $data['frinput'] = $firstareain;
     $this->setstatus();
     $nowday = date('Y-m-d', time());
     $where = '  where ord.posttime > ' . strtotime($nowday . ' 00:00:00') . ' and ord.posttime < ' . strtotime($nowday . ' 23:59:59');
     //查询当天所有订单数据
     //	$where .= ' and ord.status = 0 ';
     if (!empty($firstareain)) {
         $where .= " and FIND_IN_SET('" . $firstareain . "',`areaids`)";
     }
     $where .= $statustypearr[$statustype];
     //$where .= ' and ord.status = 0 ';
     $where .= empty($dno) ? '' : ' and ord.dno =\'' . $dno . '\'';
     $orderlist = $this->mysql->getarr("select ord.*,mb.username as acountname from " . Mysite::$app->config['tablepre'] . "order as ord left join  " . Mysite::$app->config['tablepre'] . "member as mb on mb.uid = ord.buyeruid   " . $where . " order by ord.id desc limit 0,1000");
     $shuliang = $this->mysql->counts("select ord.*,mb.username as acountname from " . Mysite::$app->config['tablepre'] . "order as ord left join  " . Mysite::$app->config['tablepre'] . "member as mb on mb.uid = ord.buyeruid   " . $where . " ");
     $data['list'] = array();
     if ($orderlist) {
         foreach ($orderlist as $key => $value) {
             $value['detlist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "orderdet where   order_id = " . $value['id'] . " order by id desc ");
             $value['maijiagoumaishu'] = 0;
             if ($value['buyeruid'] > 0) {
                 $value['maijiagoumaishu'] = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "order where buyeruid='" . $value['buyeruid'] . "' and  status = 3 order by id desc");
             }
             $data['list'][] = $value;
         }
     }
     /*构造城市*/
     $areainfo = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "area   order by orderid asc");
     $this->getgodigui($areainfo, 0, 0);
     $data['arealist'] = $this->digui;
     $data['showdet'] = intval(IReq::get('showdet'));
     $data['playwave'] = ICookie::get('playwave');
     //shoporderlist
     Mysite::$app->setdata($data);
 }
Example #25
0
 /**
  * 用户报名参加团购
  *
  * 用户可以参加本次团购的条件:
  * 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' => '本次团购您存在未完成交易');
     }
 }
Example #26
0
    ?>
					<tr><td colspan="2">
						<div class="prompt"><img src="<?php 
    echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/images/front/error_s.gif";
    ?>
" width="16" height="15" /><?php 
    echo isset($this->message) ? $this->message : "";
    ?>
</div>
					</td></tr>
					<?php 
}
?>

					<tr><th>用户名/邮箱:</th><td><input class="gray" type="text" name="login_info" value="<?php 
echo ICookie::get('loginName');
?>
" pattern='required' alt='填写用户名或邮箱' /></td></tr>
					<tr><th>密码:</th><td><input class="gray" type="password" name="password" pattern='^\S{6,32}$' alt='填写密码' /></td></tr>
					<tr class="low"><td></td>
						<td>
							<label class="attr"><input class="radio" type="checkbox" name="remember" value='1' />记住登录名</label>
							<label class="attr"><a class="link pwd" href="<?php 
echo IUrl::creatUrl("/simple/find_password");
?>
">忘记密码</a></label>
						</td>
					</tr>
					<tr class="low">
						<td></td>
						<td>
Example #27
0
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time_radio = IFilter::act(IReq::get('accept_time_radio'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $is_tax = IFilter::act(IReq::get('is_tax'), 'int');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = intval(IReq::get('direct_gid'));
     $num = intval(IReq::get('direct_num'));
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = intval(IReq::get('direct_active_id'));
     $tourist = IReq::get('tourist');
     //游客方式购物
     $order_no = block::createOrderNum();
     $order_type = 0;
     $is_protectPrice = IFilter::act(IReq::get('protect_price'));
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //活动特殊处理
     if ($promo != '' && $active_id != '') {
         //团购
         if ($promo == 'groupon') {
             $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}");
             //此团购还存在已经报名但是未付款的情况
             if (regiment::hasJoined($active_id, $hashId) == true) {
                 IError::show(403, '您已经参加过此次团购,请先完成支付');
                 exit;
             }
             //团购已经达到限定的人数
             if (regiment::isFull($active_id) == true) {
                 IError::show(403, '此团购的参加人数已满');
                 exit;
             }
             $order_type = 1;
             //团购开始报名
             $joinUserId = $user_id ? $user_id : null;
             $resultData = regiment::join($active_id, $joinUserId);
             $is_success = '';
             if ($resultData['flag'] == true) {
                 $regimentRelationObj = new IModel('regiment_user_relation');
                 $regimentRelationObj->setData(array('order_no' => $order_no));
                 $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
             }
             if ($is_success == '' || $resultData['flag'] == false) {
                 $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
                 IError::show(403, $errorMsg);
                 exit;
             }
         } else {
             if ($promo == 'time') {
                 $order_type = 2;
             }
         }
     }
     //付款方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id, 'type');
     if ($deliveryRow['type'] == 0 && $payment == 0) {
         IError::show(403, '请选择支付方式');
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         }
     }
     $countSumObj = new CountSum();
     //直接购买商品方式
     if ($type != '' && $gid != 0) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     $sum_r = $goodsResult['sum'];
     $proReduce_r = $goodsResult['proReduce'];
     $reduce_r = $goodsResult['reduce'];
     $final_sum_r = $goodsResult['final_sum'];
     $freeFreight_r = $goodsResult['freeFreight'];
     $point_r = $goodsResult['point'];
     $exp_r = $goodsResult['exp'];
     //计算运费$deliveryPrice和保价$protect_price
     $deliveryList = Delivery::getDelivery($province, $goodsResult['weight'], $final_sum_r);
     $deliveryPrice = $deliveryList[$delivery_id]['price'];
     if ($is_protectPrice == null) {
         $protect_price = 0;
         $if_insured = 0;
     } else {
         $protect_price = $deliveryList[$delivery_id]['protect_price'];
         $if_insured = 1;
     }
     if ($freeFreight_r == true) {
         $deliveryPrice_r = 0;
     } else {
         $deliveryPrice_r = $deliveryPrice;
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $ticket_value = $ticketRow['value'];
                 $reduce_r += $ticket_value;
                 $final_sum_r -= $ticket_value;
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //获取税率$tax
     if ($is_tax == 1) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $tax_per = isset($site_config['tax']) ? $site_config['tax'] : 0;
         $tax = $final_sum_r * ($tax_per / 100);
     } else {
         $tax = 0;
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $payment_fee = 0;
         $paymentType = 0;
         $paymentNote = '';
     } else {
         //计算支付手续费
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,poundage,poundage_type,name,note');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
         $paymentNote = $paymentRow['note'];
         if ($paymentRow['poundage_type'] == 1) {
             $payment_fee = ($final_sum_r + $tax + $deliveryPrice_r + $protect_price) * ($paymentRow['poundage'] / 100);
         } else {
             $payment_fee = $paymentRow['poundage'];
         }
     }
     //最终订单金额计算
     $order_amount = $final_sum_r + $deliveryPrice_r + $payment_fee + $tax + $protect_price;
     $order_amount = $order_amount <= 0 ? 0 : round($order_amount, 2);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'status' => 1, 'pay_status' => 0, 'distribution_status' => 0, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'invoice' => $is_tax, 'postscript' => $order_message, 'invoice_title' => $tax_title, 'accept_time' => $accept_time, 'exp' => $exp_r, 'point' => $point_r, 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $deliveryPrice, 'real_freight' => $deliveryPrice_r, 'pay_fee' => $payment_fee, 'taxes' => $tax, 'promotions' => $proReduce_r + $reduce_r, 'order_amount' => $order_amount, 'if_insured' => $if_insured, 'insured' => $protect_price);
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderGoodsObj = new IModel('order_goods');
     $goodsArray = array('order_id' => $this->order_id);
     $findType = array('goods' => 'goodsList', 'product' => 'productList');
     foreach ($findType as $key => $list) {
         if (isset($goodsResult[$list]) && count($goodsResult[$list]) > 0) {
             foreach ($goodsResult[$list] as $k => $val) {
                 //拼接商品名称和规格数据
                 $specArray = array('name' => $val['name'], 'value' => '');
                 if ($key == 'product') {
                     $goodsArray['product_id'] = $val['id'];
                     $goodsArray['goods_id'] = $val['goods_id'];
                     $spec = block::show_spec($val['spec_array']);
                     foreach ($spec as $skey => $svalue) {
                         $specArray['value'] .= $skey . ':' . $svalue . ' , ';
                     }
                 } else {
                     $goodsArray['goods_id'] = $val['id'];
                     $goodsArray['product_id'] = 0;
                 }
                 $specArray = serialize($specArray);
                 $goodsArray['goods_price'] = $val['sell_price'];
                 $goodsArray['real_price'] = $val['sell_price'] - $val['reduce'];
                 $goodsArray['goods_nums'] = $val['count'];
                 $goodsArray['goods_weight'] = $val['weight'];
                 $goodsArray['goods_array'] = $specArray;
                 $orderGoodsObj->setData($goodsArray);
                 $orderGoodsObj->add();
             }
         }
     }
     //更改购买商品的库存数量
     Block::updateStore($this->order_id, 'reduce');
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
         $addressRow = $addressObj->getObj('user_id = ' . $user_id);
         if (empty($addressRow)) {
             $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile);
             $addressObj->setData($addressData);
             $addressObj->add();
         } else {
             //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
             $radio_address = intval(IReq::get('radio_address'));
             if ($radio_address != 0) {
                 $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
                 if (empty($addressDefRow)) {
                     $addressData = array('default' => 1);
                     $addressObj->setData($addressData);
                     $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
                 }
             }
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment_fee = $payment_fee;
     $this->payment = $paymentName;
     $this->delivery = $deliveryList[$delivery_id]['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     $this->paymentType = $paymentType;
     $this->paymentNote = $paymentNote;
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = payment::updateOrder($dataArray['order_no']);
         if ($order_id != '') {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->redirect('cart3');
     }
 }