mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-10 09:49:39 +08:00
Merge branch 'refs/heads/develop' into prism_plus_support
# Conflicts: # core/data/alembic/versions/16f34bf7b968_mai2_kaleidx_scope_support.py # core/data/alembic/versions/5cf98cfe52ad_mai2_prism_support.py # core/data/alembic/versions/5d7b38996e67_mai2_prism_support.py # core/data/alembic/versions/bdf710616ba4_mai2_add_prism_playlog_support.py # titles/mai2/index.py # titles/mai2/prism.py # titles/mai2/read.py # titles/mai2/schema/static.py
This commit is contained in:
165
core/allnet.py
165
core/allnet.py
@@ -586,39 +586,19 @@ class BillingServlet:
|
||||
rsa = RSA.import_key(open(self.config.billing.signing_key, "rb").read())
|
||||
signer = PKCS1_v1_5.new(rsa)
|
||||
digest = SHA.new()
|
||||
traces: List[TraceData] = []
|
||||
try:
|
||||
req = BillingInfo(req_dict[0])
|
||||
except KeyError as e:
|
||||
self.logger.error(f"Billing request failed to parse: {e}")
|
||||
return PlainTextResponse("result=5&linelimit=&message=field is missing or formatting is incorrect\r\n")
|
||||
|
||||
for x in range(1, len(req_dict)):
|
||||
if not req_dict[x]:
|
||||
continue
|
||||
|
||||
try:
|
||||
tmp = TraceData(req_dict[x])
|
||||
if tmp.trace_type == TraceDataType.CHARGE:
|
||||
tmp = TraceDataCharge(req_dict[x])
|
||||
elif tmp.trace_type == TraceDataType.EVENT:
|
||||
tmp = TraceDataEvent(req_dict[x])
|
||||
elif tmp.trace_type == TraceDataType.CREDIT:
|
||||
tmp = TraceDataCredit(req_dict[x])
|
||||
|
||||
traces.append(tmp)
|
||||
|
||||
except KeyError as e:
|
||||
self.logger.warning(f"Tracelog failed to parse: {e}")
|
||||
|
||||
kc_serial_bytes = req.keychipid.encode()
|
||||
|
||||
|
||||
machine = await self.data.arcade.get_machine(req.keychipid)
|
||||
if machine is None and not self.config.server.allow_unregistered_serials:
|
||||
msg = f"Unrecognised serial {req.keychipid} attempted billing checkin from {request_ip} for {req.gameid} v{req.gamever}."
|
||||
await self.data.base.log_event(
|
||||
"allnet", "BILLING_CHECKIN_NG_SERIAL", logging.WARN, msg, ip=request_ip, game=req.gameid, version=req.gamever
|
||||
"allnet", "BILLING_CHECKIN_NG_SERIAL", logging.WARN, msg, ip=request_ip, game=req.gameid, version=str(req.gamever)
|
||||
)
|
||||
self.logger.warning(msg)
|
||||
|
||||
@@ -629,18 +609,101 @@ class BillingServlet:
|
||||
"billing_type": req.billingtype.name,
|
||||
"nearfull": req.nearfull,
|
||||
"playlimit": req.playlimit,
|
||||
"messages": []
|
||||
}
|
||||
playhist = "000000/0:000000/0:000000/0"
|
||||
|
||||
if machine is not None:
|
||||
await self.data.base.log_event("billing", "BILLING_CHECKIN_OK", logging.INFO, "", log_details, None, machine['arcade'], machine['id'], request_ip, req.gameid, req.gamever)
|
||||
if self.config.allnet.save_billing:
|
||||
lastcredit = await self.data.arcade.billing_get_last_playcount(machine['id'], req.gameid)
|
||||
if lastcredit is not None:
|
||||
last_playct = lastcredit['playct']
|
||||
else:
|
||||
last_playct = 0
|
||||
|
||||
# Technically if a cab resets it's playcount and then does more plays then the previous
|
||||
# playcount before a billing checkin occours, we will lose plays equal to the current playcount.
|
||||
if req.playcnt < last_playct: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt)
|
||||
elif req.playcnt == last_playct: pass # No plays since last checkin, skip update
|
||||
else: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt - last_playct)
|
||||
|
||||
plays = await self.data.arcade.billing_get_playcount_3mo(machine['id'], req.gameid)
|
||||
if plays is not None and len(plays) > 0:
|
||||
playhist = ""
|
||||
|
||||
for x in range(len(plays) - 1, -1, -1): playhist += f"{plays[x]['year']:04d}{plays[x]['month']:02d}/{plays[x]['playct']}:"
|
||||
playhist = playhist[:-1]
|
||||
|
||||
for x in range(1, len(req_dict)):
|
||||
if not req_dict[x]:
|
||||
continue
|
||||
|
||||
try:
|
||||
tmp = TraceData(req_dict[x])
|
||||
if tmp.trace_type == TraceDataType.CHARGE:
|
||||
tmp = TraceDataCharge(req_dict[x])
|
||||
if self.config.allnet.save_billing:
|
||||
await self.data.arcade.billing_add_charge(
|
||||
machine['id'],
|
||||
tmp.game_id,
|
||||
float(tmp.game_version),
|
||||
tmp.play_count,
|
||||
tmp.play_limit,
|
||||
tmp.product_code,
|
||||
tmp.product_count,
|
||||
tmp.func_type,
|
||||
tmp.player_number
|
||||
)
|
||||
|
||||
self.logger.info(
|
||||
f"Charge Trace from {req.keychipid}: {tmp.game_id} v{tmp.game_version} - player {tmp.player_number} got {tmp.product_count} of {tmp.product_code} func {tmp.func_type}"
|
||||
)
|
||||
|
||||
elif tmp.trace_type == TraceDataType.EVENT:
|
||||
tmp = TraceDataEvent(req_dict[x])
|
||||
log_details['messages'].append(tmp.message)
|
||||
self.logger.info(f"Event Trace from {req.keychipid}: {tmp.message}")
|
||||
|
||||
elif tmp.trace_type == TraceDataType.CREDIT:
|
||||
tmp = TraceDataCredit(req_dict[x])
|
||||
if self.config.allnet.save_billing:
|
||||
await self.data.arcade.billing_set_credit(
|
||||
machine['id'],
|
||||
req.gameid,
|
||||
tmp.chute_type.value,
|
||||
tmp.service_type.value,
|
||||
tmp.operation_type.value,
|
||||
tmp.coin_rate0,
|
||||
tmp.coin_rate1,
|
||||
tmp.bonus_addition,
|
||||
tmp.credit_rate,
|
||||
tmp.credit0,
|
||||
tmp.credit1,
|
||||
tmp.credit2,
|
||||
tmp.credit3,
|
||||
tmp.credit4,
|
||||
tmp.credit5,
|
||||
tmp.credit6,
|
||||
tmp.credit7
|
||||
)
|
||||
|
||||
self.logger.info(
|
||||
f"Credit Trace from {req.keychipid}: {tmp.operation_type} mode, {tmp.credit_rate} coins per credit, breakdown: {tmp.credit0} | {tmp.credit1} | {tmp.credit2} | {tmp.credit3} | {tmp.credit4} | {tmp.credit5} | {tmp.credit6} | {tmp.credit7} | "
|
||||
)
|
||||
|
||||
except KeyError as e:
|
||||
self.logger.warning(f"Tracelog failed to parse: {e}")
|
||||
|
||||
await self.data.base.log_event("billing", "BILLING_CHECKIN_OK", logging.INFO, "", log_details, None, machine['arcade'], machine['id'], request_ip, req.gameid, str(req.gamever))
|
||||
|
||||
self.logger.info(
|
||||
f"Billing checkin from {request_ip}: game {req.gameid} ver {req.gamever} keychip {req.keychipid} playcount "
|
||||
f"{req.playcnt} billing_type {req.billingtype.name} nearfull {req.nearfull} playlimit {req.playlimit}"
|
||||
)
|
||||
|
||||
else:
|
||||
log_details['serial'] = req.keychipid
|
||||
await self.data.base.log_event("billing", "BILLING_CHECKIN_OK_UNREG", logging.INFO, "", log_details, None, None, None, request_ip, req.gameid, req.gamever)
|
||||
await self.data.base.log_event("billing", "BILLING_CHECKIN_OK_UNREG", logging.INFO, "", log_details, None, None, None, request_ip, req.gameid, str(req.gamever))
|
||||
|
||||
self.logger.info(
|
||||
f"Unregistered Billing checkin from {request_ip}: game {req.gameid} ver {req.gamever} keychip {req.keychipid} playcount "
|
||||
@@ -649,15 +712,12 @@ class BillingServlet:
|
||||
|
||||
if req.traceleft > 0:
|
||||
self.logger.warning(f"{req.traceleft} unsent tracelogs")
|
||||
kc_playlimit = req.playlimit
|
||||
kc_nearfull = req.nearfull
|
||||
|
||||
while req.playcnt > req.playlimit:
|
||||
kc_playlimit += 1024
|
||||
kc_nearfull += 1024
|
||||
playlimit = req.playlimit
|
||||
while req.playcnt > playlimit:
|
||||
playlimit += 1024
|
||||
|
||||
playlimit = kc_playlimit
|
||||
nearfull = kc_nearfull + (req.billingtype.value * 0x00010000)
|
||||
nearfull = req.nearfull + (req.billingtype.value * 0x00010000)
|
||||
|
||||
digest.update(playlimit.to_bytes(4, "little") + kc_serial_bytes)
|
||||
playlimit_sig = signer.sign(digest).hex()
|
||||
@@ -666,14 +726,12 @@ class BillingServlet:
|
||||
digest.update(nearfull.to_bytes(4, "little") + kc_serial_bytes)
|
||||
nearfull_sig = signer.sign(digest).hex()
|
||||
|
||||
# TODO: playhistory
|
||||
|
||||
resp = BillingResponse(playlimit, playlimit_sig, nearfull, nearfull_sig, req.requestno, req.protocolver)
|
||||
resp = BillingResponse(playlimit, playlimit_sig, nearfull, nearfull_sig, req.requestno, req.protocolver, playhist)
|
||||
|
||||
resp_str = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\r\n"
|
||||
|
||||
self.logger.debug(f"response {vars(resp)}")
|
||||
if req.traceleft > 0:
|
||||
if req.traceleft > 0: # TODO: should probably move this up so we don't do a ton of work that doesn't get used
|
||||
self.logger.info(f"Requesting 20 more of {req.traceleft} unsent tracelogs")
|
||||
return PlainTextResponse("result=6&waittime=0&linelimit=20\r\n")
|
||||
|
||||
@@ -768,14 +826,27 @@ class BillingType(Enum):
|
||||
A = 1
|
||||
B = 0
|
||||
|
||||
class TraceDataCreditChuteType(Enum):
|
||||
COMMON = 0
|
||||
INDIVIDUAL = 1
|
||||
|
||||
class TraceDataCreditOperationType(Enum):
|
||||
COIN = 0
|
||||
FREEPLAY = 1
|
||||
|
||||
class float5:
|
||||
def __init__(self, n: str = "0") -> None:
|
||||
def __init__(self, n: str = "0"):
|
||||
nf = float(n)
|
||||
if nf > 999.9 or nf < 0:
|
||||
raise ValueError('float5 must be between 0.000 and 999.9 inclusive')
|
||||
|
||||
return nf
|
||||
self.val = nf
|
||||
|
||||
def __float__(self) -> float:
|
||||
return self.val
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"%.{2 - int(math.log10(self.val))+1}f" % self.val
|
||||
|
||||
@classmethod
|
||||
def to_str(cls, f: float):
|
||||
return f"%.{2 - int(math.log10(f))+1}f" % f
|
||||
@@ -786,13 +857,13 @@ class BillingInfo:
|
||||
self.keychipid = str(data.get("keychipid", None))
|
||||
self.functype = int(data.get("functype", None))
|
||||
self.gameid = str(data.get("gameid", None))
|
||||
self.gamever = float(data.get("gamever", None))
|
||||
self.gamever = float5(data.get("gamever", None))
|
||||
self.boardid = str(data.get("boardid", None))
|
||||
self.tenpoip = str(data.get("tenpoip", None))
|
||||
self.libalibver = float(data.get("libalibver", None))
|
||||
self.libalibver = float5(data.get("libalibver", None))
|
||||
self.datamax = int(data.get("datamax", None))
|
||||
self.billingtype = BillingType(int(data.get("billingtype", None)))
|
||||
self.protocolver = float(data.get("protocolver", None))
|
||||
self.protocolver = float5(data.get("protocolver", None))
|
||||
self.operatingfix = bool(data.get("operatingfix", None))
|
||||
self.traceleft = int(data.get("traceleft", None))
|
||||
self.requestno = int(data.get("requestno", None))
|
||||
@@ -825,7 +896,7 @@ class TraceData:
|
||||
self.date = datetime.strptime(data.get("dt", None), BILLING_DT_FORMAT)
|
||||
|
||||
self.keychip = str(data.get("kn", None))
|
||||
self.lib_ver = float(data.get("alib", 0))
|
||||
self.lib_ver = float5(data.get("alib", 0))
|
||||
except Exception as e:
|
||||
raise KeyError(e)
|
||||
|
||||
@@ -834,7 +905,7 @@ class TraceDataCharge(TraceData):
|
||||
super().__init__(data)
|
||||
try:
|
||||
self.game_id = str(data.get("gi", None)) # these seem optional...?
|
||||
self.game_version = float(data.get("gv", 0))
|
||||
self.game_version = float5(data.get("gv", 0))
|
||||
self.board_serial = str(data.get("bn", None))
|
||||
self.shop_ip = str(data.get("ti", None))
|
||||
self.play_count = int(data.get("pc", None))
|
||||
@@ -858,9 +929,9 @@ class TraceDataCredit(TraceData):
|
||||
def __init__(self, data: Dict) -> None:
|
||||
super().__init__(data)
|
||||
try:
|
||||
self.chute_type = int(data.get("cct", None))
|
||||
self.service_type = int(data.get("cst", None))
|
||||
self.operation_type = int(data.get("cop", None))
|
||||
self.chute_type = TraceDataCreditChuteType(int(data.get("cct", None)))
|
||||
self.service_type = TraceDataCreditChuteType(int(data.get("cst", None)))
|
||||
self.operation_type = TraceDataCreditOperationType(int(data.get("cop", None)))
|
||||
self.coin_rate0 = int(data.get("cr0", None))
|
||||
self.coin_rate1 = int(data.get("cr1", None))
|
||||
self.bonus_addition = int(data.get("cba", None))
|
||||
@@ -884,7 +955,7 @@ class BillingResponse:
|
||||
nearfull: str = "",
|
||||
nearfull_sig: str = "",
|
||||
request_num: int = 1,
|
||||
protocol_ver: float = 1.000,
|
||||
protocol_ver: float5 = float5("1.000"),
|
||||
playhistory: str = "000000/0:000000/0:000000/0",
|
||||
) -> None:
|
||||
self.result = 0
|
||||
@@ -898,7 +969,7 @@ class BillingResponse:
|
||||
self.nearfull = nearfull
|
||||
self.nearfullsig = nearfull_sig
|
||||
self.linelimit = 100
|
||||
self.protocolver = float5.to_str(protocol_ver)
|
||||
self.protocolver = str(protocol_ver)
|
||||
# playhistory -> YYYYMM/C:...
|
||||
# YYYY -> 4 digit year, MM -> 2 digit month, C -> Playcount during that period
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ class AllnetConfig:
|
||||
)
|
||||
|
||||
@property
|
||||
def allow_online_updates(self) -> int:
|
||||
def allow_online_updates(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "allow_online_updates", default=False
|
||||
)
|
||||
@@ -373,6 +373,12 @@ class AllnetConfig:
|
||||
self.__config, "core", "allnet", "update_cfg_folder", default=""
|
||||
)
|
||||
|
||||
@property
|
||||
def save_billing(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "save_billing", default=False
|
||||
)
|
||||
|
||||
class BillingConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
164
core/data/alembic/versions/263884e774cc_acc_opt_tables.py
Normal file
164
core/data/alembic/versions/263884e774cc_acc_opt_tables.py
Normal file
@@ -0,0 +1,164 @@
|
||||
"""acc_opt_tables
|
||||
|
||||
Revision ID: 263884e774cc
|
||||
Revises: 1d0014d35220
|
||||
Create Date: 2025-04-07 18:05:53.349320
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '263884e774cc'
|
||||
down_revision = '1d0014d35220'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('chuni_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='chuni_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('cm_static_opts',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=True),
|
||||
sa.Column('gekiVersion', sa.INTEGER(), nullable=True),
|
||||
sa.Column('gekiReleaseVer', sa.INTEGER(), nullable=True),
|
||||
sa.Column('maiVersion', sa.INTEGER(), nullable=True),
|
||||
sa.Column('maiReleaseVer', sa.INTEGER(), nullable=True),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='cm_static_opts_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('mai2_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('cmReleaseVer', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='mai2_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('ongeki_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('cmReleaseVer', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='ongeki_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('chuni_static_avatar', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_avatar', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_cards', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_character', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_character', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_charge', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_charge', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_events', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_events', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_gachas', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_gachas', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_login_bonus', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_login_bonus', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_login_bonus_preset', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_login_bonus_preset', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_map_icon', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_map_icon', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_music', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_system_voice', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_system_voice', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_trophy', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_trophy', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_cards', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_event', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_event', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_music', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_ticket', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_ticket', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_cards', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_events', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_events', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_gachas', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_gachas', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_music', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_rewards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_rewards', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("ongeki_static_rewards_ibfk_1", 'ongeki_static_rewards', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_rewards', 'opt')
|
||||
op.drop_constraint("ongeki_static_music_ibfk_1", 'ongeki_static_music', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_music', 'opt')
|
||||
op.drop_constraint("ongeki_static_gachas_ibfk_1", 'ongeki_static_gachas', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_gachas', 'opt')
|
||||
op.drop_constraint("ongeki_static_events_ibfk_1", "ongeki_static_events", type_='foreignkey')
|
||||
op.drop_column('ongeki_static_events', 'opt')
|
||||
op.drop_constraint("ongeki_static_cards_ibfk_1", "ongeki_static_cards", type_='foreignkey')
|
||||
op.drop_column('ongeki_static_cards', 'opt')
|
||||
op.drop_constraint("mai2_static_ticket_ibfk_1", "mai2_static_ticket", type_='foreignkey')
|
||||
op.drop_column('mai2_static_ticket', 'opt')
|
||||
op.drop_constraint("mai2_static_music_ibfk_1", "mai2_static_music", type_='foreignkey')
|
||||
op.drop_column('mai2_static_music', 'opt')
|
||||
op.drop_constraint("mai2_static_event_ibfk_1", "mai2_static_event", type_='foreignkey')
|
||||
op.drop_column('mai2_static_event', 'opt')
|
||||
op.drop_constraint("mai2_static_cards_ibfk_1", "mai2_static_cards", type_='foreignkey')
|
||||
op.drop_column('mai2_static_cards', 'opt')
|
||||
op.drop_constraint("chuni_static_trophy_ibfk_1", "chuni_static_trophy", type_='foreignkey')
|
||||
op.drop_column('chuni_static_trophy', 'opt')
|
||||
op.drop_constraint("chuni_static_system_voice_ibfk_1", "chuni_static_system_voice", type_='foreignkey')
|
||||
op.drop_column('chuni_static_system_voice', 'opt')
|
||||
op.drop_constraint("chuni_static_music_ibfk_1", "chuni_static_music", type_='foreignkey')
|
||||
op.drop_column('chuni_static_music', 'opt')
|
||||
op.drop_constraint("chuni_static_map_icon_ibfk_1", "chuni_static_map_icon", type_='foreignkey')
|
||||
op.drop_column('chuni_static_map_icon', 'opt')
|
||||
op.drop_constraint("chuni_static_login_bonus_preset_ibfk_1", "chuni_static_login_bonus_preset", type_='foreignkey')
|
||||
op.drop_column('chuni_static_login_bonus_preset', 'opt')
|
||||
op.drop_constraint("chuni_static_login_bonus_ibfk_2", "chuni_static_login_bonus", type_='foreignkey')
|
||||
op.drop_column('chuni_static_login_bonus', 'opt')
|
||||
op.drop_constraint("chuni_static_gachas_ibfk_1", "chuni_static_gachas", type_='foreignkey')
|
||||
op.drop_column('chuni_static_gachas', 'opt')
|
||||
op.drop_constraint("chuni_static_events_ibfk_1", "chuni_static_events", type_='foreignkey')
|
||||
op.drop_column('chuni_static_events', 'opt')
|
||||
op.drop_constraint("chuni_static_charge_ibfk_1", "chuni_static_charge", type_='foreignkey')
|
||||
op.drop_column('chuni_static_charge', 'opt')
|
||||
op.drop_constraint("chuni_static_character_ibfk_1", "chuni_static_character", type_='foreignkey')
|
||||
op.drop_column('chuni_static_character', 'opt')
|
||||
op.drop_constraint("chuni_static_cards_ibfk_1", "chuni_static_cards", type_='foreignkey')
|
||||
op.drop_column('chuni_static_cards', 'opt')
|
||||
op.drop_constraint("chuni_static_avatar_ibfk_1", "chuni_static_avatar", type_='foreignkey')
|
||||
op.drop_column('chuni_static_avatar', 'opt')
|
||||
op.drop_table('ongeki_static_opt')
|
||||
op.drop_table('mai2_static_opt')
|
||||
op.drop_table('cm_static_opts')
|
||||
op.drop_table('chuni_static_opt')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,66 @@
|
||||
"""add_billing_tables
|
||||
|
||||
Revision ID: 27e3434740df
|
||||
Revises: ae364c078429
|
||||
Create Date: 2025-04-17 18:32:06.008601
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '27e3434740df'
|
||||
down_revision = 'ae364c078429'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('machine_billing_charge',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('game_id', sa.CHAR(length=5), nullable=False),
|
||||
sa.Column('game_ver', sa.FLOAT(), nullable=False),
|
||||
sa.Column('play_count', sa.INTEGER(), nullable=False),
|
||||
sa.Column('play_limit', sa.INTEGER(), nullable=False),
|
||||
sa.Column('product_code', sa.INTEGER(), nullable=False),
|
||||
sa.Column('product_count', sa.INTEGER(), nullable=False),
|
||||
sa.Column('func_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('player_number', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('machine_billing_credit',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('chute_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('service_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('operation_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_rate0', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_rate1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_bonus', sa.INTEGER(), nullable=False),
|
||||
sa.Column('credit_rate', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot0', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot3', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot4', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot5', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot6', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot7', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('machine'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('machine_billing_credit')
|
||||
op.drop_table('machine_billing_charge')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,8 +1,14 @@
|
||||
"""Mai2 PRiSM support
|
||||
|
||||
<<<<<<<< HEAD:core/data/alembic/versions/5d7b38996e67_mai2_prism_support.py
|
||||
Revision ID: 5d7b38996e67
|
||||
Revises: 1d0014d35220
|
||||
Create Date: 2025-04-04 06:28:24.898912
|
||||
========
|
||||
Revision ID: 5cf98cfe52ad
|
||||
Revises: 263884e774cc
|
||||
Create Date: 2025-04-08 08:00:51.243089
|
||||
>>>>>>>> refs/heads/develop:core/data/alembic/versions/5cf98cfe52ad_mai2_prism_support.py
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -10,14 +16,20 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
<<<<<<<< HEAD:core/data/alembic/versions/5d7b38996e67_mai2_prism_support.py
|
||||
revision = '5d7b38996e67'
|
||||
down_revision = '1d0014d35220'
|
||||
========
|
||||
revision = '5cf98cfe52ad'
|
||||
down_revision = '263884e774cc'
|
||||
>>>>>>>> refs/heads/develop:core/data/alembic/versions/5cf98cfe52ad_mai2_prism_support.py
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
<<<<<<<< HEAD:core/data/alembic/versions/5d7b38996e67_mai2_prism_support.py
|
||||
op.create_table('mai2_static_kaleidxscope_condition',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('conditionId', sa.Integer(), nullable=True),
|
||||
@@ -28,6 +40,8 @@ def upgrade():
|
||||
sa.UniqueConstraint('conditionId', 'conditionName', 'songId', 'songName', name='mai2_static_kaleidxscope_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
========
|
||||
>>>>>>>> refs/heads/develop:core/data/alembic/versions/5cf98cfe52ad_mai2_prism_support.py
|
||||
op.create_table('mai2_score_kaleidxscope',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user', sa.Integer(), nullable=False),
|
||||
@@ -59,5 +73,8 @@ def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('mai2_playlog', 'extBool2')
|
||||
op.drop_table('mai2_score_kaleidxscope')
|
||||
<<<<<<<< HEAD:core/data/alembic/versions/5d7b38996e67_mai2_prism_support.py
|
||||
op.drop_table('mai2_static_kaleidxscope_condition')
|
||||
========
|
||||
>>>>>>>> refs/heads/develop:core/data/alembic/versions/5cf98cfe52ad_mai2_prism_support.py
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,30 @@
|
||||
"""chuni_nameplate_add_opt
|
||||
|
||||
Revision ID: ae364c078429
|
||||
Revises: 5cf98cfe52ad
|
||||
Create Date: 2025-04-08 00:22:22.370660
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ae364c078429'
|
||||
down_revision = '5cf98cfe52ad'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('chuni_static_nameplate', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_nameplate', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("chuni_static_nameplate_ibfk_1", 'chuni_static_nameplate', type_='foreignkey')
|
||||
op.drop_column('chuni_static_nameplate', 'opt')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""Mai2 add PRiSM+ playlog support
|
||||
|
||||
Revision ID: bdf710616ba4
|
||||
Revises: 16f34bf7b968
|
||||
Create Date: 2025-04-02 12:42:08.981516
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bdf710616ba4'
|
||||
down_revision = '16f34bf7b968'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('mai2_playlog', sa.Column('extBool3', sa.Boolean(), nullable=True,server_default=sa.text("NULL")))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('mai2_playlog', 'extBool3')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,50 @@
|
||||
"""add_billing_playcount
|
||||
|
||||
Revision ID: f6007bbf057d
|
||||
Revises: 27e3434740df
|
||||
Create Date: 2025-04-19 18:20:35.554137
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f6007bbf057d'
|
||||
down_revision = '27e3434740df'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('machine_billing_playcount',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('game_id', sa.CHAR(length=5), nullable=False),
|
||||
sa.Column('year', sa.INTEGER(), nullable=False),
|
||||
sa.Column('month', sa.INTEGER(), nullable=False),
|
||||
sa.Column('playct', sa.BIGINT(), server_default='1', nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('machine'),
|
||||
sa.UniqueConstraint('machine', 'game_id', 'year', 'month', name='machine_billing_playcount_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('machine_billing_credit', sa.Column('game_id', sa.CHAR(length=5), nullable=False))
|
||||
op.drop_constraint("machine_billing_credit_ibfk_1", "machine_billing_credit", "foreignkey")
|
||||
op.drop_index('machine', table_name='machine_billing_credit')
|
||||
op.create_unique_constraint('machine_billing_credit_uk', 'machine_billing_credit', ['machine', 'game_id'])
|
||||
op.create_foreign_key("machine_billing_credit_ibfk_1", "machine_billing_credit", "machine", ["machine"], ["id"], onupdate='cascade', ondelete='cascade')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("machine_billing_credit_ibfk_1", "machine_billing_credit", "foreignkey")
|
||||
op.drop_constraint('machine_billing_credit_uk', 'machine_billing_credit', type_='unique')
|
||||
op.create_index('machine', 'machine_billing_credit', ['machine'], unique=True)
|
||||
op.create_foreign_key("machine_billing_credit_ibfk_1", "machine_billing_credit", "machine", ["machine"], ["id"], onupdate='cascade', ondelete='cascade')
|
||||
op.drop_column('machine_billing_credit', 'game_id')
|
||||
op.drop_table('machine_billing_playcount')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,12 +1,13 @@
|
||||
import re
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, Table, and_, or_
|
||||
from sqlalchemy import Column, Table, and_, or_, UniqueConstraint
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.sql.schema import ForeignKey, PrimaryKeyConstraint
|
||||
from sqlalchemy.types import JSON, Boolean, Integer, String
|
||||
from sqlalchemy.types import JSON, Boolean, Integer, String, BIGINT, INTEGER, CHAR, FLOAT
|
||||
|
||||
from core.data.schema.base import BaseData, metadata
|
||||
|
||||
@@ -67,6 +68,76 @@ arcade_owner: Table = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
billing_charge: Table = Table(
|
||||
"machine_billing_charge",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("game_ver", FLOAT, nullable=False),
|
||||
Column("play_count", INTEGER, nullable=False),
|
||||
Column("play_limit", INTEGER, nullable=False),
|
||||
Column("product_code", INTEGER, nullable=False),
|
||||
Column("product_count", INTEGER, nullable=False),
|
||||
Column("func_type", INTEGER, nullable=False),
|
||||
Column("player_number", INTEGER, nullable=False),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
# These settings are only really of interest
|
||||
# for real cabinets operating as pay-to-play
|
||||
billing_credit: Table = Table(
|
||||
"machine_billing_credit",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("chute_type", INTEGER, nullable=False),
|
||||
Column("service_type", INTEGER, nullable=False),
|
||||
Column("operation_type", INTEGER, nullable=False),
|
||||
Column("coin_rate0", INTEGER, nullable=False),
|
||||
Column("coin_rate1", INTEGER, nullable=False),
|
||||
Column("coin_bonus", INTEGER, nullable=False),
|
||||
Column("credit_rate", INTEGER, nullable=False),
|
||||
Column("coin_count_slot0", INTEGER, nullable=False),
|
||||
Column("coin_count_slot1", INTEGER, nullable=False),
|
||||
Column("coin_count_slot2", INTEGER, nullable=False),
|
||||
Column("coin_count_slot3", INTEGER, nullable=False),
|
||||
Column("coin_count_slot4", INTEGER, nullable=False),
|
||||
Column("coin_count_slot5", INTEGER, nullable=False),
|
||||
Column("coin_count_slot6", INTEGER, nullable=False),
|
||||
Column("coin_count_slot7", INTEGER, nullable=False),
|
||||
UniqueConstraint("machine", "game_id", name="machine_billing_credit_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
billing_playct: Table = Table(
|
||||
"machine_billing_playcount",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False, unique=True
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("year", INTEGER, nullable=False),
|
||||
Column("month", INTEGER, nullable=False),
|
||||
Column("playct", BIGINT, nullable=False, server_default="1"),
|
||||
UniqueConstraint("machine", "game_id", "year", "month", name="machine_billing_playcount_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
class ArcadeData(BaseData):
|
||||
async def get_machine(self, serial: Optional[str] = None, id: Optional[int] = None) -> Optional[Row]:
|
||||
@@ -345,6 +416,120 @@ class ArcadeData(BaseData):
|
||||
return result.fetchone()['count_1']
|
||||
self.logger.error("Failed to count machine serials that start with A69A!")
|
||||
|
||||
async def billing_add_charge(self, machine_id: int, game_id: str, game_ver: float, playcount: int, playlimit, product_code: int, product_count: int, func_type: int, player_num: int) -> Optional[int]:
|
||||
result = await self.execute(billing_charge.insert().values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
game_ver=game_ver,
|
||||
play_count=playcount,
|
||||
play_limit=playlimit,
|
||||
product_code=product_code,
|
||||
product_count=product_count,
|
||||
func_type=func_type,
|
||||
player_number=player_num
|
||||
))
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to add billing charge for machine {machine_id}!")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def billing_get_last_charge(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_charge.select(
|
||||
and_(billing_charge.c.machine == machine_id, billing_charge.c.game_id == game_id)
|
||||
).order_by(billing_charge.c.id.desc()).limit(3))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def billing_set_credit(self, machine_id: int, game_id: str, chute_type: int, service_type: int, op_mode: int, coin_rate0: int, coin_rate1: int,
|
||||
bonus_adder: int, coin_to_credit_rate: int, coin_count_slot0: int, coin_count_slot1: int, coin_count_slot2: int, coin_count_slot3: int,
|
||||
coin_count_slot4: int, coin_count_slot5: int, coin_count_slot6: int, coin_count_slot7: int) -> Optional[int]:
|
||||
|
||||
sql = insert(billing_credit).values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
chute_type=chute_type,
|
||||
service_type=service_type,
|
||||
operation_type=op_mode,
|
||||
coin_rate0=coin_rate0,
|
||||
coin_rate1=coin_rate1,
|
||||
coin_bonus=bonus_adder,
|
||||
credit_rate=coin_to_credit_rate,
|
||||
coin_count_slot0=coin_count_slot0,
|
||||
coin_count_slot1=coin_count_slot1,
|
||||
coin_count_slot2=coin_count_slot2,
|
||||
coin_count_slot3=coin_count_slot3,
|
||||
coin_count_slot4=coin_count_slot4,
|
||||
coin_count_slot5=coin_count_slot5,
|
||||
coin_count_slot6=coin_count_slot6,
|
||||
coin_count_slot7=coin_count_slot7,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
chute_type=chute_type,
|
||||
service_type=service_type,
|
||||
operation_type=op_mode,
|
||||
coin_rate0=coin_rate0,
|
||||
coin_rate1=coin_rate1,
|
||||
coin_bonus=bonus_adder,
|
||||
credit_rate=coin_to_credit_rate,
|
||||
coin_count_slot0=coin_count_slot0,
|
||||
coin_count_slot1=coin_count_slot1,
|
||||
coin_count_slot2=coin_count_slot2,
|
||||
coin_count_slot3=coin_count_slot3,
|
||||
coin_count_slot4=coin_count_slot4,
|
||||
coin_count_slot5=coin_count_slot5,
|
||||
coin_count_slot6=coin_count_slot6,
|
||||
coin_count_slot7=coin_count_slot7,
|
||||
)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to set billing credit settings for machine {machine_id}!")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def billing_get_credit(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_credit.select(
|
||||
and_(billing_credit.c.machine == machine_id, billing_credit.c.game_id == game_id)
|
||||
))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def billing_add_playcount(self, machine_id: int, game_id: str, playct: int = 1) -> None:
|
||||
now = datetime.now()
|
||||
sql = insert(billing_playct).values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
year=now.year,
|
||||
month=now.month,
|
||||
playct=playct
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(playct=billing_playct.c.playct + playct)
|
||||
result = await self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to add playcount for machine {machine_id} running {game_id}")
|
||||
|
||||
async def billing_get_playcount_3mo(self, machine_id: int, game_id: str) -> Optional[List[Row]]:
|
||||
result = await self.execute(billing_playct.select(and_(
|
||||
billing_playct.c.machine == machine_id,
|
||||
billing_playct.c.game_id == game_id
|
||||
)).order_by(billing_playct.c.year.desc(), billing_playct.c.month.desc()).limit(3))
|
||||
|
||||
if result is not None:
|
||||
return result.fetchall()
|
||||
|
||||
async def billing_get_last_playcount(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_playct.select(and_(
|
||||
billing_playct.c.machine == machine_id,
|
||||
billing_playct.c.game_id == game_id
|
||||
)).order_by(billing_playct.c.year.desc(), billing_playct.c.month.desc()).limit(1))
|
||||
|
||||
if result is not None:
|
||||
return result.fetchone()
|
||||
|
||||
def format_serial(
|
||||
self, platform_code: str, platform_rev: int, serial_letter: str, serial_num: int, append: int, dash: bool = False
|
||||
) -> str:
|
||||
@@ -371,7 +556,6 @@ class ArcadeData(BaseData):
|
||||
month = ((month - 1) + 9) % 12 # Offset so April=0
|
||||
return f"{year:02}{month // 6:01}{month % 6 + 1:01}"
|
||||
|
||||
|
||||
def parse_keychip_suffix(self, suffix: str) -> tuple[int, int]:
|
||||
year = int(suffix[0:2])
|
||||
half = int(suffix[2])
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime, timezone
|
||||
from os import walk
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, Optional
|
||||
import math
|
||||
|
||||
import jwt
|
||||
from starlette.requests import Request
|
||||
@@ -92,6 +93,8 @@ class Utils:
|
||||
|
||||
return cls.real_title_port_ssl
|
||||
|
||||
def floor_to_nearest_005(version: int) -> int:
|
||||
return (version // 5) * 5
|
||||
|
||||
def create_sega_auth_key(
|
||||
aime_id: int,
|
||||
|
||||
Reference in New Issue
Block a user