Commit 91edb697 authored by zhz's avatar zhz

salemonth

parent 0e7e5445
...@@ -929,8 +929,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -929,8 +929,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$orderDAO = \DAO\Order\OrderModel::getInstance(); $orderDAO = \DAO\Order\OrderModel::getInstance();
$goodsCommonDAO = \DAO\GoodsCommonModel::getInstance(); $goodsCommonDAO = \DAO\GoodsCommonModel::getInstance();
$goodsCommonRedis = \Redis\Db4\GoodsCommonRedisModel::getInstance(); $goodsCommonRedis = \Redis\Db4\GoodsCommonRedisModel::getInstance();
$pageSize = 1000; $pageIndex = \Our\PageConst::taskPageBegin;
$pageIndex = 0; $pageSize = \Our\PageConst::taskPageSize;
$storeIds = $storeDAO->getOnlineStores(null, 'store_id'); $storeIds = $storeDAO->getOnlineStores(null, 'store_id');
while (true) { while (true) {
$limit = array($pageIndex * $pageSize, $pageSize); $limit = array($pageIndex * $pageSize, $pageSize);
......
...@@ -69,10 +69,14 @@ class OrderModel extends \DAO\AbstractModel ...@@ -69,10 +69,14 @@ class OrderModel extends \DAO\AbstractModel
return $this->db->from($this->_tableName)->where($where)->fetchNum(); return $this->db->from($this->_tableName)->where($where)->fetchNum();
} }
public function getCounts($where, $field, $group = false) public function getCounts($where, $field, $group = false, $limit = [])
{ {
$this->setDb(); $this->setDb();
return $this->db->select($field)->from($this->_tableName)->where($where)->group($group)->fetchAll(); $this->db->select($field)->from($this->_tableName)->where($where)->group($group);
if($limit) {
$this->db->limit($limit[0],$limit[1]);
}
return $this->db->fetchAll();
} }
public function getOrderCounts($where, $field) public function getOrderCounts($where, $field)
......
...@@ -6,11 +6,18 @@ ...@@ -6,11 +6,18 @@
*/ */
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级 define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/common.php'; require APPLICATION_PATH . '/scripts/crontab/common.php';
$data = \DAO\Order\OrderModel::getInstance()->getCounts('payment_time >= '.(time()-30*24*60*60),'count(order_id) as num,store_id','store_id'); $pageIndex = \Our\PageConst::taskPageBegin;
$pageSize = \Our\PageConst::taskPageSize;
do{
$limit = array($pageIndex * $pageSize, $pageSize);
$data = \DAO\Order\OrderModel::getInstance()->getCounts('payment_time >= '.(time()-30*24*60*60),'count(order_id) as num,store_id','store_id',$limit);
//$data = \DAO\Order\OrderModel::getInstance()->getCounts('payment_time >= 1518303150','store_id,count(order_id) as num','store_id'); //$data = \DAO\Order\OrderModel::getInstance()->getCounts('payment_time >= 1518303150','store_id,count(order_id) as num','store_id');
if($data){ if($data){
foreach ($data as &$v){ foreach ($data as &$v){
$v['updatetime'] = time(); $v['updatetime'] = time();
}
\DAO\StoreMonthSalesModel::getInstance()->insertAllOrUpdate($data);
} }
\DAO\StoreMonthSalesModel::getInstance()->insertAllOrUpdate($data); $pageIndex++;
} }while(!empty($data));
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