Beispiel #1
0
        public ResponseModel SendBindMobileCode(string Mobile, string OpenId)
        {
            var    result = new ResponseModel();
            object obj    = new object();

            result.error_code = Result.SUCCESS;
            if (CheckInputHelper.RegexPhone(Mobile) && !string.IsNullOrWhiteSpace(OpenId))
            {
                var user = _userService.GetUserByPhoneOrOpenId(Mobile, OpenId);
                if (user == null)
                {
                    //发送验证码
                    lock (obj)
                    {
                        string code = Assistant.GetRandomNumber(6);
                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        dic.Add("code", code);
                        dic.Add("product", "H5点餐系统");
                        var a = SendSMSCommon.SendSMSsingleAsync(SmsTemplate.SmsRegister, Mobile, dic);
                        _smsLogService.Insert(new SmsLog()
                        {
                            Code       = code,
                            CreateTime = System.DateTime.Now,
                            Module     = (int)EnumHelp.SmsLogModuleEnum.前端,
                            Phone      = Mobile,
                            Remark     = "手机绑定验证码"
                        });
                    }
                }
                else
                {
                    result.message    = "您已绑定手机号,请勿重复绑定";
                    result.error_code = Result.ERROR;
                }
            }
            else
            {
                result.message    = "手机号码或OpenId有误";
                result.error_code = Result.ERROR;
            }
            return(result);
        }
Beispiel #2
0
        public ResponseModel <int> PostAppointment(PostAppointment postAppointment)
        {
            var result = new ResponseModel <int>();

            result.error_code = Result.SUCCESS;
            if (string.IsNullOrWhiteSpace(postAppointment.value_ids))
            {
                throw new Exception("衣品id不能为空");
            }
            if (postAppointment.module != (int)EnumHelp.BusinessTypeEnum.食)
            {
                throw new Exception("模块id有误");
            }
            var user = _userService.GetById(postAppointment.user_id);

            if (user == null || user.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || user.Status == (int)EnumHelp.EnabledEnum.无效)
            {
                throw new Exception("用户id有误,或用户已删除");
            }
            var business = _businessInfoService.GetById(postAppointment.business_id);

            if (business == null || business.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || business.Status == (int)EnumHelp.EnabledEnum.无效)
            {
                throw new Exception("商家id有误,或商家已删除");
            }
            DateTime appointTime;

            if (postAppointment.appointment_time == null)
            {
                throw new Exception("预约时间不能为空");
            }
            else if (!DateTime.TryParse(postAppointment.ToString(), out appointTime))
            {
                throw new Exception("预约时间有误");
            }
            if (string.IsNullOrWhiteSpace(postAppointment.user_name))
            {
                throw new Exception("用户名不能为空");
            }

            if (!CheckInputHelper.RegexPhone(postAppointment.phone_no))
            {
                throw new Exception("手机号码有误");
            }
            DateTime createTime = System.DateTime.Now;
            var      goodsIds   = postAppointment.value_ids.Split(',').ToArray();

            int[] output = Array.ConvertAll <string, int>(goodsIds, delegate(string s) { return(int.Parse(s)); });
            var   goods  = business.BusinessGoodsList.Where(c => c.IsDelete == (int)EnumHelp.IsDeleteEnum.效 && c.Status == (int)EnumHelp.IsDeleteEnum.效).ToList();

            if (goods != null && goods.Count > 0)
            {
                var searchGoods = goods.Where(c => output.Contains(c.GoodsId)).ToList();
                if (searchGoods != null && searchGoods.Count == output.Length)
                {
                    var insertResult = _appointmentService.Insert(new Appointment()
                    {
                        AppointmentTime = appointTime,
                        BusinessInfoId  = postAppointment.business_id,
                        UserId          = postAppointment.user_id,
                        CreateTime      = createTime,
                        DenyReason      = "",
                        EditTime        = createTime,
                        ModuleId        = postAppointment.module,
                        Status          = (int)EnumHelp.IsDeleteEnum.效,
                        IsDelete        = (int)EnumHelp.IsDeleteEnum.效,
                        Remark          = postAppointment.remark,
                        ValueIds        = postAppointment.value_ids,
                        UserName        = postAppointment.user_name,
                        Phone           = postAppointment.phone_no
                    });
                    if (insertResult.AppointmentId <= 0)
                    {
                        throw new Exception("预约失败");
                    }
                    result.data = insertResult.AppointmentId;
                }
                else
                {
                    throw new Exception("衣品id有误");
                }
            }
            else
            {
                throw new Exception("商家无衣品可以预约");
            }
            return(result);
        }
        public ResponseModel <CustomerDTO> AddCustomer(Customer Customer)
        {
            var result = new ResponseModel <CustomerDTO>();

            result.error_code  = Result.SUCCESS;
            result.total_count = 0;
            EnumHelp.IdCardType type;
            if (Customer.UserId <= 0 || Customer.CardType <= 0 || string.IsNullOrWhiteSpace(Customer.Name) || string.IsNullOrWhiteSpace(Customer.Mobile) || string.IsNullOrWhiteSpace(Customer.CardNo))
            {
                result.error_code = Result.ERROR;
                result.message    = "必须字段不能为0或空";
                return(result);
            }
            else if (!CheckInputHelper.RegexPhone(Customer.Mobile))
            {
                result.error_code = Result.ERROR;
                result.message    = "Mobile不合法";
                return(result);
            }
            else if (!CheckInputHelper.RegexCardNo(Customer.CardNo))
            {
                result.error_code = Result.ERROR;
                result.message    = "CardNo不合法";
                return(result);
            }
            else if (!Enum.TryParse(Customer.CardType.ToString(), out type))
            {
                result.error_code = Result.ERROR;
                result.message    = "CardType不合法";
                return(result);
            }
            var user = _userService.GetById(Customer.UserId);

            if (user == null)
            {
                result.error_code = Result.ERROR;
                result.message    = "用户不存在";
                return(result);
            }
            if (user.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || user.Status == (int)EnumHelp.EnabledEnum.无效)
            {
                result.error_code = Result.ERROR;
                result.message    = "用户状态无效";
                return(result);
            }
            CustomerDTO dto = new CustomerDTO();

            if (Customer.CustomerId > 0)//编辑
            {
                var customer = _customerService.GetById(Customer.CustomerId);
                if (customer != null)
                {
                    customer.EditTime = System.DateTime.Now;
                    customer.CardNo   = Customer.CardNo;
                    customer.CardType = Customer.CardType;
                    customer.Mobile   = Customer.Mobile;
                    customer.Name     = Customer.Name;
                    _customerService.Update(customer);
                    dto.CustomerId = Customer.CustomerId;
                }
            }
            else//新增
            {
                var searchCustomer = _customerService.GetCustomerByCardNo(Customer.UserId, Customer.CardNo, Customer.CardType);
                if (searchCustomer != null)
                {
                    result.error_code = Result.ERROR;
                    result.message    = "该身份证已存在";
                    return(result);
                }
                Customer.CustomerId = 0;
                Customer.CreateTime = System.DateTime.Now;
                Customer.EditTime   = System.DateTime.Now;
                var cus = _customerService.Insert(Customer);
                if (cus.CustomerId <= 0)
                {
                    result.error_code = Result.ERROR;
                    result.message    = "插入身份证失败";
                    return(result);
                }
                dto.CustomerId = cus.CustomerId;
            }
            result.data = dto;
            return(result);
        }
Beispiel #4
0
        public ResponseModel <int> BindMobile(PostBindMobile postBindMobile)
        {
            var result = new ResponseModel <int>();

            result.error_code = Result.SUCCESS;
            //参数验证
            if (!string.IsNullOrWhiteSpace(postBindMobile.Mobile) && !string.IsNullOrWhiteSpace(postBindMobile.Code) && !string.IsNullOrWhiteSpace(postBindMobile.OpenId) && CheckInputHelper.RegexPhone(postBindMobile.Mobile))
            {
                var getResult = _smsLogService.GetByPhoneNo(postBindMobile.Mobile);
                //获取验证码数据
                if (getResult != null)
                {
                    //判断验证码正误
                    if (getResult.Code == postBindMobile.Code)
                    {
                        var userByPhone = _userService.GetUserByPhoneOrOpenId(postBindMobile.Mobile, "");
                        if (userByPhone != null)//解绑
                        {
                            userByPhone.PhoneNo      = "";
                            userByPhone.EditTime     = System.DateTime.Now;
                            userByPhone.EditPersonId = (int)EnumHelp.SmsLogModuleEnum.前端;
                            _userService.Update(userByPhone);
                        }
                        var user = _userService.GetUserByPhoneOrOpenId("", postBindMobile.OpenId);
                        if (user != null)
                        {
                            user.PhoneNo  = postBindMobile.Mobile;
                            user.EditTime = System.DateTime.Now;
                            _userService.Update(user);
                            result.data = user.UserId;
                        }
                        else
                        {
                            result.error_code = Result.ERROR;
                            result.message    = "绑定失败OpenId不存在";
                        }
                    }
                    else
                    {
                        result.error_code = Result.ERROR;
                        result.message    = "验证码错误";
                    }
                }
                else
                {
                    result.error_code = Result.ERROR;
                    result.message    = "请先发送验证码";
                }
            }
            else
            {
                result.message    = "参数无效";
                result.error_code = Result.ERROR;
            }
            return(result);
        }