Пример #1
0
        public static int ModifyCustomer(CustomerEntity customerEntity, CustomerExtendEntity extendEntity)
        {
            CustomerRepository cr = new CustomerRepository();
            int result            = 0;

            if (customerEntity != null && extendEntity != null)
            {
                CustomerInfo       info       = TranslateCustomerEntity(customerEntity);
                CustomerExtendInfo extendInfo = TranslateCustomerExtendEntity(extendEntity);

                if (customerEntity.CustomerID > 0)
                {
                    cr.ModifyCustomer(info);
                    result = cr.ModifyCustomer(extendInfo);
                }
                else
                {
                    long customerid = cr.CreateNewCustomer(info);
                    extendInfo.CustomerID = customerid;
                    result = cr.CreateNewCustomerExtend(extendInfo);
                }
            }

            return(result);
        }
Пример #2
0
        public static CustomerExtendEntity AddFile(long userid, string base64, string fileType)
        {
            CustomerRepository   customerRes = new CustomerRepository();
            CustomerExtendEntity cEntity     = new CustomerExtendEntity();

            if (!string.IsNullOrEmpty(base64))
            {
                CustomerExtendInfo customerInfo = customerRes.GetCustomerExtendByCustomerID(userid);
                if (customerInfo != null)//已经存在
                {
                    CustomerExtendInfo cInfo = new CustomerExtendInfo();
                    cInfo.CustomerID = userid;
                    cInfo.CardType   = fileType;
                    cInfo.ID         = customerInfo.ID;
                    cInfo.Base64     = base64;
                    customerRes.ModifyCustomer(cInfo);
                }
                else
                {
                    CustomerExtendInfo cInfo = new CustomerExtendInfo();
                    cInfo.CustomerID = userid;
                    cInfo.CardType   = fileType;
                    cInfo.Base64     = base64;
                    customerRes.CreateNewCustomerExtend(cInfo);
                }
            }
            CustomerExtendEntity detail = GetCustomerExtendByCustomerID(userid, true);

            return(detail);
        }
Пример #3
0
        private static CustomerExtendInfo TranslateCustomerExtendEntity(CustomerExtendEntity entity)
        {
            CustomerExtendInfo info = new CustomerExtendInfo();

            if (entity != null)
            {
                info.ID            = entity.ID;
                info.CustomerID    = entity.CustomerID;
                info.CustomerCode  = entity.CustomerCode;
                info.AttachmentIDs = entity.AttachmentIDs;
                info.CustomerName  = entity.CustomerName;
                info.Mobile        = entity.Mobile;
                info.Email         = entity.Email;
                info.CardType      = entity.CardType;
                info.CardNo        = entity.CardNo;
                info.Channel       = entity.Channel;
                info.RegisterTime  = entity.RegisterTime;
                info.Status        = entity.Status;
                info.AuditTime     = entity.AuditTime;
                info.Auditor       = entity.Auditor;
                info.ModifyDate    = entity.ModifyDate;
                info.Operator      = entity.Operator;
                info.WXCode        = entity.WXCode;
            }

            return(info);
        }
Пример #4
0
        public static CustomerExtendEntity GetCustomerExtendByCustomerID(long id, bool isAPI = false)
        {
            CustomerRepository   mr     = new CustomerRepository();
            CustomerExtendInfo   info   = mr.GetCustomerExtendByCustomerID(id);
            CustomerExtendEntity entity = TranslateCustomerExtendEntity(info, isAPI);

            return(entity);
        }
Пример #5
0
        public static List <CustomerExtendEntity> GetCustomerList(string name, string code, int status, PagerInfo pager, bool isAPI = false)
        {
            List <CustomerExtendEntity> all    = new List <CustomerExtendEntity>();
            CustomerRepository          mr     = new CustomerRepository();
            List <CustomerExtendInfo>   miList = mr.GetCustomerExtend(name, code, status, pager);

            foreach (CustomerExtendInfo mInfo in miList)
            {
                CustomerExtendEntity customerExtendEntity = TranslateCustomerExtendEntity(mInfo, isAPI);
                all.Add(customerExtendEntity);
            }
            return(all);
        }
Пример #6
0
 /// <summary>
 /// 上传头像
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public JsonResult HeadImage(string userid, string data)
 {
     //LogHelper.WriteTextLog("HeadImage", "userid:" + userid + "data:" + data, DateTime.Now);
     try
     {
         CustomerExtendEntity entity   = new CustomerExtendEntity();
         CustomerExtendEntity customer = CustomerService.AddFile(long.Parse(userid), data, "CD05");//用户头像
         return(Json(JsonHelper.ToJson(customer)));
     }
     catch (Exception ex)
     {
         LogHelper.WriteTextLog("HeadImage", ex.ToString(), DateTime.Now);
     }
     return(Json(""));
 }
Пример #7
0
        public static long CreateNewCustomer(CustomerEntity customerEntity, CustomerExtendEntity extendEntity)
        {
            long result           = 0;
            CustomerRepository cr = new CustomerRepository();

            if (customerEntity != null && extendEntity != null)
            {
                CustomerInfo       info       = TranslateCustomerEntity(customerEntity);
                CustomerExtendInfo extendInfo = TranslateCustomerExtendEntity(extendEntity);
                result = cr.CreateNewCustomer(info);
                extendInfo.CustomerID = result;
                result = cr.CreateNewCustomerExtend(extendInfo);
            }

            return(result);
        }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="fileName"></param>
        /// <param name="fileType">身份证:CD01/驾驶证:CD02/用户头像:CD05</param>
        /// <returns></returns>
        public static CustomerExtendEntity AddFile(long userid, string fileName, string fileType, string FilePath, string fileExtension)
        {
            CustomerRepository customerRes = new CustomerRepository();
            AttachmentEntity   attachment  = new AttachmentEntity();

            attachment.FileName       = fileName.Substring(0, fileName.IndexOf("."));
            attachment.FileExtendName = fileExtension;
            attachment.FilePath       = "~" + FilePath;
            attachment.FileType       = fileType;
            attachment.BusinessType   = fileType;
            attachment.Remark         = "";
            attachment.FileSize       = "";
            attachment.Channel        = "Offline";
            attachment.UploadDate     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            attachment.Operator       = userid;
            attachment.AttachmentID   = BaseDataService.CreateAttachment(attachment);
            //用户扩展信息插入

            CustomerExtendEntity cEntity      = new CustomerExtendEntity();
            CustomerExtendInfo   customerInfo = customerRes.GetCustomerExtendByID(userid);

            if (customerInfo != null)//已经存在
            {
                CustomerExtendInfo cInfo = new CustomerExtendInfo();
                cInfo.AttachmentIDs = attachment.AttachmentID.ToString();
                cInfo.CustomerID    = userid;
                cInfo.CardType      = fileType;
                cInfo.ID            = customerInfo.ID;
                customerRes.ModifyCustomer(cInfo);
            }
            else
            {
                CustomerExtendInfo cInfo = new CustomerExtendInfo();
                cInfo.AttachmentIDs = attachment.AttachmentID.ToString();
                cInfo.CustomerID    = userid;
                cInfo.CardType      = fileType;
                customerRes.CreateNewCustomerExtend(cInfo);
            }
            CustomerExtendEntity detail = GetCustomerExtendInfoByID(userid, true);

            return(detail);
        }
Пример #9
0
        public void CreateRelation(long sid, string code, string wxcode)
        {
            if (sid > 0 && !string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(wxcode))
            {
                CustomerEntity exist = CustomerService.GetCustomerByWXCode(wxcode);
                if (exist == null || exist.CustomerID == 0)//微信号不存在
                {
                    //注册成为新的用户
                    CustomerExtendEntity extendEntity = new CustomerExtendEntity();
                    extendEntity.CustomerCode = DateTime.Now.ToString("yyyyMMddHHmmss");
                    extendEntity.RegisterTime = DateTime.Now;
                    extendEntity.AuditTime    = DateTime.Parse("1753-01-01");
                    extendEntity.WXCode       = wxcode;
                    extendEntity.Channel      = 4;

                    CustomerEntity customer = new CustomerEntity();
                    customer.CustomerID   = extendEntity.CustomerID;
                    customer.CustomerName = "扫码注册客户";
                    customer.CustomerCode = extendEntity.CustomerCode;
                    customer.Channel      = extendEntity.Channel;
                    customer.Mobile       = extendEntity.Mobile;
                    customer.WXCode       = extendEntity.WXCode;
                    customer.Name         = "";
                    if (customer.CustomerID < 1)
                    {
                        customer.Password = EncryptHelper.MD5Encrypt("123456");
                    }

                    long   customerID   = CustomerService.CreateNewCustomer(customer, extendEntity);
                    string customerCode = extendEntity.CustomerCode;


                    //绑定和业务员之间的关系
                    SalerRelationEntity sr = new SalerRelationEntity();
                    sr.SalerCode    = code;
                    sr.SalerID      = sid;
                    sr.CustomerID   = customerID;
                    sr.CustomerCode = customerCode;
                    SalerService.CreateRelation(sr);
                }
            }
        }
Пример #10
0
        /// <summary>
        ///  验证登录功能
        /// </summary>
        /// <param name="telephone"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static CustomerEntity Login(string telephone, string password)
        {
            CustomerEntity     entity = null;
            CustomerRepository CR     = new CustomerRepository();
            CustomerInfo       info   = CR.Login(telephone, password);

            if (info != null)
            {
                entity              = new CustomerEntity();
                entity.Channel      = info.Channel;
                entity.CustomerCode = info.CustomerCode;
                entity.CustomerID   = info.CustomerID;
                entity.CustomerName = info.CustomerName;
                entity.Mobile       = info.Mobile;
                entity.Name         = info.Name;
                CustomerExtendEntity cutomerEntity = GetCustomerExtendByCustomerID(entity.CustomerID, true);
                entity.Detail = cutomerEntity;
            }
            return(entity);
        }
Пример #11
0
        public void Modify(CustomerExtendEntity extendEntity)
        {
            if (extendEntity != null)
            {
                CustomerEntity customer = new CustomerEntity();
                customer.CustomerID   = extendEntity.CustomerID;
                customer.CustomerName = extendEntity.CustomerName;
                customer.CustomerCode = extendEntity.CustomerCode;
                customer.Channel      = extendEntity.Channel;
                customer.Mobile       = extendEntity.Mobile;
                customer.WXCode       = extendEntity.WXCode;
                customer.Name         = "";
                if (customer.CustomerID < 1)
                {
                    customer.Password = EncryptHelper.MD5Encrypt("123456");
                }
                CustomerService.ModifyCustomer(customer, extendEntity);
            }

            Response.Redirect("/Customer/");
        }
Пример #12
0
        private static CustomerExtendEntity TranslateCustomerExtendEntity(CustomerExtendInfo info, bool isAPI = false)
        {
            CustomerExtendEntity entity = new CustomerExtendEntity();

            if (info != null)
            {
                entity.ID            = info.ID;
                entity.CustomerID    = info.CustomerID;
                entity.CustomerCode  = info.CustomerCode;
                entity.AttachmentIDs = info.AttachmentIDs;
                entity.CustomerName  = info.CustomerName;
                entity.Mobile        = info.Mobile;
                entity.Email         = info.Email;
                entity.CardType      = info.CardType;
                entity.CardNo        = info.CardNo;
                entity.Channel       = info.Channel;
                entity.RegisterTime  = info.RegisterTime;
                entity.Status        = info.Status;
                entity.AuditTime     = info.AuditTime;
                entity.Auditor       = info.Auditor;
                entity.ModifyDate    = info.ModifyDate;
                entity.Operator      = info.Operator;
                entity.Base64        = info.Base64;
                entity.WXCode        = info.WXCode;
                if (!string.IsNullOrEmpty(entity.CardType))
                {
                    BaseDataEntity cardType = BaseDataService.GetBaseDataAll().First(t => t.TypeCode == entity.CardType) ?? new BaseDataEntity();
                    entity.CardTypeInfo = cardType;
                }

                List <AttachmentEntity> attachments = new List <AttachmentEntity>();
                if (!string.IsNullOrEmpty(entity.AttachmentIDs))
                {
                    attachments = BaseDataService.GetAttachmentInfoByKyes(entity.AttachmentIDs, isAPI);
                }
                entity.AttachmentInfos = attachments;
            }

            return(entity);
        }
Пример #13
0
        private static CustomerEntity TranslateCustomerInfo(CustomerInfo info)
        {
            CustomerEntity entity = new CustomerEntity();

            if (info != null)
            {
                entity.CustomerID   = info.CustomerID;
                entity.CustomerCode = info.CustomerCode;
                entity.Password     = info.Password;
                entity.CustomerName = info.CustomerName;
                entity.Mobile       = info.Mobile;
                entity.Name         = info.Name;
                entity.Channel      = info.Channel;
                entity.WXCode       = info.WXCode;

                CustomerExtendEntity detail = GetCustomerExtendInfoByID(entity.CustomerID);
                if (detail != null && detail.ID > 0)
                {
                    entity.Detail = detail;
                }
            }

            return(entity);
        }
Пример #14
0
        public ActionResult Edit(long cid = -1)
        {
            List <BaseDataEntity> cardTypes = BaseDataService.GetBaseDataAll().Where(t => t.PCode == "CD00").ToList();

            CustomerExtendEntity entity = new CustomerExtendEntity();

            if (cid > 0)
            {
                entity = CustomerService.GetCustomerExtendInfoByID(cid);
                if (entity == null || entity.ID < 1)
                {
                    CustomerEntity ce = CustomerService.GetCustomerByID(cid);
                    if (ce != null && ce.CustomerID > 0)
                    {
                        entity.CustomerID   = ce.CustomerID;
                        entity.CustomerName = ce.CustomerName;
                        entity.CustomerCode = ce.CustomerCode;
                        entity.Channel      = ce.Channel;
                        entity.Mobile       = ce.Mobile;
                        entity.WXCode       = ce.WXCode;
                    }
                }
            }
            else
            {
                entity.CustomerCode = DateTime.Now.ToString("yyyyMMddHHmmss");
                entity.RegisterTime = DateTime.Now;
                entity.AuditTime    = DateTime.Parse("1753-01-01");
                entity.Channel      = 3;
            }

            ViewBag.Extend    = entity;
            ViewBag.CardTypes = cardTypes;

            return(View());
        }