Commit f6d2dc81 authored by wwccw0591's avatar wwccw0591

pc

parent c7fc933b
...@@ -54,7 +54,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -54,7 +54,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$orderDao=\DAO\Order\OrderModel::getInstance(); $orderDao=\DAO\Order\OrderModel::getInstance();
$favoritesStoreDao=\DAO\FavoritesStoreModel::getInstance(); $favoritesStoreDao=\DAO\FavoritesStoreModel::getInstance();
$orderGoodsDao=\DAO\Order\OrderGoodsModel::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; $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::tenDaySecond, array($storeId));
...@@ -484,6 +484,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -484,6 +484,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName); $orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance(); $orderDao=\DAO\Order\OrderModel::getInstance();
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName); $storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$reufndReturnDao=\DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime); $gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime);
$gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero; $gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero;
$beginTime = $gmtCreate; $beginTime = $gmtCreate;
...@@ -501,7 +502,16 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -501,7 +502,16 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$memberIds=array_unique($memberId); $memberIds=array_unique($memberId);
$goodsNumCount=$orderGoodDao->getMemberStoreOrderGoodsCount($storeIds,$memberIds); $goodsNumCount=$orderGoodDao->getMemberStoreOrderGoodsCount($storeIds,$memberIds);
$ordersCount=$orderDao->getSumAmountCountByMemberAndStoreId($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)){ if(!empty($goodsNumCount)){
$storeMemberStatisticDao->addAll($goodsNumCount,'orderGoodsCount'); $storeMemberStatisticDao->addAll($goodsNumCount,'orderGoodsCount');
} }
......
...@@ -29,7 +29,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -29,7 +29,7 @@ class OrderModel extends \DAO\AbstractModel
*/ */
protected $_tableName = 'han_order'; 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 ...@@ -396,11 +396,7 @@ class OrderModel extends \DAO\AbstractModel
$memberIds=implode(',',$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})",$storeIds,$memberIds,'-1,0');
// $where['store_id']=array('in',$storeIds); $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();
// $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();
return $res; return $res;
} }
......
...@@ -66,8 +66,11 @@ class OrderGoodsModel extends \DAO\AbstractModel { ...@@ -66,8 +66,11 @@ class OrderGoodsModel extends \DAO\AbstractModel {
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where['store_id']=$storeId; $where['store_id']=$storeId;
$where['is_refund']=array('neq',ApiConst::refundSuccess); $where['is_refund']=array('neq',ApiConst::refundSuccess);
$goodsCount = $this->db->select($this->orderGoodsGoodsNumCountField)->from($this->_tableName)->where($where)->fetchNum(); if(is_array($where)){
return $goodsCount; $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 { ...@@ -225,7 +228,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
} }
public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){ public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){
$this->setDb($this->dbName); $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); $res=$this->lists($where,array('gmt_create'=>'asc'),$this->sumField,$pageIndex,$pageSize);
return $res['list']?$res:false; return $res['list']?$res:false;
} }
......
...@@ -59,6 +59,19 @@ class RefundReturnModel extends \DAO\AbstractModel { ...@@ -59,6 +59,19 @@ class RefundReturnModel extends \DAO\AbstractModel {
$res=$this->db->from($this->_tableName)->select($this->sumRefundAmount)->where($where)->fetchValue(); $res=$this->db->from($this->_tableName)->select($this->sumRefundAmount)->where($where)->fetchValue();
return !empty($res)?$res:ApiConst::zero; 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 ...@@ -72,7 +72,7 @@ class cliShopkeeperIndex extends basecli
try { try {
$shopkeeperService->insertStoreMemberStatics(); $shopkeeperService->insertStoreMemberStatics();
$shopkeeperService->reduceStoreMemberStatics(); $shopkeeperService->reduceStoreMemberStatics();
$shopkeeperService->storeStatictisTask(); //$shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId(); $shopkeeperService->updateLastId();
} catch (Exception $ex) { } catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage()); 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