Commit db4aa47c authored by liuyuzhen's avatar liuyuzhen

定时器

parent 72dbd34d
...@@ -1175,18 +1175,23 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1175,18 +1175,23 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$topSaleList = array(); $topSaleList = array();
for($i=0;$i<2000;$i++){ for($i=0;$i<2000;$i++){
$storeId = $storeTopSaleGoodsModel->getChangedSaleStoreId(); $storeId = $storeTopSaleGoodsModel->getChangedSaleStoreId();
if($storeId!==false){ if($storeId===false){
break; break;
} }
if($storeIds&&!($storeIds&&in_array($storeId,$storeIds))){ if($storeId){
$topSaleList=$storeTopSaleGoodsModel->getStoreTopSaleGoodsListByStoreId($storeId); if(($storeIds&&in_array($storeId,$storeIds))){
$storeTopSaleList = $this->getNewStoreTopSaleGoodsList($topSaleList,$storeId); continue;
}
$topSaleListTemp=$storeTopSaleGoodsModel->getStoreTopSaleGoodsListByStoreId($storeId);
$storeTopSaleList = $this->getNewStoreTopSaleGoodsList($topSaleListTemp,$storeId);
$topSaleList = $topSaleList?array_merge($topSaleList,$storeTopSaleList):$storeTopSaleList; $topSaleList = $topSaleList?array_merge($topSaleList,$storeTopSaleList):$storeTopSaleList;
} }
} }
\Our\Log::getInstance()->write(json_encode($topSaleList)); if($topSaleList){
$result = $storeTopSaleGoodsModel->insertAllOrUpdate($topSaleList); $result = $storeTopSaleGoodsModel->insertAllOrUpdate($topSaleList);
\Our\Log::getInstance()->write('店铺销量更新'.($result?'success':'fail')); \Our\Log::getInstance()->write('店铺销量更新'.($result?'success':'fail'));
}
\Our\Log::getInstance()->write('本次没有店铺数据需要更新');
} }
/** /**
......
...@@ -94,7 +94,7 @@ FROM han_goods_common t1 where t1.goods_state={1} and t1.goods_verify={2} and t1 ...@@ -94,7 +94,7 @@ FROM han_goods_common t1 where t1.goods_state={1} and t1.goods_verify={2} and t1
left join han_goods_score_statistics b left join han_goods_score_statistics b
on a.goods_commonid = b.goods_commonid on a.goods_commonid = b.goods_commonid
WHERE a.group_id<=3 AND a.sale_num>0 ',\Our\ApiConst::defaultGoodsScore,\Our\ApiConst::onlineGoodsState,\Our\ApiConst::onlineGoodsVerify,$storeId); WHERE a.group_id<=3 AND a.sale_num>0 ',\Our\ApiConst::defaultGoodsScore,\Our\ApiConst::onlineGoodsState,\Our\ApiConst::onlineGoodsVerify,$storeId);
$list = $this->db->query($sql)->fetchAll(); $list = $this->db->query($sql)->rows;
return $list; return $list;
} }
...@@ -113,7 +113,7 @@ on t1.goods_commonid = t2.goods_commonid ...@@ -113,7 +113,7 @@ on t1.goods_commonid = t2.goods_commonid
where t1. where t1.
) a ) a
WHERE a.group_id<=3 AND a.sale_num>0 and a.goods_state=1 and a.goods_verify=1 ORDER BY a.store_id ,a.group_id'; WHERE a.group_id<=3 AND a.sale_num>0 and a.goods_state=1 and a.goods_verify=1 ORDER BY a.store_id ,a.group_id';
$list = $this->db->query($sql)->fetchAll(); $list = $this->db->query($sql)->rows;
return $list; return $list;
} }
...@@ -123,7 +123,7 @@ WHERE a.group_id<=3 AND a.sale_num>0 and a.goods_state=1 and a.goods_verify=1 OR ...@@ -123,7 +123,7 @@ WHERE a.group_id<=3 AND a.sale_num>0 and a.goods_state=1 and a.goods_verify=1 OR
$baseSql = "insert into {$this->_tableName}(store_id,goods_commonid,goods_score,rank,goods_name,goods_image) values"; $baseSql = "insert into {$this->_tableName}(store_id,goods_commonid,goods_score,rank,goods_name,goods_image) values";
$insertAllSql = $baseSql; $insertAllSql = $baseSql;
for ($i = 0; $i < count($datas); $i++) { for ($i = 0; $i < count($datas); $i++) {
$addSql = \Our\Common::format("({0},{1},{2},{3},{4},{5}),", $datas[$i]['store_id'],$datas[$i]['goods_commonid'], $datas[$i]['goods_score'], $datas[$i]['rank'],$datas[$i]['goods_name'],$datas[$i]['goods_image']); $addSql = \Our\Common::format("('{0}','{1}','{2}','{3}','{4}','{5}'),", $datas[$i]['store_id'],$datas[$i]['goods_commonid'], $datas[$i]['goods_score'], $datas[$i]['rank'],$datas[$i]['goods_name'],$datas[$i]['goods_image']);
$insertAllSql .= $addSql; $insertAllSql .= $addSql;
if ($i % 1000 == 0 && $i != 0) { if ($i % 1000 == 0 && $i != 0) {
$insertAllSql = rtrim($insertAllSql, ','); $insertAllSql = rtrim($insertAllSql, ',');
......
...@@ -133,7 +133,7 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{ ...@@ -133,7 +133,7 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{
$this->addChangedGoodsClass(serialize($goodsClass),$type); $this->addChangedGoodsClass(serialize($goodsClass),$type);
if($goodsCommon['goods_class_t_id']){ if($goodsCommon['goods_class_t_id']){
$goodsClass['gc_id_3'] = $goodsCommon['goods_class_t_id']; $goodsClass['gc_id_3'] = $goodsCommon['goods_class_t_id'];
$goodsClass['gc_from'] = \Our\ApiConst::zero; $goodsClass['gc_from'] = \Our\ApiConst::one;
$this->addChangedGoodsClass(serialize($goodsClass),$type); $this->addChangedGoodsClass(serialize($goodsClass),$type);
} }
return true; return true;
......
...@@ -96,12 +96,8 @@ class AbstractModel extends \Redis\AbstractModel { ...@@ -96,12 +96,8 @@ class AbstractModel extends \Redis\AbstractModel {
return $this->lpush($this->calcKey($h),$value); return $this->lpush($this->calcKey($h),$value);
} }
public function tableLPop($h){ public function tableLPop($h){
if($res=$this->lpop($this->calcKey($h))){ $res=$this->lpop($this->calcKey($h));
return $res; return $res;
}else{
return false;
}
} }
public function tableSRandMember($h,$count = null){ public function tableSRandMember($h,$count = null){
return $this->sRandMember($this->calcKey($h),$count); return $this->sRandMember($this->calcKey($h),$count);
......
<?php <?php
$redis =new Redis();
$redis->connect('192.168.134.18','6379');
$redis->rPush('test',0);
$res=$redis->lPop('test');
var_dump($res);
$res1=$redis->lPop('test');
var_dump($res1);
exit;
function is_https() { function is_https() {
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true; return true;
......
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