public object addDevice(Dictionary <string, object> dicParas) { string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty; string mcuId = dicParas.ContainsKey("mcuId") ? dicParas["mcuId"].ToString() : string.Empty; string deviceToken = string.Empty; if (string.IsNullOrEmpty(storeId)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店号无效")); } if (string.IsNullOrEmpty(mcuId)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备ID无效")); } int storeids = int.Parse(storeId); IStoreService storeService = BLLContainer.Resolve <IStoreService>(); var menlist = storeService.GetModels(x => x.id == storeids).FirstOrDefault <t_store>(); if (menlist == null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "门店号无效")); } deviceToken = DeviceManaBusiness.GetDeviceToken(); int StoreType = 1; string dbname = menlist.store_dbname; if (dbname == "XCCloudRS232") { StoreType = 0; } IDeviceService device = BLLContainer.Resolve <IDeviceService>(); var devicelist = device.GetModels(x => x.DeviceId == mcuId && x.StoreId == storeId).FirstOrDefault <t_device>(); if (devicelist != null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该店号已经存在该设备信息!")); } string sql = @"select a.MCUID,b.GameName,b.GameType from t_head a inner join t_game b on a.GameID = b.GameID where MCUID = '" + mcuId + "'"; System.Data.DataSet ds = XCGameBLL.ExecuteQuerySentence(sql, dbname, null); if (ds.Tables[0].Rows.Count > 0) { DeviceModel deviceModel = Utils.GetModelList <DeviceModel>(ds.Tables[0])[0]; t_device device1 = new t_device(); device1.TerminalNo = deviceToken; device1.StoreId = storeId; device1.StoreType = StoreType; device1.DeviceName = deviceModel.GameName; device1.DeviceType = deviceModel.GameType; device1.DeviceId = deviceModel.MCUID; device.Add(device1); return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "")); } return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "未查询到相关数据")); }
public static void XCGameManaDeviceInit() { try { DeviceManaBusiness.Init(); LogHelper.SaveLog(TxtLogType.SystemInit, "ManaDevice Init Sucess"); } catch (Exception ex) { LogHelper.SaveLog(TxtLogType.SystemInit, "ManaDevice Init Fail..." + Utils.GetException(ex)); } }
public object register(Dictionary <string, object> dicParas) { //MerchID,DeviceName,DeviceType,SN,Token,QRURL,Status,motor1,motor2,nixie_tube_type,motor2_coin,motor1_coin,FromDevice,ToCard,SSR,alert_value string deviceName = dicParas.ContainsKey("deviceName") ? dicParas["deviceName"].ToString() : string.Empty; string deviceType = dicParas.ContainsKey("deviceType") ? dicParas["deviceType"].ToString() : string.Empty; string sn = dicParas.ContainsKey("sn") ? dicParas["sn"].ToString() : string.Empty; string qrUrl = dicParas.ContainsKey("qrUrl") ? dicParas["qrUrl"].ToString() : string.Empty; string motor1 = dicParas.ContainsKey("motor1") ? dicParas["motor1"].ToString() : string.Empty; string motor2 = dicParas.ContainsKey("motor2") ? dicParas["motor2"].ToString() : string.Empty; string nixie_tube_type = dicParas.ContainsKey("nixie_tube_type") ? dicParas["nixie_tube_type"].ToString() : string.Empty; string motor2_coin = dicParas.ContainsKey("motor2_coin") ? dicParas["motor2_coin"].ToString() : string.Empty; string motor1_coin = dicParas.ContainsKey("motor1_coin") ? dicParas["motor1_coin"].ToString() : string.Empty; string fromDevice = dicParas.ContainsKey("fromDevice") ? dicParas["fromDevice"].ToString() : string.Empty; string toCard = dicParas.ContainsKey("toCard") ? dicParas["toCard"].ToString() : string.Empty; string ssr = dicParas.ContainsKey("ssr") ? dicParas["ssr"].ToString() : string.Empty; string alert_value = dicParas.ContainsKey("alert_value") ? dicParas["alert_value"].ToString() : string.Empty; if (int.Parse(deviceType) < 0 || int.Parse(deviceType) > 4) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备类型不正确")); } XCCloudService.BLL.IBLL.XCCloudRS232.IDeviceService xcCloudRS232DeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IDeviceService>(); XCCloudService.BLL.IBLL.XCGameManager.IDeviceService xcGameManaDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>(); var xcCloudRS232DeviceModel = xcCloudRS232DeviceService.GetModels(p => p.SN.Equals(sn)).FirstOrDefault <Base_DeviceInfo>(); if (xcCloudRS232DeviceModel == null) { string deviceToken = DeviceManaBusiness.GetDeviceToken(); bool isExist = false; while (isExist == false) { if (xcGameManaDeviceService.GetCount(p => p.TerminalNo.Equals(deviceToken)) == 0 && xcCloudRS232DeviceService.GetCount(p => p.SN.Equals(deviceToken)) == 0) { isExist = true; } else { deviceToken = DeviceManaBusiness.GetDeviceToken(); } System.Threading.Thread.Sleep(100); } Base_DeviceInfo deviceModel = new Base_DeviceInfo(); deviceModel.MerchID = 0; deviceModel.DeviceName = deviceName; deviceModel.DeviceType = int.Parse(deviceType); deviceModel.SN = sn; deviceModel.Token = deviceToken; deviceModel.QRURL = qrUrl; deviceModel.Status = 1; deviceModel.motor1 = int.Parse(motor1); deviceModel.motor2 = int.Parse(motor2); deviceModel.nixie_tube_type = int.Parse(nixie_tube_type); deviceModel.motor1_coin = int.Parse(motor1_coin); deviceModel.motor2_coin = int.Parse(motor2_coin); deviceModel.FromDevice = int.Parse(fromDevice); deviceModel.ToCard = int.Parse(toCard); deviceModel.SSR = int.Parse(ssr); deviceModel.alert_value = int.Parse(alert_value); xcCloudRS232DeviceService.Add(deviceModel); return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "")); } else { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备信息已存在")); } }
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; } }
public object GetGameInfo(Dictionary <string, object> dicParas) { //获取token模式 XCGameMemberTokenModel memberTokenModel = (XCGameMemberTokenModel)(dicParas[Constant.XCGameMemberTokenModel]); string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty; StoreBusiness store = new StoreBusiness(); string xcGameDBName = string.Empty; string password = string.Empty; string errMsg = string.Empty; string storeId = string.Empty; //验证门店信息 if (!store.IsEffectiveStore(memberTokenModel.StoreId, out xcGameDBName, out password, out errMsg)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg)); } //验证设备信息 XCCloudService.Model.XCGameManager.t_device deviceModel = null; XCCloudService.Model.XCGame.t_member memberModel = null; if (!DeviceManaBusiness.ExistDevice(deviceToken, ref deviceModel, out errMsg)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg)); } //验证设备门店信息和会员门店信息 if (!memberTokenModel.StoreId.Equals(deviceModel.StoreId)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg)); } //验证会员信息 if (!MemberBusiness.IsEffectiveStore(memberTokenModel.Mobile, xcGameDBName, ref memberModel, out errMsg)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg)); } //验证头信息 XCCloudService.BLL.IBLL.XCGame.IHeadService headService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IHeadService>(xcGameDBName); var headModel = headService.GetModels(p => p.MCUID.Equals(deviceModel.DeviceId)).FirstOrDefault <XCCloudService.Model.XCGame.t_head>(); if (headModel == null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备门店头部信息不存在")); } //验证游戏机信息 XCCloudService.BLL.IBLL.XCGame.IGameService gameService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IGameService>(xcGameDBName); var gameModel = gameService.GetModels(p => p.GameID.Equals(headModel.GameID)).FirstOrDefault <XCCloudService.Model.XCGame.t_game>(); if (gameModel == null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备门店头部信息不存在")); } //获取游戏机投币规则 XCCloudService.BLL.IBLL.XCGame.IPushRuleService pushRuleService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IPushRuleService>(xcGameDBName); List <XCCloudService.Model.XCGame.t_push_rule> pushRuleModelList = pushRuleService.GetModels(p => p.game_id.Equals(headModel.GameID) && p.member_level_id == memberModel.MemberLevelID).OrderBy(p => p.level).ToList <XCCloudService.Model.XCGame.t_push_rule>(); List <int> pushRuleModelResultList = new List <int>(); //验证会员是否存在优惠记录 List <object> gameFreeRuleObjList = new List <object>(); List <XCCloudService.Model.XCGame.t_game_free_rule> gameFreeRuleModelList = null; XCCloudService.BLL.IBLL.XCGame.IFlwGameFreeService flwGameFreeService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IFlwGameFreeService>(xcGameDBName); var flwGameFreeModel = flwGameFreeService.GetModels(p => p.GameID.Equals(headModel.GameID) && p.ICCardID.Equals(memberModel.ICCardID.ToString())).FirstOrDefault <XCCloudService.Model.XCGame.flw_game_free>(); if (flwGameFreeModel == null) { //如果不存在优惠记录,则返回优惠信息 XCCloudService.BLL.IBLL.XCGame.IGameFreeRuleService gameFreeRuleService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IGameFreeRuleService>(xcGameDBName); gameFreeRuleModelList = gameFreeRuleService.GetModels( p => p.GameID.Equals(headModel.GameID) && p.MemberLevelID == memberModel.MemberLevelID && p.State == "启用").ToList <XCCloudService.Model.XCGame.t_game_free_rule>(); } gameFreeRuleModelList = gameFreeRuleModelList.OrderBy(p => p.FreeCoin / decimal.Parse(p.NeedCoin.ToString())).ToList <XCCloudService.Model.XCGame.t_game_free_rule>(); for (int i = 0; i < gameFreeRuleModelList.Count; i++) { DateTime currentTime = System.DateTime.Now; if (currentTime >= gameFreeRuleModelList[i].StartTime && currentTime <= gameFreeRuleModelList[i].EndTime) { var obj = new { id = gameFreeRuleModelList[i].ID, needCoin = gameFreeRuleModelList[i].NeedCoin, freeCoin = gameFreeRuleModelList[i].FreeCoin, exitCoin = gameFreeRuleModelList[i].ExitCoin }; gameFreeRuleObjList.Add(obj); } } foreach (var pushRuleModel in pushRuleModelList) { if (gameModel.PushReduceFromCard > pushRuleModel.coin) { pushRuleModelResultList.Add(Convert.ToInt32(gameModel.PushReduceFromCard)); } } if (pushRuleModelResultList.Count == 0) { pushRuleModelResultList.Add(Convert.ToInt32(gameModel.PushReduceFromCard)); } var obj2 = new { gameId = gameModel.GameID, gameName = gameModel.GameName, gameType = GetGameType(gameModel.GameType), price = gameModel.PushReduceFromCard, discountPrice = pushRuleModelResultList[0], gameFreeRule = gameFreeRuleObjList }; return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj2)); }
public object payRequest(Dictionary <string, object> dicParas) { string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty; string memberToken = dicParas.ContainsKey("memberToken") ? dicParas["memberToken"].ToString() : string.Empty; string orderTip = dicParas.ContainsKey("orderTip") ? dicParas["orderTip"].ToString() : string.Empty; string orderAmountStr = dicParas.ContainsKey("orderAmount") ? dicParas["orderAmount"].ToString() : string.Empty; decimal orderAmount = 0; string storeId = string.Empty; if (!string.IsNullOrEmpty(deviceToken)) { if (!DeviceManaBusiness.ExistDevice(deviceToken, out storeId)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在")); } } else if (!string.IsNullOrEmpty(memberToken)) { XCGameMemberTokenModel model = MemberTokenBusiness.GetMemberTokenModel(memberToken); if (model == null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌无效")); } storeId = model.StoreId; } else { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌或设备令牌无效")); } if (string.IsNullOrEmpty(orderTip)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "订单标题无效")); } if (!decimal.TryParse(orderAmountStr, out orderAmount)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "订单金额无效")); } string orderNo = ""; string timeStamp = Utils.ConvertDateTimeToLong(System.DateTime.Now, 0).ToString(); string nonceStr = Utils.GetGuid(); string prepay_id = System.DateTime.Now.ToString("yyyyMMddHHmmss"); string package = "prepay_id=" + prepay_id; string signType = "MD5"; string paySignStr = string.Format("appId={0}&nonceStr={1}&package={2}&signType={3}&timeStamp={4}&key={5}", WeiXinConfig.WXSmallAppId, nonceStr, package, signType, timeStamp, WeiXinConfig.WXSmallAppSecret); //paySign = MD5(appId=wxd678efh567hg6787&nonceStr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id=wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key=qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6 string paySign = Utils.MD5(paySignStr); var data = new { orderNo = orderNo, timeStamp = timeStamp, nonceStr = nonceStr, package = package, signType = signType, paySign = paySign }; var resObj = new { reutrn_code = "1", return_msg = "", result_code = "1", result_msg = "", data = data }; return(resObj); }