Example #1
0
        public JsonResult InsertAgent(JMP.MDL.CoAgent jmpagent)
        {
            object obj = new { success = 0, msg = "添加失败!" };

            jmpagent.Password = DESEncrypt.Encrypt(jmpagent.Password);
            jmpagent.ServiceFeeRatioGradeId = _coAgentService.FindMax(" select top 1 Id  from   CoServiceFeeRatioGrade where  AgentPushMoneyRatio in(select  max(AgentPushMoneyRatio)   from CoServiceFeeRatioGrade )");
            jmpagent.RoleId = int.Parse(ConfigurationManager.AppSettings["AgentRoleId"]);
            try
            {
                if (jmpagent.Classify == 0)
                {
                    jmpagent.PersonalPhotoPath = string.IsNullOrEmpty(jmpagent.PersonalPhotoPath) ? "" : jmpagent.PersonalPhotoPath;
                }
                else
                {
                    jmpagent.BusinessLicensePhotoPath = string.IsNullOrEmpty(jmpagent.BusinessLicensePhotoPath) ? "" : jmpagent.BusinessLicensePhotoPath;
                    jmpagent.PersonalPhotoPath        = string.IsNullOrEmpty(jmpagent.PersonalPhotoPath) ? " " : jmpagent.PersonalPhotoPath;
                }

                jmpagent.QQ             = string.IsNullOrEmpty(jmpagent.QQ) ? "" : jmpagent.QQ;
                jmpagent.ContactAddress = string.IsNullOrEmpty(jmpagent.ContactAddress) ? " " : jmpagent.ContactAddress;
                jmpagent.CreatedOn      = DateTime.Now;
                jmpagent.CreatedById    = UserInfo.UserId;
                jmpagent.CreatedByName  = UserInfo.UserName;
                jmpagent.OwnerId        = UserInfo.UserId;
                jmpagent.OwnerName      = UserInfo.UserName;
                bool flag = false;
                flag = _coAgentService.Insert(jmpagent) > 0;
                obj  = new { success = flag ? 1 : 0, msg = flag ? "添加成功!" : "添加失败!" };
                //写日志
                if (flag)
                {
                    Logger.CreateLog("添加代理商", jmpagent);
                }
            }
            catch (Exception ex)
            {
                obj = new { success = 0, msg = "添加异常!" };

                Logger.OperateLog("添加代理商报错", ex.ToString());
            }
            return(Json(obj));
        }
Example #2
0
        public JsonResult UpdateAgents(JMP.MDL.CoAgent jmpagent)
        {
            object obj = new { success = 0, msg = "更新失败!" };

            JMP.BLL.CoAgent userBll      = new JMP.BLL.CoAgent();
            JMP.MDL.CoAgent oldUser      = userBll.GetModel(jmpagent.Id);
            var             oldUserClone = oldUser.Clone();

            oldUser.Classify              = jmpagent.Classify;
            oldUser.LoginName             = jmpagent.LoginName;
            oldUser.Password              = DESEncrypt.Encrypt(jmpagent.Password);
            oldUser.DisplayName           = jmpagent.DisplayName;
            oldUser.EmailAddress          = jmpagent.EmailAddress;
            oldUser.MobilePhone           = jmpagent.MobilePhone;
            oldUser.QQ                    = jmpagent.QQ;
            oldUser.Website               = jmpagent.Website;
            oldUser.ContactAddress        = jmpagent.ContactAddress;
            oldUser.IDCardNumber          = jmpagent.IDCardNumber;
            oldUser.BusinessLicenseNumber = jmpagent.BusinessLicenseNumber;
            oldUser.BankAccount           = jmpagent.BankAccount;
            oldUser.BankAccountName       = jmpagent.BankAccountName;
            oldUser.BankFullName          = jmpagent.BankFullName;
            try
            {
                if (jmpagent.Classify == 0)
                {
                    oldUser.PersonalPhotoPath = string.IsNullOrEmpty(jmpagent.PersonalPhotoPath) ? "" : jmpagent.PersonalPhotoPath;
                }
                else
                {
                    oldUser.BusinessLicensePhotoPath = string.IsNullOrEmpty(jmpagent.BusinessLicensePhotoPath) ? "" : jmpagent.BusinessLicensePhotoPath;
                    oldUser.PersonalPhotoPath        = string.IsNullOrEmpty(jmpagent.PersonalPhotoPath) ? " " : jmpagent.PersonalPhotoPath;
                }

                if (string.IsNullOrEmpty(jmpagent.QQ))
                {
                    oldUser.QQ = " ";
                }
                if (string.IsNullOrEmpty(jmpagent.ContactAddress))
                {
                    oldUser.ContactAddress = " ";
                }

                //jmpagent.CreatedOn = oldUser.CreatedOn;
                //jmpagent.CreatedById = oldUser.CreatedById;
                //jmpagent.CreatedByName = oldUser.CreatedByName;
                //jmpagent.OwnerId = oldUser.OwnerId;
                //jmpagent.OwnerName = oldUser.OwnerName;
                bool flag = _coAgentService.Update(oldUser);
                obj = new { success = flag ? 1 : 0, msg = flag ? "更新成功!" : "更新失败!" };
                //写日志
                if (flag)
                {
                    Logger.ModifyLog("修改代理商", oldUserClone, jmpagent);

                    //审核状态改变是发送私信和邮件给用户
                    if (jmpagent.AuditState != oldUserClone.AuditState)
                    {
                        JMP.BLL.jmp_message messbll = new JMP.BLL.jmp_message();
                        JMP.MDL.jmp_message j_mess  = new JMP.MDL.jmp_message();
                        string tipmsg = string.Empty;
                        #region 组装私信实体
                        j_mess.m_sender   = UserInfo.UserId;
                        j_mess.m_receiver = oldUser.Id.ToString();
                        j_mess.m_type     = 1;
                        j_mess.m_time     = DateTime.Now;
                        j_mess.m_state    = 0;
                        switch (jmpagent.AuditState)
                        {
                        case -1:
                            tipmsg = "你的账号审核未通过!";
                            break;

                        case 0:
                            tipmsg = "你的账号正在审核中,如有疑问请联系我们!";
                            break;

                        case 1:
                            tipmsg = "你的账号审核通过!";
                            break;
                        }
                        j_mess.m_content = tipmsg;
                        #endregion
                        //发送私信
                        if (jmpagent.AuditState == 1)
                        {
                            //更改审核状态为通过时,才发送私信
                            int record = messbll.Add(j_mess);
                            if (record > 0)
                            {
                                Logger.CreateLog("发送私信给用户", j_mess);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.OperateLog("修改代理商报错" + jmpagent.Id, ex.ToString());
                obj = new { success = 0, msg = "更新出错了!" };
            }
            return(Json(obj));
        }