// DB LOAD
        public CardShopSlot(User user, Resource.Data_Shop data_shop, Dictionary <Resource.PriceType, Currency> currencies, Table.TblShopSlot tblShop, List <Table.TblShopSlotCard> tblShopCard) : base(user, data_shop, currencies)
        {
            logger.Debug($"Init UserID={UID} ShopType={data_shop?.shopType} SlotIndex={tblShop?.slotIndex} cardCount={tblShopCard?.Count}");

            this.tblShop     = tblShop;
            this.tblShopCard = tblShopCard;
            this.lockOpen    = true;
        }
        public override TcpMsg.Error OpenSlot(User user)
        {
            logger.Debug($"OpenSlot UserID={UID} ShopType={data_shop?.shopType} SlotIndex={data_shop.slotIndex}");

            if (!lockOpen)
            {
                return(TcpMsg.Error.ShopSlotOpenFailed);
            }

            if (tblShop != null)
            {
                if (GetRemainSec() > 0)
                {
                    logger.Warn($"GetRemainSec() > 0 UserUID={UID} ShopType={data_shop?.shopType} SlotIndex={data_shop.slotIndex}");
                    return(TcpMsg.Error.RemainShopSlotTime);
                }
                ReadySlot(user, null);
            }

            var cardids = ChooseCardIds();

            if (cardids.Count < 1)
            {
                logger.Warn($"cardids.Count < 1");
                return(TcpMsg.Error.ShopSlotOpenFailed);
            }

            var repoUser = TCGGameSrv.IocContainer.Resolve <Repository.IUser>();

            var insert = new Table.TblShopSlot()
            {
                uuid           = UID,
                shopType       = (int)data_shop.shopType,
                slotIndex      = data_shop.slotIndex,
                resetTime      = DateTime.Now.AddSeconds(data_shop.slotTimer),
                productType    = (int)data_shop.productType,
                productSubType = data_shop.productSubType,
                sellCount      = data_shop.sellCount,
                priceType      = (int)data_shop.priceType,
                priceValue     = data_shop.priceValue,
                itemName       = data_shop.itemName,
                extraValue     = data_shop.extraValue
            };

            repoUser.InsertShopSlot(insert);
            tblShop = insert;

            List <Table.TblShopSlotCard> insert_failed;

            (tblShopCard, insert_failed) = repoUser.InsertShopSlotCard(tblShop.suid, cardids.ToArray());
            foreach (var it in insert_failed)
            {
                logger.Warn($"{Table.TblShopSlotCard.Name} Insert Fail UserUID={UID} SUID={it.suid} CardID={it.cardid}");
            }

            return(TcpMsg.Error.None);
        }
        public override void Clear()
        {
            base.Clear();

            tblShop = null;
            if (tblShopCard != null)
            {
                tblShopCard.Clear();
                tblShopCard = null;
            }
        }
        public override void OnReadySlot(User user)
        {
            logger.Debug($"OnReadySlot UserID={UID} ShopType={data_shop?.shopType} SlotIndex={data_shop.slotIndex}");

            var repoUser = TCGGameSrv.IocContainer.Resolve <Repository.IUser>();

            repoUser.DeleteShopSlot(tblShop);
            repoUser.DeleteShopSlotCard(tblShopCard);

            tblShop     = null;
            tblShopCard = null;

            var ack = new TcpMsg.AckShopSlotReady();

            ack.shopSlotInfo = ToMsg(user.tblUser.level);
            if (ack.shopSlotInfo == null)
            {
                ack.errCode = TcpMsg.Error.ShopSlotReadyFailed;
            }

            ack.currencyInfos = user.ToCurrencyInfoList();
            user.Send(new Packet(ack));
        }