<?php
|
|
/**
|
* 更新分数及历史最高分
|
*/
|
|
include_once "../../../Common/CommFunc.php";
|
include_once "../../../Common/Logging.php";
|
include_once '../../../Common/MongoDB7.php';
|
include_once "errorCode.php";
|
|
\Logging\CreateLogging("updateScore.php");
|
|
$openid = $_GET['openid'];
|
$gamename = $_GET['gamename'];
|
$weekScore = (int) $_GET['weekScore'];
|
$highestScore = (int) $_GET['highestScore'];
|
if ($openid == "") {
|
echo json_encode(ErrorCode::retErr(ErrorCode::$ParamErr, "no openid"));
|
return;
|
}
|
if ($gamename == "") {
|
echo json_encode(ErrorCode::retErr(ErrorCode::$ParamErr, "no gamename"));
|
return;
|
}
|
|
$update = [
|
'weekScore' => $weekScore,
|
'highestScore' => $highestScore,
|
];
|
|
$ret;
|
\Logging\LogInfo('更新玩家得分 openid=' . $openid . ' update=' . print_r($update, true));
|
$gameconfig = parse_ini_file("config/" . $gamename . ".ini", true);
|
$dbOpt = new \MongoDB7\MongoDb("Player", $gameconfig["db"]);
|
$where = ['openid' => $openid];
|
$modCount = $dbOpt->update($where, $update);
|
\Logging\LogInfo('更新条数: ' . $modCount);
|
if ($modCount > 0) {
|
$ret = ErrorCode::retOK($update);
|
} else {
|
$ret = ErrorCode::retOK();
|
}
|
echo json_encode($ret);
|