public static bool IsEffectiveMerch(string openId, out MerchInfoCacheModel merchInfoCacheModel) { merchInfoCacheModel = null; if (MerchInfoList.Any <MerchInfoCacheModel>(p => p.WxOpenID.Equals(openId, StringComparison.OrdinalIgnoreCase))) { merchInfoCacheModel = MerchInfoList.Where(p => p.WxOpenID.Equals(openId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); return(true); } return(false); }
public object ResetPassword(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; //string mobil = dicParas.ContainsKey("mobil") ? dicParas["mobil"].ToString() : string.Empty; //if (string.IsNullOrEmpty(mobil)) //{ // errMsg = "手机号不能为空"; // return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg); //} //if (!Utils.CheckMobile(mobil)) //{ // errMsg = "手机号不正确"; // return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg); //} //bool isSMSTest = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["isSMSTest"].ToString()); //string pwd = "123456"; //if (!isSMSTest) //{ // //生成6位随机字母数字混合 // pwd = Utils.GetCheckCode(6); // ResetPasswordCache.Add(mobil, pwd, CacheExpires.SMSCodeExpires); // if (!SMSBusiness.SendSMSCode("3", mobil, pwd, out errMsg)) // { // return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg); // } //} //else //{ // ResetPasswordCache.Add(mobil, pwd, CacheExpires.SMSCodeExpires); //} string openId = dicParas.ContainsKey("openId") ? dicParas["openId"].ToString() : string.Empty; if (string.IsNullOrEmpty(openId)) { errMsg = "openId不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } MerchInfoCacheModel merchInfoCacheModel = null; if (!MerchBusiness.IsEffectiveMerch(openId, out merchInfoCacheModel)) { errMsg = "该商户不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } string merchId = merchInfoCacheModel.MerchID; string pwd = Utils.GetCheckCode(6); IBase_MerchantInfoService base_MerchantInfoService = BLLContainer.Resolve <IBase_MerchantInfoService>(); var base_MerchantInfoModel = base_MerchantInfoService.GetModels(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); base_MerchantInfoModel.MerchPassword = Utils.MD5(pwd); if (!base_MerchantInfoService.Update(base_MerchantInfoModel)) { errMsg = "更新数据库失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } //推送微信消息 ResetPasswordMessagePush(openId, base_MerchantInfoModel.MerchAccount, pwd); return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }