mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2025-12-14 08:06:23 +08:00
Update to v2.8.2 without release
- Try to add support for Anniversary 5 ticket - Update the song database > Well, there may be bugs with Anniversary 5 ticket. Remember it can only be used when the pack is on sale.
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,7 @@ import json
|
||||
|
||||
# 数据库初始化文件,删掉arcaea_database.db文件后运行即可,谨慎使用
|
||||
|
||||
ARCAEA_SERVER_VERSION = 'v2.8.1'
|
||||
ARCAEA_SERVER_VERSION = 'v2.8.2'
|
||||
|
||||
|
||||
def main(path='./'):
|
||||
@@ -223,7 +223,8 @@ def main(path='./'):
|
||||
price int,
|
||||
orig_price int,
|
||||
discount_from int,
|
||||
discount_to int
|
||||
discount_to int,
|
||||
discount_reason text
|
||||
);''')
|
||||
c.execute('''create table if not exists purchase_item(purchase_name text,
|
||||
item_id text,
|
||||
@@ -399,6 +400,8 @@ def main(path='./'):
|
||||
('fragment', 'fragment', 1, ''))
|
||||
c.execute('''insert into item values(?,?,?,?)''',
|
||||
('memory', 'memory', 1, ''))
|
||||
c.execute('''insert into item values(?,?,?,?)''',
|
||||
('anni5tix', 'anni5tix', 1, ''))
|
||||
|
||||
def insert_items(c, items):
|
||||
# 物品数据导入
|
||||
@@ -411,8 +414,12 @@ def main(path='./'):
|
||||
discount_to = -1
|
||||
else:
|
||||
discount_to = i['discount_to']
|
||||
c.execute('''insert into purchase values(?,?,?,?,?)''',
|
||||
(i['name'], i['price'], i['orig_price'], discount_from, discount_to))
|
||||
if 'discount_reason' not in i:
|
||||
discount_reason = ''
|
||||
else:
|
||||
discount_reason = i['discount_reason']
|
||||
c.execute('''insert into purchase values(?,?,?,?,?,?)''',
|
||||
(i['name'], i['price'], i['orig_price'], discount_from, discount_to, discount_reason))
|
||||
for j in i['items']:
|
||||
if "_id" not in j:
|
||||
_id = ''
|
||||
|
||||
@@ -632,10 +632,11 @@ def pack(user_id):
|
||||
|
||||
# 单曲购买信息获取
|
||||
@app.route(add_url_prefix('/purchase/bundle/single'), methods=['GET'])
|
||||
def single():
|
||||
@server.auth.auth_required(request)
|
||||
def single(user_id):
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"value": server.arcpurchase.get_single_purchase()
|
||||
"value": server.arcpurchase.get_single_purchase(user_id)
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from server.sql import Connect
|
||||
import server.item
|
||||
import server.character
|
||||
import time
|
||||
import json
|
||||
|
||||
|
||||
def int2b(x):
|
||||
@@ -13,7 +12,7 @@ def int2b(x):
|
||||
return True
|
||||
|
||||
|
||||
def get_purchase(c, type='pack'):
|
||||
def get_purchase(c, user_id, type='pack'):
|
||||
# 读取packs内容,返回字典列表
|
||||
c.execute(
|
||||
'''select * from purchase where purchase_name in (select purchase_name from purchase_item where type = :a)''', {'a': type})
|
||||
@@ -50,7 +49,6 @@ def get_purchase(c, type='pack'):
|
||||
"amount": amount
|
||||
})
|
||||
|
||||
|
||||
if t is not None:
|
||||
# 放到列表头
|
||||
items = [t, items]
|
||||
@@ -62,19 +60,27 @@ def get_purchase(c, type='pack'):
|
||||
|
||||
if i[3] > 0:
|
||||
r['discount_from'] = i[3]
|
||||
if i[4] > 0:
|
||||
r['discount_to'] = i[4]
|
||||
if i[4] > 0:
|
||||
r['discount_to'] = i[4]
|
||||
|
||||
if i[5] == 'anni5tix' and i[3] <= int(time.time() * 1000) <= i[4]:
|
||||
c.execute(
|
||||
'''select amount from user_item where user_id=? and item_id="anni5tix"''', (user_id,))
|
||||
z = c.fetchone()
|
||||
if z and z[0] >= 1:
|
||||
r['discount_reason'] = 'anni5tix'
|
||||
r['price'] = 0
|
||||
|
||||
re.append(r)
|
||||
|
||||
return re
|
||||
|
||||
|
||||
def get_single_purchase():
|
||||
def get_single_purchase(user_id):
|
||||
# main里面没开数据库,这里写一下代替
|
||||
re = []
|
||||
with Connect() as c:
|
||||
re = get_purchase(c, type='single')
|
||||
re = get_purchase(c, user_id, 'single')
|
||||
|
||||
return re
|
||||
|
||||
@@ -98,6 +104,25 @@ def buy_item(c, user_id, price):
|
||||
return True, ticket - price
|
||||
|
||||
|
||||
def buy_item_with_anni5tix(c, user_id):
|
||||
# 兑换券购买接口,返回成功与否标志
|
||||
c.execute('''select amount from user_item where user_id = :a and item_id = "anni5tix"''',
|
||||
{'a': user_id})
|
||||
amount = c.fetchone()
|
||||
if amount:
|
||||
amount = amount[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
if amount <= 0:
|
||||
return False
|
||||
|
||||
c.execute('''update user_item set amount = :b where user_id = :a and item_id = "anni5tix"''',
|
||||
{'a': user_id, 'b': amount-1})
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def buy_thing(user_id, purchase_id):
|
||||
# 购买物品接口,返回字典
|
||||
success_flag = False
|
||||
@@ -107,7 +132,7 @@ def buy_thing(user_id, purchase_id):
|
||||
characters = []
|
||||
|
||||
with Connect() as c:
|
||||
c.execute('''select price, orig_price, discount_from, discount_to from purchase where purchase_name=:a''',
|
||||
c.execute('''select price, orig_price, discount_from, discount_to, discount_reason from purchase where purchase_name=:a''',
|
||||
{'a': purchase_id})
|
||||
x = c.fetchone()
|
||||
price = 0
|
||||
@@ -117,6 +142,7 @@ def buy_thing(user_id, purchase_id):
|
||||
orig_price = x[1]
|
||||
discount_from = x[2]
|
||||
discount_to = x[3]
|
||||
discount_reason = x[4]
|
||||
else:
|
||||
return {
|
||||
"success": False,
|
||||
@@ -130,6 +156,8 @@ def buy_thing(user_id, purchase_id):
|
||||
now = int(time.time() * 1000)
|
||||
if not(discount_from <= now <= discount_to):
|
||||
price = orig_price
|
||||
elif discount_reason == 'anni5tix' and buy_item_with_anni5tix(c, user_id):
|
||||
price = 0
|
||||
|
||||
flag, ticket = buy_item(c, user_id, price)
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ def get_user_me_c(user_id):
|
||||
def get_purchase_pack(user_id):
|
||||
# 返回曲包数据
|
||||
with Connect() as c:
|
||||
return server.arcpurchase.get_purchase(c, 'pack')
|
||||
return server.arcpurchase.get_purchase(c, user_id)
|
||||
|
||||
|
||||
def get_game_info():
|
||||
@@ -261,7 +261,7 @@ def arc_aggregate_big(user_id):
|
||||
"value": get_user_me(c, user_id)
|
||||
}, {
|
||||
"id": 1,
|
||||
"value": server.arcpurchase.get_purchase(c, 'pack')
|
||||
"value": server.arcpurchase.get_purchase(c, user_id)
|
||||
}, {
|
||||
"id": 2,
|
||||
"value": id_2
|
||||
|
||||
@@ -55,20 +55,20 @@ def claim_user_item(c, user_id, item_id, item_type, amount=1):
|
||||
else:
|
||||
return False
|
||||
|
||||
if item_type == 'core':
|
||||
if item_type in ['core', 'anni5tix']:
|
||||
c.execute(
|
||||
'''select amount from user_item where user_id=? and item_id=? and type="core"''', (user_id, item_id))
|
||||
'''select amount from user_item where user_id=? and item_id=? and type=?''', (user_id, item_id, item_type))
|
||||
x = c.fetchone()
|
||||
if x:
|
||||
if x[0] + amount < 0: # 数量不足
|
||||
return False
|
||||
c.execute('''update user_item set amount=? where user_id=? and item_id=? and type="core"''',
|
||||
(x[0]+amount, user_id, item_id))
|
||||
c.execute('''update user_item set amount=? where user_id=? and item_id=? and type=?''',
|
||||
(x[0]+amount, user_id, item_id, item_type))
|
||||
else:
|
||||
if amount < 0: # 添加数量错误
|
||||
return False
|
||||
c.execute('''insert into user_item values(?,?,"core",?)''',
|
||||
(user_id, item_id, amount))
|
||||
c.execute('''insert into user_item values(?,?,?,?)''',
|
||||
(user_id, item_id, item_type, amount))
|
||||
|
||||
elif item_type == 'memory':
|
||||
c.execute('''select ticket from user where user_id=?''', (user_id,))
|
||||
|
||||
@@ -19,7 +19,7 @@ class Config():
|
||||
游戏API地址前缀
|
||||
Game API's URL prefix
|
||||
'''
|
||||
GAME_API_PREFIX = '/bridge/18'
|
||||
GAME_API_PREFIX = '/years/19'
|
||||
'''
|
||||
--------------------
|
||||
'''
|
||||
@@ -30,7 +30,7 @@ class Config():
|
||||
Allowed game versions
|
||||
If it is blank, all are allowed.
|
||||
'''
|
||||
ALLOW_APPVERSION = ['3.5.3', '3.5.3c', '3.12.0', '3.12.0c']
|
||||
ALLOW_APPVERSION = ['3.5.3', '3.5.3c', '3.12.2', '3.12.2c']
|
||||
'''
|
||||
--------------------
|
||||
'''
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
<span>Discount to: </span>
|
||||
<span class="char-num">{{item['discount_to']}}</span>
|
||||
<br />
|
||||
|
||||
<span>Whether it is allowed to purchase with exchange certificate: </span>
|
||||
<span class="char-num">{{item['discount_reason']}}</span>
|
||||
<br />
|
||||
{% if item['items'] %}<br />
|
||||
{% for x in item['items'] %}
|
||||
<span>Item id: </span>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<option value='core'>Character core</option>
|
||||
<option value='fragment'>Fragment</option>
|
||||
<option value='memory'>Memory</option>
|
||||
<option value='anni5tix'>Anniversary 5 ticket</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for="amount">Amount</label>
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
<input type="datetime-local" name="discount_from" id="discount_from">
|
||||
<label for="discount_to">Discount to</label>
|
||||
<input type="datetime-local" name="discount_to" id="discount_to">
|
||||
<div>是否允许使用兑换券购买 Whether it is allowed to purchase with Anniversary 5 ticket:
|
||||
<label><input type="radio" name="discount_reason" value="0">No</label>
|
||||
<label><input type="radio" name="discount_reason" value="anni5tix">Yes</label>
|
||||
</div>
|
||||
<div class="content">时间填写是一个HTML5控件</div>
|
||||
<div class="content">Time filling is an HTML5 control.</div>
|
||||
<br />
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<option value='core'>Character core</option>
|
||||
<option value='fragment'>Fragment</option>
|
||||
<option value='memory'>Memory</option>
|
||||
<option value='anni5tix'>Anniversary 5 ticket</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for="amount">Amount</label>
|
||||
|
||||
@@ -764,6 +764,7 @@ def change_purchase():
|
||||
orig_price = request.form['orig_price']
|
||||
discount_from = request.form['discount_from']
|
||||
discount_to = request.form['discount_to']
|
||||
discount_reason = request.form['discount_reason']
|
||||
|
||||
if price:
|
||||
price = int(price)
|
||||
@@ -783,6 +784,10 @@ def change_purchase():
|
||||
discount_to, "%Y-%m-%dT%H:%M"))) * 1000
|
||||
else:
|
||||
discount_to = -1
|
||||
|
||||
if not discount_reason:
|
||||
discount_reason = ''
|
||||
|
||||
except:
|
||||
error = '数据错误 Wrong data.'
|
||||
flash(error)
|
||||
@@ -792,8 +797,8 @@ def change_purchase():
|
||||
c.execute(
|
||||
'''select exists(select * from purchase where purchase_name=:a)''', {'a': purchase_name})
|
||||
if c.fetchone() == (0,):
|
||||
c.execute('''insert into purchase values(?,?,?,?,?)''',
|
||||
(purchase_name, price, orig_price, discount_from, discount_to))
|
||||
c.execute('''insert into purchase values(?,?,?,?,?,?)''',
|
||||
(purchase_name, price, orig_price, discount_from, discount_to, discount_reason))
|
||||
|
||||
flash('购买项目添加成功 Successfully add the purchase.')
|
||||
else:
|
||||
|
||||
@@ -288,6 +288,7 @@ def get_all_purchase():
|
||||
|
||||
discount_from = None
|
||||
discount_to = None
|
||||
discount_reason = 'Yes' if i[5] == 'anni5tix' else 'No'
|
||||
|
||||
if i[3] and i[3] >= 0:
|
||||
discount_from = time.strftime(
|
||||
@@ -302,13 +303,15 @@ def get_all_purchase():
|
||||
items = []
|
||||
if y:
|
||||
for j in y:
|
||||
items.append({'item_id': j[1], 'type': j[2], 'amount':j[3]})
|
||||
items.append(
|
||||
{'item_id': j[1], 'type': j[2], 'amount': j[3]})
|
||||
|
||||
re.append({'purchase_name': i[0],
|
||||
'price': i[1],
|
||||
'orig_price': i[2],
|
||||
'discount_from': discount_from,
|
||||
'discount_to': discount_to,
|
||||
'discount_reason': discount_reason,
|
||||
'items': items
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user