Commit f1ca0cca authored by liuyuzhen's avatar liuyuzhen

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

parents 78afda56 3810dc57
...@@ -27,10 +27,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -27,10 +27,13 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyPBundlingdForOrder); \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyPBundlingdForOrder);
} }
$data = $groupList[0]; $data = $groupList[0];
if($data['goodsCountFlag'] === false){ $data['state'] = \Our\ApiConst::cartGoodsOnline;
$data['state'] = 0; if($data['bl_state'] == \Our\ApiConst::zero) {
}else{ $data['state'] = \Our\ApiConst::zero;
$data['state'] = $data['bl_state']; }else if(!($data['bl_quota_starttime'] < time() && $data['endTime'] >= time())||!$data['goodsCountFlag']) {
$data['state'] = \Our\ApiConst::cartGoodsOffline;
}else if($data['bl_storage']<=\Our\ApiConst::zero) {
$data['state'] = \Our\ApiConst::cartGoodsNoStorage;
} }
unset($data['blId']); unset($data['blId']);
unset($data['store_name']); unset($data['store_name']);
...@@ -263,24 +266,26 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -263,24 +266,26 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$group = array(); $group = array();
if($groupList){ if($groupList){
foreach ($groupList as $k=>$v){ foreach ($groupList as $k=>$v){
$v['groupId'] = $v['blId']; if($v['bl_quota_starttime']<TIMESTAMP&&$v['endTime']>=TIMESTAMP && $v['bl_storage'] > \Our\ApiConst::zero) {
$v['image'] = ImageUtil::getGoodsImgUrl($v['image'],\our\ImageConst::goodsGroupImg); $v['groupId'] = $v['blId'];
unset($v['goodsList']); $v['image'] = ImageUtil::getGoodsImgUrl($v['image'], \our\ImageConst::goodsGroupImg);
unset($v['bl_title']); unset($v['goodsList']);
unset($v['store_id']); unset($v['bl_title']);
unset($v['store_name']); unset($v['store_id']);
unset($v['bl_state']); unset($v['store_name']);
unset($v['bl_quota_starttime']); unset($v['bl_state']);
unset($v['bl_image']); unset($v['bl_quota_starttime']);
unset($v['bl_storage']); unset($v['bl_image']);
unset($v['blId']); unset($v['bl_storage']);
unset($v['goodsCountFlag']); unset($v['blId']);
unset($v['is_transport']); unset($v['goodsCountFlag']);
unset($v['transport_id']); unset($v['is_transport']);
unset($v['snapshot_id']); unset($v['transport_id']);
unset($v['goods_freight']); unset($v['snapshot_id']);
unset($v['goods_free']); unset($v['goods_freight']);
$group[] = $v; unset($v['goods_free']);
$group[] = $v;
}
} }
} }
return $group; return $group;
...@@ -331,7 +336,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -331,7 +336,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$return = array(); $return = array();
if($group){ if($group){
foreach ($group as $k=>$v){ foreach ($group as $k=>$v){
if($v['bl_quota_starttime']<TIMESTAMP&&$v['endTime']>=TIMESTAMP){ if($v['bl_quota_starttime']<TIMESTAMP&&$v['endTime']>=TIMESTAMP && $v['bl_storage'] > \Our\ApiConst::zero){
$v['groupId'] = $v['blId']; $v['groupId'] = $v['blId'];
$v['image'] = ImageUtil::getGoodsImgUrl($v['image'],\Our\ImageConst::goodsGroupImg); $v['image'] = ImageUtil::getGoodsImgUrl($v['image'],\Our\ImageConst::goodsGroupImg);
unset($v['goodsList']); unset($v['goodsList']);
......
...@@ -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