/// <summary> /// 生成兑换码 /// </summary> /// <param name="PackId"></param> /// <param name="quantity"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public ActionResult GenerateRedemptionCode(long PackId, int quantity, string startTime, string endTime) { DateTime startDate, endDate; if (!DateTime.TryParse(startTime, out startDate) || !DateTime.TryParse(endTime, out endDate) || quantity < 1) { return(Json(new { status = false, msg = "参数错误" })); } startDate = startDate.Date; endDate = endDate.Date.AddDays(1).AddSeconds(-1); if (startDate > endDate || endDate < DateTime.Now) { return(Json(new { status = false, msg = "开始时间不能大于结束时间,并且结束时间不能小于当前时间" })); } var manager = new VipBaoYangPackageManager(); var coupons = manager.GetGiftPackCouponConfig(PackId); if (coupons == null || !coupons.Any()) { return(Json(new { status = false, msg = "您还没有给礼包添加优惠券" })); } var result = manager.GenerateRedemptionCode(PackId, quantity, startDate, endDate, User.Identity.Name); return(Json(new { status = result })); }