Commit d9d7ae7a authored by zhz's avatar zhz

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

parents 8763da12 5d9b0462
...@@ -88,8 +88,13 @@ class UserController extends \Our\Controller_AbstractIndex { ...@@ -88,8 +88,13 @@ class UserController extends \Our\Controller_AbstractIndex {
if($member){ if($member){
/*$userToken=$this->memberService->findMbUserTokenByMemberId($member['member_id']); /*$userToken=$this->memberService->findMbUserTokenByMemberId($member['member_id']);
$this->memberService->clearKey($userToken['token']);*/ $this->memberService->clearKey($userToken['token']);*/
$userToken=$this->memberService->getWxUserToken($member['member_id']);
if(!empty($userToken)){
$this->updateOldLoginKey($userToken);
}
$this->memberService->clearKey($this->key); $this->memberService->clearKey($this->key);
$this->key=Common::bulidToken('', '', '', \Our\ApiConst::wechatDeviceType); $this->key=Common::bulidToken('', '', '', \Our\ApiConst::wechatDeviceType);
$this->memberService->saveWxUserToken($this->key,$member['member_id']);
session_id($this->key); session_id($this->key);
$this->sess['member_id'] = $member['member_id']; $this->sess['member_id'] = $member['member_id'];
$this->sess['user_type'] = \Our\ApiConst::wechatUserType; $this->sess['user_type'] = \Our\ApiConst::wechatUserType;
......
...@@ -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);
......
...@@ -128,6 +128,8 @@ class MemberServiceModel extends \Business\AbstractModel ...@@ -128,6 +128,8 @@ class MemberServiceModel extends \Business\AbstractModel
return $mbUserTokenModel->findByMemberId($memberId); return $mbUserTokenModel->findByMemberId($memberId);
} }
public function getMemberInfo($memberId) public function getMemberInfo($memberId)
{ {
$memberDao=\DAO\MemberModel::getInstance(\Our\DbNameConst::masterDBConnectName); $memberDao=\DAO\MemberModel::getInstance(\Our\DbNameConst::masterDBConnectName);
...@@ -182,6 +184,16 @@ class MemberServiceModel extends \Business\AbstractModel ...@@ -182,6 +184,16 @@ class MemberServiceModel extends \Business\AbstractModel
return $result; return $result;
} }
public function getWxUserToken($memberId){
$memberDao = \DAO\MemberModel::getInstance();
$userToken = $memberDao->getWxUserToken($memberId);
return $userToken;
}
public function saveWxUserToken($key,$memberId){
$memberDao = \DAO\MemberModel::getInstance();
$memberDao->saveWxUserToken($key,$memberId);
}
/** /**
* 保存会员头像 * 保存会员头像
......
...@@ -97,6 +97,21 @@ class MemberModel extends \DAO\AbstractModel ...@@ -97,6 +97,21 @@ class MemberModel extends \DAO\AbstractModel
} }
public function getWxUserToken($memberId){
$memberDb0Redis = \Redis\Db0\MemberRedisModel::getInstance();
$member = $memberDb0Redis->tableHGAll($memberId);
$memberDb0Redis->tableExpire($memberId, ApiConst::tenDaySecond);
if(isset($member['wxUserToken'])&&$member['wxUserToken']){
return $member['wxUserToken'];
}
return \Our\NameConst::emptyString;
}
public function saveWxUserToken($key,$memberId){
$memberDb0Redis = \Redis\Db0\MemberRedisModel::getInstance();
$memberDb0Redis->tableHMSet($memberId, array('wxUserToken'=>$key));
}
/** /**
* 保存用户信息 * 保存用户信息
*/ */
......
...@@ -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