private static void AutoSendBirthdayCoupon() { var customer = new CustomerRepo().GetCustomers(); var NowMonth = DateTime.Now.Month; foreach (var c in customer) { if (c.Birthday.Month == NowMonth) { int result = _couponRepo.GetCouponByAcc(c.Account, 1); if (result == 0) { _couponRepo.AddBirthdayCoupon(c.Account); } } } }
public static void AutoSendBuyTimesCoupon() { var customer = _customerRepo.GetCustomers(); foreach (var c in customer) { var times = _buyHistoryRepo.GetBuyTimes(c.Account); if (times.Count >= 1 && _couponRepo.GetCouponByAcc(c.Account, 3) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 3); } if (times.Count >= 5 && _couponRepo.GetCouponByAcc(c.Account, 4) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 4); } if (times.Count >= 10 && _couponRepo.GetCouponByAcc(c.Account, 5) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 5); } if (times.Count >= 15 && _couponRepo.GetCouponByAcc(c.Account, 6) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 6); } if (times.Count >= 20 && _couponRepo.GetCouponByAcc(c.Account, 7) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 7); } if (times.Count >= 25 && _couponRepo.GetCouponByAcc(c.Account, 8) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 8); } if (times.Count >= 30 && _couponRepo.GetCouponByAcc(c.Account, 9) == 0) { _couponRepo.AddBuyTimesCoupon(c.Account, 9); } } }