public DTOResponse <DTOUser> Activate(DTOInfo activateUserInfo) { var getUserResponse = GetUserByEmail(activateUserInfo.Email); if (getUserResponse.Code != 200) { return(new DTOResponse <DTOUser>() { Code = 400, Message = "This user email incorrect or not registered!" }); } var existingUser = getUserResponse.Data; if (string.IsNullOrWhiteSpace(existingUser.VerificationCode) || existingUser.VerificationCode != activateUserInfo.Code) { return(new DTOResponse <DTOUser>() { Code = 400, Message = "This verification code is not valid!" }); } _userCollection.UpdateOne <UserModel>(user => user.Id == existingUser.Id, Builders <UserModel> .Update.Set("VerificationCode", "").Set("IsActive", true)); return(new DTOResponse <DTOUser>() { Code = 200, Data = existingUser }); }
public DTOResponse <bool> ForgetPassword(DTOInfo forgetPasswordInfo) { if (string.IsNullOrWhiteSpace(forgetPasswordInfo.Email) || string.IsNullOrWhiteSpace(forgetPasswordInfo.Code) || string.IsNullOrWhiteSpace(forgetPasswordInfo.Password) || string.IsNullOrWhiteSpace(forgetPasswordInfo.ConfirmPassword)) { return(new DTOResponse <bool>() { Code = 400, Message = "Email, Code, Password and ConfirmPassword are required!" }); } var getUserResponse = GetUserByEmail(forgetPasswordInfo.Email); if (getUserResponse.Code != 200) { return(new DTOResponse <bool>() { Code = 400, Message = "This user email incorrect or not registered!" }); } var existingUser = getUserResponse.Data; if (string.IsNullOrWhiteSpace(existingUser.VerificationCode) || existingUser.VerificationCode != forgetPasswordInfo.Code) { return(new DTOResponse <bool>() { Code = 400, Message = "This verification code is not valid!" }); } if (forgetPasswordInfo.Password != forgetPasswordInfo.ConfirmPassword) { return(new DTOResponse <bool>() { Code = 400, Message = "The password and confirm password dont match!" }); } var newUserPasswordHash = SecurePasswordHasher.Hash(forgetPasswordInfo.ConfirmPassword); _userCollection.UpdateOne <UserModel>(user => user.Id == existingUser.Id, Builders <UserModel> .Update.Set("VerificationCode", "").Set("PasswordHash", newUserPasswordHash)); return(new DTOResponse <bool>() { Code = 200 }); }
public void Persist(OrderInfo order) { foreach (var subOrder in order.SubOrderList.Values) { //创建订单捆绑销售规则 var dicountDetailGroups = subOrder.DiscountDetailList.Where(x => x.DiscountType == 1 && x.DiscountActivityNo > 0) .GroupBy( k => new { SaleRuleSysNo = k.DiscountActivityNo, SaleRuleName = k.DiscountActivityName }, v => v ); DTOInfo dtoInfo = null; StringBuilder note = new StringBuilder(); decimal discount = 0m; foreach (var theGroup in dicountDetailGroups) { dtoInfo = new DTOInfo(); discount = 0m; note.Clear(); foreach (var item in theGroup) { discount += item.UnitDiscount * item.Quantity; note.AppendFormat("{0},{1},{2};", item.Quantity, item.ProductSysNo, (-1) * item.UnitDiscount); } dtoInfo["SOSysNo"] = subOrder.ID; dtoInfo["SaleRuleSysNo"] = theGroup.Key.SaleRuleSysNo; dtoInfo["SaleRuleName"] = theGroup.Key.SaleRuleName; dtoInfo["Discount"] = (-1m) * discount; dtoInfo["Times"] = 1; //拆单的时候,套餐的折扣信息已经合并,Discount字段记录的即是总折扣 dtoInfo["Note"] = note.ToString(); PipelineDA.CreateSalesRuleInfo(dtoInfo); } //更新优惠券信息 if (subOrder.CouponCodeSysNo.HasValue && subOrder.CouponCodeSysNo > 0) { PipelineDA.CreateSONewPromotionLog(subOrder); } if (subOrder.MerchantCouponCodeSysNo.HasValue && subOrder.MerchantCouponCodeSysNo > 0) { PipelineDA.CreateSONewMerchantPromotionLog(subOrder); } } }
public DTOResponse <bool> ValidateVerificationCode(DTOInfo validateCodeInfo) { if (string.IsNullOrWhiteSpace(validateCodeInfo.Email) || string.IsNullOrWhiteSpace(validateCodeInfo.Code)) { return(new DTOResponse <bool>() { Code = 400, Message = "Email and Code are required!" }); } var getUserResponse = GetUserByEmail(validateCodeInfo.Email); if (getUserResponse.Code != 200) { return(new DTOResponse <bool>() { Code = 400, Message = "This user email incorrect or not registered!" }); } var existingUser = getUserResponse.Data; if (string.IsNullOrWhiteSpace(existingUser.VerificationCode) || existingUser.VerificationCode != validateCodeInfo.Code) { return(new DTOResponse <bool>() { Code = 400, Message = "This verification code is not valid!" }); } return(new DTOResponse <bool>() { Code = 200 }); }
public override string TransferIn(DTOInfo inf, BUS.BUSControl.TransferMode mode) { string sErr = string.Empty; if (inf is CpPackageEventInfo) { ((CpPackageEventInfo)inf).updatedby = USER_ID; if (mode == BUS.BUSControl.TransferMode.AddNew) { ((CpPackageEventInfo)inf).createdby = USER_ID; Add((DTO.CpPackageEventInfo)inf, ref sErr); } else if (mode == BUS.BUSControl.TransferMode.Update) { sErr = Update((CpPackageEventInfo)inf); } else { sErr = InsertUpdate((CpPackageEventInfo)inf); } } return(sErr); }
public void Persist(OrderInfo order) { //更新当前收货地址为用户的默认收货地址 PipelineDA.SetCustomerShippingAddressAsDefault(order.Contact.ID, order.Customer.SysNo); foreach (var subOrder in order.SubOrderList.Values) { //更新用户积分信息 if (subOrder.PointPayAmount > 0m) { subOrder["Memo"] = "创建订单扣减积分"; var msgResult = PipelineDA.UpdatePointForCustomer(subOrder); if (String.IsNullOrWhiteSpace(msgResult) || !msgResult.Trim().Equals("1000099")) { ECommerce.Utility.Logger.WriteLog("Update point of customer failed,ErrorCode:" + msgResult, "SOPipeline.NeweggSpecialPersister"); throw new BusinessException("用户积分不足"); } } //更新用户余额 if (subOrder.BalancePayAmount > 0m) { PipelineDA.UpdateCustomerPrepayBasic(subOrder); } //更新用户扩展信息 PipelineDA.UpdateCustomerExtend(subOrder); //订单发货仓库 //subOrder["LocalWHSysNo"] = subOrder.OrderItemGroupList.FirstOrDefault().ProductItemList.FirstOrDefault().WarehouseNumber; subOrder["LocalWHSysNo"] = subOrder["WarehouseNumber"]; //订单运费检查 PipelineDA.UpdateSOCheckShipping(subOrder); //创建订单扩展信息 PipelineDA.CreateSOMasterExtension(subOrder); //创建订单商品扩展信息 if (subOrder.OrderItemGroupList != null) { //只记录团购商品信息,用于job后台结算 subOrder.OrderItemGroupList.ForEach(g => { if (g.ProductItemList != null) { g.ProductItemList.Where(x => x.SpecialActivityType == 1) .ToList() .ForEach(item => { item["SOSysNo"] = subOrder.ID; item["ItemExtensionType"] = "G"; PipelineDA.CreateSOItemExtension(item); }); } }); } //新赠品规则 subOrder.AttachmentItemList.ForEach(item => { item["SOSysNo"] = subOrder.ID; PipelineDA.CreateSOItemAttachmentAccessory(item); //创建订单所有附件 }); List <DTOInfo> orderGiftMasterList = new List <DTOInfo>(); subOrder.GiftItemList.ForEach(item => { DTOInfo dtoInfo = orderGiftMasterList.Find(f => (int)f["ActivityNo"] == item.ActivityNo); if (dtoInfo == null) { dtoInfo = new DTOInfo(); dtoInfo["SOSysNo"] = subOrder.ID; dtoInfo["ActivityNo"] = item.ActivityNo; dtoInfo["SaleGiftType"] = item.SaleGiftType; dtoInfo["Count"] = item.UnitQuantity; dtoInfo["Order"] = 0; orderGiftMasterList.Add(dtoInfo); } else { dtoInfo["Count"] = (int)dtoInfo["Count"] + item.UnitQuantity; dtoInfo["Order"] = (int)dtoInfo["Order"] + 1; } PipelineDA.CreateSOItemGiftAccessory(item); //创建订单所有赠品 PipelineDA.CreateSOGiftItem(item); //促销活动订单赠品列表 }); foreach (DTOInfo dtoInfo in orderGiftMasterList) { PipelineDA.CreateSOGiftMaster(dtoInfo);//促销活动订单赠送 } } }
public DTOResponse <DTOUser> Login(DTOInfo loginInfo) { if (string.IsNullOrWhiteSpace(loginInfo.Email) || string.IsNullOrWhiteSpace(loginInfo.Password)) { return(new DTOResponse <DTOUser>() { Code = 400, Message = "Email and Password are required!" }); } var getUserResponse = GetUserByEmail(loginInfo.Email); if (getUserResponse.Code != 200) { return(new DTOResponse <DTOUser>() { Code = 401, Message = "Invalid user email or password!" }); } var existingUser = getUserResponse.Data; //if (!existingUser.IsActive) //{ // return new DTOApiResponse() // { // Code = 400, // Message = "This user is not active, please check your email, we have sent you a verification code!" // }; //} var userSavedPasswordHash = this.GetUserPasswordHash(existingUser.Id); var passwordIsValid = SecurePasswordHasher.Verify(loginInfo.Password, userSavedPasswordHash); if (!passwordIsValid) { return(new DTOResponse <DTOUser>() { Code = 401, Message = "Invalid user email or password!" }); } LoadUserInfo(existingUser); var token = new JwtSecurityToken( expires: DateTime.Now.AddDays(7), claims: new[] { new Claim(JwtRegisteredClaimNames.Sub, existingUser.Id) }, signingCredentials: new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_generalSettings.JwtSecret)), SecurityAlgorithms.HmacSha256) ); existingUser.Token = new JwtSecurityTokenHandler().WriteToken(token); return(new DTOResponse <DTOUser>() { Code = 200, Data = existingUser }); }
public DTOResponse <List <DTOPet> > GetAllPetsFromUser(DTOInfo loginInfo) { return(_petDomain.GetPetsByUserId(loginInfo.Id)); }
public DTOResponse <bool> ChangePassword(DTOInfo changePasswordInfo) { return(_userDomain.ChangePassword(changePasswordInfo)); }
public DTOResponse <bool> ValidateVerificationCode(DTOInfo validateCodeInfo) { return(_userDomain.ValidateVerificationCode(validateCodeInfo)); }
public DTOResponse <bool> SendActivationCode(DTOInfo activateUserInfo) { return(_userDomain.SendVerificationCode(activateUserInfo.Email)); }
public DTOResponse <DTOUser> Activate(DTOInfo activateUserInfo) { return(_userDomain.Activate(activateUserInfo)); }
public DTOResponse <bool> CheckIfEmailExists(DTOInfo checkIfEmailExistsInfo) { return(_userDomain.CheckIfEmailExists(checkIfEmailExistsInfo.Email)); }
public DTOResponse <DTOUser> AdminLogin(DTOInfo loginInfo) { return(_userDomain.AdminLogin(loginInfo)); }
public DTOResponse <bool> ForgotPassword(DTOInfo forgetPasswordInfo) { return(_userDomain.ForgetPassword(forgetPasswordInfo)); }