Administrator
2023-10-26 d410fd4b976b7073734a74b180532f0a76dcf575
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
L2卖管理
"""
import json
 
from db import redis_manager
from db.redis_manager import RedisUtils
from log_module import async_log_util
from log_module.log import logger_l2_market_sell
 
 
class L2MarketSellManager:
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
    __instance = None
    __current_total_sell_data_cache = {}
    __last_total_sell_data_cache = {}
 
    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super(L2MarketSellManager, cls).__new__(cls, *args, **kwargs)
            cls.__load_datas()
        return cls.__instance
 
    @classmethod
    def __get_redis(cls):
        return cls.__redis_manager.getRedis()
 
    @classmethod
    def __load_datas(cls):
        __redis = cls.__get_redis()
        try:
            pass
        finally:
            RedisUtils.realse(__redis)
 
    # 设置当前的总卖
    def set_current_total_sell_data(self, code, time_str, money):
        # 记录日志
        async_log_util.info(logger_l2_market_sell, f"{code}: {time_str}-{money}")
        if code in self.__current_total_sell_data_cache:
            self.__last_total_sell_data_cache[code] = self.__current_total_sell_data_cache.get(code)
        self.__current_total_sell_data_cache[code] = (time_str, money)
 
    # 获取参考卖的数据
    def get_refer_sell_data(self, code, time_str):
        cuurent = self.__current_total_sell_data_cache.get(code)
        if int(time_str.replace(":", "")) > int(cuurent[0].replace(":", "")):
            return cuurent
        last = self.__last_total_sell_data_cache.get(code)
        if int(time_str.replace(":", "")) > int(last[0].replace(":", "")):
            return last
        return None