Commit ca736fb3 authored by wwccw0591's avatar wwccw0591

pc

parent 04cdae35
...@@ -673,35 +673,25 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -673,35 +673,25 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
{ {
$refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName); $refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName);
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName); $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 = file_get_contents($this->baseDir . PathConst::refundRetrunGmtUpdate);
$gmtUpdate = $gmtUpdate ? $gmtUpdate : ApiConst::zero; $gmtUpdate = $gmtUpdate ? $gmtUpdate : ApiConst::zero;
$this->taskIndex = PageConst::taskPageBegin; $this->taskIndex = PageConst::taskPageBegin;
$this->taskSize = PageConst::taskPageSize; $this->taskSize = PageConst::taskPageSize;
do { do {
$addDatas = array();
$storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize); $storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false; $storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
if ($storeMemberStatisticData) { if(!empty($storeMemberStatisticData)){
$this->taskIndex++; $orderIds=array_column($storeMemberStatisticData,'orderId');
foreach ($storeMemberStatisticData as $value) { foreach($orderIds as $orderId){
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['storeId'] = $value['storeId']; $res=$orderGoodsDao->find(array('order_id'=>$orderId,'refund_id'=>ApiConst::zero));
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['memberId'] = $value['buyerId']; if(empty($res)){
if (isset($addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'])) { $orderDao->update(array('order_id'=>$orderId),array('order_state'=>ApiConst::orderStateClose));
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'] += $value['goodsNum'];
} else {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'] = $value['goodsNum'];
}
if (isset($addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'])) {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] += $value['refundAmount'];
} else {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] = $value['refundAmount'];
} }
} }
} }
$addDatas = array_values($addDatas); $this->taskIndex++;
$storeMemberStatisticDao->addAllReduce($addDatas);
$this->reduceRefundModel($storeMemberStatisticData);
} while ($storeMemberStatisticData); } while ($storeMemberStatisticData);
file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP); file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
......
...@@ -25,7 +25,7 @@ class RefundReturnModel extends \DAO\AbstractModel { ...@@ -25,7 +25,7 @@ class RefundReturnModel extends \DAO\AbstractModel {
protected $_tableName = 'han_refund_return'; protected $_tableName = 'han_refund_return';
public $refundDetailField='is_platform_in as isPlatformIn,seller_state as sellerState,platform_state as platformState,refund_id as refundId,order_id as orderId,store_id as storeId,order_goods_id as orderGoodsId'; public $refundDetailField='is_platform_in as isPlatformIn,seller_state as sellerState,platform_state as platformState,refund_id as refundId,order_id as orderId,store_id as storeId,order_goods_id as orderGoodsId';
public $refundReturnField="seller_state,refund_state,is_platform_in,platform_state"; public $refundReturnField="seller_state,refund_state,is_platform_in,platform_state";
private $sumField="buyer_id as buyerId,store_id as storeId,goods_num as goodsNum,refund_amount as refundAmount,is_suc_refund as isSucRefund,gmt_update as gmtUpdate"; private $sumField="order_id as orderId,buyer_id as buyerId,store_id as storeId,goods_num as goodsNum,refund_amount as refundAmount,is_suc_refund as isSucRefund,gmt_update as gmtUpdate";
/** /**
* 主键 * 主键
* *
...@@ -409,7 +409,7 @@ class RefundReturnModel extends \DAO\AbstractModel { ...@@ -409,7 +409,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 is_suc_refund={2}',$gmtUpdate,TIMESTAMP,ApiConst::refundSuccess); $where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1} and refund_state={2}',$gmtUpdate,TIMESTAMP,ApiConst::refundStateComplete);
$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;
} }
......
...@@ -192,7 +192,7 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -192,7 +192,7 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ','); $insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql; $insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql); $one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) { if ($one===false) {
$error++; $error++;
} }
$insertAllSql = $baseSql; $insertAllSql = $baseSql;
...@@ -202,13 +202,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -202,13 +202,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ','); $insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql; $insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql); $one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) { if ($one===false) {
$error++; $error++;
} }
} }
if ($error > 0) { if ($error > 0) {
$dataJson=json_encode($datas); $dataJson=json_encode($datas);
throw new Exception('插入han_store_member_statistics失败,'.$dataJson, 4); echo '插入han_store_member_statistics失败,'.$dataJson;
} }
} }
...@@ -227,7 +227,7 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -227,7 +227,7 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ','); $insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql; $insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql); $one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) { if ($one===false) {
$error++; $error++;
} }
$insertAllSql = $baseSql; $insertAllSql = $baseSql;
...@@ -237,13 +237,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -237,13 +237,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ','); $insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql; $insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql); $one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) { if ($one===false) {
$error++; $error++;
} }
} }
if ($error > 0) { if ($error > 0) {
$dataJson=json_encode($datas); $dataJson=json_encode($datas);
throw new Exception('插入han_store_member_statistics失败,'.$dataJson, 4); echo '插入han_store_member_statistics失败,'.$dataJson;
} }
} }
......
...@@ -71,7 +71,7 @@ class cliShopkeeperIndex extends basecli ...@@ -71,7 +71,7 @@ class cliShopkeeperIndex extends basecli
$shopkeeperService->baseDir= \Our\Common::getConfig('out.config'); $shopkeeperService->baseDir= \Our\Common::getConfig('out.config');
try { try {
$shopkeeperService->insertStoreMemberStatics(); $shopkeeperService->insertStoreMemberStatics();
// $shopkeeperService->reduceStoreMemberStatics(); $shopkeeperService->reduceStoreMemberStatics();
$shopkeeperService->storeStatictisTask(); $shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId(); $shopkeeperService->updateLastId();
} catch (Exception $ex) { } catch (Exception $ex) {
......
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