using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.Base;
using WX.CRM.IBLL.Res;
using WX.CRM.IBLL.Sms;
using WX.CRM.IBLL.Util;
using WX.CRM.Model.Enum;
using WX.CRM.WEB.ViewModel.Level2;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Level2
{
public class L2RetPasswordController : BaseController
{
[Ninject.Inject]
public ISecurityHelper sHelper { get; set; }
[Ninject.Inject]
public ICACHE_Q cacheQ { get; set; }
[Ninject.Inject]
public IRES_RESOURCEMOBILE_Q RESOURCEMOBILE_Q { get; set; }
[Ninject.Inject]
public IBAS_PARAMETER_Q PARAMETER_Q { get; set; }
[Ninject.Inject]
public IRES_CUSTOMER_Q RES_CUSTOMER_Q { get; set; }
[Ninject.Inject]
public ISMS_MESSAGE_HIS_Q SMS_MESSAGE_HIS_Q { get; set; }
//
// GET: /L2RetPassword/
[AuthorizeRedirect(Roles = InitRights.CONST_L2重置密码)]
public ActionResult Index()
{
return View();
}
///
/// 重置密码
///
///
///
[AuthorizeRedirect(Roles = InitRights.CONST_L2重置密码)]
public JsonResult RetPaw(string uname, string resid, string randnum)
{
#region New 重置密码,并将新密码通知客服
//重置密码
Soft_CRMRetPwd crmRetpwd = new Soft_CRMRetPwd();
returnResult result = crmRetpwd.Retpaw(uname, "");
if (result.result)
{
return JsonHandler.ManageMessage("密码重置成功,新密码为" + result.retpwd, true);
}
else
{
return JsonHandler.ManageMessage("重置失败:" + Utility.GetCheckEnumNameByValue(result.retcode), false);
}
#endregion
#region OLD 需填客户ID,并将其作为接收短信的手机号,暂时先改一下这个逻辑
//#region 判断resid和电话号码是否存在
//RES_CUSTOMER RES_CUSTOMER = RES_CUSTOMER_Q.getResCustomerByResId(resid);
//if (RES_CUSTOMER == null)
//{
// return JsonHandler.ManageMessage("RESID不存在!", false);
//}
//string mobile = RESOURCEMOBILE_Q.GetNumberByResId(resid);
//if (string.IsNullOrEmpty(mobile))
//{
// return JsonHandler.ManageMessage("RESID没有找到对应的电话号码!", false);
//}
//#endregion
////判断当天是否已发送3次短信
//if (SMS_MESSAGE_HIS_Q.IsSendSmsThree(resid))
//{
// //重置密码
// Soft_CRMRetPwd crmRetpwd = new Soft_CRMRetPwd();
// returnResult result = crmRetpwd.Retpaw(uname, mobile);
// if (result.result)
// {
// try
// {
// #region 发送短信
// //短信内容
// BAS_PARAMETER resp = PARAMETER_Q.GetModel_Patameter("SMS_ResetPwd_Message");
// if (resp != null)
// {
// string smsmessage = string.Format(resp.PARAVALUE, uname, result.retpwd);
// //短信model
// SmsServiceModel smsmodel = new SmsServiceModel();
// smsmodel.SubTypeCode = "SMS_ResetPwd";
// smsmodel.typeCode = "ISVRSMS0001";
// smsmodel.resid = resid;
// smsmodel.mobile = mobile;
// smsmodel.message = smsmessage;
// //将短信model转成json
// string key = Utility.ObjectToJson(smsmodel);
// key = sHelper.createSignEncodingStr(key,SecurityHelper.OrderClientIdKey);
// //获取url
// string url = Utility.GetSettingByKey("L2Retpwdsms");
// string retmsg = Utility.PostData(url + "?" + key, Encoding.UTF8);
// //retmsg = JsonHelper.JsonDivertToObj(retmsg);
// retmsg = sHelper.decyptData(SecurityHelper.OrderClientIdKey, retmsg);
// SmsSendMsgModel retmessage = JsonHelper.JsonDivertToObj(retmsg);
// if (retmessage.result)
// {
// return JsonHandler.ManageMessage("密码重置成功,短信发送成功!", true);
// }
// else
// {
// return JsonHandler.ManageMessage("密码重置成功,短信发送失败!" + retmsg, false);
// }
// }
// else
// {
// return JsonHandler.ManageMessage("获取短信内容失败!", false);
// }
// #endregion
// }
// catch (Exception e)
// {
// Common.LogHelper.Error(string.Concat("短信发送错误", e.Message, e.StackTrace));
// return JsonHandler.ManageMessage("密码重置成功,短信发送失败!", false);
// }
// }
// else
// {
// return JsonHandler.ManageMessage("重置失败:" + Utility.GetCheckEnumNameByValue(result.retcode), false);
// }
//}
//else
//{
// return JsonHandler.ManageMessage("密码重置失败,今天重置密码已超过3次!", false);
//}
#endregion
}
}
}