Beispiel #1
0
        public HttpMsg.MessageResponse ReqAuthorizationCallBack(HttpMsg.MessageType reqType, DispatchData request)
        {
            logger.Debug($"\n{JValue.Parse(request.ReqData).ToString(Formatting.Indented)}");

            var reqData = request.GetData <HttpMsg.ReqAuthorizationCallBack>();

            var intlData = new InternalMsg.IntlMsg_Authorization();

            intlData.guid = reqData.state;

            intlData.state = reqData.state;
            intlData.code  = reqData.code;
            intlData.friendship_status_changed = reqData.friendship_status_changed;

            intlData.error       = reqData.error;
            intlData.description = reqData.description;

            NetServer.InternalHandleMessageByGuid(intlData);

            return(null);
        }
        void FungibleTransferUserStateProcess(string fromAddr, string toAddr, List <LBD.TokenInfo> tokenInfos)
        {
            if (null != tokenInfos && tokenInfos.Count > 0)
            {
                switch (user.stateType)
                {
                case UserStateType.NewUserConnect:
                {
                    tokenInfos.ForEach(x =>
                        {
                            user.FungibleTokenTransfer(x.tokenType, x.amount);
                            user.Currency_SetPrice(x.tokenType, x.amount);
                        });

                    user.OperatorServiceTokenMint(1000);
                }
                break;

                case UserStateType.RegisterTradeGoodsFees:
                {
                    tokenInfos.ForEach(x =>
                        {
                            user.FungibleTokenTransfer(x.tokenType, -x.amount);
                            user.Currency_SetPrice(x.tokenType, -x.amount);
                        });

                    var tblTrade = TradingManager.Instance.RegisterTradeGoods(user.UID);
                    user.RegisterTradeGoodsSucess(tblTrade);
                }
                break;

                case UserStateType.SellerPayments:
                {
                    tokenInfos.ForEach(x =>
                        {
                            user.FungibleTokenTransfer(x.tokenType, -x.amount);
                            user.Currency_SetPrice(x.tokenType, -x.amount);
                        });

                    var toUser = NetServer.WalletAddressToFindUser(toAddr);
                    if (null != toUser)
                    {
                        NetServer.InternalHandleMessageByUid(new InternalMsg.IntlMsg_SellerPayments()
                            {
                                uid         = toUser.UID,
                                guid        = toUser.Id.ToString(),
                                fromUserUid = user.UID,
                                tokenType   = tokenInfos[0].tokenType,
                                amount      = tokenInfos[0].amount
                            });
                    }

                    var buyerData = TradingManager.Instance.GetBuyerData(user.UID);
                    var goods     = buyerData.goods;

                    user.stateType = UserStateType.BuyerGiveGoods;
                    LBD.LBDApiManager.Instance.AddLBDCmd(new LBD.Msg.LBDMsg_UserId_NonFungible_Transfer()
                        {
                            uid        = user.UID,
                            guid       = user.Id.ToString(),
                            fromUserId = goods.userid,
                            toAddr     = string.Empty,
                            toUserId   = user.lineUID,
                            tokenType  = goods.tokentype,
                            tokenIndex = goods.tokenidx
                        });
                }
                break;

                case UserStateType.BuyFungible:
                {
                    tokenInfos.ForEach(x => user.FungibleTokenTransfer(x.tokenType, x.amount));

                    var currency = tokenInfos.ToDictionary(x => x.tokenType, x => (Int64)x.amount);
                    user.OnMintBuyShopSlot(currency);
                }
                break;

                case UserStateType.BuyShopSlot:
                {
                    tokenInfos.ForEach(x => user.FungibleTokenTransfer(x.tokenType, -x.amount));

                    user.OnBurnShopSlot(tokenInfos);
                }
                break;

                case UserStateType.RefreshShopCardSlot:
                {
                    tokenInfos.ForEach(x => user.FungibleTokenTransfer(x.tokenType, -x.amount));

                    user.OnBurnRefreshShopCardSlot(tokenInfos);
                }
                break;

                default:
                    break;
                }
            }
            else
            {
                logger.Warn($"transfer_ft userUid={user.UID} tokenInfo is null~~");
            }
        }