Пример #1
0
        /// <summary>
        /// 验证门店设备信息
        /// </summary>
        /// <param name="deviceStoreType"></param>
        /// <param name="storeId"></param>
        /// <param name="deviceId"></param>
        /// <param name="segment"></param>
        /// <param name="mcuId"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static bool checkStoreDeviceInfo(XCGameManaDeviceStoreType deviceStoreType, string storeId, string deviceId, out string segment, out string mcuId, out string xcGameDBName, out int deviceIdentityId, out string storePassword, out string storeName, out string errMsg)
        {
            errMsg           = string.Empty;
            segment          = string.Empty;
            storeName        = string.Empty;
            mcuId            = string.Empty;
            xcGameDBName     = string.Empty;
            deviceIdentityId = 0;
            storePassword    = string.Empty;
            if (deviceStoreType == XCGameManaDeviceStoreType.Store)
            {
                StoreBusiness   store      = new StoreBusiness();
                StoreCacheModel storeModel = null;
                if (!store.IsEffectiveStore(storeId, ref storeModel, out errMsg))
                {
                    errMsg = "门店不存在";
                    return(false);
                }
                storePassword = storeModel.StorePassword;
                xcGameDBName  = storeModel.StoreDBName;
                storeName     = storeModel.StoreName;

                XCCloudService.BLL.IBLL.XCGame.IDeviceService xcGameDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(xcGameDBName);
                var xcGameDeviceModel = xcGameDeviceService.GetModels(p => p.MCUID.Equals(deviceId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (xcGameDeviceModel == null)
                {
                    errMsg = "设备不存在";
                    return(false);
                }
                else
                {
                    if (xcGameDeviceModel.state != "启用")
                    {
                        errMsg = "设备未启用";
                        return(false);
                    }
                    else
                    {
                        segment          = xcGameDeviceModel.segment;
                        mcuId            = xcGameDeviceModel.MCUID;
                        deviceIdentityId = (int)(xcGameDeviceModel.id);
                        return(true);
                    }
                }
            }
            else if (deviceStoreType == XCGameManaDeviceStoreType.Merch)
            {
                XCCloudService.BLL.IBLL.XCCloudRS232.IBase_DeviceInfoService deviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IBase_DeviceInfoService>();
                var deviceModel = deviceService.GetModels(p => p.SN.Equals(deviceId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCCloudRS232.Base_DeviceInfo>();
                if (deviceModel == null)
                {
                    errMsg = "设备不存在";
                    return(false);
                }
                else
                {
                    if (deviceModel.Status != 1)
                    {
                        errMsg = "设备未启用";
                        return(false);
                    }
                    else
                    {
                        mcuId            = deviceModel.SN;
                        deviceIdentityId = deviceModel.ID;
                        return(true);
                    }
                }
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public object register(Dictionary <string, object> dicParas)
        {
            try
            {
                string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
                string mcuId   = dicParas.ContainsKey("mcuId") ? dicParas["mcuId"].ToString() : string.Empty;
                XCCloudService.Model.CustomModel.XCGameManager.StoreCacheModel storeCacheModel = null;
                string errMsg      = string.Empty;
                string deviceToken = string.Empty;
                //验证门店信息
                XCCloudService.Business.XCGameMana.StoreBusiness xcGameManaStoreBusiness = new XCCloudService.Business.XCGameMana.StoreBusiness();
                if (!xcGameManaStoreBusiness.IsEffectiveStore(storeId, ref storeCacheModel, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
                }
                //获取子库中是否存在mcuId
                XCCloudService.BLL.IBLL.XCGame.IDeviceService xcGameDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(storeCacheModel.StoreDBName);
                var xcGameDeviceModel = xcGameDeviceService.GetModels(p => p.MCUID.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (xcGameDeviceModel == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在"));
                }
                //获取总库中是否存在
                XCCloudService.BLL.IBLL.XCGameManager.IDeviceService xcGameManaDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>();
                var xcGameManaDeviceModel = xcGameManaDeviceService.GetModels(p => p.StoreType == (int)(XCGameManaDeviceStoreType.Store) && p.DeviceId.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>();
                if (xcGameManaDeviceModel != null)
                {
                    if (!xcGameManaDeviceModel.DeviceName.Equals(xcGameDeviceModel.name) || !xcGameManaDeviceModel.DeviceType.Equals(xcGameDeviceModel.type))
                    {
                        xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type;
                        xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name;
                        xcGameManaDeviceService.Update(xcGameManaDeviceModel);
                    }
                    deviceToken = xcGameManaDeviceModel.TerminalNo;
                }
                else
                {
                    deviceToken = DeviceManaBusiness.GetDeviceToken();
                    bool isExist = false;
                    while (isExist == false)
                    {
                        if (xcGameManaDeviceService.GetCount(p => p.TerminalNo.Equals(deviceToken)) == 0)
                        {
                            isExist = true;
                        }
                        else
                        {
                            deviceToken = DeviceManaBusiness.GetDeviceToken();
                        }
                        System.Threading.Thread.Sleep(100);
                    }
                    xcGameManaDeviceModel            = new XCCloudService.Model.XCGameManager.t_device();
                    xcGameManaDeviceModel.DeviceId   = xcGameDeviceModel.MCUID;
                    xcGameManaDeviceModel.TerminalNo = deviceToken;
                    xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name;
                    xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type;
                    xcGameManaDeviceModel.StoreId    = storeId;
                    xcGameManaDeviceModel.Note       = xcGameDeviceModel.note;
                    xcGameManaDeviceModel.StoreType  = (int)(XCGameManaDeviceStoreType.Store);
                    xcGameManaDeviceService.Add(xcGameManaDeviceModel);
                }

                var obj = new { deviceToken = deviceToken };
                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        private bool getCoins(XCGameManaDeviceStoreType deviceStoreType, string xcGameDBName, string mobile, int balance, int coins, int icCardId, string segment, string deviceId, int deviceIdentityId, out int lastBalance, out string errMsg)
        {
            errMsg      = string.Empty;
            lastBalance = 0;
            //提币数据库操作
            if (deviceStoreType == XCGameManaDeviceStoreType.Store)
            {
                XCCloudService.BLL.IBLL.XCGame.IDeviceService deviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(xcGameDBName);
                var deviceModel = deviceService.GetModels(p => p.MCUID.Equals(deviceId)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (deviceModel == null)
                {
                    errMsg = "设备不存在";
                    return(false);
                }
                XCCloudService.BLL.IBLL.XCGame.Iflw_485_coinService coinService   = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.Iflw_485_coinService>(xcGameDBName);
                XCCloudService.BLL.IBLL.XCGame.IMemberService       memberService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IMemberService>(xcGameDBName);
                var memberModel = memberService.GetModels(p => p.Mobile.Equals(mobile, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.t_member>();
                memberModel.Balance = Convert.ToInt32(memberModel.Balance) - coins;
                lastBalance         = (int)(memberModel.Balance);
                XCCloudService.Model.XCGame.flw_485_coin coinModel = new Model.XCGame.flw_485_coin();
                coinModel.Balance     = Convert.ToInt32(memberModel.Balance) - coins;
                coinModel.ICCardID    = icCardId;
                coinModel.Segment     = segment;
                coinModel.HeadAddress = deviceModel.address;
                coinModel.Coins       = coins;
                coinModel.CoinType    = "3";
                coinModel.RealTime    = System.DateTime.Now;
                coinModel.SN          = 0;

                using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    coinService.Add(coinModel);
                    memberService.Update(memberModel);
                    transactionScope.Complete();
                }
                return(true);
            }
            else if (deviceStoreType == XCGameManaDeviceStoreType.Merch)
            {
                XCCloudService.BLL.IBLL.XCCloudRS232.Iflw_485_coinService coinService   = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.Iflw_485_coinService>(xcGameDBName);
                XCCloudService.BLL.IBLL.XCCloudRS232.IMemberService       memberService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IMemberService>(xcGameDBName);
                var memberModel = memberService.GetModels(p => p.Mobile.Equals(mobile, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCCloudRS232.t_member>();
                memberModel.Balance = Convert.ToInt32(memberModel.Balance) - coins;
                lastBalance         = (int)(memberModel.Balance);
                XCCloudService.Model.XCCloudRS232.flw_485_coin coinModel = new XCCloudService.Model.XCCloudRS232.flw_485_coin();
                coinModel.Balance  = Convert.ToInt32(memberModel.Balance) - coins;
                coinModel.ICCardID = icCardId;
                coinModel.DeviceID = deviceIdentityId;
                coinModel.Coins    = coins;
                coinModel.CoinType = 3;
                using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    coinService.Add(coinModel);
                    memberService.Update(memberModel);
                    transactionScope.Complete();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }