Commit 59675070 authored by christ's avatar christ

refundStatic

parent c4f4c5c1
...@@ -310,6 +310,7 @@ class ApiConst ...@@ -310,6 +310,7 @@ class ApiConst
const commonClassStyle = 1; const commonClassStyle = 1;
const signClassStyle = 2; const signClassStyle = 2;
const isEffective=0;
const defaultAddressCount = 3; const defaultAddressCount = 3;
......
...@@ -663,17 +663,28 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -663,17 +663,28 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$this->taskSize = PageConst::taskPageSize; $this->taskSize = PageConst::taskPageSize;
do { do {
$storeMemberStatisticData = $orderDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize); $storeMemberStatisticData = $orderDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false; $orders = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
if ($storeMemberStatisticData) { $storeMemberStatisticsDatas=array();
if ($orders) {
$this->taskIndex++; $this->taskIndex++;
$storeIds = array_column($storeMemberStatisticData, 'storeId'); foreach($orders as $order){
$memberIds = array_column($storeMemberStatisticData, 'buyerId'); $storeMemberStatisticsData['store_id']=$order['storeId'];
$goodsNumCount = $orderGoodDao->getMemberStoreOrderGoodsCount($storeIds, $memberIds); $storeMemberStatisticsData['member_id']=$order['memberId'];
$refundLists = $reufndReturnDao->getRefundSuccessMoneyByStoreIdAndMemberId($storeIds, $memberIds); $orderRes=$orderDao->getSumAmountCountByMemberIdAndStoreId($storeMemberStatisticsData['store_id'],$storeMemberStatisticsData['member_id']);
$storeMemberStatisticsData['order_total']=$orderRes['orderTotal']?$orderRes['orderTotal']:ApiConst::zero;
$orderGoodsRes=$orderGoodDao->getOrderGoodsCountBuyStoreIdAndMemberId( $storeMemberStatisticsData['store_id'],$storeMemberStatisticsData['member_id']);
$orderGoodsCount=$orderGoodsRes?$orderGoodsRes['orderGoodsCount']:ApiConst::zero;
$storeMemberStatisticsData['order_goods_count']=$orderGoodsCount;
$storeMemberStatisticsData['add_time']=TIMESTAMP;
array_push($storeMemberStatisticsDatas,$storeMemberStatisticsData);
}
} }
} while ($storeMemberStatisticData); } while ($storeMemberStatisticData);
if(!empty($storeMemberStatisticsDatas)){
$storeMemberStatisticDao->addAll($storeMemberStatisticsDatas);
}
file_put_contents($this->baseDir . PathConst::orderGoodsCreateTime, TIMESTAMP); file_put_contents($this->baseDir . PathConst::orderGoodsCreateTime, TIMESTAMP);
} }
...@@ -876,7 +887,6 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -876,7 +887,6 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
} }
} }
//任务脚本 //任务脚本
public function reduceStoreMemberStatics() public function reduceStoreMemberStatics()
{ {
...@@ -889,25 +899,61 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -889,25 +899,61 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$this->taskIndex = PageConst::taskPageBegin; $this->taskIndex = PageConst::taskPageBegin;
$this->taskSize = PageConst::taskPageSize; $this->taskSize = PageConst::taskPageSize;
do { do {
$storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize); $refundReturns = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false; $this->taskIndex++;
if (!empty($storeMemberStatisticData)) { $refundReturns = isset($refundReturns['list']) ? $refundReturns['list'] : false;
foreach ($storeMemberStatisticData as $item) { $reduceDatas=array();
$orderDao->deleteOrderCache($item['buyerId'], $item['orderId'], $item['storeId'], true, true); if (!empty($refundReturns)) {
} foreach ($refundReturns as $refundReturn) {
$orderIds = array_column($storeMemberStatisticData, 'orderId'); $orderDao->deleteOrderCache($refundReturn['buyerId'], $refundReturn['orderId'], $refundReturn['storeId'], true, true);
foreach ($orderIds as $orderId) { $res = $orderGoodsDao->find(array('order_id' => $refundReturn['orderId'], 'refund_id' => ApiConst::zero));
$res = $orderGoodsDao->find(array('order_id' => $orderId, 'refund_id' => ApiConst::zero));
if (empty($res)) { if (empty($res)) {
$orderDao->update(array('order_id' => $orderId), array('order_state' => ApiConst::orderStateClose)); $reduceData['store_id']=$refundReturn['storeId'];
$reduceData['member_id']=$refundReturn['buyerId'];
$reduceData['order_goods_count']=ApiConst::zero;
$reduceData['order_total']=$refundReturn['orderAmount'];
$reduceData['addTime']=TIMESTAMP;
array_push($reduceDatas,$reduceData);
} }
} }
} }
$this->taskIndex++;
} while ($storeMemberStatisticData); } while ($refundReturns);
$storeMemberStatisticDao->addAllReduce($refundReturns);
file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP); file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
} }
// //任务脚本
// public function reduceStoreMemberStatics()
// {
// $refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName);
// $storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
// $gmtUpdate = file_get_contents($this->baseDir . PathConst::refundRetrunGmtUpdate);
// $gmtUpdate = $gmtUpdate ? $gmtUpdate : ApiConst::zero;
// $this->taskIndex = PageConst::taskPageBegin;
// $this->taskSize = PageConst::taskPageSize;
// do {
// $storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
// $storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
// if (!empty($storeMemberStatisticData)) {
// foreach ($storeMemberStatisticData as $item) {
// $orderDao->deleteOrderCache($item['buyerId'], $item['orderId'], $item['storeId'], true, true);
// }
// $orderIds = array_column($storeMemberStatisticData, 'orderId');
// foreach ($orderIds as $orderId) {
// $res = $orderGoodsDao->find(array('order_id' => $orderId, 'refund_id' => ApiConst::zero));
// if (empty($res)) {
// $orderDao->update(array('order_id' => $orderId), array('order_state' => ApiConst::orderStateClose));
// }
// }
// }
// $this->taskIndex++;
// } while ($storeMemberStatisticData);
// file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
//
// }
//店铺订单统计任务脚本 //店铺订单统计任务脚本
public function storeStatictisTask() public function storeStatictisTask()
......
...@@ -439,6 +439,18 @@ class OrderModel extends \DAO\AbstractModel ...@@ -439,6 +439,18 @@ class OrderModel extends \DAO\AbstractModel
$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(); $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; return $res;
} }
public function getSumAmountCountByMemberIdAndStoreId($storeId,$memberId)
{
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$where['buyer_id']=$memberId;
$where['is_effective']=ApiConst::isEffective;
if(is_array($where)){
$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)) AS orderTotal")->fetchOne();
return $res?$res:array();
}
//待收货获取订单状态信息 //待收货获取订单状态信息
public function getOrderStatusExtent($order) public function getOrderStatusExtent($order)
......
...@@ -253,6 +253,16 @@ class OrderGoodsModel extends \DAO\AbstractModel { ...@@ -253,6 +253,16 @@ class OrderGoodsModel extends \DAO\AbstractModel {
return $res; return $res;
} }
public function getOrderGoodsCountBuyStoreIdAndMemberId($storeId,$memberId){
$this->setDb($this->dbName);
$where['store_id']=array('eq',$storeId);
$where['buyer_id']=array('eq',$memberId);
$where['is_refund']=array('neq',ApiConst::refundSuccess);
$where=$this->db->getSqlWhereByArray($where);
$res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
return $res?$res:array();
}
// public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){ // public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){
// $this->setDb($this->dbName); // $this->setDb($this->dbName);
// $orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName); // $orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
......
...@@ -676,7 +676,7 @@ class RefundReturnModel extends \DAO\AbstractModel ...@@ -676,7 +676,7 @@ class RefundReturnModel extends \DAO\AbstractModel
public function getMemberStoreStaticsByGmtUpdate($gmtUpdate, $pageIndex, $pageSize) public function getMemberStoreStaticsByGmtUpdate($gmtUpdate, $pageIndex, $pageSize)
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where = \Our\Common::format(' gmt_update>={0} and gmt_update<{1} and refund_state={2}', $gmtUpdate, TIMESTAMP, ApiConst::refundStateComplete); $where = \Our\Common::format(' gmt_update>={0} and gmt_update<{1} and is_suc_refund={2}', $gmtUpdate, TIMESTAMP, ApiConst::zero);
$res = $this->lists($where, array('gmt_update' => 'asc'), $this->sumField, $pageIndex, $pageSize); $res = $this->lists($where, array('gmt_update' => 'asc'), $this->sumField, $pageIndex, $pageSize);
return $res['list'] ? $res : false; return $res['list'] ? $res : false;
} }
......
...@@ -48,7 +48,7 @@ class cliOrderClose extends basecli ...@@ -48,7 +48,7 @@ class cliOrderClose extends basecli
$redis->auth($conf['password']); $redis->auth($conf['password']);
} }
$clientPush=\JPush\ClientPush::getInstance(); $clientPush=\JPush\ClientPush::getInstance();
$clientPush->pushTest(array());exit; $clientPush->pushTest(array());
$memberCenterServiceDao=\Business\User\MemberCenterServiceModel::getInstance(); $memberCenterServiceDao=\Business\User\MemberCenterServiceModel::getInstance();
//$messageService=\DAO\MessageHistoryModel::getInstance(); //$messageService=\DAO\MessageHistoryModel::getInstance();
while($pushData=$redis->rPop('push_center')){ while($pushData=$redis->rPop('push_center')){
......
...@@ -74,7 +74,7 @@ class cliShopkeeperIndex extends basecli ...@@ -74,7 +74,7 @@ class cliShopkeeperIndex extends basecli
//退货退款订单自动关闭 //退货退款订单自动关闭
// $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