Exemple #1
0
        /// <summary>
        /// 优惠券设置
        /// </summary>
        /// <param name="mCouponRegister"></param>
        public static void SetCouponSendByRegister(Himall.DTO.CouponSendByRegisterModel mCouponSendByRegisterModel)
        {
            List <Himall.Model.CouponSendByRegisterDetailedInfo> lmCouponSendByRegisterDetailed = new List <Model.CouponSendByRegisterDetailedInfo>();

            foreach (var item in mCouponSendByRegisterModel.CouponIds)
            {
                lmCouponSendByRegisterDetailed.Add(new Himall.Model.CouponSendByRegisterDetailedInfo()
                {
                    CouponId = item.Id
                });
            }
            var model = new Himall.Model.CouponSendByRegisterInfo
            {
                Himall_CouponSendByRegisterDetailed = lmCouponSendByRegisterDetailed,
                Link   = mCouponSendByRegisterModel.Link,
                Status = mCouponSendByRegisterModel.Status,
                Id     = mCouponSendByRegisterModel.Id
            };

            if (model.Id <= 0)
            {
                CouponSendByRegisterApplication.AddCouponSendByRegister(model);
            }
            else
            {
                CouponSendByRegisterApplication.UpdateCouponSendByRegister(model);
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取优惠券设置
        /// </summary>
        /// <returns></returns>
        public static Himall.DTO.CouponSendByRegisterModel GetCouponSendByRegister()
        {
            var vModel = new Himall.DTO.CouponSendByRegisterModel();
            var model  = CouponSendByRegisterApplication.GetCouponSendByRegister();

            if (model != null)
            {
                vModel.Id     = model.Id;
                vModel.Link   = model.Link;
                vModel.Status = model.Status;

                int     total    = 0;
                decimal price    = 0;
                var     lmCoupon = new List <Himall.DTO.CouponModel>();
                foreach (var item in model.Himall_CouponSendByRegisterDetailed)
                {
                    int inventory = item.Himall_Coupon.Num - item.Himall_Coupon.Himall_CouponRecord.Count();//优惠券剩余量
                    if (inventory > 0 && item.Himall_Coupon.EndTime > DateTime.Now)
                    {
                        total += inventory;
                        price += item.Himall_Coupon.Price;
                        lmCoupon.Add(new Himall.DTO.CouponModel
                        {
                            Id          = item.CouponId,
                            CouponName  = item.Himall_Coupon.CouponName,
                            inventory   = inventory,
                            Num         = item.Himall_Coupon.Num,
                            useNum      = item.Himall_Coupon.Himall_CouponRecord.Count(),
                            Price       = item.Himall_Coupon.Price,
                            ShopId      = item.Himall_Coupon.ShopId,
                            ShopName    = item.Himall_Coupon.ShopName,
                            EndTime     = item.Himall_Coupon.EndTime,
                            StartTime   = item.Himall_Coupon.StartTime,
                            OrderAmount = item.Himall_Coupon.OrderAmount == 0 ? "不限制" : "满" + item.Himall_Coupon.OrderAmount
                        });
                    }
                }
                vModel.CouponIds = lmCoupon;
                vModel.total     = total;
                vModel.price     = price;
                if (vModel.CouponIds.Count.Equals(0))
                {
                    vModel.Status = Himall.CommonModel.CouponSendByRegisterStatus.Shut;
                }
            }
            return(vModel);
        }