public function order() { $id = $this->_get('id', 'intval'); $reward_id = $this->_get('reward_id', 'intval'); $info = $this->getCrowdfunding($id); $reward = $this->getReward($reward_id, $id); if ($this->checkStatus($info)) { $this->assign('is_over', 1); } if ($this->wxuser['winxintype'] == 3 && $this->wxuser['oauth'] == 1) { $addr = new WechatAddr($this->wxuser); $this->assign('addrSign', $addr->addrSign()); } $this->assign('reward', $reward); $this->assign('info', $info); $this->display(); }
public function orderCart() { $this->noaccess(); $userinfo_model = D('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find(); $this->assign('thisUser', $thisUser); //是否要支付 $alipay_config_db = M('Alipay_config'); $alipayConfig = $alipay_config_db->where(array('token' => $this->token))->find(); $this->assign('alipayConfig', $alipayConfig); // if (IS_POST) { $row = array(); //2015-05-30 创建订单之前判断虚拟商品是否足够 $row['sn'] = 0; $sn = M('Product')->where(array('token' => $this->token, 'id' => (int) $_POST['productid']))->getField('sn'); if ($sn) { $where['sendstutas'] = 0; $where['order_id'] = 0; $where['pid'] = (int) $_POST['productid']; $where['token'] = $this->token; $count = M('ProductSn')->where($where)->count(); if ($count < (int) $_POST['quantity']) { $this->error('虚拟商品库存不足'); exit; } $row['sn'] = 1; } else { $num = M('Product')->where(array('token' => $this->token, 'id' => (int) $_POST['productid']))->getField('groupon_num'); if ($_POST['quantity'] > $num) { $this->error('商品库存不足'); exit; } } $orderid = $this->randStr(4) . time(); $row['orderid'] = $orderid; // $row['truename'] = $this->_post('truename'); $row['tel'] = $this->_post('tel'); $row['address'] = $this->_post('address'); $row['token'] = $this->token; $row['wecha_id'] = $this->wecha_id; if (!$row['wecha_id']) { $row['wecha_id'] = 'null'; } $time = time(); $row['time'] = $time; //分别加入3类订单 $product_cart_model = M('product_cart'); $row['total'] = intval($_POST['quantity']); $row['price'] = $row['total'] * floatval($_POST['price']); $row['diningtype'] = 0; $row['productid'] = intval($_POST['productid']); $row['code'] = substr($row['wecha_id'], 0, 6) . $time; $row['tableid'] = 0; $row['info'] = serialize(array(intval($_POST['productid']) => array('count' => $row['total'], 'price' => intval($_POST['price'])))); $row['groupon'] = 1; $row['dining'] = 0; $product_cart_model->add($row); //。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 $product_model = M('product'); $product_cart_list_model = M('product_cart_list'); $product_model->where(array('id' => intval($_POST['productid'])))->setInc('salecount', $_POST['quantity']); $productName = $product_model->where(array('id' => intval($_POST['productid'])))->getField('name'); //保存个人信息 if ($_POST) { $userRow = array('tel' => $row['tel'], 'truename' => $row['truename'], 'address' => $row['address']); if ($thisUser) { $userinfo_model->where(array('id' => $thisUser['id']))->save($userRow); } else { $userRow['token'] = $this->token; $userRow['wecha_id'] = $this->wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = -1; $userRow['age'] = 0; $userRow['birthday'] = ''; $userRow['info'] = ''; // $userRow['total_score'] = 0; $userRow['sign_score'] = 0; $userRow['expend_score'] = 0; $userRow['continuous'] = 0; $userRow['add_expend'] = 0; $userRow['add_expend_time'] = 0; $userRow['live_time'] = 0; $userinfo_model->add($userRow); } } $orderName = '团购-' . $productName; if ($this->_post('paytype') == 1) { $this->redirect(U('CardPay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'single_orderid' => $orderid))); Sms::sendSms($this->token, '您在微信上有新的团购订单'); exit; } if ($alipayConfig['open']) { //$this->printOrder($orderid); if ($row['sn'] == 1) { $this->success('提交成功,转向支付页面', U('Alipay/pay', array('notOffline' => 1, 'token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'orderid' => $orderid))); } else { $this->success('提交成功,转向支付页面', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'orderid' => $orderid))); } } else { Sms::sendSms($this->token, '您在微信上有新的团购订单'); //$this->printOrder($orderid); $this->redirect(U('Groupon/my', array('token' => $_GET['token'], 'wecha_id' => $_GET['wecha_id'], 'success' => 1))); } } else { $where = array('token' => $this->token); if (isset($_GET['id'])) { $id = intval($_GET['id']); $where['id'] = $id; } if ($this->wxuser['winxintype'] == 3 && $this->wxuser['oauth'] == 1) { $addr = new WechatAddr($this->wxuser); $this->assign('addrSign', $addr->addrSign()); } $product = $this->product_model->where($where)->find(); $this->assign('product', $product); $this->display('orderCart_' . $this->tplid); } }
public function order() { $id = $this->_get("id", "intval"); $reward_id = $this->_get("reward_id", "intval"); $info = $this->getCrowdfunding($id); $reward = $this->getReward($reward_id, $id); if ($this->checkStatus($info)) { $this->assign("is_over", 1); } if (($this->wxuser["winxintype"] == 3) && ($this->wxuser["oauth"] == 1)) { $addr = new WechatAddr($this->wxuser); $this->assign("addrSign", $addr->addrSign()); } $db = M("Userinfo"); $where["token"] = $this->token; $where["wecha_id"] = $this->wecha_id; $list = $db->where($where)->find(); $this->assign("list", $list); $this->assign("reward", $reward); $this->assign("info", $info); $this->display(); }
public function orderCart() { $set = M("New_twitter_set")->where(array('token' => $this->token, 'cid' => $this->_cid))->find(); if (empty($this->wecha_id) && empty($this->mytwid) && $set) { $callbackurl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; session('callbackurl', $callbackurl); $this->redirect(U('Storenew/login', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'twid' => $this->_twid, 'rget' => 1))); } elseif (empty($this->wecha_id)) { unset($_SESSION[$this->session_cart_name]); } $wecha_id = $this->wecha_id ? $this->wecha_id : session('twid'); $cid = $this->_isgroup ? $this->mainCompany['id'] : $this->_cid; $orid = isset($_GET['orid']) ? intval($_GET['orid']) : 0; $setting = M('New_product_setting')->where(array('token' => $this->token, 'cid' => $cid))->find(); $this->assign('setting', $setting); //是否要支付 // $alipayConfig = M('Alipay_config')->where(array('token' => $this->token))->find(); // $this->assign('alipayConfig', $alipayConfig); $totalCount = $totalFee = 0; if ($orid && ($cartObj = M('New_product_cart')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'id' => $orid))->find())) { $products = unserialize($cartObj['info']); $data = $this->getCat($products); } else { $data = $this->getCat($this->_getCart()); } if (empty($data[0])) { $this->redirect(U('Storenew/cart', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'twid' => $this->_twid))); } if (isset($data[1])) { foreach ($data[1] as $pid => $row) { $totalCount += $row['total']; $totalFee += $row['totalPrice']; } } if ($cartObj) { $totalFee -= $cartObj['score'] / $setting['score']; } if (empty($totalCount)) { $this->error('没有购买商品!', U('Storenew/cart', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'twid' => $this->_twid))); } if ($this->wxuser['winxintype'] == 3 && $this->wxuser['oauth'] == 1) { $addr = new WechatAddr($this->wxuser); $this->assign('addrSign', $addr->addrSign()); } $list = $data[0]; $this->assign('orid', $orid); $this->assign('products', $list); $this->assign('totalFee', $totalFee); $this->assign('totalCount', $totalCount); $this->assign('mailprice', $data[2]); $this->assign('metaTitle', '购物车结算'); $this->display(xdxorderCart); }
public function order() { $id = $this->_get('id', 'intval'); $reward_id = $this->_get('reward_id', 'intval'); $info = $this->getCrowdfunding($id); $reward = $this->getReward($reward_id, $id); if ($this->checkStatus($info)) { $this->assign('is_over', 1); } if ($this->wxuser['winxintype'] == 3 && $this->wxuser['oauth'] == 1) { $addr = new WechatAddr($this->wxuser); $this->assign('addrSign', $addr->addrSign()); } $db = M('Userinfo'); $where['token'] = $this->token; $where['wecha_id'] = $this->wecha_id; $list = $db->where($where)->find(); $this->assign('list', $list); $this->assign('reward', $reward); $this->assign('info', $info); $this->display(); }