/// <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 }));
        }
        /// <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));
        }