/// <summary> /// 发放优惠券到指定会员 /// </summary> /// <param name="member"></param> /// <param name="coupon"></param> /// <returns></returns> private bool SendCouponToMember(Member member, Models.Coupon coupon) { CouponRelation couponRel = new CouponRelation { Id = KeyGenerator.GetGuidKey(), CouponId = coupon.Id, CouponCode = _couponService.CreateCouponCode(), MemberId = member.Id, CreateTime = DateTime.Now, IsUsed = false, FromType = CouponRelation.EnumFromType.Send }; //有效期 if (coupon.ExpiryType == ExpiryType.ExpiryByDay) { couponRel.StartTime = DateTime.Now; if (coupon.ExpiryDay != 0) { couponRel.EndTime = DateTime.Now.AddDays(Convert.ToInt32(coupon.ExpiryDay)); } else { couponRel.EndTime = DateTime.MaxValue; } } else { couponRel.StartTime = coupon.StartTime; couponRel.EndTime = coupon.EndTime; } return(_currencyService.Create(couponRel)); }
public CouponRelationModel(CouponRelation model) { CouponCode = model.CouponCode; CouponType = model.Coupon.CouponType; Id = model.CouponId; Title = model.Coupon.Title; Describe = model.Coupon.Describe; IsUsed = model.IsUsed; StartTime = Convert.ToDateTime(model.StartTime).ToString("yyyy-MM-dd"); EndTime = Convert.ToDateTime(model.EndTime).ToString("yyyy-MM-dd"); if (model.Coupon.CouponType == CouponType.FullCut) { Money = model.Coupon.Money; Minimum = model.Coupon.Minimum; } else { Discount = model.Coupon.Discount; } if (model.IsUsed) { Status = 1; //已使用 } else { if (Convert.ToDateTime(model.EndTime) < DateTime.Now) { Status = 2; //已失效 } else { Status = 0;//未使用 } } }