/// <summary> /// 添加礼包优惠券配置 /// </summary> /// <param name="packId"></param> /// <param name="getRuleId"></param> /// <param name="quantity"></param> /// <returns></returns> public ActionResult AddGiftPackCouponConfig(long packId, int quantity, Guid?getRuleId) { if (packId < 0 || getRuleId == null || getRuleId.Value == Guid.Empty || quantity < 0) { return(Json(new { status = false, msg = "礼包、优惠券领取Id、优惠券数量必须填写" })); } var manager = new VipBaoYangPackageManager(); var users = new[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }; if (!users.Contains(User.Identity.Name)) { var list = manager.GetRedemptionCodeSimpleInfo(packId); if (list.Any()) { return(Json(new { status = false, msg = "已经生成过兑换码不能再添加优惠券" })); } } var validatedResult = manager.ValidateGiftPackCouponConfig(packId, getRuleId.Value); if (!validatedResult.Item1) { return(Json(new { status = false, msg = validatedResult.Item2 })); } var result = manager.AddGiftPackCouponConfig(packId, getRuleId.Value, quantity, User.Identity.Name); return(Json(new { status = result })); }
/// <summary> /// 根据礼包Id获取优惠券配置 /// </summary> /// <param name="packId"></param> /// <returns></returns> public ActionResult GetGiftPackCouponConfig(long packId) { var manager = new VipBaoYangPackageManager(); var result = manager.GetGiftPackCouponConfig(packId); var list = manager.GetRedemptionCodeSimpleInfo(packId); var existsRedemptionCode = list.Any(); return(Json(new { data = result.Select(x => new { x.RuleID, x.Description, x.GetRuleID, x.Name, x.PackId, x.PromtionName, x.Quantity, x.Term, ValiEndDate = x.ValiEndDate?.ToString("yyyy-MM-dd"), ValiStartDate = x.ValiStartDate?.ToString("yyyy-MM-dd"), }), ExistsRedemptionCode = existsRedemptionCode, }, JsonRequestBehavior.AllowGet)); }