diff --git a/cronjob/vas/vas_deal.py b/cronjob/vas/vas_deal.py index 614b424..152592c 100644 --- a/cronjob/vas/vas_deal.py +++ b/cronjob/vas/vas_deal.py @@ -16,10 +16,8 @@ class S: # 获取订单 def get_orders(self): - sql = ''' - select * from vas_order where ct<{} and order_status=1 and product_id='membership' - '''.format(int(time.time()) - 86400 * 7) - logger.Info("sql: {}".format(sql)) + sql = "select * from vas_order where ct<{} and order_status=1 and product_id='membership'".format(int(time.time()) - 86400 * 7) + logger.Info("get_orders sql: {}".format(sql)) docs = self.mysql_db_vas.query(sql) return docs @@ -33,28 +31,47 @@ class S: res = call_service(url, param) return res - # 获取订单 + # 获取金币订单 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)) docs = self.mysql_db_vas.query(sql) - if not docs: - return - return + return docs + + # 结算一个订单 + @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): 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())))) orders = self.get_orders() logger.Info("len(orders): {}".format(len(orders))) - idx = 0 - for order in orders: - idx += 1 - order_id = safe_get_str(order, "id") - res = self.deal_one_order(order_id) - logger.Info("{}/{} deal_one_order, {}, {}, {}".format(idx, len(orders), order_id, res, order)) - return + if orders and len(orders) > 0: + idx = 0 + for order in orders: + idx += 1 + order_id = safe_get_str(order, "id") + res = self.deal_one_order(order_id) + logger.Info("{}/{} deal_one_order, {}, {}, {}".format(idx, len(orders), order_id, dict2json(res), dict2json(order))) + 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