示例#1
0
 public function indexAction()
 {
     //http://www.xiguxigu.com/g/1
     $gid = $this->param('gid');
     $group = GroupData::getById($gid);
     if (!$group) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     //根据群组id获取群组支持的分类,一级和二级
     $cats = CategoryData::groupCategorys($gid);
     $this->assign('cats', $cats);
     $this->assign('group', $group);
     $this->display();
 }
 public function indexAction()
 {
     $cid = intval($this->param('cid', 0));
     if (!$cid) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $category = CategoryData::getById($cid);
     if (!$category) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $curTime = time();
     $category['start_time'] = '09:00:00';
     $category['end_time'] = '24:00:00';
     $startTime = strtotime($category['start_time']);
     $endTime = strtotime($category['end_time']);
     $notStart = $curTime < $startTime ? true : false;
     //true为尚未开始
     $isOver = $curTime > $endTime ? true : false;
     //true为已结束
     $isOn = !$notStart && !$isOver;
     //过程中
     $this->assign('notStart', $notStart);
     $this->assign('isOver', $isOver);
     $this->assign('isOn', $isOn);
     $group = GroupData::getById($category['group_id']);
     $store = StoreData::getById($category['store_id']);
     $goods = GoodsData::getsByCid($cid);
     $cart = array();
     $cart = $this->getCart($cid);
     $this->assign('category', $category);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('goods', $goods);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }
示例#3
0
 /**
  * 提交订单
  */
 public function goAction()
 {
     if (ComTool::isAjax()) {
         if (!$this->isLogin()) {
             ComTool::ajax(Cola::getConfig('_error.mustlogin'), '请先登录,即将跳转至登录页面');
         }
         $mobile = trim($this->post('mobile'));
         ComTool::checkEmpty($mobile, '请填写常用手机号');
         if (!ComTool::isMobile($mobile)) {
             ComTool::ajax(100001, '请填写正确的手机号');
         }
         $receiver = $this->post('receiver', '');
         ComTool::checkMaxLen($receiver, 16, "收货人姓名最多16位");
         $addrDesc = $this->post('addr_desc', '');
         ComTool::checkMaxLen($addrDesc, 32, "详细位置最多32位");
         $message = trim($this->post('message', ''));
         ComTool::checkMaxLen($message, 100, "留言最多100字");
         $curCategory = $this->post('cate', 0);
         $curCategory = intval(base64_decode($curCategory));
         if (!isset($_SESSION['cart'][$curCategory])) {
             ComTool::ajax(100001, '购物车为空');
         }
         $cart = $this->getCart($curCategory);
         if (!$cart) {
             ComTool::ajax(100001, '购物车为空');
         }
         $groupName = $this->post('group', '');
         if (!$groupName) {
             $category = CategoryData::getById($curCategory);
             $group = GroupData::getById($category['group_id']);
             $groupName = $group['name'];
         } else {
             $groupName = base64_decode($groupName);
         }
         $currUser = $this->getCurrentUser();
         $data = array();
         $orderId = ComTool::getOrderId();
         $data['id'] = $orderId;
         $data['user_id'] = $currUser['id'];
         $data['category_id'] = $curCategory;
         $data['user_name'] = $receiver;
         $data['user_tel'] = $mobile;
         $data['user_addr'] = "{$groupName} {$addrDesc}";
         $data['message'] = $message;
         $data['create_time'] = $data['update_time'] = time();
         $data['create_date'] = date("Y-m-d");
         $data['total_cost'] = $cart['totalPrice'];
         $data['status'] = '1';
         $res = OrderData::add($data);
         if ($res === false) {
             ComTool::ajax(100001, '服务器忙,请重试');
         }
         $sql = "insert into order_detail(order_id,good_id,good_name,amount,`price`,price_desc,`status`) values";
         foreach ($cart['products'] as $product) {
             $sql .= "('{$orderId}','{$product['id']}','{$product['name']}','{$product['quantity']}','{$product['price']}','{$product['price']}({$product['price_num']}{$product['price_unit']})','1'),";
         }
         $sql = trim($sql, ',');
         $res = OrderData::sql($sql);
         if ($res === false) {
             ComTool::ajax(100001, '服务器忙,请重试');
         }
         //TODO 清除此分类购物车的session
         ComTool::ajax(100000, 'ok');
     }
 }
示例#4
0
 /**
  * 获取圈子信息
  */
 public function getgroupAction()
 {
     if (ComTool::isAjax()) {
         $ajax = $this->get('ajax');
         $field = $this->get('f');
         $id = intval($this->get('id', 0));
         if (empty($id)) {
             ComTool::ajax(100001, 'empty id');
         }
         $group = GroupData::getById($id);
         if (!$group) {
             ComTool::ajax(100001, 'wrong id');
         }
         ComTool::ajax(100000, 'ok', $group[$field]);
     }
 }