Commit 5b917573 authored by zhz's avatar zhz

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev

parents d99769bb 72dbd34d
......@@ -1120,14 +1120,27 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
*/
public function storeOnlineGoodsClass(){
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
$plusFlag = false;
$minusFlag = false;
for($i=0;$i<2000;$i++){
$goodsClassStr = $storeOnlineGoodsClassDao->getChangedGoodsClass(\Our\ApiConst::plus);
$goodsClass = unserialize($goodsClassStr);
$this->checkExistOnlineGoodsClass($goodsClass);
if($goodsClassStr&&$plusFlag==false){
$goodsClass = unserialize($goodsClassStr);
$this->checkExistOnlineGoodsClass($goodsClass);
}else{
$plusFlag=true;
}
$goodsClassStrMinus = $storeOnlineGoodsClassDao->getChangedGoodsClass(\Our\ApiConst::minus);
$goodsClassMinus = unserialize($goodsClassStrMinus);
$this->checkRemoveOnlineGoodsClass($goodsClassMinus);
if($goodsClassStrMinus&&$minusFlag==false){
$goodsClassMinus = unserialize($goodsClassStrMinus);
$this->checkRemoveOnlineGoodsClass($goodsClassMinus);
}else{
$minusFlag = true;
}
if($plusFlag&&$minusFlag){
break;
}
}
}
......@@ -1138,7 +1151,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
*/
public function checkExistOnlineGoodsClass($goodsClass){
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
$oldTemp = $storeOnlineGoodsClassDao->find($goodsClass);
$oldTemp = $storeOnlineGoodsClassDao->findByWhere($goodsClass);
if(!$oldTemp){
$storeOnlineGoodsClassDao->insert($goodsClass);
}
......@@ -1172,10 +1185,10 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$topSaleList = array();
for($i=0;$i<2000;$i++){
$storeId = $storeTopSaleGoodsModel->getChangedSaleStoreId();
if(!$storeId){
if($storeId!==false){
break;
}
if(!($storeIds&&in_array($storeId,$storeIds))){
if($storeIds&&!($storeIds&&in_array($storeId,$storeIds))){
$topSaleList=$storeTopSaleGoodsModel->getStoreTopSaleGoodsListByStoreId($storeId);
$storeTopSaleList = $this->getNewStoreTopSaleGoodsList($topSaleList,$storeId);
$topSaleList = $topSaleList?array_merge($topSaleList,$storeTopSaleList):$storeTopSaleList;
......
......@@ -53,6 +53,8 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// $storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
$orderDao=\DAO\Order\OrderModel::getInstance();
$favoritesStoreDao=\DAO\FavoritesStoreModel::getInstance();
$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance();
$goodsCount=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
$condition['store_id'] = $storeId;
//获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
......@@ -64,7 +66,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$data['storeId'] = $store['store_id'];
$data['storeName'] = $store['store_name'];
$data['storeLabel'] = $store['store_label'];
$data['goodsCount'] = ApiConst::zero;
$data['goodsCount'] = $goodsCount;
$data['orderCount'] =$storeStats['orderCount'];
$data['orderTotal'] = $storeStats['orderTotal'];
$data['favCount'] = $storeFavariteCount['favCount'];
......
......@@ -454,6 +454,9 @@ class AddressServiceModel extends \Business\AbstractModel {
if(!($address['address']&&$address['name'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyAddressAndName);
}
if(!($address['tag_type']>=\Our\ApiConst::zero&&$address['tag_type']<=3)){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::wrongAddressTagType);
}
if($province){
$province = mb_substr($province,0,2);
$provinceList = $areaList[\Our\ApiConst::zero];
......
......@@ -84,6 +84,7 @@ class StoreTopSaleGoodsModel extends \DAO\AbstractModel{
* @return mixed
*/
public function getStoreTopSaleGoodsListByStoreId($storeId){
$this->setDb();
$sql = \Our\Common::format('SELECT a.store_id,a.sale_num,a.goods_commonid,IFNULL((evaluation_score/evaluation_number),{0}) as goods_score,a.group_id as rank,a.goods_name,a.goods_image
FROM
(
......@@ -101,6 +102,7 @@ WHERE a.group_id<=3 AND a.sale_num>0 ',\Our\ApiConst::defaultGoodsScore,\Our\Api
* @return mixed
*/
public function getSourceGoodsList(){
$this->setDb();
$sql = 'SELECT a.store_id,a.goods_commonid,IFNULL(a.evaluation_score/a.evaluation_number,'.\Our\ApiConst::defaultGoodsScore.') as goods_score,a.group_id as rank,a.goods_name,a.goods_image
FROM
(
......
......@@ -36,6 +36,7 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{
public function insert($data){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$data['gmt_create'] = TIMESTAMP;
$data['gmt_update'] = TIMESTAMP;
$result = $this->db->insert($this->_tableName)->rows($data)->execute();
if($result){
$storeId = $data['store_id'];
......@@ -47,9 +48,11 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{
public function del($where){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$temp = $this->findByWhere($where);
$result = $this->db->delete($this->_tableName)->where($where)->execute();
if($result){
$storeId = $where['store_id'];
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$this, 'getList'),array(),array($storeId));
}
return $result;
}
......
......@@ -800,7 +800,10 @@ class OrderModel extends \DAO\AbstractModel
if ($deleteGetFavoritesCountByStoreId) {
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$favoritesStoreDao->deleteGetFavoritesCountByStoreId($stroeId);
}
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao->deleteOrderGoodsCache($memberId, $orderId,$stroeId);
}
if(!empty($diliverymanId)){
......
......@@ -28,6 +28,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
*/
protected $_primaryKey = 'rec_id';
public $orderGoodsGoodsNumCountField=" sum(goods_num) as goodsNum";
public function init(){
......@@ -57,10 +58,16 @@ class OrderGoodsModel extends \DAO\AbstractModel {
}
public function getOrderGoods($where,$field,$db=DbNameConst::salveDBConnectName){
$this->setDb($db);
$this->setDb($this->dbName);
$list = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
return $list;
}
public function getOrderGoodsCountByStoreId($storeId){
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$goodsCount = $this->db->select($this->orderGoodsGoodsNumCountField)->from($this->_tableName)->where($where)->fetchNum();
return $goodsCount;
}
/**
* 获取单条数据
* @param $where
......@@ -100,13 +107,16 @@ class OrderGoodsModel extends \DAO\AbstractModel {
return $this->getOrderGoods($where,$field);
}
public function deleteOrderGoodsCache($memberId,$orderIds){
public function deleteOrderGoodsCache($memberId,$orderIds,$storeId=false){
if($memberId){
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getOrderGoodsByOrderIds'), array($memberId));
}
if($orderIds){
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getOrderGoodsByOrderIds'), array($orderIds));
}
if(!empty($storeId)){
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getOrderGoodsCountByStoreId'), array($storeId));
}
}
public function getIsRefundMoney($orderGoodses,$promotionsId){
$isRefundMoney=ApiConst::zero;
......
......@@ -354,6 +354,7 @@ const notAllowDelete=300114;
const emptyCityId = 140019;
const emptyDistrictId = 140020;
const emptyAddressAndName = 140021;
const wrongAddressTagType = 140022;
//消息,推送等
const removeMessage=150001;
......@@ -580,6 +581,7 @@ const notAllowDelete=300114;
self::emptyCityId => '找不到对应城市',
self::emptyDistrictId => '找不到对应区',
self::emptyAddressAndName => '地址和具体街道不能为空',
self::wrongAddressTagType => '地址标签传输错误',
self::emptyLatLng => '经纬度不能为空',
self::emptyCityCode => '高德地图城市编码不能为空',
......
......@@ -96,7 +96,12 @@ class AbstractModel extends \Redis\AbstractModel {
return $this->lpush($this->calcKey($h),$value);
}
public function tableLPop($h){
return $this->lpop($this->calcKey($h));
if($res=$this->lpop($this->calcKey($h))){
return $res;
}else{
return false;
}
}
public function tableSRandMember($h,$count = null){
return $this->sRandMember($this->calcKey($h),$count);
......
......@@ -56,6 +56,7 @@ class cliStoreOnlineGoodsClass extends basecli
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir=$this->_getBaseFileName('storeOnlineGoodsClass');
echo $lockDir;
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
......@@ -82,7 +83,7 @@ class cliStoreOnlineGoodsClass extends basecli
}
}
$oCli = new cliShopkeeperIndex(TRUE);
$oCli = new cliStoreOnlineGoodsClass(TRUE);
EXIT;
?>
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