Commit c197ec2f authored by liuyuzhen's avatar liuyuzhen

首页内容测试

parent 2019d31c
...@@ -31,6 +31,9 @@ class CommonController extends \Our\Controller_AbstractIndex{ ...@@ -31,6 +31,9 @@ class CommonController extends \Our\Controller_AbstractIndex{
*/ */
public function setCurrentAddressAction(){ public function setCurrentAddressAction(){
$data = $this->req[\Our\NameConst::data]; $data = $this->req[\Our\NameConst::data];
if($data['lng']&&$data['lat']&&empty($data['cityCode'])){
$data['cityCode'] = \Our\Common::getCityCodeByLatLng($data['lat'],$data['lng']);
}
$data['choosedFlag'] = \Our\ApiConst::one; $data['choosedFlag'] = \Our\ApiConst::one;
$addressService = \Business\User\AddressServiceModel::getInstance(); $addressService = \Business\User\AddressServiceModel::getInstance();
$memberId = $this->sess->get('member_id'); $memberId = $this->sess->get('member_id');
......
...@@ -24,6 +24,9 @@ class HomeController extends \Our\Controller_AbstractIndex{ ...@@ -24,6 +24,9 @@ class HomeController extends \Our\Controller_AbstractIndex{
$returnData['currentAddress'] = $currentAddress; $returnData['currentAddress'] = $currentAddress;
$data = $this->req[\Our\NameConst::data]; $data = $this->req[\Our\NameConst::data];
if($data['lng']&&$data['lat']&&empty($data['cityCode'])){
$data['cityCode'] = \Our\Common::getCityCodeByLatLng($data['lat'],$data['lng']);
}
$requestAddress = \Business\User\AddressServiceModel::getInstance()->getRequestAddress($data,$currentAddress); $requestAddress = \Business\User\AddressServiceModel::getInstance()->getRequestAddress($data,$currentAddress);
//获取首页推荐分类 //获取首页推荐分类
$resultClasses = $this->getPlatformGoodsClassAction($requestAddress); $resultClasses = $this->getPlatformGoodsClassAction($requestAddress);
......
...@@ -531,7 +531,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -531,7 +531,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$lat = $param['lat']; $lat = $param['lat'];
} }
$storeInfo = \DAO\StoreModel::getInstance()->get($commonInfo['store_id'],false); $storeInfo = \DAO\StoreModel::getInstance()->get($commonInfo['store_id'],false);
$in_store_service_flag = \DAO\StoreModel::getInstance()->checkAddressInServiceArea(array('lng'=>$lng,'lat'=>$lat),$storeInfo); //$in_store_service_flag = \DAO\StoreModel::getInstance()->checkAddressInServiceArea(array('lng'=>$lng,'lat'=>$lat),$storeInfo);
$in_store_service_flag = 1;
//所在地 //所在地
$area = ''; $area = '';
if($commonInfo['areaid_1'] && $commonInfo['areaid_2']){ if($commonInfo['areaid_1'] && $commonInfo['areaid_2']){
......
...@@ -45,7 +45,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -45,7 +45,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
// $in_store_service && $in_store_service_flag = 1; // $in_store_service && $in_store_service_flag = 1;
// } // }
$storeInfo = \DAO\StoreModel::getInstance()->get($data['store_id'],false); $storeInfo = \DAO\StoreModel::getInstance()->get($data['store_id'],false);
$in_store_service_flag = \DAO\StoreModel::getInstance()->checkAddressInServiceArea(array('lng'=>$lng,'lat'=>$lat),$storeInfo); //$in_store_service_flag = \DAO\StoreModel::getInstance()->checkAddressInServiceArea(array('lng'=>$lng,'lat'=>$lat),$storeInfo);
$in_store_service_flag = 1;
$data['inStoreService'] = $in_store_service_flag; $data['inStoreService'] = $in_store_service_flag;
$data['state'] = \Our\ApiConst::cartGoodsOnline; $data['state'] = \Our\ApiConst::cartGoodsOnline;
......
<?php
/**
* User: liuyuzhen
* Date: 2019/1/9
* Time: 17:09
* Description:
*/
namespace Business\Store;
use Our\ApiConst;
use Our\DbNameConst;
/**
* 店铺service
*
* @date 2018-5-15
* @author zhz
*/
class ClassStoreServiceModel extends \Business\AbstractModel{
$classStoreField = 'store_id as storeId,store_name as storeName,store_label as storeLabel,store_intro as storeIntro,store_longitude,store_latitude,gc_id as gcId,gc_name as gcName';
public function init() {
}
public function getRecommondStores($where,$memberId){
$addressDao = \DAO\AddressModel::getInstance();
$validFlag = $addressDao->getValidAddress($where);
if(!$validFlag){
\Error\ErrorModel::throwException($addressDao->errorCode);
}
$condition['lat'] = $where['lat'];
$condition['lng'] = $where['lng'];
$condition['cityCode'] = $where['cityCode'];
$gcId = $where['gcId'];
\DAO\AddressModel::getInstance()->getValidAddress($condition);
if(!$gcId){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyGcId);
}
\Our\RedisHelper::cachedFunction(\Redis\Db6\ClassStoreRedisModel::getInstance(), array(&$classStoreModel, 'getList'), array(array('gc_id'=>$gcId),'store_id,fav_time'), \Our\ApiConst::oneHour,array($memberId));
}
public function getStoreListByGcId($gcId,$position){
$lat = $position['lat'];
$lng = $position['lng'];
$classStoreModel = \DAO\Store\ClassStoreModel::getInstance();
$storeList = \Our\RedisHelper::cachedFunction(\Redis\Db6\ClassStoreRedisModel::getInstance(), array(&$classStoreModel, 'getList'), array(array('gc_id'=>$gcId),$this->classStoreField), \Our\ApiConst::oneHour,array());
$newStoreList = array();
if($storeList){
}
}
/**
*/
private static $_instance = null;
/**
* 单例模式获取类实例
*
*/
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
...@@ -313,7 +313,7 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -313,7 +313,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$sellerDistribution = $storeInfo['seller_distribution']; $sellerDistribution = $storeInfo['seller_distribution'];
$buyerDistribution = $storeInfo['buyer_distribution']; $buyerDistribution = $storeInfo['buyer_distribution'];
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv,'memberId'=>$storeInfo['member_id'],'businessHours'=>$businessHours,'sellerDistribution'=>$sellerDistribution,'buyerDistribution'=>$buyerDistribution,'bannerColor'=>'#ffa92f','isClose'=>$storeInfo['isClose']); return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>1,'adv'=>$adv,'memberId'=>$storeInfo['member_id'],'businessHours'=>$businessHours,'sellerDistribution'=>$sellerDistribution,'buyerDistribution'=>$buyerDistribution,'bannerColor'=>'#ffa92f','isClose'=>$storeInfo['isClose']);
} }
/** /**
......
...@@ -38,118 +38,6 @@ class PlatformFirstClassModel extends \DAO\AbstractModel{ ...@@ -38,118 +38,6 @@ class PlatformFirstClassModel extends \DAO\AbstractModel{
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll(); $result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
return $result; return $result;
} }
public function getStoreOnlineGoodsClassesByGcIdFromCache($gcId,$storeId,$field = \Our\NameConst::allField){
$gcIds = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$this, 'getStoreOnlineGoodsClassesByGcId'),array($gcId,$storeId,$field),\Our\ApiConst::oneDaySecond,array($storeId));
return $gcIds;
}
public function getStoreOnlineGoodsClassesByGcId($gcId,$storeId,$field = \Our\NameConst::allField){
$where['gc_id_1'] = $gcId;
$where['store_id'] = $storeId;
$list = $this->getList($where);
if($list){
$platThirdGcIds = array();
$storeThirdGcIds = array();
$secondGcIds = array_unique(array_column($list,'gc_id_2'));
$treeGcIds =array();
foreach($list as $temp){
if($temp['gc_from']==\Our\ApiConst::zero){
$platThirdGcIds[] = $temp['gc_id_3'];
}else{
$storeThirdGcIds[] = $temp['gc_id_3'];
}
if(!(isset($treeGcIds[$temp['gc_id_2']][$temp['gc_from']])&&in_array($temp['gc_id_3'], $treeGcIds[$temp['gc_id_2']][$temp['gc_from']]))){
$treeGcIds[$temp['gc_id_2']][$temp['gc_from']][] = $temp['gc_id_3'];
}
}
$platThirdGcIds = array_unique($platThirdGcIds);
$storeThirdGcIds = array_unique($storeThirdGcIds);
return array('secondGcIds'=>$secondGcIds,'treeGcIds'=>$treeGcIds,'platThirdGcIds'=>$platThirdGcIds,'storeThirdGcIds'=>$storeThirdGcIds);
}
return false;
}
/**
* 检查获取店铺一级在售分类传参是否正确
*/
public function checkStoreTopClasses($data){
if(!isset($data['storeId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyStoreIdForOnlineTopClass);
}
}
/**
* 检查获取店铺下级在售分类及广告传参是否正确
*/
public function checkStoreChildrenClasses($data){
if(!isset($data['storeId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyStoreIdForOnlineChildrenClass);
}
if(!isset($data['gcId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emtpyGcIdForOnlineChildrenClass);
}
}
/**
* 商品详情发生改变存如缓存
* @param $goodsCommon goodsCommon详情
* @param int $type 操作类型(1:加,0:减)
* @return bool
*/
public function addGoodsToGoodsClassCache($goodsCommon,$type = \Our\ApiConst::plus){
if(!$goodsCommon){
return false;
}
$goodsClass['gc_id_1'] = $goodsCommon['gc_id_1'];
$goodsClass['gc_id_2'] = $goodsCommon['gc_id_2'];
$goodsClass['gc_id_3'] = $goodsCommon['gc_id_3'];
$goodsClass['store_id'] = $goodsCommon['store_id'];
$goodsClass['gc_from'] = \Our\ApiConst::zero;
if($goodsClass['gc_id_3']){
$this->addChangedGoodsClass(serialize($goodsClass),$type);
}
if($goodsCommon['goods_class_t_id']){
$goodsClass['gc_id_3'] = $goodsCommon['goods_class_t_id'];
$goodsClass['gc_from'] = \Our\ApiConst::one;
$this->addChangedGoodsClass(serialize($goodsClass),$type);
}
return true;
}
public function addChangedGoodsClass($goodsClass,$type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
$storeOnlineClassRedisModel->tableLPush($key,$goodsClass);
}
public function getChangedGoodsClass($type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
return $storeOnlineClassRedisModel->tableLPop($key);
}
/**
* 获取更改商品
* @param $start 记录开始条数
* @param $end 记录结束条数
* @return \Redis\mix
*/
public function getChangedGoodsClasses($start,$end,$type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
return $storeOnlineClassRedisModel->tableLRange($key,$start,$end);
}
/** /**
* 类实例 * 类实例
*/ */
......
<?php
/**
* User: liuyuzhen
* Date: 2019/1/9
* Time: 16:52
* Description:
*/
namespace DAO\Store;
class ClassStoreModel extends \DAO\AbstractModel{
protected function init()
{
}
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_class_store';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'id';
public function findByWhere($where){
$this->setDb(\Our\DbNameConst::salveDBConnectName);
$address = $this->db->from($this->_tableName)->where($where)->fetchOne();
return $address;
}
public function getList($where,$field = \Our\NameConst::allField,$orders = array('gc_parent_id'=>'asc','gc_sort'=>'asc','gc_id'=>'asc')){
$this->setDb($this->dbName);
$this->db->select($field)->from($this->_tableName);
if($orders){
foreach($orders as $key=>$val){
$this->db->order($key,$val);
}
}
$result = $this->db->where($where)->fetchAll();
return $result;
}
/**
* 类实例
*/
private static $_instance = null;
/**
* 获取类实例
*/
public static function getInstance($dbName= \Our\DbNameConst::salveDBConnectName) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($dbName);
}
return self::$_instance;
}
}
<?php
namespace Redis\Db6;
/**
* 分类店铺信息缓存
*/
class ClassStoreRedisModel extends \Redis\Db6\AbstractModel {
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_class_store';
/**
* 计算key
*
* @param int $id
* @return string
*/
public function calcKey($id) {
return $this->_tableName . self::DELIMITER . $id;
}
/**
* 根据id查找店铺信息
*
* @param int $id
* @return array
*/
public function find($id,$expire=\Our\ApiConst::zero) {
$result = $this->get($this->calcKey($id));
if($expire>\Our\ApiConst::zero){
$this->expire($this->calcKey($id),$expire);
}
if($this->is_serialized($result)){
return unserialize($result);
}
return $result;
}
/**
* 更新数据
*
* @param int $id
* @param array $data
*/
public function update($id, $data,$expire=0) {
return $this->set($this->calcKey($id), serialize($data),$expire);
}
public function tableHSet($h,$key,$val,$experio=0){
return $this->hset($this->calcKey($h),$key,$val,$experio);
}
public function tableHGet($h,$key){
return $this->hget($this->calcKey($h),$key);
}
public function tableHMSet($h,$keysvalue,$experio=0){
return $this->hmset($this->calcKey($h),$keysvalue,$experio);
}
public function tableHMGet($h,$keyvalues){
return $this->hmget($this->calcKey($h),$keyvalues);
}
public function tableHGAll($h){
return $this->hGetAll($this->calcKey($h));
}
public function tableDel($h){
return $this->del($this->calcKey($h));
}
public function tableCacheGet($id){
$result = $this->get($this->calcKey($id));
return $result;
}
public function tableCacheSet($id,$data,$experio){
$res=$this->set($this->calcKey($id), $data,$experio);
return $res;
}
/**
* 类实例
*
* @var \Redis\Db0\UserModel
*/
private static $_instance = null;
/**
* 获取类实例
*
* @return \Redis\Db0\UserModel
*/
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment