//验证签名 private bool CheckSignKey(SignKeyEnum signKeyEnum, Dictionary <string, object> dicParas, out string signkeyToken, out string errMsg) { errMsg = string.Empty; signkeyToken = string.Empty; if (signKeyEnum == SignKeyEnum.MobileToken) { string mobile = string.Empty; string mobileToken = Utils.GetDictionaryValue <string>(dicParas, "mobileToken").ToString(); string storeId = Utils.GetDictionaryValue <string>(dicParas, "storeId").ToString(); //如果是手机token if (MobileTokenBusiness.ExistToken(mobileToken, out mobile)) { MobileTokenModel mobileTokenTokenModel = new MobileTokenModel(mobile); dicParas.Add(Constant.MobileTokenModel, mobileTokenTokenModel); return(true); } else { errMsg = "手机令牌无效"; return(false); } } else if (signKeyEnum == SignKeyEnum.XCGameMemberToken) { string token = dicParas["memberToken"].ToString(); //验证token XCGameMemberTokenModel memberTokenKeyModel = MemberTokenBusiness.GetMemberTokenModel(token); if (memberTokenKeyModel == null) { errMsg = "token无效"; return(false); } else { dicParas.Add(Constant.XCGameMemberTokenModel, memberTokenKeyModel); return(true); } } else if (signKeyEnum == SignKeyEnum.XCGameMemberOrMobileToken) { string mobile = string.Empty; string mobileToken = Utils.GetDictionaryValue <string>(dicParas, "mobileToken").ToString(); string memberToken = Utils.GetDictionaryValue <string>(dicParas, "memberToken").ToString(); if (string.IsNullOrEmpty(mobileToken) && string.IsNullOrEmpty(memberToken)) { errMsg = "手机令牌或会员令牌不正确"; return(false); } else if (!string.IsNullOrEmpty(mobileToken) && string.IsNullOrEmpty(memberToken)) { //如果是手机token if (MobileTokenBusiness.ExistToken(mobileToken, out mobile)) { MobileTokenModel mobileTokenTokenModel = new MobileTokenModel(mobile); dicParas.Add(Constant.MobileTokenModel, mobileTokenTokenModel); return(true); } else { errMsg = "手机令牌无效"; return(false); } } else if (!string.IsNullOrEmpty(memberToken) && string.IsNullOrEmpty(mobileToken)) { XCGameMemberTokenModel memberTokenModel = MemberTokenBusiness.GetMemberTokenModel(memberToken); if (memberTokenModel != null) { dicParas.Add(Constant.XCGameMemberTokenModel, memberTokenModel); return(true); } else { errMsg = "会员令牌无效"; return(false); } } else if (!string.IsNullOrEmpty(memberToken) && !string.IsNullOrEmpty(mobileToken)) { //手机token验证 if (!MobileTokenBusiness.ExistToken(mobileToken, out mobile)) { errMsg = "手机令牌无效"; return(false); } MobileTokenModel mobileTokenModel = new MobileTokenModel(mobile); dicParas.Add(Constant.MobileTokenModel, mobileTokenModel); //会员token XCGameMemberTokenModel memberTokenModel = MemberTokenBusiness.GetMemberTokenModel(memberToken); if (memberTokenModel == null) { errMsg = "会员令牌无效"; return(false); } dicParas.Add(Constant.XCGameMemberTokenModel, memberTokenModel); //会员token和手机token手机号对比 if (!memberTokenModel.Mobile.Equals(mobileTokenModel.Mobile)) { errMsg = "手机令牌和会员令牌手机号不一致"; return(false); } return(true); } return(true); } else if (signKeyEnum == SignKeyEnum.XCGameUserCacheToken) { string mobile = dicParas.ContainsKey("mobile") ? dicParas["mobile"].ToString() : string.Empty; string UserName = dicParas.ContainsKey("UserName") ? dicParas["UserName"].ToString() : string.Empty; string PassWord = dicParas.ContainsKey("PassWord") ? dicParas["PassWord"].ToString() : string.Empty; string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty; if (string.IsNullOrEmpty(storeId)) { errMsg = "门店Id不能为空"; return(false); } if (string.IsNullOrEmpty(UserName)) { errMsg = "用户名不能为空"; return(false); } if (string.IsNullOrEmpty(PassWord)) { errMsg = "密码不能为空"; return(false); } if (string.IsNullOrEmpty(mobile)) { errMsg = "手机号码不能为空"; return(false); } return(true); } else if (signKeyEnum == SignKeyEnum.XCCloudUserCacheToken) { string token = dicParas["userToken"].ToString(); //验证token XCCloudUserTokenModel userTokenKeyModel = XCCloudUserTokenBusiness.GetUserTokenModel(token); if (userTokenKeyModel == null) { errMsg = "token无效"; return(false); } else { dicParas.Add(Constant.XCCloudUserTokenModel, userTokenKeyModel); return(true); } } else if (signKeyEnum == SignKeyEnum.MethodToken) { return(true); } else if (signKeyEnum == SignKeyEnum.XCGameAdminToken) { string userToken = dicParas.ContainsKey("userToken") ? dicParas["userToken"].ToString() : string.Empty; string configUnionId = System.Configuration.ConfigurationManager.AppSettings["BossUnionId"].ToString(); string unionId = string.Empty; if (!UnionIdTokenBusiness.ExistToken(userToken, out unionId)) { errMsg = "用户令牌无效"; return(false); } if (!configUnionId.Contains(unionId)) { errMsg = "用户没有授权"; return(false); } return(true); } else if (signKeyEnum == SignKeyEnum.XCGameManaUserToken) { string userToken = dicParas.ContainsKey("userToken") ? dicParas["userToken"].ToString() : string.Empty; XCCloudManaUserTokenModel userTokenModel = XCCloudManaUserTokenBusiness.GetManaUserTokenModel(userToken); if (userTokenModel == null) { errMsg = "用户没有授权"; return(false); } dicParas.Add(Constant.XCGameManaUserToken, userTokenModel); return(true); } else if (signKeyEnum == SignKeyEnum.XCGameManamAdminUserToken) { string userToken = dicParas.ContainsKey("userToken") ? dicParas["userToken"].ToString() : string.Empty; XCGameManaAdminUserTokenModel tokenModel = XCGameManaAdminUserTokenBusiness.GetTokenModel(userToken); if (tokenModel == null) { errMsg = "用户没有授权"; return(false); } dicParas.Add(Constant.XCGameManamAdminUserToken, tokenModel); return(true); } else { string token = dicParas["token"].ToString(); string signKey = dicParas["signkey"].ToString(); errMsg = string.Empty; signkeyToken = "default"; return(true); } }
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); }