Esempio n. 1
0
        public object getDeviceState(Dictionary <string, object> dicParas)
        {
            string storeId      = string.Empty;
            string state        = string.Empty;
            string stateName    = string.Empty;
            string mcuId        = string.Empty;
            string segment      = string.Empty;
            string xcGameDBName = string.Empty;
            int    deviceIdentityId;
            string storePassword = string.Empty;
            string storeName     = string.Empty;
            string errMsg        = string.Empty;
            string deviceId      = string.Empty;
            string deviceToken   = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

            XCGameManaDeviceStoreType deviceStoreType;

            if (!ExtendBusiness.checkXCGameManaDeviceInfo(deviceToken, out deviceStoreType, out storeId, out deviceId))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号不存在"));
            }

            if (deviceStoreType == XCGameManaDeviceStoreType.Store)
            {
                //验证门店信息和设备状态是否为启用状态
                if (!ExtendBusiness.checkStoreDeviceInfo(deviceStoreType, storeId, deviceId, out segment, out mcuId, out xcGameDBName, out deviceIdentityId, out storePassword, out storeName, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                //验证雷达设备缓存状态
                if (!ExtendBusiness.checkRadarDeviceState(deviceStoreType, storeId, deviceId, out state, out stateName, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                var obj = new {
                    deviceToken = deviceToken,
                    deviceId    = deviceId,
                    mcuId       = mcuId,
                    segment     = segment,
                    storeName   = storeName
                };
                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
            }
            else
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号无效"));
            }
        }
Esempio n. 2
0
        public object foodsale(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg           = string.Empty;
                string storeName        = string.Empty;
                string foodName         = string.Empty;
                string storePassword    = string.Empty;
                int    icCardId         = 0; //会员
                int    balance          = 0; //币余额
                int    memberLevelId    = 0; //会员级别
                string state            = string.Empty;
                string stateName        = string.Empty;
                string mobile           = string.Empty;
                string segment          = string.Empty;
                string mcuId            = string.Empty;
                string storeId          = string.Empty;
                string deviceId         = string.Empty;
                int    foodId           = 0;
                int    deviceIdentityId = 0;
                string terminalNo       = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string type             = dicParas.ContainsKey("type") ? dicParas["type"].ToString() : string.Empty;
                string paymentype       = dicParas.ContainsKey("Paymentype") ? dicParas["Paymentype"].ToString() : string.Empty; //获取支付方式
                string foodIdStr        = dicParas.ContainsKey("foodid") ? dicParas["foodid"].ToString() : string.Empty;         //获取支付方式
                string money            = dicParas.ContainsKey("money") ? dicParas["money"].ToString() : string.Empty;
                string orderId          = dicParas.ContainsKey("OrderID") ? dicParas["OrderID"].ToString() : string.Empty;
                int    coins            = int.Parse(dicParas.ContainsKey("Coins") ? dicParas["Coins"].ToString() : string.Empty);
                int    foodNum          = int.Parse(dicParas.ContainsKey("foodNum") ? dicParas["foodNum"].ToString() : "1");
                int.TryParse(foodIdStr, out foodId);

                XCGameMemberTokenModel memberTokenModel = (XCGameMemberTokenModel)(dicParas[Constant.XCGameMemberTokenModel]);
                mobile = memberTokenModel.Mobile;

                if (string.IsNullOrEmpty(orderId))
                {
                    orderId = System.Guid.NewGuid().ToString("N");
                }

                if (type == "购币")
                {
                    string xcGameDBName = string.Empty;
                    //根据终端号查询终端号是否存在
                    XCGameManaDeviceStoreType deviceStoreType;
                    if (!ExtendBusiness.checkXCGameManaDeviceInfo(terminalNo, out deviceStoreType, out storeId, out deviceId))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号不存在"));
                    }
                    //验证会员令牌的门店号和设备门店号
                    if (!memberTokenModel.StoreId.Equals(storeId))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌不能再此设备上操作"));
                    }
                    //验证门店信息和设备状态是否为启用状态
                    if (!ExtendBusiness.checkStoreDeviceInfo(deviceStoreType, storeId, deviceId, out segment, out mcuId, out xcGameDBName, out deviceIdentityId, out storePassword, out storeName, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //验证雷达设备缓存状态
                    if (!ExtendBusiness.checkRadarDeviceState(deviceStoreType, storeId, deviceId, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //获取会员信息
                    if (!ExtendBusiness.GetMemberInfo(deviceStoreType, mobile, xcGameDBName, out balance, out icCardId, out memberLevelId, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //购币
                    if (!BuyCoin(deviceStoreType, xcGameDBName, storeId, icCardId, memberLevelId, foodId, orderId, money, coins, balance, paymentype, deviceId, deviceIdentityId, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //请求雷达处理出币
                    if (!IConUtiltiy.DeviceOutputCoin(deviceStoreType, DevieControlTypeEnum.出币, storeId, mobile, icCardId, orderId, segment, mcuId, storePassword, foodId, coins, string.Empty, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //设置推送消息的缓存结构
                    string form_id = dicParas.ContainsKey("form_id") ? dicParas["form_id"].ToString() : string.Empty;
                    MemberFoodSaleNotifyDataModel dataModel = new MemberFoodSaleNotifyDataModel("购币", storeName, mobile, foodName, foodNum, icCardId, decimal.Parse(money), coins);
                    SAppMessageMana.SetMemberCoinsMsgCacheData(SAppMessageType.MemberFoodSaleNotify, orderId, form_id, mobile, dataModel, out errMsg);
                }
                else if (type == "充值")
                {
                    StoreCacheModel           storeModel = null;
                    XCGameManaDeviceStoreType deviceStoreType;
                    //验证门店
                    StoreBusiness store = new StoreBusiness();
                    if (!store.IsEffectiveStore(memberTokenModel.StoreId, out deviceStoreType, ref storeModel, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //获取会员信息
                    if (!ExtendBusiness.GetMemberInfo(deviceStoreType, mobile, storeModel.StoreDBName, out balance, out icCardId, out memberLevelId, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //充值
                    LogHelper.SaveLog(TxtLogType.Api, TxtLogContentType.Debug, TxtLogFileType.Day, "Recharge:" + errMsg);
                    if (!Recharge(deviceStoreType, mobile, storeModel.StoreDBName, storeId, icCardId, memberLevelId, foodId, orderId, money, coins, balance, paymentype, deviceId, deviceIdentityId, out foodName, out errMsg))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }
                    //推送消息
                    string form_id = dicParas.ContainsKey("form_id") ? dicParas["form_id"].ToString() : string.Empty;
                    SAppMessageMana.PushMemberFoodSaleMsg("", "", "充值", storeModel.StoreName, mobile, orderId, foodName, foodNum, icCardId, decimal.Parse(money), coins, form_id, out errMsg);
                }
                else
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "类型无效"));
                }


                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
        public object flw_485_coinSale(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobile           = string.Empty;
                string storeId          = string.Empty;
                string deviceId         = string.Empty;
                string errMsg           = string.Empty;
                string segment          = string.Empty;
                string mcuId            = string.Empty;
                string xcGameDBName     = string.Empty;
                int    memberLevelId    = 0;
                string storeName        = string.Empty;
                int    balance          = 0;
                int    icCardId         = 0;
                int    deviceIdentityId = 0;
                int    lastBalance      = 0;
                string storePassword    = string.Empty;
                string orderId          = dicParas.ContainsKey("orderId") ? dicParas["orderId"].ToString() : string.Empty;
                string deviceToken      = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                int    coins            = Convert.ToInt32(dicParas["coins"]);
                XCGameMemberTokenModel memberTokenModel = (XCGameMemberTokenModel)(dicParas[Constant.XCGameMemberTokenModel]);
                mobile = memberTokenModel.Mobile;

                if (string.IsNullOrEmpty(orderId))
                {
                    orderId = System.Guid.NewGuid().ToString("N");
                }

                //根据终端号查询终端号是否存在
                XCGameManaDeviceStoreType deviceStoreType;
                if (!ExtendBusiness.checkXCGameManaDeviceInfo(deviceToken, out deviceStoreType, out storeId, out deviceId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号不存在"));
                }
                //验证会员令牌的门店号和设备门店号
                if (!memberTokenModel.StoreId.Equals(storeId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌不能再此设备上操作"));
                }
                //验证门店信息和设备状态是否为启用状态
                if (!ExtendBusiness.checkStoreDeviceInfo(deviceStoreType, storeId, deviceId, out segment, out mcuId, out xcGameDBName, out deviceIdentityId, out storePassword, out storeName, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                //验证雷达设备缓存状态
                if (!ExtendBusiness.checkRadarDeviceState(deviceStoreType, storeId, deviceId, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                //获取会员信息
                if (!ExtendBusiness.GetMemberInfo(deviceStoreType, mobile, xcGameDBName, out balance, out icCardId, out memberLevelId, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                //验证余额
                if (coins > balance)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "币数余额不足"));
                }
                //数据库提币操作
                if (!getCoins(deviceStoreType, xcGameDBName, mobile, balance, coins, icCardId, segment, deviceId, deviceIdentityId, out lastBalance, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                //请求雷达处理出币
                if (!IConUtiltiy.DeviceOutputCoin(deviceStoreType, DevieControlTypeEnum.出币, storeId, mobile, icCardId, orderId, segment, mcuId, storePassword, 0, coins, string.Empty, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                //设置推送消息的缓存结构
                string form_id = dicParas.ContainsKey("form_id") ? dicParas["form_id"].ToString() : string.Empty;
                MemberCoinsOperationNotifyDataModel dataModel = new MemberCoinsOperationNotifyDataModel("提币", storeName, mobile, icCardId, coins, lastBalance);
                SAppMessageMana.SetMemberCoinsMsgCacheData(SAppMessageType.MemberCoinsOperationNotify, orderId, form_id, mobile, dataModel, out errMsg);

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }