Commit ca736fb3 authored by wwccw0591's avatar wwccw0591

pc

parent 04cdae35
......@@ -673,35 +673,25 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
{
$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 {
$addDatas = array();
$storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
if ($storeMemberStatisticData) {
$this->taskIndex++;
foreach ($storeMemberStatisticData as $value) {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['storeId'] = $value['storeId'];
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['memberId'] = $value['buyerId'];
if (isset($addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'])) {
$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'];
if(!empty($storeMemberStatisticData)){
$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));
}
}
}
$addDatas = array_values($addDatas);
$storeMemberStatisticDao->addAllReduce($addDatas);
$this->reduceRefundModel($storeMemberStatisticData);
$this->taskIndex++;
} while ($storeMemberStatisticData);
file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
......
......@@ -25,7 +25,7 @@ class RefundReturnModel extends \DAO\AbstractModel {
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 $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 {
public function getMemberStoreStaticsByGmtUpdate($gmtUpdate,$pageIndex,$pageSize){
$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);
return $res['list']?$res:false;
}
......
......@@ -192,7 +192,7 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) {
if ($one===false) {
$error++;
}
$insertAllSql = $baseSql;
......@@ -202,13 +202,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) {
if ($one===false) {
$error++;
}
}
if ($error > 0) {
$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 {
$insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) {
if ($one===false) {
$error++;
}
$insertAllSql = $baseSql;
......@@ -237,13 +237,13 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
$insertAllSql = rtrim($insertAllSql, ',');
$insertSql=$insertAllSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($insertSql);
if (!$one) {
if ($one===false) {
$error++;
}
}
if ($error > 0) {
$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
$shopkeeperService->baseDir= \Our\Common::getConfig('out.config');
try {
$shopkeeperService->insertStoreMemberStatics();
// $shopkeeperService->reduceStoreMemberStatics();
$shopkeeperService->reduceStoreMemberStatics();
$shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId();
} 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