|
@@ -1,7 +1,9 @@
|
|
|
<?php
|
|
|
|
|
|
namespace loyalsoft;
|
|
|
+
|
|
|
require_once __DIR__ . '/../service_call/pay/official/pay_op.php';
|
|
|
+
|
|
|
/**
|
|
|
* Description of UserProc
|
|
|
* 玩家数据处理流程
|
|
@@ -53,24 +55,24 @@ class UserProc {
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 检测遗漏订单
|
|
|
*/
|
|
|
- static function checkMissOrder() {
|
|
|
+ static function checkMissOrder() {
|
|
|
$tableName = "tpl_order_tab";
|
|
|
-
|
|
|
- if (daoInst()->tableExist($tableName)) {
|
|
|
+
|
|
|
+ if (daoInst()->tableExist($tableName)) {
|
|
|
$arr = daoInst()->select("*")->from($tableName)
|
|
|
- ->where('uid')->eq(req()->uid)
|
|
|
- ->andWhere('zoneid')->eq(req()->zoneid)
|
|
|
- ->andWhere('status')->eq(1)
|
|
|
- ->andWhere('drawed_ts')->eq(0)
|
|
|
- ->fetchAll();
|
|
|
-
|
|
|
- if(count($arr)!=null){
|
|
|
- foreach ($arr as $item){
|
|
|
- $result = pay_op::CheckAndDrawOrder(req()->uid,$item->cpOrderId,array(new PayProc,'distributePayGoods'));
|
|
|
+ ->where('uid')->eq(req()->uid)
|
|
|
+ ->andWhere('zoneid')->eq(req()->zoneid)
|
|
|
+ ->andWhere('status')->eq(1)
|
|
|
+ ->andWhere('drawed_ts')->eq(0)
|
|
|
+ ->fetchAll();
|
|
|
+
|
|
|
+ if (count($arr) != null) {
|
|
|
+ foreach ($arr as $item) {
|
|
|
+ $result = pay_op::CheckAndDrawOrder(req()->uid, $item->cpOrderId, array(new PayProc, 'distributePayGoods'));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -309,7 +311,7 @@ class UserProc {
|
|
|
if ($zone->isRecommended > 0 && $zone->status == 1) {
|
|
|
$zoneList[] = $zone;
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
$zoneList[] = $zone;
|
|
@@ -398,7 +400,7 @@ class UserProc {
|
|
|
self::checkMissOrder(); #校验是否有漏单
|
|
|
UserProc::updateUserInfo(); # 这一步回存操作只有在 userInfo正常存在的情况下才进行
|
|
|
$resp = Resp::ok($userInfo); # 设置返回值
|
|
|
- self::backupUserInfo(); # 数据回写
|
|
|
+// self::backupUserInfo(); # 数据回写
|
|
|
|
|
|
AuctionProc::TriggerSettlement(); #结算流拍信息
|
|
|
self::updtateUserZoneInfo(); # 1. 更新玩家分区记录
|
|
@@ -481,7 +483,7 @@ class UserProc {
|
|
|
ShopProc::DailyCheck();
|
|
|
TaskProc::ResetDailyTaskCards(); # 重置每日任务卡
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// <editor-fold defaultstate="collapsed" desc="创建新用户">
|
|
|
|
|
|
/**
|
|
@@ -553,7 +555,17 @@ class UserProc {
|
|
|
$key = MemKey_User::Info_hash($zoneid, $uid);
|
|
|
$a = new Data_UserGame();
|
|
|
if (null == $a->readDataFromMem($key)) {
|
|
|
- return null;
|
|
|
+ $collection = "ylsj2019.userInfoBack";
|
|
|
+ $cursor = gMongo()->find($collection, ['key' => $key]);
|
|
|
+ if ($cursor) {
|
|
|
+ foreach ($cursor as $v) {
|
|
|
+ $a->LoadFrom($v->value); # 加载
|
|
|
+ $a->updateDataFull($key); # 反向写回redis
|
|
|
+ break; # 其实是只有一条
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
$usrInfo = new UserInfoMo();
|
|
|
$g = new Data_UserGame($a);
|
|
@@ -575,14 +587,16 @@ class UserProc {
|
|
|
* @param UserInfoMo $userInfo
|
|
|
*/
|
|
|
public static function setUserInfo($userInfo) {
|
|
|
+ $OK = false;
|
|
|
if ($userInfo) {
|
|
|
$zoneid = req()->zoneid;
|
|
|
$uid = req()->uid;
|
|
|
$userInfo->game->baseInfo->lastSaveTs = now();
|
|
|
$key = MemKey_User::Info_hash($zoneid, $uid);
|
|
|
- return $userInfo->game->updateDataFull($key);
|
|
|
+ $OK = $userInfo->game->updateDataFull($key); # 向Redis回写玩家数据
|
|
|
+ self::backupUserInfoMongo(); # 向MongoDB备份数据
|
|
|
}
|
|
|
- return false;
|
|
|
+ return $OK;
|
|
|
}
|
|
|
|
|
|
// </editor-fold>
|
|
@@ -647,6 +661,27 @@ class UserProc {
|
|
|
daoInst()->exec($sql); # 也可以用exec($sql)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 备份玩家数据,(玩家数据落地),一天一份,当天记为最后一次登录时的状态而非最后一次操作的状态
|
|
|
+ * @history
|
|
|
+ * version 4.0.0 切换到MongoDB存储
|
|
|
+ * version 3.0.13 mysql版备份玩家数据, (性能优化后表现还不错)
|
|
|
+ * 除非用脚本在redis中实现备份,否则直接写入mysql.
|
|
|
+ * 主要是mysql版本利用存储过程之后性能已经和redis版相差不多.
|
|
|
+ * version 2.0.0 Redis storage 从MySQL转到Redis中存储. 这个备份数据没有大规模导出硬盘的需求
|
|
|
+ * 因为mysql版本实在是负载太大了, 上百毫秒. 所以改在redis中了.
|
|
|
+ * version 1.0.0 Mysql storagef 1. 分表不做了, 2. 存储过程不用了 3. 先能用再说
|
|
|
+ */
|
|
|
+ public static function backupUserInfoMongo() {
|
|
|
+ $collectionName = "ylsj2019.userInfoBack"; # 表名
|
|
|
+ $key = MemKey_User::Info_hash(req()->zoneid, req()->uid);
|
|
|
+ $doc = array('key' => $key, # # 最新文档
|
|
|
+ 'ts' => TimeUtil::dtCurrent(), # # 更新时间
|
|
|
+ 'value' => req()->userInfo->game); # 玩家数据
|
|
|
+ $filter = array('key' => $key); # 指定条件
|
|
|
+ gMongo()->update($collectionName, $filter, $doc, true); # 更新
|
|
|
+ }
|
|
|
+
|
|
|
// </editor-fold>
|
|
|
//</editor-fold>
|
|
|
//
|