using CallCenter.Utility;
using CallCenterApi.Common;
using CallCenterApi.DB;
using CallCenterApi.Interface.Controllers.Base;
using CallCenterApi.Interface.Models.Filter;
using CallCenterApi.Interface.Models.Input;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CallCenterApi.Interface.Controllers
{

    public class UserAccountController : BaseController
    {
        private BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
        private BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
        private BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
        private BLL.T_Cus_RegionCategory bllCus_Region = new BLL.T_Cus_RegionCategory();
        //[Authority]
        //用户列表
        public ActionResult GetList(FilterUserAccount filter)
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                DataTable dt = new DataTable();
                string sql = " ";

                int userId = CurrentUser.UserData.F_UserId;
                int roleId = CurrentUser.UserData.F_RoleId;
                int deptid = CurrentUser.UserData.F_DeptId;         //部门id
                string deptCode = CurrentUser.UserData.F_DeptCode;  //部门code
               
                if (filter.dptid > 0)
                {
                    Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(filter.dptid);
                    if (deptModel != null)
                    {
                        sql += " and F_DeptId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '" + deptModel.F_DeptCode + "%') ";
                    }
                }
                if (!string.IsNullOrWhiteSpace(filter.Key))
                {
                 
                    sql = "";
                    string str = string.Format(" and (F_WorkNumber like '%{0}%' or F_UserName like '%{1}%'" +
                        "or F_Mobile like '%{2}%' "+
                        "or F_Remark like '%{3}%')", filter.Key, filter.Key, filter.Key, filter.Key);
                    sql += str;
                }
                int recordCount = 0;
                dt = BLL.PagerBLL.GetListPager(
                                        "T_Sys_UserAccount",
                                        "F_UserId",
                                        "*",
                                        sql,
                                        "ORDER BY F_UserId desc",
                                        filter.PageSize,
                                        filter.PageIndex,
                                        true,
                                        out recordCount);

                List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
              
                var obj = new
                {
                    rows = modelList.Select(x => new
                    {
                        F_UserId = x.F_UserId,
                        F_UserCode = x.F_UserCode,
                        F_ExtensionNumber = x.F_ExtensionNumber,
                        F_UserName = x.F_UserName,
                        F_GroupName = x.F_GroupName,
                        F_DeptId = x.F_DeptId,
                        F_RoleId = x.F_RoleId,
                        F_GroupId = x.F_GroupId,
                        F_SeatFlag = x.F_SeatFlag,
                        F_SeatRight = x.F_SeatRight,
                        F_SeatLevel = x.F_SeatLevel,
                        F_SexFlag = x.F_SexFlag,
                        F_RemindFlag = x.F_RemindFlag,
                        F_Remark = x.F_Remark,
                        F_Telephone = x.F_Telephone,
                        F_Mobile = x.F_Mobile,
                        F_HomePhone = x.F_HomePhone,
                        F_Birthday = x.F_Birthday,
                        F_CreateOn = x.F_CreateOn,
                        F_CancelOn = x.F_CancelOn,
                        F_DeleteFlag = x.F_DeleteFlag,
                        F_APPOnFlag = x.F_APPOnFlag,
                        F_LastActiveTime = x.F_LastActiveTime,
                        F_See = x.F_See,
                        F_HJType = x.F_HJType,
                        F_PId = x.F_PId,
                        F_TmId = x.F_TmId,
                        F_RoleName = x.F_RoleName,
                        F_DeptName = x.F_DeptName,
                        F_WorkNumber = x.F_WorkNumber,
                        //F_WXNo=x.F_WXNo,
                        F_AreaName = GetModelDeptName(x.F_DeptId),
                        F_SeatGroup = x.F_SeartGroup,
                        F_Flag=x.F_Flag
                    }),
                    total = recordCount
                };

                res = Content(obj.ToJson());


                dt.Clear();
                dt.Dispose();

            }
            return res;
        }
        private string GetModelDeptName(int deptid)
        {
            string str = "";
            Model.T_Sys_Department dept = departmentBLL.GetModel(deptid);
            if (dept !=null )
            {
                if (dept.F_Layer == 1)
                {
                    str = dept.F_DeptName;
                }
                else if (dept.F_Layer == 2)
                {
                    Model.T_Sys_Department dept1 = departmentBLL.GetModel(dept.F_ParentId);
                    if (dept1 != null)
                    {
                        str = dept1.F_DeptName;
                    }
                }
            }
            return str;
        }
        /// <summary>
        /// 获取下一个工号
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUserCode()
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                int UserCode = 0;
                string strSql = "select Max(F_UserCode) F_UserCode from T_Sys_UserAccount ";
                object ob = DbHelperSQL.GetSingle(strSql.ToString());
                if (ob == null)
                {
                    UserCode= 0;
                }
                else
                {
                    UserCode= Convert.ToInt32(ob);
                }
                var obj = new
                {
                    state = "success",
                    message = "成功",
                    UserCode  = UserCode+1,
                };
                return Content(obj.ToJson()); ;
            }
            return res;
        }
        public int   Getcode()
        {
         
                int UserCode = 0;
                string strSql = "select Max(F_UserCode) F_UserCode from T_Sys_UserAccount ";
                object ob = DbHelperSQL.GetSingle(strSql.ToString());
                if (ob == null)
                {
                    UserCode = 0;
                }
                else
                {
                    UserCode = Convert.ToInt32(ob);
                }
            return UserCode + 1;
               
        }
        //[Authority]
        //获取用户信息
        public ActionResult GetUser(int userId = 0, string userCode = "")
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                string sql = "";
                if (userId > 0)
                {
                    sql += " and F_UserId=" + userId;
                }
                if (!string.IsNullOrWhiteSpace(userCode))
                {
                    sql += " and F_UserCode=" + userCode;
                }
                if (string.IsNullOrWhiteSpace(sql))
                    return Error("获取失败");

                Model.T_Sys_UserAccount userModel = sysUserAccountBll.GetModelList(" 1=1 " + sql).FirstOrDefault();
                if (userModel == null) return Error("获取失败");
                var depModel = departmentBLL.GetModel(userModel.F_DeptId);
                var zxzModel = dicValueBLL.GetModel(userModel.F_GroupId ?? 0);
                //var modelRegion = bllCus_Region.GetModel(userModel.RegionId);
                res = Success("获取成功", new
                {
                   
                    F_UserId = userModel.F_UserId,
                    F_UserCode = userModel.F_UserCode,
                    F_ExtensionNumber = userModel.F_ExtensionNumber,
                    F_UserName = userModel.F_UserName,
                    F_DeptId = userModel.F_DeptId,
                    F_RoleId = userModel.F_RoleId,
                    F_GroupId = userModel.F_GroupId,
                    F_SeatFlag = userModel.F_SeatFlag,
                    F_SeatRight = userModel.F_SeatRight,
                    F_SeatLevel = userModel.F_SeatLevel,
                    F_SexFlag = userModel.F_SexFlag,
                    F_RemindFlag = userModel.F_RemindFlag,
                    F_Remark = userModel.F_Remark,
                    F_Telephone = userModel.F_Telephone,
                    F_Mobile = userModel.F_Mobile,
                    F_HomePhone = userModel.F_HomePhone,
                    F_Birthday = (userModel.F_Birthday != null ? userModel.F_Birthday.Value.ToString("yyyy-MM-dd") : ""),
                    F_CreateOn = userModel.F_CreateOn,
                    F_CancelOn = userModel.F_CancelOn,
                    F_DeleteFlag = userModel.F_DeleteFlag,
                    F_APPOnFlag = userModel.F_APPOnFlag,
                    F_LastActiveTime = userModel.F_LastActiveTime,
                    F_See = userModel.F_See,
                    F_HJType = userModel.F_HJType ?? 0,
                    F_PId = userModel.F_PId,
                    F_TmId = userModel.F_TmId,
                    F_WorkNumber = userModel.F_WorkNumber,
                    F_SeartGroupID = userModel.F_SeartGroupID,
                    //F_WXNo = userModel.F_WXNo,

                    F_SeatGroup = userModel.F_SeartGroup,
                    zxzname = zxzModel?.F_Name ?? "",
                    depname = depModel?.F_DeptName ?? "",
                    flag=userModel.F_Flag
                    //regionId = userModel.RegionId,   //项目id,
                    //regionName = modelRegion?.F_RegionName   //项目名称
                });
            }
            return res;
        }
        //[Authority]
        //添加用户信息
        public ActionResult AddUsers(UserAccountInput input)
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {

                Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
                //员工工号不能重复
                string ucode = input.WorkNumber.Trim();
                if (!string.IsNullOrEmpty(ucode))
                {
                    Model.T_Sys_UserAccount uModel = new BLL.T_Sys_UserAccount().GetworkModel(ucode);
                    if (uModel != null)
                    {
                        return Error("不能重复添加编号");
                    }
                    else
                    {
                        userAccountModel.F_UserCode = Getcode().ToString();
                        userAccountModel.F_WorkNumber = ucode;
                    }
                   
                }
              
             
                if (input.Username != null)
                    userAccountModel.F_UserName = input.Username.Trim();
                if (input.Password != null)
                    userAccountModel.F_Password = input.Password.Trim();
                if (input.Extno != null)
                    userAccountModel.F_ExtensionNumber = input.Extno.Trim();
                if (input.DeptId != 0)
                    userAccountModel.F_DeptId = input.DeptId;
                if (!string.IsNullOrEmpty(input.DeptCode))
                    userAccountModel.F_DeptCode = input.DeptCode;
                if (input.RoleId != 0)
                    userAccountModel.F_RoleId = input.RoleId;
                //if (input.GroupId != 0)
                //    userAccountModel.F_GroupId = input.GroupId;

                userAccountModel.F_SeatFlag = input.IsSeat;
                if (input.SearRight != null)
                    userAccountModel.F_SeatRight = input.SearRight;
                if (input.Sex != null)
                    userAccountModel.F_SexFlag = input.Sex;
                if (input.Remark != null)
                    userAccountModel.F_Remark = input.Remark;
                if (input.Mobile != null)
                    userAccountModel.F_Mobile = input.Mobile;
                if (input.Telphone != null)
                    userAccountModel.F_Telephone = input.Telphone;
                if (input.Birth != null)
                    userAccountModel.F_Birthday = input.Birth;
                userAccountModel.F_CreateOn = DateTime.Now;
                userAccountModel.F_DeleteFlag = 0;
                if (input.HjType != null)
                    userAccountModel.F_HJType = input.HjType;
                if (input.F_Flag != 0)
                    userAccountModel.F_Flag = input.F_Flag;//标识(1-负责外线工单处理，2-负责内线工单处理)
                //if (input.IsSeat)
                //{
                //    userAccountModel.F_WXNo = input.WXNo.Trim();
                //}
                //if (input.SeartGroupID != 0)
                if (!string .IsNullOrEmpty (input.GroupId))
                {
                    userAccountModel.F_SeartGroupID = input.GroupId.ToString ();
                    var GroupIDList = input.GroupId.Split('|');
                    userAccountModel.F_SeartGroup = "";
                    if (GroupIDList.Length >0)
                    {
                        foreach (var it in GroupIDList)
                        {
                            Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(int.Parse(it));
                            if (sm != null)
                            {
                                if (userAccountModel.F_SeartGroup != "")
                                {
                                    userAccountModel.F_SeartGroup = userAccountModel.F_SeartGroup + "|" + sm.F_ZXZName;
                                }
                                else
                                {
                                    userAccountModel.F_SeartGroup = sm.F_ZXZName;
                                }

                            }
                        }
                    }
                   
                   
                }
                if (input.IsSeat)
                {
                    SysConfigController sys = new SysConfigController();
                    //话务人员限制权限判断
                    if (sys.IsValidSeatPermission(""))
                    {
                        var model = sysUserAccountBll.GetModel(int.Parse(userAccountModel.F_UserCode));
                        if (model != null)
                            return Error("当前员工工号存在，请更换！");
                        if (sysUserAccountBll.Add(userAccountModel) > 0)
                            res = Success("新增成功！");
                        else
                            res = Error("新增失败！");
                    }
                    else
                    {
                        res = Error("话务人员数量已超！");
                    }
                }
                else
                {
                    if (sysUserAccountBll.Add(userAccountModel) > 0)
                        res = Success("新增成功！");
                    else
                        res = Error("新增失败！");
                }
            }
            return res;
        }
        // [Authority]
        //修改用户信息
        public ActionResult EditUsers(UserAccountInput input)
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
                Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList("  F_UserId = " + input.UserId).FirstOrDefault();
                if (userAccountModel == null)
                    return Error("获取用户失败");
                
                //员工工号不能重复
                string ucode = input.Usercode.Trim();
                if (!string.IsNullOrEmpty(ucode))
                {
                    Model.T_Sys_UserAccount uModel = new BLL.T_Sys_UserAccount().GetModel(ucode);
                    if (uModel==null )
                    {
                        return Error("查找不到该用户");
                    }
                    else
                    {
                       userAccountModel.F_UserCode  = ucode;
                    }
                }
                if (!string .IsNullOrEmpty (input.WorkNumber))
                    userAccountModel.F_WorkNumber  = input.WorkNumber.Trim ();
                if (input.Username != null)
                    userAccountModel.F_UserName = input.Username.Trim();
                if (input.Password != null)
                    userAccountModel.F_Password = input.Password.Trim();
                if (input.Extno != null)
                    userAccountModel.F_ExtensionNumber = input.Extno.Trim();
                //if (input.WXNo != null)
                //    userAccountModel.F_WXNo = input.WXNo.Trim();
                #region  原程序 20220307
                //if (input.DeptId != 0)
                //    userAccountModel.F_DeptId = input.DeptId;
                #endregion
                #region 修改增加原部门字段 20220307
                if (input.DeptId != 0)
                {
                    if (userAccountModel.F_DeptId != input.DeptId)
                    {
                       string dptids = string.IsNullOrEmpty(userAccountModel.F_Origdepts)? userAccountModel.F_DeptId.ToString() : userAccountModel.F_Origdepts+","+ userAccountModel.F_DeptId.ToString();
                        userAccountModel.F_Origdepts = String.Join(",", dptids.Split(',').Distinct());
                        userAccountModel.F_DeptId = input.DeptId;
                    }
                }
                #endregion
                if (!string.IsNullOrEmpty(input.DeptCode))
                    userAccountModel.F_DeptCode = input.DeptCode;
                if (input.RoleId != 0)
                    userAccountModel.F_RoleId = input.RoleId;
                //if (input.GroupId != 0)
                //    userAccountModel.F_GroupId = input.GroupId;
                userAccountModel.F_SeatFlag = input.IsSeat;
                if (input.SearRight != null)
                    userAccountModel.F_SeatRight = input.SearRight;
                if (input.Sex != null)
                    userAccountModel.F_SexFlag = input.Sex;
                    userAccountModel.F_Remark = input.Remark;
                if (input.Mobile != null)
                    userAccountModel.F_Mobile = input.Mobile;
                if (input.Telphone != null)
                    userAccountModel.F_Telephone = input.Telphone;
                if (input.Birth != null)
                    userAccountModel.F_Birthday = input.Birth;            
                //userAccountModel.F_CreateOn = DateTime.Now;

                //if (input.SeartGroupID != 0)
                userAccountModel.F_SeartGroup = "";
                if (!string .IsNullOrEmpty (input.GroupId))
                {
                    userAccountModel.F_SeartGroupID = input.GroupId;
                    var GroupIDList = input.GroupId.Split('|');
                    if (GroupIDList.Length > 0)
                    {
                        foreach (var it in GroupIDList)
                        {
                            Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(int.Parse(it));
                            if (sm != null)
                            {
                                if (userAccountModel.F_SeartGroup != "")
                                {
                                    userAccountModel.F_SeartGroup = userAccountModel.F_SeartGroup + "|" + sm.F_ZXZName;
                                }
                                else
                                {
                                    userAccountModel.F_SeartGroup = sm.F_ZXZName;
                                }

                            }
                        }
                    }
                }
                userAccountModel.F_DeleteFlag = 0;
                if (input.HjType != null)
                    userAccountModel.F_HJType = input.HjType;
            if (input.F_Flag != 0)
                userAccountModel.F_Flag = input.F_Flag;//标识(1-负责外线工单处理，2-负责内线工单处理)
            #region 20220426 增加用户标识
            if (input.F_Flag != 0)
                    userAccountModel.F_Flag = input.F_Flag;//标识(1-负责外线工单处理，2-负责内线工单处理)
                #endregion

                if (input.IsSeat)
                {
                    SysConfigController sys = new SysConfigController();
                    //话务人员限制权限判断
                    if (sys.IsValidSeatPermission(input.Usercode))
                    {
                        if (sysUserAccountBll.Update(userAccountModel))
                            res = Success("编辑成功！");
                        else
                            res = Error("编辑失败！");
                    }
                    else
                    {
                        res = Error("话务人员数量已超！");
                    }
                }
                else
                {
                    if (sysUserAccountBll.Update(userAccountModel))
                        res = Success("编辑成功！");
                    else
                        res = Error("编辑失败！");
                }
            }
            return res;
        }
        //[Authority]
        //删除/禁用/启用 用户
        [Authority]
        public ActionResult DelUsers(string[] ids, int state = 0)
        {
            //ActionResult res = NoToken("未知错误，请重新登录");
            //if (Request.IsAuthenticated)
            //{
            if (ids == null || ids.Length <= 0)
                return Error("请选择用户");
            var idStr = string.Join(",", ids);
            if (string.IsNullOrEmpty(idStr))
                return Error("请选择用户");

            SysConfigController sys = new SysConfigController();
            if (state == 0)
            {
                //话务人员限制权限判断
                if (sys.IsValidSeatPermission(""))
                {
                    if (sysUserAccountBll.DeleteList(idStr, state))
                        return Success("设置成功");
                    else
                        return Error("设置失败");
                }
                return Error("话务人员数量已超！");
            }
            if (sysUserAccountBll.DeleteList(idStr, state))
                return Success("设置成功");
            else
                return Error("设置失败");
            //}
            //return res;
        }

        //[Authority]
        //删除用户
        public ActionResult DeleteUsers(string[] ids)
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                if (ids == null || ids.Length <= 0)
                    return Error("请选择用户");
                var idStr = string.Join(",", ids);
                if (string.IsNullOrEmpty(idStr))
                    return Error("请选择用户");
                if (sysUserAccountBll.DeleteList(idStr))
                    res = Success("删除成功");
                else
                    res = Error("删除失败");
            }
            return res;
        }

        //获取坐席列表
        public ActionResult GetSeatList()
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                string sql = " f_seatflag=1 ";
                int userId = CurrentUser.UserData.F_UserId;
                int roleId = CurrentUser.UserData.F_RoleId;
                //int userRegionId = CurrentUser.UserData.RegionId;  //项目id

                List<Model.T_Sys_UserAccount> userSeartList = sysUserAccountBll.GetModelList(sql + " order by f_userid desc ");
                res = Success("列表加载成功", userSeartList);
                //if (userSeartList.Count > 0)
                //    res = Success("列表加载成功", userSeartList);
                //else
                //    res = Error("列表加载失败");
            }
            return res;
        }

        /// <summary>
        /// 根据部门获取用户 - pc wx
        /// </summary>
        /// <param name="proid"></param>
        /// <param name="deptid">目前只展示部门一级id</param>
        /// <returns></returns>
        public ActionResult GetDeptUserList(int deptid = 0)
        {

            List<Model.T_Sys_UserAccount> DeptUserList = sysUserAccountBll.GetModelList(" 1=1 and F_DeptId=" + deptid + "and F_DeleteFlag=0  order by f_userid desc ");
            var rolelist = new BLL.T_Sys_RoleInfo().GetModelList("").ToList();
            foreach (var item in DeptUserList)
            {
                var roleinfo = rolelist.Where(r => r.F_RoleId == item.F_RoleId).FirstOrDefault();
                if (roleinfo != null)
                    item.F_UserCode = item.F_UserCode + "-" + roleinfo.F_RoleName;
            }
            return Success("列表加载成功", DeptUserList);

        }
        //获取当前用户信息
        public ActionResult GetNowUser()
        {
            ActionResult res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(CurrentUser.UserData.F_UserId);
                if (userModel == null)
                    return Error("获取失败");
                Model.T_Sys_RoleInfo roleModel = new BLL.T_Sys_RoleInfo().GetModel(userModel.F_RoleId);
                //部门
                Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(userModel.F_DeptId);
                if (modelDep == null)
                    return Error("获取失败!");
                #region 添加部门角色
                int usertype = 0;
                if (userModel.F_RoleId == 17)
                {
                    //管理员
                    usertype = -1;
                }
                else
                {
                    //部门操作权限：1接待部，2办理人员，3区域客服，4监管
                    if (modelDep.F_Type == 1)
                    {
                        //1--接待部
                        usertype = 1;
                    }
                    //else if (modelDep.F_Type == 2)
                    //{
                    //    //2--办理人员
                    //    usertype = 2;
                    //}
                    //else if (modelDep.F_Type == 3)
                    //{
                    //    //3--区域客服
                    //    usertype = 3;
                    //}
                    //else if (modelDep.F_Type == 4)
                    //{
                    //    //4--监管
                    //    usertype = 4;
                    //}
                    else
                    {
                        usertype = 0;
                    }
                }
                #endregion

                var obj = new
                {
                    user = userModel,
                    role = roleModel,
                    usertype = usertype
                };
                res = Success("获取成功", obj);
            }
            return res;
        }
        // [Authority]
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="usercode"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public ActionResult ResetPwd(string usercode = "", string pwd = "")
        {
            var res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(pwd))
                    return Error("请输入密码");
                var model = sysUserAccountBll.GetModel(usercode);
                if (model == null) return Error("此用户不存在");
                model.F_Password = pwd;
                if (sysUserAccountBll.Update(model))
                    res = Success("重置密码成功");
                else
                    res = Error("重置密码失败");
            }
            return res;
        }

        public ActionResult UpdatePwd(string usercode = "", string pwd = "", string oldPwd = "", string mobile = "")
        {
            var res = NoToken("未知错误，请重新登录");
            if (Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(pwd))
                    return Error("请输入密码");
                if (string.IsNullOrWhiteSpace(usercode))
                    return Error("账号错误");
                var model = sysUserAccountBll.GetModel(int.Parse(usercode));
                if (model == null) return Error("此用户不存在");
                if (!model.F_Password.Equals(oldPwd)) return Error("原密码不正确");
                model.F_Password = pwd;
                if (!string.IsNullOrWhiteSpace(mobile))
                    model.F_Mobile = mobile;
                if (sysUserAccountBll.Update(model))
                    res = Success("重置密码成功");
                else
                    res = Error("重置密码失败");
            }
            return res;
        }

    }
}