コード例 #1
0
 public function edit()
 {
     $id = I('id');
     $admin = M('admin');
     $data = $admin->find($id);
     $address = $data['address'];
     $arr = explode("#", $address);
     $data['address'] = $arr[3];
     $a = array($arr[0], $arr[1], $arr[2]);
     $city = Area::city($a);
     $this->assign("city", $city);
     $this->assign('admin', $data);
     $this->display();
 }
コード例 #2
0
ファイル: UserController.class.php プロジェクト: Caojunkai/jd
 public function address()
 {
     //地址列表显示
     $useraddress = M("useraddress");
     $id = session('uid');
     $data = $useraddress->where("user_id={$id}")->select();
     $this->assign("useraddress", $data);
     foreach ($data as $k => &$v) {
         $v[$v['id']] = str_replace('#', '', $v['address']);
         //完整地址
         $v['last'] = explode('#', $v['address'])[3];
     }
     $this->assign("address", $data);
     //三级连动地址
     $city = Area::city();
     $this->assign("city", $city);
     $this->display();
 }
コード例 #3
0
 public function index()
 {
     //判断用户是否登录
     if (empty($_SESSION['user'])) {
         $this->redirect('Login/index');
     }
     //判断是否有收货地址
     $addr = M('address');
     $res = $addr->where('uid=' . $_SESSION['user'][0]['id'])->select();
     if (!empty($res)) {
         $this->redirect('Order/buy');
     }
     //地区显示
     $Area = array("请选择", "请选择", "请选择");
     $city = Area::city($Area);
     $this->assign("city", $city);
     $this->display('city');
 }
コード例 #4
0
ファイル: CarController.class.php プロジェクト: Caojunkai/jd
 public function order()
 {
     $user_id = session('uid');
     //根据user_id 查询出地址
     $useraddress = M('useraddress');
     //主地址
     $main_add = $useraddress->where("user_id={$user_id} AND ismain=2")->find();
     $adds = $useraddress->where("user_id={$user_id} AND ismain=1")->select();
     //========将session中的值分配到订单页==========
     $order = session('order');
     $this->assign('orders', $order);
     //dump($order);
     //exit;
     //==========地址三级连动=================
     $city = Area::city();
     $this->assign("city", $city);
     $this->assign('main_add', $main_add);
     $this->assign('adds', $adds);
     $this->display();
 }
コード例 #5
0
 public function collect()
 {
     //SEO
     $ident = "collect";
     $idents = $this->seo($ident);
     $this->assign('productactive', 'active');
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $buy_now = I('get.buy');
     $user_id = $_SESSION['user']['userid'];
     if ($user_id == "") {
         $this->redirect("Login/login");
     } else {
         $user_confirmation = $_SESSION['user']['userconfirmation'];
         if (!$user_confirmation) {
             $this->error('购买前,请先补全个人信息!', U('MobileMember/information'), 3);
             exit;
         }
         //物流信息
         $shipping = M("shippings");
         $ship_company = M("shipping_company");
         $ships = $shipping->order('is_default desc')->select();
         foreach ($ships as &$v1) {
             $v1['cname'] = $ship_company->field("cname")->where("id = " . $v1['sid'])->find();
         }
         // dump($ships);
         // die;
         $this->assign("ships", $ships);
         //收货地址
         //$user_id = $_SESSION['user']['userid'];
         $user = $_SESSION['user']['username'];
         $add = M("user_address");
         $address = $add->where("user_id = " . $user_id)->order('is_default desc')->select();
         if ($buy_now == 'now') {
             $cart = $_SESSION['order'];
             $this->assign('buy_now', $buy_now);
         } else {
             $cart = isset($_COOKIE['cart']) ? unserialize($_COOKIE['cart']) : array();
         }
         // 循环每一个商品取出详情信息
         $db = M("product");
         $list = M("products_attr");
         $_cart = array();
         $sum = "";
         $num = "";
         foreach ($cart as $k => $v) {
             $_attr = explode('-', $k);
             $_cart[$k]['id'] = $_attr[0];
             $_cart[$k]['versionId'] = $_attr[1];
             $_cart[$k]['colorId'] = $_attr[2];
             $img = $db->field("list_image,pro_name,promote_price,is_ship,is_promote,unit,unit_weight,weight_unit")->where(array('id' => $_cart[$k]['id']))->find();
             $_cart[$k]['img'] = $img['list_image'];
             $_cart[$k]['pro_name'] = $img['pro_name'];
             $_cart[$k]['is_ship'] = $img['is_ship'];
             $_cart[$k]['unit'] = $img['unit'];
             $_cart[$k]['weight_unit'] = $img['weight_unit'];
             if ($_cart[$k]['is_ship']) {
                 $_cart[$k]['unit_weight'] = 0;
             } else {
                 $_cart[$k]['unit_weight'] = $img['unit_weight'];
             }
             if ($_cart[$k]['weight_unit'] == "克") {
                 $weightper = $_cart[$k]['unit_weight'] / 1000;
             } elseif ($_cart[$k]['weight_unit'] == "千克") {
                 $weightper = $_cart[$k]['unit_weight'];
             }
             $_cart[$k]['promote_price'] = $img['promote_price'];
             $_cart[$k]['color'] = $list->field('prop_name,prop_price')->where(array('id' => $_cart[$k]['colorId']))->find();
             $_cart[$k]['version'] = $list->field('prop_name,prop_price')->where(array('id' => $_cart[$k]['versionId']))->find();
             //取库存
             $ModelNum = M('productnum');
             $attrls = array();
             $attrls = array($_cart[$k]['colorId'], $_cart[$k]['versionId']);
             sort($attrls);
             $attrls = implode('|', $attrls);
             $map['product_id'] = $_cart[$k]['id'];
             $map['product_attr'] = $attrls;
             $_cart[$k]['num'] = $ModelNum->where($map)->getfield('product_number');
             $_cart[$k]['price'] = $_cart[$k]['promote_price'] + $_cart[$k]['color']['prop_price'] + $_cart[$k]['version']['prop_price'];
             $_cart[$k]['ordernum'] = $v;
             //取出促销信息
             if ($img['is_promote']) {
                 $ProModel = M('promote');
                 $_cart[$k]['promote'] = $ProModel->where(array('product_id' => $_cart[$k]['id']))->find();
                 if ($_cart[$k]['promote']['status'] == 1) {
                     $_cart[$k]['price'] = $_cart[$k]['price'] * ($promote['rate'] / 100);
                 }
                 if ($_cart[$k]['promote']['status'] == 2) {
                     if ($_SESSION['user']['userlevel']) {
                         $MemRate = M('members_rate');
                         $Memrate = $MemRate->where(array('product_id' => $_cart[$k]['id'], 'level_id' => $_SESSION['user']['userlevel']))->getField('rate');
                         $promote['rate'] = $Memrate;
                         $_cart[$k]['price'] = $_cart[$k]['price'] * ($promote['rate'] / 100);
                     }
                 }
                 if ($_cart[$k]['promote']['status'] == 3) {
                     $giftId = $ProModel->where(array('product_id' => $_cart[$k]['id']))->getField('gifts');
                     $_cart[$k]['promote']['gift'] = $db->field('list_image,id,pro_name,market_price')->where(array('id' => $giftId))->find();
                 }
                 if ($_cart[$k]['promote']['status'] == 4) {
                     $gift = $ProModel->field('condition,gifts')->where(array('product_id' => $_cart[$k]['id']))->find();
                     if ($_cart[$k]['ordernum'] >= $gift['condition']) {
                         $_cart[$k]['promote']['gift'] = $db->field('list_image,id,pro_name,market_price')->where(array('id' => $gift['gifts']))->find();
                     }
                 }
                 if ($_cart[$k]['promote']['status'] == 5) {
                     $qiang = $ProModel->field('id,status,start_time,end_time,rate')->where(array('product_id' => $_cart[$k]['id']))->find();
                     $now = time();
                     if ($qiang['start_time'] <= $now and $qiang['end_time'] > $now) {
                         $_cart[$k]['price'] = $_cart[$k]['price'] * ($qiang['rate'] / 100);
                     }
                 }
             }
             $sum += $_cart[$k]['price'] * $_cart[$k]['ordernum'];
             $num += $_cart[$k]['ordernum'];
             $weight += $weightper * $_cart[$k]['ordernum'];
         }
         // dump($_cart);
         // die;
         $this->assign('weight', $weight);
         $this->assign("num", $num);
         $this->assign("sum", $sum);
         $this->assign("goods", $_cart);
         $this->assign("address", $address);
         //三级联动
         $city = array("--请选择省--", "--市--", "--区县--");
         $c = Area::city($city);
         // dump($c);
         // die;
         $this->assign("city", $c);
         $this->display();
     }
 }
コード例 #6
0
 public function addressGet()
 {
     $id = $_POST['id'];
     $db = M('user_address');
     $row = $db->where("id = {$id}")->find();
     $province = $row['province'];
     $city = $row['city'];
     $area = $row['area'];
     $city = array($province, $city, $area);
     $c = Area::city($city);
     $this->assign("o", $c);
     $this->ajaxReturn($row);
     $this->display('address');
 }
コード例 #7
0
 public function index()
 {
     //==========地址三级连动=================
     $city = Area::city();
     $this->assign("city", $city);
     //=============根据商品 id 获取商品评价======
     $goods = M('goods');
     //作为测试  假设商品id=1
     $goods_id = I('id');
     //
     $goodsreviews = M('goodsreviews');
     //===========将浏览次浏览记录添加到浏览历史开始=================
     $histories = M('histories');
     $his['goods_id'] = $goods_id;
     $his['user_id'] = session('uid');
     $his['addtime'] = time();
     //dump($his);
     $data = $histories->where("goods_id={$his['goods_id']}")->find();
     if (!$data) {
         if ($histories->create($his)) {
             $histories->add();
         }
     }
     //===========将浏览次浏览记录添加到浏览历史结束=================
     $users = M('users');
     $attr = M('attr');
     $attrvalue = M('attrvalue');
     //==========获取商品的详细信息============
     $goods_info = $goods->find($goods_id);
     //根据商品的id获取属性id,进而获取属性值
     $attr_ids = $attr->where("goods_id={$goods_id}")->select();
     $attrvalue_id = "";
     //定义一个变量,用户存放属性值id
     $stock = 0;
     //定义一个变量,用户存放总库存
     foreach ($attr_ids as $attr_id) {
         $attrvalue_id .= $attr_id['attrvalue_id'] . ",";
         $stock += $attr_id['stock'];
     }
     $attrvalue_id = rtrim($attrvalue_id, ",");
     //获取商品分类级别栏
     $type_id = $goods_info['type_id'];
     //所属类别ID
     $typeData = getData('type');
     $typeIds = getParentId($typeData, $type_id);
     $typeIds = explode(',', $typeIds);
     //组合数组
     foreach ($typeData as $v) {
         $typeInfo[$v['id']] = $v['name'];
         //遍历得到一维数组,下标为类ID,值为类名称
     }
     //获取颜色
     $c['attrname'] = array('EQ', "颜色");
     $c['id'] = array("IN", $attrvalue_id);
     $at_value['color'] = $attrvalue->where($c)->select();
     //获取尺寸
     $s['attrname'] = array('EQ', "尺码");
     $s['id'] = array("IN", $attrvalue_id);
     $at_value['size'] = $attrvalue->where($s)->select();
     //dump($at_value);
     //exit;
     //=================获取全部评价数,好,中,差========
     $al['goods_id'] = array('EQ', $goods_id);
     $al['state'] = array('EQ', "1");
     $count['all'] = $goodsreviews->where($al)->count();
     $wl['goods_id'] = array('EQ', $goods_id);
     $wl['star'] = array('EQ', "5");
     $count['w'] = $goodsreviews->where($wl)->count();
     $ml['goods_id'] = array('EQ', $goods_id);
     $ml['star'] = array('IN', "3,4");
     $count['m'] = $goodsreviews->where($ml)->count();
     $bl['goods_id'] = array('EQ', $goods_id);
     $bl['star'] = array('IN', "1,2");
     $count['b'] = $goodsreviews->where($bl)->count();
     //====好,中差评率===
     $rate['w'] = ceil($count['w'] / $count['all'] * 100);
     $rate['m'] = floor($count['m'] / $count['all'] * 100);
     $rate['b'] = floor($count['b'] / $count['all'] * 100);
     //=======================获取商品全部评价============================================
     $page_count = $goodsreviews->where($al)->count();
     $Page = new \Think\Page($page_count, 10);
     $all_show = $Page->show();
     $all_data = $goodsreviews->where($al)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     //	dump($all_data);
     //	exit;
     //获取到评论人的 id ,在根据id 获取到====(会员名)===(会员等级)=====
     $reviewsreply = M('reviewsreply');
     foreach ($all_data as $all) {
         //将评论信息存储到以评论id为名字的数组中,下标为'review' ,
         $a[$all['id']]['review'] = $all;
         //获取评论人的id,进而获取详细信息,并将获取的信息储存到 $a[$all['id']]['user']
         $user_id = $all['user_id'];
         $a[$all['id']]['user'] = $users->where("id={$user_id}")->find();
         //评论id = $all['id'] ,利用其查询出对应的回复
         $a[$all['id']]['reviewsreply'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->limit("5")->select();
         $a[$all['id']]['count'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->count();
     }
     //=======================获取商品好评============================================
     $all_data = $goodsreviews->where($wl)->select();
     //获取到评论人的 id ,在根据id 获取到====(会员名)===(会员等级)=====
     $reviewsreply = M('reviewsreply');
     foreach ($all_data as $all) {
         //将评论信息存储到以评论id为名字的数组中,下标为'review' ,
         $w[$all['id']]['review'] = $all;
         //获取评论人的id,进而获取详细信息,并将获取的信息储存到 $a[$all['id']]['user']
         $user_id = $all['user_id'];
         $w[$all['id']]['user'] = $users->find($user_id);
         //评论id = $all['id'] ,利用其查询出对应的回复
         $w[$all['id']]['reviewsreply'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->limit("5")->select();
         $w[$all['id']]['count'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->count();
     }
     //=======================获取商品中评============================================
     $all_data = $goodsreviews->where($ml)->select();
     //获取到评论人的 id ,在根据id 获取到====(会员名)===(会员等级)=====
     $reviewsreply = M('reviewsreply');
     foreach ($all_data as $all) {
         //将评论信息存储到以评论id为名字的数组中,下标为'review' ,
         $m[$all['id']]['review'] = $all;
         //获取评论人的id,进而获取详细信息,并将获取的信息储存到 $a[$all['id']]['user']
         $user_id = $all['user_id'];
         $m[$all['id']]['user'] = $users->find($user_id);
         //评论id = $all['id'] ,利用其查询出对应的回复
         $m[$all['id']]['reviewsreply'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->limit("5")->select();
         $m[$all['id']]['count'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->count();
     }
     //=======================获取商品差评============================================
     $all_data = $goodsreviews->where($bl)->select();
     //获取到评论人的 id ,在根据id 获取到====(会员名)===(会员等级)=====
     $reviewsreply = M('reviewsreply');
     foreach ($all_data as $all) {
         //将评论信息存储到以评论id为名字的数组中,下标为'review' ,
         $b[$all['id']]['review'] = $all;
         //获取评论人的id,进而获取详细信息,并将获取的信息储存到 $a[$all['id']]['user']
         $user_id = $all['user_id'];
         $b[$all['id']]['user'] = $users->find($user_id);
         //评论id = $all['id'] ,利用其查询出对应的回复
         $b[$all['id']]['reviewsreply'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->limit("5")->select();
         $b[$all['id']]['count'] = $reviewsreply->where("reviews_id={$all['id']}")->order('addtime desc')->count();
     }
     $best_data = $goods->where("ishot=2 AND state = 2")->limit('10')->order('addtime')->select();
     //热销商品
     $this->assign('typeIds', $typeIds);
     //所属类前辈类ID数组(一维)
     $this->assign('typeInfo', $typeInfo);
     //类信息数组(一维)
     $this->assign('type_id', $type_id);
     //所属类ID
     $this->assign('best_goods', $best_data);
     $this->assign('histories', $hot_data);
     $this->assign("count", $count);
     //评论数
     $this->assign("rate", $rate);
     //好评率
     $this->assign("goods_info", $goods_info);
     //商品信息
     $this->assign("a", $a);
     //$a 全部评级
     $this->assign("w", $w);
     //$w 好评
     $this->assign("m", $m);
     //$m 中评
     $this->assign("b", $b);
     //$b 差评
     $this->assign("all_page", $all_show);
     //评论分页
     $this->assign("at_color", $at_value['color']);
     //商颜色属性值
     $this->assign("at_size", $at_value['size']);
     //商品尺寸属性值
     //$this -> assign("stock",$stock);  //商品库存量
     $this->display();
 }
コード例 #8
0
 public function add()
 {
     $city = Area::city();
     $this->assign("city", $city);
     $this->display();
 }
コード例 #9
0
 public function applyProcess()
 {
     //SEO
     $ident = "service";
     $idents = $this->seo($ident);
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $pro_attr = M("products_attr");
     $product = M("product");
     $order_product = M("order_products");
     $order = M("orders");
     $product_id = $_GET['id'];
     $order_id = $_GET['ids'];
     $map['order_id'] = $map2['a.id'] = array("eq", $order_id);
     $user_id = $_SESSION['user']['userid'];
     $map['user_id'] = $map2['a.user_id'] = array("eq", $user_id);
     $map['product_id'] = $map2['b.product_id'] = array("eq", $product_id);
     //判断是否存在订单
     $orders = $order->alias('a')->join('LEFT JOIN im_order_products b ON a.id = b.order_id')->where($map2)->find();
     if (!$orders) {
         $this->error('订单不存在请检查!');
         exit;
     }
     //查找商品是否有赠品
     $zp = $pro_attr->field("prop_value")->where("pro_id = " . $product_id . " AND prop_id =3")->find();
     if ($zp) {
         $list = $product->field("pro_name")->where("id IN (" . $zp['prop_value'] . ")")->select();
         $this->assign("zplist", $list);
     }
     //查找商品的购买数量
     $number = $order_product->field("product_number")->where($map)->find();
     $this->assign("number", $number);
     //查找商品的信息
     $pro = $product->field("id,pro_name,pro_subname,list_image")->where("id = " . $product_id)->find();
     $this->assign("product", $pro);
     //查找收货人的信息
     $addr = $order->field(shipping_addr_id)->where("id = " . $order_id)->find();
     $user_addr = M("user_address");
     $address = $user_addr->where("id = " . $addr['shipping_addr_id'])->find();
     $city = array($address['province'], $address['city'], $address['area']);
     $c = Area::city($city);
     $this->assign("city", $c);
     $this->assign("order_id", $order_id);
     $this->assign("address", $address);
     $this->display();
 }
コード例 #10
0
 public function addressMod()
 {
     if (empty($_SESSION['user'])) {
         $this->redirect('Login/index');
     }
     $uid = $_SESSION['user'][0]['id'];
     $u['uid'] = $uid;
     $address = M("address");
     $id = I('id');
     $data = $address->where($u)->where('id=' . $id)->find();
     //dump($data);
     $addr = $data['addr'];
     $res = explode('|', $addr);
     $pro = $res[0];
     $cit = $res[1];
     $cou = $res[2];
     $add = $res[3];
     $c = array("{$pro}", "{$cit}", "{$cou}");
     $city = Area::city($c);
     $this->assign("city", $city);
     //dump($c);
     $this->assign('add', $res[3]);
     //dump($res);
     $this->assign('address', $data);
     $this->display();
 }
コード例 #11
0
 /**
  * 会员基本资料修改
  * @date 2015-01-18
  * @return void 
  */
 public function userEdit()
 {
     $getUserId = I('get.id');
     $modelUserInfo = M();
     $userInfoRes = $modelUserInfo->table('__USERS__ AS u, __USER_INFO__ AS i')->where("u.id = i.user_id AND u.id='{$getUserId}'")->find();
     if (!empty($userInfoRes['province'])) {
         $city = array($userInfoRes['province'], $userInfoRes['city'], $userInfoRes['area']);
     } else {
         $city = array('选择省', '选择市', '选择县');
     }
     $c = Area::city($city);
     $this->assign('user', $userInfoRes);
     $this->assign("city", $c);
     $this->display('user_edit');
 }