This commit is contained in:
lwl0608 2024-02-05 00:12:25 +08:00
parent 8fc3468eae
commit a54908d362
1 changed files with 33 additions and 16 deletions

View File

@ -16,10 +16,8 @@ class S:
# 获取订单 # 获取订单
def get_orders(self): def get_orders(self):
sql = ''' sql = "select * from vas_order where ct<{} and order_status=1 and product_id='membership'".format(int(time.time()) - 86400 * 7)
select * from vas_order where ct<{} and order_status=1 and product_id='membership' logger.Info("get_orders sql: {}".format(sql))
'''.format(int(time.time()) - 86400 * 7)
logger.Info("sql: {}".format(sql))
docs = self.mysql_db_vas.query(sql) docs = self.mysql_db_vas.query(sql)
return docs return docs
@ -33,28 +31,47 @@ class S:
res = call_service(url, param) res = call_service(url, param)
return res return res
# 获取订单 # 获取金币订单
def get_coin_orders(self): def get_coin_orders(self):
sql = "select * from vas_coin_order where ct<{} and order_status=1 and product_id='membership'".format(int(time.time()) - 86400 * 7) sql = "select * from vas_coin_order where ct<{} and order_status in (1,2,3,4)".format(int(time.time()) - 86400 * 7)
logger.Info("get_coin_orders sql: {}".format(sql)) logger.Info("get_coin_orders sql: {}".format(sql))
docs = self.mysql_db_vas.query(sql) docs = self.mysql_db_vas.query(sql)
if not docs: return docs
return
return # 结算一个订单
@staticmethod
def deal_one_coin_order(coin_order_id):
url = "https://api.tiefen.fun/api/vas/deal_one_coin_order"
param = {
"coin_order_id": coin_order_id
}
res = call_service(url, param)
return res
def proc(self): def proc(self):
logger.Info("==== start: {} ====".format(get_time_str_by_ts(int(time.time())))) logger.Info("==== start: {} ====".format(get_time_str_by_ts(int(time.time()))))
logger.Info("==== start_order: {} ====".format(get_time_str_by_ts(int(time.time())))) logger.Info("==== start_order: {} ====".format(get_time_str_by_ts(int(time.time()))))
orders = self.get_orders() orders = self.get_orders()
logger.Info("len(orders): {}".format(len(orders))) logger.Info("len(orders): {}".format(len(orders)))
if orders and len(orders) > 0:
idx = 0 idx = 0
for order in orders: for order in orders:
idx += 1 idx += 1
order_id = safe_get_str(order, "id") order_id = safe_get_str(order, "id")
res = self.deal_one_order(order_id) res = self.deal_one_order(order_id)
logger.Info("{}/{} deal_one_order, {}, {}, {}".format(idx, len(orders), order_id, res, order)) logger.Info("{}/{} deal_one_order, {}, {}, {}".format(idx, len(orders), order_id, dict2json(res), dict2json(order)))
return
logger.Info("==== start_coin_order: {} ====".format(get_time_str_by_ts(int(time.time()))))
coin_orders = self.get_coin_orders()
logger.Info("len(coin_orders): {}".format(len(coin_orders)))
if coin_orders and len(coin_orders) > 0:
idx = 0
for coin_order in coin_orders:
idx += 1
order_id = safe_get_str(coin_order, "id")
res = self.deal_one_coin_order(order_id)
logger.Info("{}/{} deal_one_coin_order, {}, {}, {}".format(idx, len(orders), order_id, res, coin_order))
logger.Info("==== end: {} ====".format(get_time_str_by_ts(int(time.time()))))
return return