Пример #1
0
 /// <summary>
 /// 出币
 /// </summary>
 /// <returns></returns>
 public static bool DeviceOutputCoin(XCGameManaDeviceStoreType deviceStoreType, DevieControlTypeEnum deviceControlType, string storeId, string mobile, int icCardId, string orderId, string segment, string mcuId, string storePassword, int foodId, int coins, string ruleId, out string errMsg)
 {
     errMsg = string.Empty;
     if (deviceStoreType == XCGameManaDeviceStoreType.Store || deviceStoreType == XCGameManaDeviceStoreType.Merch)
     {
         string action = ((int)(deviceControlType)).ToString();
         string sn     = UDPSocketAnswerBusiness.GetSN();
         if (string.IsNullOrEmpty(orderId))
         {
             orderId = System.Guid.NewGuid().ToString("N");
         }
         DeviceControlRequestDataModel deviceControlModel = new DeviceControlRequestDataModel(storeId, mobile, icCardId.ToString(), segment, mcuId, action, coins, sn, orderId, storePassword, foodId, ruleId);
         MPOrderBusiness.AddTCPAnswerOrder(orderId, mobile, coins, action, "", storeId);
         IconOutLockBusiness.Add(mobile, coins);
         if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         errMsg = "门店类型不正确";
         return(false);
     }
 }
Пример #2
0
        /// <summary>
        /// 验证总库设备信息
        /// </summary>
        /// <param name="deviceToken"></param>
        /// <param name="deviceStoreType"></param>
        /// <param name="storeId"></param>
        /// <param name="deviceId"></param>
        /// <returns></returns>
        public static bool checkXCGameManaDeviceInfo(string deviceToken, out XCGameManaDeviceStoreType deviceStoreType, out string storeId, out string deviceId)
        {
            storeId         = string.Empty;
            deviceId        = string.Empty;
            deviceStoreType = XCGameManaDeviceStoreType.Store;
            XCCloudService.BLL.IBLL.XCGameManager.IDeviceService deviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>();
            var deviceModel = deviceService.GetModels(p => p.TerminalNo.Equals(deviceToken, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>();

            if (deviceModel == null)
            {
                return(false);
            }
            else
            {
                deviceStoreType = (XCGameManaDeviceStoreType)(deviceModel.StoreType);
                if (deviceStoreType == XCGameManaDeviceStoreType.Store)
                {
                    storeId = deviceModel.StoreId;
                }
                else
                {
                    storeId = deviceModel.StoreId;
                }
                deviceId = deviceModel.DeviceId;
                return(true);
            }
        }
Пример #3
0
        private bool putCoins(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.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 = "";
                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);
            }
        }
Пример #4
0
        public bool IsEffectiveStore(string storeId, out XCGameManaDeviceStoreType deviceStoreType, ref StoreCacheModel storeModel, out string errMsg)
        {
            errMsg          = string.Empty;
            deviceStoreType = XCGameManaDeviceStoreType.Store;
            List <StoreCacheModel> list = StoreCache.GetStore();
            var model = list.Where <StoreCacheModel>(p => p.StoreID.ToString().Equals(storeId)).FirstOrDefault <StoreCacheModel>();

            if (model == null)
            {
                errMsg = "门店信息不存在";
                return(false);
            }
            else
            {
                storeModel      = model;
                deviceStoreType = (XCGameManaDeviceStoreType)(storeModel.StoreType);
                return(true);
            }
        }
Пример #5
0
 /// <summary>
 /// 读取会员信息
 /// </summary>
 /// <param name="mobile">手机号码</param>
 /// <param name="xcGameDBName">XCGame数据库名</param>
 /// <param name="balance">会员卡余额</param>
 /// <param name="icCardId">会员卡号</param>
 /// <param name="memberLevelId">会员</param>
 /// <param name="errMsg">错误信息</param>
 /// <returns></returns>
 public static bool GetMemberInfo(XCGameManaDeviceStoreType deviceStoreType, string mobile, string xcGameDBName, out int balance, out int icCardId, out int memberLevelId, out string errMsg)
 {
     balance       = 0;
     icCardId      = 0;
     memberLevelId = 0;
     errMsg        = string.Empty;
     if (deviceStoreType == XCGameManaDeviceStoreType.Store)
     {
         XCCloudService.Model.XCGame.t_member memberModel = null;
         if (XCCloudService.Business.XCGame.MemberBusiness.IsEffectiveStore(mobile, xcGameDBName, ref memberModel, out errMsg))
         {
             balance       = Convert.ToInt32(memberModel.Balance);
             icCardId      = memberModel.ICCardID;
             memberLevelId = Convert.ToInt32(memberModel.MemberLevelID);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (deviceStoreType == XCGameManaDeviceStoreType.Merch)
     {
         XCCloudService.Model.XCCloudRS232.t_member memberModel = null;
         if (XCCloudService.Business.XCCloud.MemberBusiness.IsEffectiveStore(mobile, ref memberModel, out errMsg))
         {
             balance  = Convert.ToInt32(memberModel.Balance);
             icCardId = (int)(memberModel.ICCardID);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Пример #6
0
        /// <summary>
        /// 验证雷达设备状态
        /// </summary>
        /// <param name="deviceStoreType">设备门店类型</param>
        /// <param name="storeId">门店Id</param>
        /// <param name="deviceId">设备Id</param>
        /// <param name="errMsg">错误消息</param>
        /// <returns></returns>
        public static bool checkRadarDeviceState(XCGameManaDeviceStoreType deviceStoreType, string storeId, string deviceId, out string errMsg)
        {
            string state     = string.Empty;
            string stateName = string.Empty;

            errMsg = string.Empty;
            if (deviceStoreType == XCGameManaDeviceStoreType.Store)
            {
                if (DeviceStateBusiness.ExistDeviceState(storeId, deviceId))
                {
                    state = DeviceStateBusiness.GetDeviceState(storeId, deviceId);
                }
                if (state != "1")
                {
                    stateName = DeviceStateBusiness.GetStateName(state);
                    errMsg    = stateName;
                    return(false);
                }
                return(true);
            }
            else if (deviceStoreType == XCGameManaDeviceStoreType.Merch)
            {
                if (DeviceStateBusiness.ExistDeviceState(storeId, deviceId))
                {
                    state = DeviceStateBusiness.GetDeviceState(storeId, deviceId);
                }
                if (state != "1")
                {
                    stateName = DeviceStateBusiness.GetStateName(state);
                    errMsg    = stateName;
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        private bool Recharge(XCGameManaDeviceStoreType deviceStoreType, string mobile, string xcGameDBName, string storeId, int icCardId, int memberLevelId, int foodId, string orderId, string money, int coins, int balance, string paymentype, string deviceId, int deviceIdentityId, out string foodName, out string errMsg)
        {
            foodName = string.Empty;
            errMsg   = string.Empty;
            balance += coins;
            if (deviceStoreType == XCGameManaDeviceStoreType.Store)
            {
                //验证套餐信息

                XCCloudService.BLL.IBLL.XCGame.IFoodsService foodservice = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IFoodsService>(xcGameDBName);
                var foodModel = foodservice.GetModels(p => p.FoodID == foodId).FirstOrDefault <XCCloudService.Model.XCGame.t_foods>();
                if (foodModel == null)
                {
                    errMsg = "套餐明细不存在";
                    return(false);
                }
                foodName = foodModel.FoodName;
                //验证班次信息
                XCCloudService.BLL.IBLL.XCGame.IScheduleService scheduleService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IScheduleService>(xcGameDBName);
                var schedulelist = scheduleService.GetModels(p => p.State.Equals("0", StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.flw_schedule>();
                if (schedulelist == null)
                {
                    errMsg = "相关班次不存在";
                    return(false);
                }

                string         sql        = "exec RechargeFood @Balance,@ICCardID,@FoodID,@CoinQuantity,@Point,@MemberLevelID,@UserID,@ScheduleID,@WorkStation,@MacAddress,@OrderID,@FoodName,@Money,@Paymentype,@Return output ";
                SqlParameter[] parameters = new SqlParameter[15];
                parameters[0]            = new SqlParameter("@Balance", balance);
                parameters[1]            = new SqlParameter("@ICCardID", icCardId);
                parameters[2]            = new SqlParameter("@FoodID", foodId);
                parameters[3]            = new SqlParameter("@CoinQuantity", coins);
                parameters[4]            = new SqlParameter("@Point", "0");
                parameters[5]            = new SqlParameter("@MemberLevelID", memberLevelId);
                parameters[6]            = new SqlParameter("@UserID", Convert.ToInt32(schedulelist.UserID));
                parameters[7]            = new SqlParameter("@ScheduleID", schedulelist.ID.ToString());
                parameters[8]            = new SqlParameter("@WorkStation", schedulelist.WorkStation);
                parameters[9]            = new SqlParameter("@MacAddress", "");
                parameters[10]           = new SqlParameter("@OrderID", orderId);
                parameters[11]           = new SqlParameter("@FoodName", foodModel.FoodName);
                parameters[12]           = new SqlParameter("@Money", money);
                parameters[13]           = new SqlParameter("@Paymentype", paymentype);
                parameters[14]           = new SqlParameter("@Return", 0);
                parameters[14].Direction = System.Data.ParameterDirection.Output;
                XCCloudService.BLL.IBLL.XCGame.IFoodsaleService foodsale = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IFoodsaleService>(xcGameDBName);
                XCCloudService.Model.XCGame.flw_food_sale       member   = foodsale.SqlQuery(sql, parameters).FirstOrDefault <XCCloudService.Model.XCGame.flw_food_sale>();
            }
            else if (deviceStoreType == XCGameManaDeviceStoreType.Merch)
            {
                XCCloudService.BLL.IBLL.XCCloudRS232.IFoodSaleService foodsale = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IFoodSaleService>();
                XCCloudService.Model.XCCloudRS232.flw_food_sale       flwFood  = new Model.XCCloudRS232.flw_food_sale();
                flwFood.OrderID      = orderId;
                flwFood.MerchID      = int.Parse(storeId);
                flwFood.ICCardID     = icCardId;
                flwFood.DeviceID     = deviceIdentityId;
                flwFood.FlowType     = 1;
                flwFood.CoinQuantity = coins;
                flwFood.TotalMoney   = decimal.Parse(money);
                flwFood.Point        = 0;
                flwFood.Balance      = balance;
                flwFood.Note         = string.Empty;
                flwFood.PayType      = PayBusiness.GetPaymentTypeId(paymentype);
                flwFood.PayTime      = System.DateTime.Now;
                flwFood.PayState     = 1;
                flwFood.PayTotal     = 0;

                XCCloudService.BLL.IBLL.XCCloudRS232.IMemberService memberService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IMemberService>();
                var memberModel = memberService.GetModels(p => p.Mobile.Equals(mobile, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCCloudRS232.t_member>();
                memberModel.Balance = Convert.ToInt32(memberModel.Balance) + coins;

                using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    foodsale.Add(flwFood);
                    memberService.Update(memberModel);
                    transactionScope.Complete();
                }

                return(true);
            }
            else
            {
                errMsg = "门店类型不正确";
            }
            return(true);
        }
Пример #8
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);
            }
        }
Пример #9
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 checkStoreGameDeviceInfo(XCGameManaDeviceStoreType deviceStoreType, string storeId, string deviceId, out string segment, out string mcuId, out string headId, out string gameId, out string xcGameDBName, out string storePassword, out string storeName, out string errMsg)
        {
            errMsg        = string.Empty;
            segment       = string.Empty;
            storeName     = string.Empty;
            mcuId         = string.Empty;
            headId        = string.Empty;
            gameId        = string.Empty;
            xcGameDBName  = string.Empty;
            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.IHeadService headService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IHeadService>(xcGameDBName);
                var headModel = headService.GetModels(p => p.MCUID.Equals(deviceId) && p.State.Equals("1")).FirstOrDefault <XCCloudService.Model.XCGame.t_head>();
                if (headModel == null)
                {
                    errMsg = "设备门店头部信息不存在";
                    return(false);
                }
                //验证游戏机信息
                XCCloudService.BLL.IBLL.XCGame.IGameService gameService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IGameService>(xcGameDBName);
                var gameModel = gameService.GetModels(p => p.GameID.Equals(headModel.GameID) && p.State.Equals("1")).FirstOrDefault <XCCloudService.Model.XCGame.t_game>();
                if (gameModel == null)
                {
                    errMsg = "设备门店头部信息不存在";
                    return(false);
                }

                segment = headModel.Segment;
                mcuId   = headModel.MCUID;
                headId  = headModel.HeadID;
                gameId  = headModel.GameID;
                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);
            }
        }