forked from Hay1tsme/artemis
put the upsert into transactions, show all purchasable tickets
This commit is contained in:
@ -1,6 +1,4 @@
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
|
||||||
import json
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
@ -131,19 +129,22 @@ class ChuniBase:
|
|||||||
return {"length": 0, "gameChargeList": []}
|
return {"length": 0, "gameChargeList": []}
|
||||||
|
|
||||||
charges = []
|
charges = []
|
||||||
for x in range(len(game_charge_list)):
|
|
||||||
|
for _, charge_list in itertools.groupby(game_charge_list, key=lambda x: x["chargeId"] // 1000):
|
||||||
|
for price, charge in enumerate(charge_list):
|
||||||
charges.append(
|
charges.append(
|
||||||
{
|
{
|
||||||
"orderId": x,
|
"orderId": len(charges),
|
||||||
"chargeId": game_charge_list[x]["chargeId"],
|
"chargeId": charge["chargeId"],
|
||||||
"price": 1,
|
"price": price + 1,
|
||||||
"startDate": "2017-12-05 07:00:00.0",
|
"startDate": "2017-12-05 07:00:00.0",
|
||||||
"endDate": "2099-12-31 00:00:00.0",
|
"endDate": "2099-12-31 00:00:00.0",
|
||||||
"salePrice": 1,
|
"salePrice": 1,
|
||||||
"saleStartDate": "2017-12-05 07:00:00.0",
|
"saleStartDate": "2099-12-31 07:00:00.0",
|
||||||
"saleEndDate": "2099-12-31 00:00:00.0",
|
"saleEndDate": "2099-12-31 00:00:00.0",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"length": len(charges), "gameChargeList": charges}
|
return {"length": len(charges), "gameChargeList": charges}
|
||||||
|
|
||||||
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
||||||
@ -787,6 +788,7 @@ class ChuniBase:
|
|||||||
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
|
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
|
||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
|
with self.data.session.begin():
|
||||||
if "userData" in upsert:
|
if "userData" in upsert:
|
||||||
try:
|
try:
|
||||||
upsert["userData"][0]["userName"] = self.read_wtf8(
|
upsert["userData"][0]["userName"] = self.read_wtf8(
|
||||||
@ -848,17 +850,6 @@ class ChuniBase:
|
|||||||
for song in upsert["userMusicDetailList"]:
|
for song in upsert["userMusicDetailList"]:
|
||||||
await self.data.score.put_score(user_id, song)
|
await self.data.score.put_score(user_id, song)
|
||||||
|
|
||||||
if "userPlaylogList" in upsert:
|
|
||||||
for playlog in upsert["userPlaylogList"]:
|
|
||||||
# convert the player names to utf-8
|
|
||||||
if playlog["playedUserName1"] is not None:
|
|
||||||
playlog["playedUserName1"] = self.read_wtf8(playlog["playedUserName1"])
|
|
||||||
if playlog["playedUserName2"] is not None:
|
|
||||||
playlog["playedUserName2"] = self.read_wtf8(playlog["playedUserName2"])
|
|
||||||
if playlog["playedUserName3"] is not None:
|
|
||||||
playlog["playedUserName3"] = self.read_wtf8(playlog["playedUserName3"])
|
|
||||||
await self.data.score.put_playlog(user_id, playlog, self.version)
|
|
||||||
|
|
||||||
if "userTeamPoint" in upsert:
|
if "userTeamPoint" in upsert:
|
||||||
team_points = upsert["userTeamPoint"]
|
team_points = upsert["userTeamPoint"]
|
||||||
try:
|
try:
|
||||||
@ -901,17 +892,6 @@ class ChuniBase:
|
|||||||
for rp in upsert["userRecentPlayerList"]:
|
for rp in upsert["userRecentPlayerList"]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for rating_type in {"userRatingBaseList", "userRatingBaseHotList", "userRatingBaseNextList"}:
|
|
||||||
if rating_type not in upsert:
|
|
||||||
continue
|
|
||||||
|
|
||||||
await self.data.profile.put_profile_rating(
|
|
||||||
user_id,
|
|
||||||
self.version,
|
|
||||||
rating_type,
|
|
||||||
upsert[rating_type],
|
|
||||||
)
|
|
||||||
|
|
||||||
# added in LUMINOUS
|
# added in LUMINOUS
|
||||||
if "userCMissionList" in upsert:
|
if "userCMissionList" in upsert:
|
||||||
for cmission in upsert["userCMissionList"]:
|
for cmission in upsert["userCMissionList"]:
|
||||||
@ -937,6 +917,29 @@ class ChuniBase:
|
|||||||
)
|
)
|
||||||
await self.data.profile.put_net_battle(user_id, net_battle)
|
await self.data.profile.put_net_battle(user_id, net_battle)
|
||||||
|
|
||||||
|
with self.data.session.begin():
|
||||||
|
for rating_type in {"userRatingBaseList", "userRatingBaseHotList", "userRatingBaseNextList"}:
|
||||||
|
if rating_type not in upsert:
|
||||||
|
continue
|
||||||
|
|
||||||
|
await self.data.profile.put_profile_rating(
|
||||||
|
user_id,
|
||||||
|
self.version,
|
||||||
|
rating_type,
|
||||||
|
upsert[rating_type],
|
||||||
|
)
|
||||||
|
|
||||||
|
if "userPlaylogList" in upsert:
|
||||||
|
for playlog in upsert["userPlaylogList"]:
|
||||||
|
# convert the player names to utf-8
|
||||||
|
if playlog["playedUserName1"] is not None:
|
||||||
|
playlog["playedUserName1"] = self.read_wtf8(playlog["playedUserName1"])
|
||||||
|
if playlog["playedUserName2"] is not None:
|
||||||
|
playlog["playedUserName2"] = self.read_wtf8(playlog["playedUserName2"])
|
||||||
|
if playlog["playedUserName3"] is not None:
|
||||||
|
playlog["playedUserName3"] = self.read_wtf8(playlog["playedUserName3"])
|
||||||
|
await self.data.score.put_playlog(user_id, playlog, self.version)
|
||||||
|
|
||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
async def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
async def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
||||||
|
Reference in New Issue
Block a user