Commit e57c64d8 authored by liuyuzhen's avatar liuyuzhen

首页和推荐分类相关

parent 364482e5
......@@ -73,7 +73,9 @@ class StoreController extends \Our\Controller_AbstractIndex {
$currentAddress['gcId'] = $data['gcId'];
}
$memberId = $this->sess->get('member_id');
$storeService = \Business\Store\StoreServiceModel::getInstance();
/*$storeService = \Business\Store\StoreServiceModel::getInstance();
$return = $storeService->getRecommendStores($currentAddress, $memberId);*/
$storeService = \Business\Store\ClassStoreServiceModel::getInstance();
$return = $storeService->getRecommendStores($currentAddress, $memberId);
if ($return) {
$this->success($return);
......@@ -125,7 +127,7 @@ class StoreController extends \Our\Controller_AbstractIndex {
$data = $this->req[\Our\NameConst::data];
$couponService = \Business\Coupon\CouponServiceModel::getInstance();
$couponTitles = $couponService->getStorePromotionCouponTitles($data);
$this->success($couponTitles);
$this->success($couponTitles);
}
......
......@@ -20,6 +20,9 @@ class ImageConst{
//分类图标前缀
const categoryPicPrefix = 'category-pic-';
const categoryHeadPicPrefix = 'category-headpic-';
const topClassAdvImagePrefis = 'category-hdpic-'; //一级分类对应广告图前缀
//商家举报图片存放路径
......
......@@ -55,6 +55,7 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
return array('totalCount'=>\Our\ApiConst::zero);
}
}
/**
* 获取平台全部一级分类
* @param $where
......@@ -65,8 +66,7 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
//验证参数
$addressDao = \DAO\AddressModel::getInstance();
/*$addressDao = \DAO\AddressModel::getInstance();
$validFlag = $addressDao->getValidAddress($where);
if(!$validFlag){
\Error\ErrorModel::throwException($addressDao->errorCode);
......@@ -87,7 +87,7 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
$serviceParentClassIds = $this->getServiceStoreClasses($serviceStoreIds);
if($serviceParentClassIds){
$classIds = array_merge($serviceParentClassIds,$classIds);
}
}*/
/*
//获取可快递店铺对应分类
......@@ -96,12 +96,12 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
$classIds = array_merge($expressClassIds,$classIds);
}
*/
/*$classIds = array();
$classIds = array();
$platformFirstClassDao = \DAO\GoodsClass\PlatformFirstClassModel::getInstance();
$firstClassList = \Our\RedisHelper::cachedFunction(\Redis\Db3\PlatformFirstClassRedisModel::getInstance(),array(&$platformFirstClassDao, 'getList'),array(),\Our\ApiConst::oneHour,array());
if($firstClassList){
$classIds = array_column($firstClassList,'gc_id');
}*/
$classIds = array_column($firstClassList,'gc_parent_id');
}
$classIdKeys = array_flip($classIds);
$goodsClassDao = \DAO\GoodsClassModel::getInstance();
$parentClasses = $goodsClassDao->getParentClasses();
......@@ -196,7 +196,6 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
$cityCode = $where['cityCode'];
$storeDao = \DAO\StoreModel::getInstance();
$signStoreClasses = $this->getSignClassesByCityCode($cityCode);
//var_dump($signStoreClasses);
if($signStoreClasses){
$storeIds = array_unique(array_column($signStoreClasses,'store_id'));
$tempStoreList = $storeDao->getNearbyStores($cityCode,$storeIds);
......
<?php
namespace Business\Store;
/**
* 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';
private $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){
public function getRecommendStores($where,$memberId){
$addressDao = \DAO\AddressModel::getInstance();
$validFlag = $addressDao->getValidAddress($where);
......@@ -39,25 +30,97 @@ class ClassStoreServiceModel extends \Business\AbstractModel{
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));*/
/*\Our\RedisHelper::cachedFunction(\Redis\Db6\ClassStoreRedisModel::getInstance(), array(&$classStoreModel, 'getList'), array(array('gc_id'=>$gcId),'store_id,fav_time'), \Our\ApiConst::oneHour,array($memberId));*/
$storeList = $this->getStoreListByGcId($gcId,$condition,$memberId);
return $storeList;
}
public function getStoreListByGcId($gcId,$position){
public function getStoreListByGcId($parentGcId,$position,$memberId){
$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();
$storeList = \Our\RedisHelper::cachedFunction(\Redis\Db6\ClassStoreRedisModel::getInstance(), array(&$classStoreModel, 'getList'), array(array('gc_parent_id'=>$parentGcId),$this->classStoreField), \Our\ApiConst::oneHour,array());
$newGcStoreList = array();
if($storeList){
$newStoreList = array();
foreach($storeList as $store){
$gcId = $store['gcId'];
$store_lat = $store['store_latitude'];
$store_lnt = $store['store_longitude'];
unset($store['store_latitude']);
unset($store['store_longitude']);
$store['storeLabel'] =\Our\ImageUtil::getStoreLabel($store['storeLabel'], \Our\ImageConst::storeLabel,213);
$store['storeDistance'] = \Our\CommonExtension::getDistance($lat,$lng,$store_lat,$store_lnt);
$newStoreList[$store['storeId']] = $store;
if(isset($newGcStoreList[$gcId]['inAreaFlag'])){
continue;
}
$inAreaFlag = false;
if(isset($store['sign_scope'])&&$store['sign_scope']){
$inAreaFlag = \Our\CommonExtension::locationInArea($lat,$lng,$store['sign_scope']);
}
if(!isset($newGcStoreList[$gcId])){
$newGcStoreList[$gcId]['gcName'] = htmlspecialchars_decode($store['gcName']);
$newGcStoreList[$gcId]['gcImg'] = \Our\Common::getStaticFile(\Our\ImageConst::categoryHeadPicPrefix.$store['gcId'].\Our\NameConst::jpgSuffix,\Our\ImageConst::defaultPath);
}
unset($store['gcName']);
unset($store['gcId']);
if($inAreaFlag){
$newGcStoreList[$gcId]['inAreaFlag'] = $inAreaFlag;
$newGcStoreList[$gcId]['stores']= $store;
}else{
if(isset($newGcStoreList[$gcId]['storeDistance'])){
if($store['storeDistance']<$newGcStoreList[$gcId]['storeDistance']){
$newGcStoreList[$gcId]['storeDistance'] = $store['storeDistance'];
$newGcStoreList[$gcId]['stores']= $store;
}
}else{
$newGcStoreList[$gcId]['storeDistance'] = $store['storeDistance'];
$newGcStoreList[$gcId]['stores']= $store;
}
}
}
$memberStores = \Business\Store\StoreServiceModel::getInstance()->getPurchasedStoreClass($memberId,$parentGcId);
if($memberStores){
foreach($memberStores as $key => $storeId){
$returnData[$key] = array();
$purchasedStore = $newStoreList[$storeId];
$returnData[$key]['gcName'] = htmlspecialchars_decode($purchasedStore['gcName']);
$returnData[$key]['gcImg'] = \Our\Common::getStaticFile(\Our\ImageConst::categoryHeadPicPrefix.$purchasedStore['gcId'].\Our\NameConst::jpgSuffix,\Our\ImageConst::defaultPath);
unset($purchasedStore['gcName']);
unset($purchasedStore['gcId']);
$purchasedStore['isPurchased'] = \Our\ApiConst::one;
$returnData[$key]['stores'][$storeId] = $purchasedStore;
}
}
foreach($newGcStoreList as $gcIdKey=>$storeInfo){
$tempStore = $storeInfo['stores'];
if(isset($returnData[$gcIdKey])){
if(isset($returnData[$gcIdKey]['stores'][$tempStore['storeId']])){
continue;
}
$tempStore['isPurchased'] = \Our\ApiConst::zero;
$returnData[$gcIdKey]['stores'][$tempStore['storeId']] = $tempStore;
}else{
unset($storeInfo['storeDistance']);
$storeInfo['stores'] = array();
$tempStore['isPurchased'] = \Our\ApiConst::zero;
$storeInfo['stores'][$tempStore['storeId']] = $tempStore;
$returnData[$gcIdKey] = $storeInfo;
}
}
$return = array_values($returnData);
foreach($return as &$temp){
$temp['stores'] = array_values($temp['stores']);
}
return $return;
}
}
return $newGcStoreList;
}
/**
* git
*/
private static $_instance = null;
......
......@@ -714,7 +714,10 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeRedis = \Redis\Db6\StoreRedisModel::getInstance();
$signStoreKey = \Our\NameConst::signStoreIdsPrefix . $readisSuffix;
$signStoreIds =$storeRedis->find($signStoreKey, \Our\ApiConst::oneHour);
if(!$signStoreIds){
$signStoreInfo = \Business\Goods\GoodsClassServiceModel::getInstance()->getSignStoreInfo($position);
$signStoreIds = $signStoreInfo['signStoreIds'];//当前位置签约店铺ID
}
//$serviceStoreKey = \Our\NameConst::serviceStoreIdsPrefix . $readisSuffix;
//$serviceStoreIds = $storeRedis->find($serviceStoreKey, \Our\ApiConst::oneHour);
/*if(is_array($signStoreIds)&&is_array($serviceStoreIds)){
......@@ -804,15 +807,8 @@ class StoreServiceModel extends \Business\AbstractModel{
foreach($allStores as &$store){
$store['isPurchased'] = \Our\ApiConst::zero;
}
$memberStores = null;
if($memberId){
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$memberStoreList = \Our\RedisHelper::cachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(), array(&$favoritesStoreDao, 'selectList'), array(array('member_id'=>$memberId,'fav_from'=>\Our\ApiConst::scanFavor),'store_id,fav_time'), \Our\ApiConst::oneHour,array($memberId));
//$storeMemberDao->getList(array('member_id'=>$memberId,'type'=>\Our\ApiConst::storeQrcodeMember),'distinct(store_id) as store_id')
if($memberStoreList){
$memberStores = $this->getPurchasedStoreClass($memberStoreList,$gcId);
}
}
$memberStores = $this->getPurchasedStoreClass($memberId,$gcId);
$goodsClassDao = \DAO\GoodsClassModel::getInstance();
//获取当前分类对应所有店铺信息
......@@ -830,6 +826,8 @@ class StoreServiceModel extends \Business\AbstractModel{
foreach($goodsClassList as $goodsClass){
$returnStores = array();
$returnStores['gcName'] = htmlspecialchars_decode($goodsClass['gcName']);
//$returnStores['gcImg'] = \Our\Common::getStaticFile(\Our\ImageConst::categoryHeadPicPrefix.$goodsClass['gcId'].\Our\NameConst::jpgSuffix,\Our\ImageConst::defaultPath);
$returnStores['gcImg'] = \Our\Common::getStaticFile('category-headpic-default.jpg',\Our\ImageConst::defaultPath);
$existStoreIds = null;
$returnStores['stores'] = null;
$exitStore = array();
......@@ -886,12 +884,18 @@ class StoreServiceModel extends \Business\AbstractModel{
}
public function getPurchasedStoreClass($memberStoreList,$gcId){
public function getPurchasedStoreClass($memberId,$gcId){
if(!$memberId){
return array();
}
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$memberStoreList = \Our\RedisHelper::cachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(), array(&$favoritesStoreDao, 'selectList'), array(array('member_id'=>$memberId,'fav_from'=>\Our\ApiConst::scanFavor),'store_id,fav_time'), \Our\ApiConst::oneHour,array($memberId));
$memberStoreIds = array_column($memberStoreList,'store_id');
$signStoreClassSql = ' store_id in ('.implode(',',$memberStoreIds).') and is_charged=1 and gc_parent_id ='.$gcId;
$qmStoreClassDao = \DAO\QmStoreClassModel::getInstance();
$signClassStores = $qmStoreClassDao->selectByWhere($signStoreClassSql,'store_id,gc_id');
$signClassStores = \Our\RedisHelper::cachedFunction(\Redis\Db6\QmStoreClassRedisModel::getInstance(), array(&$qmStoreClassDao, 'selectByWhere'), array($signStoreClassSql,'store_id,gc_id'), \Our\ApiConst::oneHour,array('gcId_'.$gcId.'member_'.$memberId));
//$signClassStores = $qmStoreClassDao->selectByWhere($signStoreClassSql,'store_id,gc_id');
if($signClassStores){
$return = array();
foreach($memberStoreList as $tempStore){
......@@ -1195,7 +1199,7 @@ class StoreServiceModel extends \Business\AbstractModel{
public function growStores(){
$cityCodes=array('010','021','022','023','852','853','0310','0311','0312','0313','0314','0315','0316','0317','0318','0319','0335','0570','0571','0572','0573','0574','0575','0576','0577','0578','0579','0580','024','0410','0411','0412','0413','0414','0415','0416','0417','0418','0419','0421','0427','0429','027','0710','0711','0712','0713','0714','0715','0716','0717','0718','0719','0722','0724','0728','025','0510','0511','0512','0513','0514','0515','0516','0517','0517','0518','0519','0523','0470','0471','0472','0473','0474','0475','0476','0477','0478','0479','0482','0483','0790','0791','0792','0793','0794','0795','0796','0797','0798','0799','0701','0350','0351','0352','0353','0354','0355','0356','0357','0358','0359','0930','0931','0932','0933','0934','0935','0936','0937','0938','0941','0943','0530','0531','0532','0533','0534','0535','0536','0537','0538','0539','0450','0451','0452','0453','0454','0455','0456','0457','0458','0459','0591','0592','0593','0594','0595','0595','0596','0597','0598','0599','020','0751','0752','0753','0754','0755','0756','0757','0758','0759','0760','0762','0763','0765','0766','0768','0769','0660','0661','0662','0663','028','0810','0811','0812','0813','0814','0816','0817','0818','0819','0825','0826','0827','0830','0831','0832','0833','0834','0835','0836','0837','0838','0839','0840','0730','0731','0732','0733','0734','0735','0736','0737','0738','0739','0743','0744','0745','0746','0370','0371','0372','0373','0374','0375','0376','0377','0378','0379','0391','0392','0393','0394','0395','0396','0398','0870','0871','0872','0873','0874','0875','0876','0877','0878','0879','0691','0692','0881','0883','0886','0887','0888','0550','0551','0552','0553','0554','0555','0556','0557','0558','0559','0561','0562','0563','0564','0565','0566','0951','0952','0953','0954','0431','0432','0433','0434','0435','0436','0437','0438','0439','0440','0770','0771','0772','0773','0774','0775','0776','0777','0778','0779','0851','0852','0853','0854','0855','0856','0857','0858','0859','029','0910','0911','0912','0913','0914','0915','0916','0917','0919','0971','0972','0973','0974','0975','0976','0977','0890','0898','0899','0891','0892','0893');
$storeDao=\DAO\StoreModel::getInstance();
// $memberDao = \DAO\MemberModel::getInstance();
// $memberDao = \DAO\MemberModel::getInstance();
$res =$storeDao->getAll();
$drawTableDao=\DAO\Draw\DrawTableModel::getInstance();
$drawTableDatas=$drawTableDao->getAll();
......@@ -1253,16 +1257,16 @@ class StoreServiceModel extends \Business\AbstractModel{
public function tryExpireInform() {
$storeList = \DAO\StoreModel::getInstance()->getTryExpireStore();
if($storeList) {
foreach ($storeList as $store) {
if( TIMESTAMP+9*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+10*24*3600) {
$limitday = 10;
}elseif (TIMESTAMP+4*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+5*24*3600) {
$limitday = 5;
}else{
$limitday = 3;
}
\DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($store['store_phone'],'tryExpire',array('storename'=>$store['store_name'],'limitday'=>$limitday));
}
foreach ($storeList as $store) {
if( TIMESTAMP+9*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+10*24*3600) {
$limitday = 10;
}elseif (TIMESTAMP+4*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+5*24*3600) {
$limitday = 5;
}else{
$limitday = 3;
}
\DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($store['store_phone'],'tryExpire',array('storename'=>$store['store_name'],'limitday'=>$limitday));
}
}
}
/**
......
......@@ -206,6 +206,7 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
}
\Our\RedisHelper::delCachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(),array(&$this, 'getFavoritesStores'),array(),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(), array(&$this, 'selectList'), array(),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\QmStoreClassRedisModel::getInstance(), array(\DAO\QmStoreClassModel::getInstance(), 'selectByWhere'), array(), array('*member_'.$memberId.'*'));
//更新个人中心首页数量
\DAO\MemberModel::getInstance()->_changeNum(\Our\NameConst::storeCollection,$memberId,$type == 1 ? -(count($storeIds)) : count($storeIds));
......
......@@ -390,21 +390,21 @@ elastic.master.scheme="http";
[lyztest : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
resources.database.params.hostname = "127.0.0.1"
resources.database.params.hostname = "106.14.14.233"
resources.database.params.port = 3306
resources.database.params.database = "qmcs"
resources.database.params.username = "root"
resources.database.params.password = "123456"
resources.database.params.password = "!@#$%12345werty"
resources.database.params.charset = "UTF8"
resources.database.params.driver_options.1002 = "SET NAMES utf8"
; 从库配置
resources.database.slave.params.driver = "pdo_mysql"
resources.database.slave.params.hostname = "127.0.0.1"
resources.database.slave.params.hostname = "106.14.14.233"
resources.database.slave.params.port = 3306
resources.database.slave.params.database = "qmcs"
resources.database.slave.params.username = "root"
resources.database.slave.params.password = "123456"
resources.database.slave.params.password = "!@#$%12345werty"
resources.database.slave.params.charset = "UTF8"
resources.database.slave.params.driver_options.1002 = "SET NAMES utf8"
......
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