public function getList($where = array(), $order = null, $offset = null, $limit = null) { if (empty($where['ProductFilterOption.productCategoryFilterOptionID'])) { $select = new Select(); $select->from(array('b' => 'Product')); $select->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName')); $select->where($where); $select->offset($offset); $select->limit($limit); $select->order($order); } else { $select = $this->getSelect(); $select->columns(array())->join(array('b' => 'Product'), 'ProductFilterOption.productID = b.productID')->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName'))->where($where)->offset($offset)->limit($limit)->group(array('ProductFilterOption.productID'))->having('count(ProductFilterOption.productID) > ' . (count($where['ProductFilterOption.productCategoryFilterOptionID']) - 1)); $select->order($order); } $paginator = $this->paginate($select); $paginator->setCurrentPageNumber(ceil($offset / $limit) + 1); //$paginator->setItemCountPerPage(1); $products = $paginator->getCurrentItems()->getArrayCopy(); $pages = $paginator->getPages(); $productsCount = $paginator->getTotalItemCount(); foreach ($products as $k => $v) { $products[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } return array('products' => $products, 'productsCount' => $productsCount, 'pages' => $pages); }
public function indexAction() { $banners = $this->adModel->getAdByPosition(BaseConst::AD_POSITION_INDEX_BANNER); $indexSecondAd = $this->adModel->getAdByPosition(BaseConst::AD_POSITION_INDEX_SECOND); $indexThirdLeftAd = $this->adModel->getAdByPosition(BaseConst::AD_POSITION_INDEX_THIRD_LEFT); $indexThirdRightAd = $this->adModel->getAdByPosition(BaseConst::AD_POSITION_INDEX_THIRD_RIGHT); $stores = $this->storeModel->getRecommendStores(); $stores = $stores['data']; $products = $this->productModel->getIndexRecommendProducts(); $indexRecommendArticles = $this->articleModel->getIndexRecommendArticles(); foreach ($indexRecommendArticles as $k => $v) { if (!empty($v['url'])) { preg_match_all('/memberArticleID=([\\d]*)/', $v['url'], $matches); $memberArticleID = $matches[1][0]; if (!empty($memberArticleID)) { $info = $this->memberArticleModel->setColumns(array('memberArticleContent'))->select(array('memberArticleID' => $memberArticleID))->current(); $v['articleContent'] = $info['memberArticleContent']; } } $indexRecommendArticles[$k]['articleContent'] = Utility::mbCutStr(Utility::getBodyText($v['articleContent']), 80); } $indexArticleList = $this->articleModel->getIndexArticleList(); $friendlyLinks = $this->friendlyLinkModel->select()->toArray(); $this->view->setVariables(array('products' => $products['products'], 'banners' => $banners, 'stores' => $stores, 'indexSecondAd' => $indexSecondAd, 'indexThirdLeftAd' => $indexThirdLeftAd, 'indexThirdRightAd' => $indexThirdRightAd, 'indexRecommendArticles' => $indexRecommendArticles, 'indexArticleList' => $indexArticleList, 'friendlyLinks' => $friendlyLinks)); return $this->view; }
public function indexAction() { $articleCategoryID = $this->queryData['articleCategoryID']; $display = $this->queryData['display'] ? $this->queryData['display'] : 'preview'; $articleCategories = $this->articleCategoryModel->getCategories(); $where = array(); if (!empty($articleCategoryID)) { $where['b.articleCategoryID'] = $articleCategoryID; } $articles = $this->articleModel->getArticles($this->pageNum, $this->limit, $where); foreach ($articles['data'] as $k => $v) { if (!empty($v['url'])) { preg_match_all('/memberArticleID=([\\d]*)/', $v['url'], $matches); $memberArticleID = $matches[1][0]; if (!empty($memberArticleID)) { $info = $this->memberArticleModel->setColumns(array('memberArticleContent'))->select(array('memberArticleID' => $memberArticleID))->current(); $v['articleContent'] = $info['memberArticleContent']; } } $articles['data'][$k]['imgs'] = Utility::getImgs($v['articleContent']); $body = Utility::getBodyText($v['articleContent']); if (mb_strlen($body) > 300) { $articles['data'][$k]['fullContent'] = 0; } else { $articles['data'][$k]['fullContent'] = 1; } $articles['data'][$k]['articleContent'] = Utility::mbCutStr($body, 300); } $this->view->setVariables(array('articleCategories' => $articleCategories, 'articles' => $articles['data'], 'pages' => $articles['page'], 'display' => $display, 'articleCategoryID' => $articleCategoryID)); return $this->view; }
public function markAction() { $res = $this->memberArticleMarkModel->getArticles(array('MemberArticleMark.memberID' => $this->_zoneInfo['memberID']), $this->pageNum, $this->limit); $articles = $res['data']; foreach ($articles as $k => $v) { $articles[$k]['memberArticleContent'] = Utility::mbCutStr(strip_tags($v['memberArticleContent']), 100); } $this->view->setVariables(array('articles' => $articles, 'pages' => $res['pages'])); return $this->view; }
public function getIndexRecommendArticles() { $select = $this->getSql()->select(); $select->join(array('b' => 'ArticleCategory'), 'Article.articleCategoryID = b.articleCategoryID', array('categoryName')); $select->where(array('isIndexRecommend' => 1, 'b.display' => 1, 'isDel' => 0)); $select->limit(2); $result = $this->selectWith($select)->toArray(); foreach ($result as $k => $v) { $articleContent = Utility::getBodyText($v['articleContent']); $result[$k]['articleContent'] = Utility::mbCutStr($articleContent, 30); } return $result; }
public function getProducts($where, $page = 1, $limit = 10, $order = '') { $select = $this->getSelect(); $select->join(array('b' => 'Store'), 'Product.storeID = b.storeID', array('storeName'), 'left'); $select->where($where); $select->where(array('Product.isDel' => 0)); if (!empty($order)) { $select->order($order); } else { $select->order('Product.instime DESC'); } $paginator = $this->paginate($select, $this->getSql()->getAdapter()); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($limit); $data = $paginator->getCurrentItems()->getArrayCopy(); $pages = $paginator->getPages(); $total = $paginator->getTotalItemCount(); foreach ($data as $k => $v) { $data[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } $result = array('data' => $data, 'pages' => $pages, 'total' => $total); return $result; }
public function detailAction() { $storeID = $this->queryData['storeID']; $auctionStatus = $this->queryData['auctionStatus']; $order = $this->queryData['order']; $sort = $this->queryData['sort']; $storeCategoryID = $this->queryData['storeCategoryID']; $where = array('storeID' => $storeID); $storeInfo = $this->storeModel->fetch($where); $storeCategories = $this->storeCategoryModel->select(array('storeID' => $storeID))->toArray(); /*$storeRecommendProducts = $this->productModel->getProducts(array('Product.isStoreRecommend' => 1, 'Product.storeID' => $storeID, 'Product.auctionStatus' => array(1, 2))); $storeRecommendProductsData = $storeRecommendProducts['data']; foreach($storeRecommendProductsData as $k => $v){ $storeRecommendProductsData[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); }*/ if (!empty($order) && !empty($sort)) { $order = 'Product.' . $order . ' ' . $sort; } $where = new Where(); $where->equalTo('Product.storeID', $storeID); if (!empty($auctionStatus)) { $where->equalTo('Product.auctionStatus', $auctionStatus); } else { $where->in('Product.auctionStatus', array(1, 2)); } $where->isNull('Product.specialID'); if (!empty($storeCategoryID)) { $where->and->nest()->or->equalTo('Product.firstStoreCategoryID', $storeCategoryID)->or->equalTo('Product.secondStoreCategoryID', $storeCategoryID)->or->equalTo('Product.thirdStoreCategoryID', $storeCategoryID); } $storeProducts = $this->productModel->getProducts($where, $this->pageNum, $this->limit, $order); $storeProductsData = $storeProducts['data']; foreach ($storeProductsData as $k => $v) { $storeProductsData[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } $this->view->setVariables(array('storeInfo' => $storeInfo, 'storeProducts' => $storeProductsData, 'storeCategories' => $storeCategories, 'pages' => $storeProducts['pages'], 'auctionStatus' => $auctionStatus, 'order' => $this->queryData['order'], 'sort' => $sort, 'storeCategoryID' => $storeCategoryID)); return $this->view; }
public static function returnXml($data) { header("Content-Type:application/xml;Charset=utf-8"); $data = Utility::toXml($data); die(urldecode($data)); }
public function storeVerifyAction() { $store = $this->postData; $verifyCode = $this->mobileVerifyCodeModel->getLastVerifyCode($store['storeMobile']); if ($verifyCode != $store['storeMobileCode']) { return $this->response(ApiError::VERIFY_CODE_INVALID, ApiError::VERIFY_CODE_INVALID_MSG); } unset($store['storeMobileCode']); $store['idPic'] = Utility::saveBaseCodePic($store['idPic']); $store['memberIdPic'] = Utility::saveBaseCodePic($store['memberIdPic']); $store['memberID'] = $this->memberInfo['memberID']; $store['storeName'] = $this->memberInfo['nickName']; try { $this->storeModel->beginTransaction(); if (!empty($this->_storeInfo)) { $store['verifyStatus'] = 1; $this->storeModel->update($store, array('storeID' => $this->_storeInfo['storeID'])); } else { $this->storeModel->insert($store); $storeID = $this->storeModel->getLastInsertValue(); $this->memberInfoModel->update(array('storeID' => $storeID), array('memberID' => $this->memberInfo['memberID'])); } $this->storeModel->commit(); return $this->response(ApiSuccess::COMMON_SUCCESS, ApiSuccess::COMMON_SUCCESS_MSG); } catch (\Exception $e) { $this->storeModel->rollback(); return $this->response($e->getCode(), $e->getMessage()); } }
public function makeSign($data) { //签名步骤一:按字典序排序参数 ksort($data); $string = Utility::toUrlParams($data); //签名步骤二:在string后加入KEY $string = $string . "&key=" . $this->key; //var_dump($string); //签名步骤三:MD5加密 $string = md5($string); //签名步骤四:所有字符转为大写 $result = strtoupper($string); return $result; }
public function categoryAction() { $categories = $this->productCategoryModel->getList(); $categoryFilters = $this->productCategoryFilterModel->getList(); $categoryFilterOptions = $this->productCategoryFilterOptionModel->getList(); $categories = Utility::recreateIndex($categories, 'productCategoryID'); $categoryFilters = Utility::recreateIndex($categoryFilters, 'productCategoryFilterID'); $categoryFilterOptions = Utility::recreateIndex($categoryFilterOptions, 'productCategoryFilterOptionID'); foreach ($categoryFilterOptions as $k => $v) { $categoryFilters[$v['productCategoryFilterID']]['options'][$k] = $v; } foreach ($categoryFilters as $k => $v) { $categories[$v['productCategoryID']]['filters'][$k] = $v; } $result = array(); foreach ($categories as $k => $v) { $tmp = array(); if (!empty($v['filters'])) { foreach ($v['filters'] as $sk => $sv) { $tmp2 = array(); if (!empty($sv['options'])) { foreach ($sv['options'] as $ssk => $ssv) { $tmp2 = array('optionID' => $ssk, 'optionName' => $ssv['optionName']); } } $tmp[] = array('filterID' => $sk, 'filterName' => $sv['filterName'], 'options' => $tmp2); } } $result[] = array('categoryID' => $k, 'categoryName' => $v['categoryName'], 'filters' => $tmp); } return $this->response(ApiSuccess::COMMON_SUCCESS, ApiSuccess::COMMON_SUCCESS_MSG, $result); }
public function wxLoginAction() { $code = $this->queryData['code']; $token = Utility::curl('https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx8599ed3526a343ea&secret=bf4aa929f93736b3f09c177ed8e609ab&code=' . $code . '&grant_type=authorization_code', array(), 'get'); $token = json_decode($token, true); if (!empty($token['access_token'])) { $userInfo = Utility::curl('https://api.weixin.qq.com/sns/userinfo?access_token=' . $token['access_token'] . '&openid=' . $token['openid'], array(), 'get'); $userInfo = json_decode($userInfo, true); if (!empty($userInfo['nickname'])) { $nickName = $userInfo['nickname']; $member = array('wxOpenID' => $token['openid']); $exist = $this->memberModel->select($member)->current(); if (empty($exist)) { $this->memberModel->beginTransaction(); $this->memberModel->insert($member); $memberID = $this->memberModel->getLastInsertValue(); $infoData = array('memberID' => $memberID, 'nickName' => $nickName); $this->memberInfoModel->insert($infoData); $this->memberModel->commit(); } else { $memberID = $exist['memberID']; } $memberInfo = $this->memberInfoModel->select(array('memberID' => $memberID))->current(); $loginSession = new Session(self::FRONT_PLATFORM, null, null); $loginSession->write($memberInfo); return $this->redirect()->toUrl('/'); } } return $this->redirect()->toUrl('/login/do-login'); }
public function wxSpecialNotifyAction() { $xml = $GLOBALS['HTTP_RAW_POST_DATA']; $postData = Utility::decodeXml($xml); /*$postData = array( 'return_code' => 'SUCCESS', 'result_code' => 'SUCCESS', 'out_trade_no' => '1606231043392673', 'total_fee' => '399' );*/ if ($postData['return_code'] == 'SUCCESS' && $postData['result_code'] == 'SUCCESS') { $unitePayID = $postData['out_trade_no']; $price = $postData['total_fee']; $payDetail = $this->specialModel->select(array('unitePayID' => $unitePayID))->current(); if ($this->siteSettings['specialMoney'] * 100 == $price && $payDetail['isPaid'] == 0) { $this->sm->get("COM\\Service\\PayMod\\WxPay")->specialNotify($unitePayID); $requestUri = $_SERVER['REQUEST_URI']; $data = array('money' => $this->siteSettings['specialMoney'], 'payNotifyInfo' => $requestUri, 'postData' => json_encode($postData), 'unitePayID' => $unitePayID, 'payType' => 5, 'type' => 3); $this->payNotifyLogModel->insert($data); Utility::returnXml(array('return_code' => 'SUCCESS', 'return_msg' => '成功')); } else { Utility::returnXml(array('return_code' => 'FAIL', 'return_msg' => '金额错误')); } } else { Utility::returnXml(array('return_code' => 'FAIL', 'return_msg' => '失败')); } }