Commit 3810dc57 authored by zhz's avatar zhz

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

parents a9ae3a19 4458ba48
......@@ -54,7 +54,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$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));
$goodsCount=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::one, array($storeId));
$condition['store_id'] = $storeId;
//获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
......@@ -484,6 +484,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$reufndReturnDao=\DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime);
$gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero;
$beginTime = $gmtCreate;
......@@ -501,7 +502,16 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$memberIds=array_unique($memberId);
$goodsNumCount=$orderGoodDao->getMemberStoreOrderGoodsCount($storeIds,$memberIds);
$ordersCount=$orderDao->getSumAmountCountByMemberAndStoreId($storeIds,$memberIds);
$refundLists=$reufndReturnDao->getRefundSuccessMoneyByStoreIdAndMemberId($storeIds,$memberIds);
if(!empty($ordersCount) && !empty($refundLists)){
foreach($ordersCount as &$order){
foreach($refundLists as $refund){
if($order['buyerId']==$refund['buyerId'] and $order['storeId']==$refund['storeId']){
$order['orderTotal']=$order['orderTotal']-$refund['refundTotal'];
}
}
}
}
if(!empty($goodsNumCount)){
$storeMemberStatisticDao->addAll($goodsNumCount,'orderGoodsCount');
}
......
......@@ -29,7 +29,7 @@ class OrderModel extends \DAO\AbstractModel
*/
protected $_tableName = 'han_order';
private $countField = '(sum(order_amount)-sum(refund_amount)) as orderTotal,count(*) as orderCount';
private $countField = '(sum(order_amount)) as orderTotal,count(*) as orderCount';
/**
* 主键
*
......@@ -396,11 +396,7 @@ class OrderModel extends \DAO\AbstractModel
$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['store_id']=array('in',$storeIds);
// $where['buyer_id']=array('in',$memberIds);
// $where['order_state']=array('notin','-1,0');
// $where=$this->db->getSqlWhereByArray($where);
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(order_amount)-SUM(refund_amount)) AS orderTotal")->group('buyer_id')->group('store_id')->fetchAll();
$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;
}
......
......@@ -66,8 +66,11 @@ class OrderGoodsModel extends \DAO\AbstractModel {
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$where['is_refund']=array('neq',ApiConst::refundSuccess);
$goodsCount = $this->db->select($this->orderGoodsGoodsNumCountField)->from($this->_tableName)->where($where)->fetchNum();
return $goodsCount;
if(is_array($where)){
$where=$this->db->getSqlWhereByArray($where);
}
$goodsCount = $this->db->select($this->orderGoodsGoodsNumCountField)->from($this->_tableName)->where($where)->fetchValue();
return (int)$goodsCount;
}
/**
* 获取单条数据
......@@ -225,7 +228,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
}
public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){
$this->setDb($this->dbName);
$where =\Our\Common::format(' gmt_create>={0} and gmt_create<{1} ',$gmtCreate,TIMESTAMP);
$where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1} ',$gmtCreate,TIMESTAMP);
$res=$this->lists($where,array('gmt_create'=>'asc'),$this->sumField,$pageIndex,$pageSize);
return $res['list']?$res:false;
}
......
......@@ -59,6 +59,19 @@ class RefundReturnModel extends \DAO\AbstractModel {
$res=$this->db->from($this->_tableName)->select($this->sumRefundAmount)->where($where)->fetchValue();
return !empty($res)?$res:ApiConst::zero;
}
public function getRefundSuccessMoneyByStoreIdAndMemberId($storeId,$buyerId){
$this->setDb($this->dbName);
if(is_array($storeId)){
$storeId=implode(',',$storeId);
}
if(is_array($buyerId)){
$buyerId=implode(',',$buyerId);
}
$where=\Our\Common::format(" store_id in({0}) and buyer_id in({1}) and is_suc_refund={2}",$storeId,$buyerId,ApiConst::refundSuccess);
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(refund_amount)) AS refundTotal")->group('buyer_id')->group('store_id')->fetchAll();
return !empty($res)?$res:[];
}
/**
* 更新数据
......
......@@ -72,7 +72,7 @@ class cliShopkeeperIndex extends basecli
try {
$shopkeeperService->insertStoreMemberStatics();
$shopkeeperService->reduceStoreMemberStatics();
$shopkeeperService->storeStatictisTask();
//$shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId();
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
......
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