Commit 45f7364f authored by wwccw0591's avatar wwccw0591

statics

parent 9b9bc4b6
......@@ -53,23 +53,28 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// $storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
$orderDao = \DAO\Order\OrderModel::getInstance();
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$memberFavoritesStoreStoreMemberStatisticsDao=\DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance();
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance();
$goodsCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
//$goodsCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
$totalOrderCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$memberFavoritesStoreStoreMemberStatisticsDao, 'getGoodsCountOrderTotalByStoreId'), array($storeId), ApiConst::oneDaySecond, array($storeId));
$condition['store_id'] = $storeId;
//获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::oneDaySecond, array($storeId));
//获取店铺数据统计
//$storeStats = $storeStatisticsDao->find($condition);
//获取店铺今日销售额和订单量
// $storeStats=$orderDao->getShopKeeperCountByStoreId($storeId);
$storeStats = $orderDao->getShopKeeperCountByStoreIdCache($storeId);
$storeFavariteCount = $favoritesStoreDao->getFavoritesCountByStoreIdCache($storeId);
$goodsCount=$totalOrderCount['orderGoodsCount'];
$orderTotal=$storeStats['orderTotal'];
$data['storeId'] = $store['store_id'];
$data['storeName'] = $store['store_name'];
$data['storeLabel'] = $store['store_label'];
$data['goodsCount'] = $goodsCount;
$data['orderCount'] = $storeStats['orderCount'];
$data['orderTotal'] = $storeStats['orderTotal'];
$data['orderTotal'] = $orderTotal;
$data['favCount'] = $storeFavariteCount['favCount'];
$data['todayOrderCount'] = $storeStats['todayOrderCount'];
$data['todayOrderTotal'] = $storeStats['todayOrderTotal'];
......@@ -240,6 +245,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
} else {
$update_data['order_state'] = ApiConst::orderStateWaitSend;
$update_data['accept_time']=TIMESTAMP;
$result = $orderDao->update($where, $update_data);
$orderDao->deleteOrderCache($order['buyer_id'], $orderId, $order['store_id'], true);
// \Our\RedisHelper::memberTotalFromStateToState($order['buyer_id'], $order['order_state'], ApiConst::orderStateWaitSend);
......
......@@ -409,7 +409,7 @@ class OrderModel extends \DAO\AbstractModel
if(is_array($memberIds)){
$memberIds=implode(',',$memberIds);
}
$where=Common::format(" store_id in({0}) and buyer_id in({1}) and order_state not in({2})",$storeIds,$memberIds,'-1,0');
$where=Common::format(" store_id in({0}) and buyer_id in({1}) and order_state not in({2}) and refund_amount={3}",$storeIds,$memberIds,'-1,0',ApiConst::zero);
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(order_amount)) AS orderTotal")->group('buyer_id')->group('store_id')->fetchAll();
return $res;
}
......@@ -848,6 +848,8 @@ class OrderModel extends \DAO\AbstractModel
}
$this->deleteGetListByMemberId($stroeId);
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
\DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance()->deleteCacheGetGoodsCountOrderTotalByStoreId($stroeId);
$orderGoodsDao->deleteOrderGoodsCache($memberId, $orderId,$stroeId);
}
......
......@@ -20,6 +20,7 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* @var string
*/
protected $_tableName = 'han_member-favorites_store-store_member_statistics';
public $sumField='sum(order_total) as orderTotal,count(*) as orderGoodsCount';
public $field="fav_type as favType,member_id as memberId,member_mobile as memberMobile,is_backlist as isBacklist,fav_time as favTime,member_avatar as memberAvatar,member_name as memberName,order_total as orderTotal,order_goods_count as orderGoodsCount";
/**
......@@ -130,7 +131,7 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
}
public function getInfoByMemberId($memberId,$field='*',$isField=false)
{
$this->setDb();
$this->setDb($this->dbName);
$where['member_id'] = $memberId;
$store = $this->db->from($this->_tableName)->select($field)->where($where)->fetchOne();
if ($isField) {
......@@ -139,7 +140,15 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
return $store;
}
}
public function getGoodsCountOrderTotalByStoreId($storeId){
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$res=$this->db->from($this->_tableName)->select($this->sumField)->where($where)->fetchOne();
return $res?$res:[];
}
public function deleteCacheGetGoodsCountOrderTotalByStoreId($storeId){
return \Our\RedisHelper::delCachedFunction(\Redis\Db6\OrderRedisModel::getInstance(), array(&$this, 'getGoodsCountOrderTotalByStoreId'), array(),array($storeId));
}
/**
* 类实例
*
......
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