コード例 #1
0
ファイル: CouponController.cs プロジェクト: redpanda321/Mall
        public ActionResult Detail(long Id)
        {
            var model = _iCouponService.GetCouponInfo(CurrentSellerManager.ShopId, Id);

            if (model != null)
            {
                if (model.IsSyncWeiXin == 1 && model.WXAuditStatus != (int)WXCardLogInfo.AuditStatusEnum.Audited)
                {
                    throw new MallException("同步微信优惠券未审核通过时不可修改。");
                }
            }
            string host = CurrentUrlHelper.CurrentUrlNoPort();

            ViewBag.Url = String.Format("{0}/m-wap/vshop/CouponInfo/{1}", host, model.Id);
            var          map = Core.Helper.QRCodeHelper.Create(ViewBag.Url);
            MemoryStream ms  = new MemoryStream();

            map.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            //  将图片内存流转成base64,图片以DataURI形式显示
            string strUrl = "data:image/gif;base64," + Convert.ToBase64String(ms.ToArray());

            ms.Dispose();
            //  显示
            ViewBag.Image = strUrl;
            var market = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Coupon);

            ViewBag.EndTime = MarketApplication.GetServiceEndTime(market.Id).ToString("yyyy-MM-dd");
            return(View(model));
        }
コード例 #2
0
        ///// <summary>
        ///// 重写验证,以过滤未购买服务或已过期情况
        ///// </summary>
        ///// <param name="filterContext"></param>
        //protected override void OnActionExecuting(ActionExecutingContext filterContext)
        //{
        //    //路由处理
        //    var route = filterContext.RouteData;
        //    //string controller = route.Values["controller"].ToString().ToLower();
        //    string action = route.Values["action"].ToString().ToLower();
        //    if (action.ToLower() != "nosetting")
        //    {
        //        bool iscanmarket = FightGroupApplication.IsCanUseMarketService(CurShopId);
        //        if (!iscanmarket && action.ToLower() != "buymarketservice")
        //        {
        //            if (FightGroupApplication.IsOpenMarketService())
        //            {
        //                filterContext.Result = RedirectToAction("BuyMarketService");
        //                return;
        //            }
        //            else
        //            {
        //                filterContext.Result = RedirectToAction("Nosetting");
        //                return;
        //            }
        //        }
        //    }
        //    base.OnActionExecuting(filterContext);

        //}

        #region 活动列表
        /// <summary>
        /// 拼团管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var settings = MarketApplication.GetServiceSetting(MarketType.FightGroup);

            if (settings == null)
            {
                return(View("Nosetting"));
            }

            var market = MarketApplication.GetMarketService(CurShopId, MarketType.FightGroup);

            //未购买服务且列表刚进来则让进入购买服务页
            if ((market == null || market.Id <= 0) && Request.Query["first"].ToString() == "1")
            {
                return(RedirectToAction("BuyMarketService"));
            }

            ViewBag.Available = false;
            if (market != null && MarketApplication.GetServiceEndTime(market.Id) > DateTime.Now)
            {
                ViewBag.Available = true;
            }

            return(View());
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            var model = _iCollocationService.GetCollocation(id);

            if (model.ShopId != CurrentSellerManager.ShopId)
            {
                RedirectToAction("Management");
            }
            CollocationDataModel m = new CollocationDataModel();

            m.CreateTime = model.CreateTime.Value;
            m.EndTime    = model.EndTime;
            m.ShopId     = model.ShopId;
            m.ShortDesc  = model.ShortDesc;
            m.Title      = model.Title;
            m.StartTime  = model.StartTime;
            m.Id         = model.Id;
            var cProducts = _iCollocationService.GetProducts(new List <long> {
                model.Id
            });
            var cAllSKUs = _iCollocationService.GetSKUs(cProducts.Select(p => p.Id).ToList());
            var products = ProductManagerApplication.GetProductByIds(cProducts.Select(p => p.ProductId).ToList());
            var allSKUs  = ProductManagerApplication.GetSKUByProducts(products.Select(p => p.Id).ToList());

            m.CollocationPoruducts = cProducts.Select(a =>
            {
                var product = products.FirstOrDefault(p => p.Id == a.ProductId);
                var skus    = allSKUs.Where(p => p.ProductId == a.ProductId);
                var cSKUs   = cAllSKUs.Where(p => p.ColloProductId == a.Id);
                return(new CollocationPoruductModel()
                {
                    Id = a.Id,
                    ColloId = a.ColloId,
                    DisplaySequence = a.DisplaySequence,
                    IsMain = a.IsMain,
                    ProductId = a.ProductId,
                    ProductName = product ? .ProductName,
                    ImagePath = product ? .ImagePath,
                    CollocationSkus = cSKUs.Select(b =>
                    {
                        var sku = skus.FirstOrDefault(t => t.Id == b.SkuID);
                        return new CollocationSkus()
                        {
                            Id = b.Id,
                            Price = b.Price,
                            SkuID = b.SkuID,
                            SKUName = sku == null ? "" : sku.Color + " " + sku.Size + " " + sku.Version,
                            SkuPirce = b.SkuPirce,
                            ColloProductId = b.ColloProductId,
                            ProductId = b.ProductId
                        };
                    }).ToList()
                });
            }).OrderBy(a => a.DisplaySequence).ToList();

            var market = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Collocation);

            ViewBag.EndTime = MarketApplication.GetServiceEndTime(market.Id).ToString("yyyy-MM-dd");
            return(View(m));
        }
コード例 #4
0
        private void SetExpire()
        {
            var  now    = DateTime.Now.Date;
            var  model  = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Collocation);
            bool expire = false;

            ViewBag.LastBuyPrice = -1;
            if (model == null || model.Id <= 0)
            {
                ViewBag.IsBuy        = false;
                expire               = true;
                ViewBag.LastBuyPrice = 0;
            }
            else
            {
                ViewBag.IsBuy = true;
                var endTime = MarketApplication.GetServiceEndTime(model.Id);;
                if (endTime < now)
                {
                    expire = true;
                    ViewBag.EndDateInfo = string.Format("<font class=\"red\">{0} 年 {1} 月 {2} 日</font> (您的组合购服务已经过期)", endTime.Year, endTime.Month, endTime.Day);
                }
                else if (endTime >= now)
                {
                    ViewBag.EndDateInfo = string.Format("{0} 年 {1} 月 {2} 日", endTime.Year, endTime.Month, endTime.Day);
                }
                ViewBag.LastBuyPrice = MarketApplication.GetLastBuyPrice(model.Id);
            }
            ViewBag.Expire = expire;
        }
コード例 #5
0
        public JsonResult GetBoughtJson(string shopName, int page, int rows)
        {
            var queryModel = new MarketBoughtQuery()
            {
                PageSize   = rows,
                PageNo     = page,
                ShopName   = shopName,
                MarketType = MarketType.LimitTimeBuy
            };

            QueryPageModel <Entities.MarketServiceRecordInfo> marketEntities = _iMarketService.GetBoughtShopList(queryModel);

            var market = marketEntities.Models.OrderByDescending(m => m.MarketServiceId).ThenByDescending(m => m.EndTime)
                         .Select(item => {
                var obj = MarketApplication.GetMarketService(item.MarketServiceId);
                return(new
                {
                    Id = item.Id,
                    StartDate = item.StartTime.ToString("yyyy-MM-dd"),
                    EndDate = item.EndTime.ToString("yyyy-MM-dd"),
                    ShopName = obj.ShopName
                });
            });

            return(Json(new { rows = market, total = marketEntities.Total }));
        }
コード例 #6
0
        public ActionResult Add()
        {
            var market = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Collocation);

            ViewBag.EndTime = MarketApplication.GetServiceEndTime(market.Id).ToString("yyyy-MM-dd");
            return(View());
        }
コード例 #7
0
        public ActionResult BuyService()
        {
            var market = _iLimitTimeBuyService.GetMarketService(CurrentSellerManager.ShopId);

            ViewBag.Market = market;
            string endDate = null;
            bool   expired = false;

            ViewBag.LastBuyPrice = -1;
            if (market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(market.Id);

                if (market != null && endtime < DateTime.Now)
                {
                    endDate = string.Format("<font class=\"red\">{0} 年 {1} 月 {2} 日</font> (您的限时购服务已经过期)", endtime.Year, endtime.Month, endtime.Day);
                    expired = true;
                }
                else if (market != null && endtime > DateTime.Now)
                {
                    endDate = string.Format("{0} 年 {1} 月 {2} 日", endtime.Year, endtime.Month, endtime.Day);
                }

                ViewBag.LastBuyPrice = MarketApplication.GetLastBuyPrice(market.Id);
            }
            else
            {
                expired = true;
                ViewBag.LastBuyPrice = 0;
            }
            ViewBag.IsExpired = expired;
            ViewBag.EndDate   = endDate;
            ViewBag.Price     = _iLimitTimeBuyService.GetServiceSetting().Price;
            return(View());
        }
コード例 #8
0
        public void SetUp()
        {
            MarketApplication application = new MarketApplication();

            mock            = new Mock <IDataProvider>();
            this.controller = application.Dispatcher.Locate <ProductsController>();
        }
コード例 #9
0
        public ActionResult Management()
        {
            var settings = MarketApplication.GetServiceSetting(MarketType.LimitTimeBuy);

            if (settings == null)
            {
                return(View("Nosetting"));
            }

            var market = MarketApplication.GetMarketService(CurrentSellerManager.ShopId, MarketType.LimitTimeBuy);

            //未购买服务且列表刚进来则让进入购买服务页
            if ((market == null || market.Id <= 0) && Request.QueryString["first"] == "1")
            {
                return(RedirectToAction("BuyService"));
            }

            ViewBag.Available = false;
            if (market != null && MarketApplication.GetServiceEndTime(market.Id) > DateTime.Now)
            {
                ViewBag.Available = true;
            }

            return(View());
        }
コード例 #10
0
ファイル: CouponController.cs プロジェクト: redpanda321/Mall
        // GET: SellerAdmin/Coupon
        public ActionResult Management()
        {
            //处理错误同步结果
            _iCouponService.ClearErrorWeiXinCardSync();

            var settings = MarketApplication.GetServiceSetting(MarketType.Coupon);

            if (settings == null)
            {
                return(View("Nosetting"));
            }

            var market = _iCouponService.GetCouponService(CurrentSellerManager.ShopId);

            //未购买服务且列表刚进来则让进入购买服务页
            if ((market == null || market.Id <= 0) && Request.Query["first"].ToString() == "1")
            {
                return(RedirectToAction("BuyService"));
            }

            ViewBag.Available = false;
            if (market != null && MarketApplication.GetServiceEndTime(market.Id) > DateTime.Now)
            {
                ViewBag.Available = true;
            }

            return(View());
        }
コード例 #11
0
ファイル: CouponController.cs プロジェクト: redpanda321/Mall
        public ActionResult BuyService()
        {
            var market = _iCouponService.GetCouponService(CurrentSellerManager.ShopId);

            ViewBag.Market = market;
            string endDate = null;

            ViewBag.Available    = false;
            ViewBag.LastBuyPrice = -1;
            if (market != null)
            {
                var now     = DateTime.Now.Date;
                var endtime = MarketApplication.GetServiceEndTime(market.Id);
                ViewBag.Available = false;
                if (endtime < now)
                {
                    endDate = string.Format("<font class=\"red\">{0} 年 {1} 月 {2} 日</font> (您的优惠券服务已经过期)", endtime.Year, endtime.Month, endtime.Day);
                }
                else if (endtime >= now)
                {
                    ViewBag.Available = true;
                    endDate           = string.Format("{0} 年 {1} 月 {2} 日", endtime.Year, endtime.Month, endtime.Day);
                }
                ViewBag.LastBuyPrice = MarketApplication.GetLastBuyPrice(market.Id);
            }
            ViewBag.EndDate = endDate;
            ViewBag.Price   = _iMarketService.GetServiceSetting(MarketType.Coupon).Price;
            return(View());
        }
コード例 #12
0
ファイル: CouponController.cs プロジェクト: redpanda321/Mall
        public ActionResult Edit(long id)
        {
            var couponser = _iCouponService;
            var model     = couponser.GetCouponInfo(CurrentSellerManager.ShopId, id);

            if (model == null)
            {
                throw new MallException("错误的优惠券编号。");
            }
            if (model.IsSyncWeiXin == 1 && model.WXAuditStatus != (int)WXCardLogInfo.AuditStatusEnum.Audited)
            {
                throw new MallException("同步微信优惠券未审核通过时不可修改。");
            }

            model.FormIsSyncWeiXin = model.IsSyncWeiXin == 1;

            var viewmodel = new CouponViewModel();
            var products  = couponser.GetCouponProductsByCouponId(id);

            viewmodel.Coupon         = model;
            viewmodel.CouponProducts = products;
            viewmodel.Products       = ProductManagerApplication.GetProducts(products.Select(p => p.ProductId));
            viewmodel.Settings       = couponser.GetSettingsByCoupon(new System.Collections.Generic.List <long> {
                id
            });
            viewmodel.CanVshopIndex = CurrentSellerManager.VShopId > 0;
            var market = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Coupon);

            viewmodel.EndTime = MarketApplication.GetServiceEndTime(market.Id);
            viewmodel.CanAddIntegralCoupon = couponser.CanAddIntegralCoupon(CurrentSellerManager.ShopId, id);
            return(View(viewmodel));
        }
コード例 #13
0
        public JsonResult EditActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = FightGroupApplication.GetActive(model.Id);

            if (data == null)
            {
                throw new MallException("错误的活动编号");
            }
            if (model.EndTime < DateTime.Now)
            {
                throw new MallException("错误的结束时间");
            }
            if (model.EndTime < model.StartTime)
            {
                throw new MallException("错误的结束时间");
            }
            var market = MarketApplication.GetMarketService(CurrentSellerManager.ShopId, MarketType.FightGroup);

            if (market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(market.Id);
                var newEnd  = DateTime.Parse(endtime.ToString("yyyy-MM-dd") + " 23:59:59");
                if (newEnd < model.EndTime.Date)
                {
                    throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
                }
            }
            else
            {
                throw new MallException("您没有订购此服务");
            }
            if (ModelState.IsValid)
            {
                TryUpdateModelAsync(data);

                model = data;
                //数据有效性验证
                model.CheckValidation();

                data.IconUrl = SaveActiveIcon(data.IconUrl);


                FightGroupApplication.UpdateActive(data);
                ProductManagerApplication.SaveCaculateMinPrice(model.ProductId, CurrentShop.Id);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            else
            {
                result = new Result {
                    success = false, msg = "数据异常,请检查数据有效性", status = -1
                };
            }
            return(Json(result));
        }
コード例 #14
0
        public bool IsOverDate(DateTime bonusDateEnd, DateTime dateEnd, long shopid)
        {
            var market = GetShopBonusService(shopid);
            var time   = MarketApplication.GetServiceEndTime(market.Id);

            if (bonusDateEnd > time || dateEnd > time)
            {
                return(true);
            }
            return(false);
        }
コード例 #15
0
        public ActionResult IsOverDate(string bend, string end)
        {
            bool isExpired = false;
            var  market    = _bonusService.GetShopBonusService(CurrentSellerManager.ShopId);
            var  time      = MarketApplication.GetServiceEndTime(market.Id);
            var  newEnd    = DateTime.Parse(time.ToString("yyyy-MM-dd") + " 23:59:59");

            if (DateTime.Parse(bend) > newEnd || DateTime.Parse(end) > newEnd)
            {
                isExpired = true;
            }
            return(Json(new { IsExpired = isExpired, ExpiredDate = newEnd.ToString("yyyy-MM-dd HH:mm:ss") }));
        }
コード例 #16
0
        public ActionResult Add(ShopBonusModel model)
        {
            string image     = model.ShareImg;
            string imageName = Guid.NewGuid().ToString() + ".png";
            string moveDir   = "/Storage/Shop/Bonus/";

            if (image.Contains("/temp/"))
            {
                var source = image.Substring(image.LastIndexOf("/temp"));
                Core.HimallIO.CopyFile(source, moveDir + imageName, true);
                model.ShareImg = "/Storage/Shop/Bonus/" + imageName;
            }
            else
            {
                model.ShareImg = "";
            }
            var market = this._bonusService.GetShopBonusService(CurrentSellerManager.ShopId);
            var time   = MarketApplication.GetServiceEndTime(market.Id);

            if (model.BonusDateEnd > time || model.DateEnd > time)
            {
                throw new HimallException("随机红包截止日期不允许超过您购买的服务到期时间。");
            }
            if (model.Count < 1 || model.Count > 1000)
            {
                throw new HimallException("红包个数请控制在1-1000个!");
            }
            if (model.IsShowSyncWeiXin && string.IsNullOrWhiteSpace(model.CardTitle))
            {
                throw new HimallException("同步卡券时,请填写卡券必填项");
            }
            if (!string.IsNullOrWhiteSpace(model.CardTitle))
            {
                //判断字符长度
                var enc = System.Text.Encoding.Default;
                if (enc.GetBytes(model.CardTitle).Count() > 18)
                {
                    throw new HimallException("卡券标题不得超过9个汉字。");
                }
                if (!string.IsNullOrWhiteSpace(model.CardSubtitle))
                {
                    if (enc.GetBytes(model.CardSubtitle).Count() > 36)
                    {
                        throw new HimallException("卡券副标题不得超过18个汉字。");
                    }
                }
            }
            this._bonusService.Add(model, CurrentSellerManager.ShopId);
            return(RedirectToAction("Management"));
        }
コード例 #17
0
        public ActionResult EditData(ShopBonusModel datamodel)
        {
            var market  = this._bonusService.GetShopBonusService(CurrentSellerManager.ShopId);
            var olddata = _bonusService.GetShopBonus(datamodel.Id);

            Mapper.CreateMap <Entities.ShopBonusInfo, ShopBonusModel>();
            ShopBonusModel model = Mapper.Map <Entities.ShopBonusInfo, ShopBonusModel>(olddata);

            UpdateModel(model);
            if (olddata == null)
            {
                throw new HimallException("错误的参数!");
            }
            var time = MarketApplication.GetServiceEndTime(market.Id);

            if (model.BonusDateEnd > time || model.DateEnd > time)
            {
                throw new HimallException("随机红包截止日期不允许超过您购买的服务到期时间。");
            }
            if (model.Count < 1 || model.Count > 1000)
            {
                throw new HimallException("红包个数请控制在1-1000个!");
            }
            string image     = model.ShareImg;
            string imageName = Guid.NewGuid().ToString() + ".png";
            string moveDir   = "/Storage/Shop/Bonus/";

            if (image.Contains("/temp/"))
            {
                var source = image.Substring(image.LastIndexOf("/temp"));
                Core.HimallIO.CopyFile(source, moveDir + imageName);
                model.ShareImg = "/Storage/Shop/Bonus/" + imageName;
            }
            else if (image.Contains("/Storage/"))
            {
                model.ShareImg = image.Substring(image.LastIndexOf("/Storage/"));
            }
            else
            {
                model.ShareImg = "";
            }
            if (string.IsNullOrEmpty(model.QRPath))
            {
                model.QRPath = "";
            }
            this._bonusService.Update(model);
            return(RedirectToAction("Management"));
        }
コード例 #18
0
        public ActionResult List(MarketBoughtQuery query)
        {
            query.MarketType = MarketType.RandomlyBonus;
            var marketEntities = _iMarketService.GetBoughtShopList(query);
            var market         = marketEntities.Models.Select(item => {
                var obj = MarketApplication.GetMarketService(item.MarketServiceId);
                return(new
                {
                    Id = item.Id,
                    StartDate = item.StartTime.ToString("yyyy-MM-dd"),
                    EndDate = item.EndTime.ToString("yyyy-MM-dd"),
                    ShopName = obj.ShopName
                });
            }).ToList();

            return(Json(new { rows = market, total = marketEntities.Total }));
        }
コード例 #19
0
        public JsonResult List(MarketBoughtQuery query)
        {
            query.MarketType = MarketType.Collocation;
            var data = _iMarketService.GetBoughtShopList(query);

            var list = data.Models.Select(item => {
                var market = MarketApplication.GetMarketService(item.MarketServiceId);
                return(new
                {
                    Id = item.Id,
                    StartDate = item.StartTime.ToString("yyyy-MM-dd"),
                    EndDate = item.EndTime.ToString("yyyy-MM-dd"),
                    ShopName = market.ShopName
                });
            }).ToList();

            return(Json(new { rows = list, total = data.Total }));
        }
コード例 #20
0
        private void CheckCollocationDate(long shopId, DateTime endDate)
        {
            var co = DbFactory.Default
                     .Get <ActiveMarketServiceInfo>()
                     .Where(a => a.TypeId == MarketType.Collocation && a.ShopId == shopId)
                     .FirstOrDefault();

            if (co == null)
            {
                throw new MallException("您没有订购此服务");
            }
            var serviceEndTime = MarketApplication.GetServiceEndTime(co.Id);
            var newEnd         = DateTime.Parse(serviceEndTime.ToString("yyyy-MM-dd") + " 23:59:59");

            if (newEnd < endDate)
            {
                throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
            }
        }
コード例 #21
0
ファイル: CouponController.cs プロジェクト: redpanda321/Mall
        public ActionResult Add()
        {
            CouponInfo model     = new CouponInfo();
            long       shopId    = CurrentSellerManager.ShopId;
            var        couponser = _iCouponService;

            model             = new CouponInfo();
            model.StartTime   = DateTime.Now;
            model.EndTime     = model.StartTime.AddMonths(1);
            model.ReceiveType = CouponInfo.CouponReceiveType.ShopIndex;

            model.CanVshopIndex = CurrentSellerManager.VShopId > 0;
            var settings = new System.Collections.Generic.List <CouponSettingInfo>();

            if (model.CanVshopIndex)
            {
                settings.Add(new CouponSettingInfo()
                {
                    Display = 1, PlatForm = PlatformType.Wap
                });
            }
            settings.Add(new CouponSettingInfo()
            {
                Display = 1, PlatForm = PlatformType.PC
            });
            ViewBag.Settings       = settings;
            model.FormIsSyncWeiXin = false;
            model.ShopId           = shopId;
            var market     = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Coupon);
            var maxEndTime = MarketApplication.GetServiceEndTime(market?.Id ?? 0);

            if (model.EndTime > maxEndTime.Date)
            {
                model.EndTime = maxEndTime.Date;
            }
            ViewBag.EndTime = maxEndTime.ToString("yyyy-MM-dd");
            ViewBag.CanAddIntegralCoupon = couponser.CanAddIntegralCoupon(shopId);
            return(View(model));
        }
コード例 #22
0
        private void CheckFlashSale(FlashSaleModel model)
        {
            if (DbFactory.Default.Get <FlashSaleInfo>().Where(p => (p.Id != 0 && p.Id != model.Id && p.ShopId == model.ShopId && p.ProductId == model.ProductId && p.EndDate > DateTime.Now && p.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) ||
                                                              (p.Id != 0 && p.Id != model.Id && p.ShopId == model.ShopId && p.ProductId == model.ProductId && p.EndDate > DateTime.Now && p.Status == FlashSaleInfo.FlashSaleStatus.WaitForAuditing)).Exist())
            {
                throw new MallException("此商品已存在限时购活动");
            }
            var co = DbFactory.Default.Get <ActiveMarketServiceInfo>().Where(a => a.TypeId == MarketType.LimitTimeBuy && a.ShopId == model.ShopId).FirstOrDefault();

            if (co == null)
            {
                throw new MallException("您没有订购此服务");
            }
            var date    = Convert.ToDateTime(model.EndDate);
            var endtime = MarketApplication.GetServiceEndTime(co.Id);
            var newEnd  = DateTime.Parse(endtime.ToString("yyyy-MM-dd") + " 23:59:59");

            if (newEnd < date)
            {
                //throw new MallException("结束日期不能超过购买限时购服务的日期");
                throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
            }
        }
コード例 #23
0
        public JsonResult GetBoughtList(MarketBoughtQuery query)
        {
            query.MarketType = MarketType.FightGroup;
            var data = MarketApplication.GetBoughtShopList(query);
            var list = data.Models.Select(d => {
                var market = MarketApplication.GetMarketService(d.MarketServiceId);
                return(new MarketServiceBuyRecordModel
                {
                    Id = d.Id,
                    EndTime = d.EndTime,
                    MarketServiceId = d.MarketServiceId,
                    StartTime = d.StartTime,
                    SettlementFlag = d.SettlementFlag,
                    ShopName = market.ShopName
                });
            }).ToList();
            var result = new QueryPageModel <MarketServiceBuyRecordModel>
            {
                Models = list,
                Total  = data.Total
            };

            return(Json(result, true));
        }
コード例 #24
0
        public ActionResult BuyService()
        {
            var model = new ShopBonusBuyServiceViewModel();

            model.Market = this._bonusService.GetShopBonusService(CurrentSellerManager.ShopId);
            var active = _iMarketService.GetServiceSetting(MarketType.RandomlyBonus);

            model.IsNo = true;
            string endDate = null;
            var    now     = DateTime.Now.Date;

            ViewBag.LastBuyPrice = -1;
            if (model.Market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(model.Market.Id);
                if (endtime < now)
                {
                    endDate = string.Format("<font class=\"red\">{0} 年 {1} 月 {2} 日</font> (您的随机红包服务已经过期)", endtime.Year, endtime.Month, endtime.Day);
                }
                else if (endtime >= now)
                {
                    model.Available = true;
                    endDate         = string.Format("{0} 年 {1} 月 {2} 日", endtime.Year, endtime.Month, endtime.Day);
                }
                ViewBag.LastBuyPrice = MarketApplication.GetLastBuyPrice(model.Market.Id);
            }

            else if (active == null)
            {
                model.IsNo = false;
                return(View(model));
            }
            model.EndDate = endDate;
            model.Price   = active.Price;
            return(View(model));
        }
コード例 #25
0
ファイル: CouponService.cs プロジェクト: sky63886/Himall3.3
        public void AddCoupon(CouponInfo info)
        {
            CanAddOrEditCoupon(info);
            var coupon = DbFactory.Default.Get <ActiveMarketServiceInfo>().Where(a => a.TypeId == MarketType.Coupon && a.ShopId == info.ShopId).FirstOrDefault();

            if (coupon == null)
            {
                throw new HimallException("您没有订购此服务");
            }
            var serviceEndTime = MarketApplication.GetServiceEndTime(coupon.Id);
            var newEnd         = DateTime.Parse(serviceEndTime.ToString("yyyy-MM-dd") + " 23:59:59");

            if (newEnd < info.EndTime)
            {
                throw new HimallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            info.WXAuditStatus = 1;
            if (info.IsSyncWeiXin == 1)
            {
                //微信卡券同步改为自动过审后有BUG,暂时默认优惠券添加就是同步状态成功的
                //info.WXAuditStatus = 0;
            }
            DbFactory.Default
            .InTransaction(() =>
            {
                DbFactory.Default.Add(info);

                info.CouponSettingInfo.ForEach(p => p.CouponID = info.Id);
                DbFactory.Default.AddRange(info.CouponSettingInfo);

                if (info.CouponProductInfo != null)
                {
                    info.CouponProductInfo.ForEach(p => p.CouponId = info.Id);
                    DbFactory.Default.Add <CouponProductInfo>(info.CouponProductInfo);
                }

                #region  步微信
                if (info.IsSyncWeiXin == 1)
                {
                    WXCardLogInfo wxdata = new WXCardLogInfo();
                    wxdata.CardColor     = info.FormWXColor;
                    wxdata.CardTitle     = info.FormWXCTit;
                    wxdata.CardSubTitle  = info.FormWXCSubTit;
                    wxdata.CouponType    = ThisCouponType;
                    wxdata.CouponId      = info.Id;
                    wxdata.ShopId        = info.ShopId;
                    wxdata.ShopName      = info.ShopName;
                    wxdata.ReduceCost    = (int)(info.Price * 100);
                    wxdata.LeastCost     = (int)(info.OrderAmount * 100);
                    wxdata.Quantity      = info.Num;
                    wxdata.GetLimit      = info.PerMax;
                    wxdata.DefaultDetail = info.Price.ToString("F2") + "元优惠券1张";
                    wxdata.BeginTime     = info.StartTime.Date;
                    wxdata.EndTime       = info.EndTime.AddDays(1).AddMinutes(-1);
                    if (ser_wxcard.Add(wxdata))
                    {
                        DbFactory.Default
                        .Set <CouponInfo>()
                        .Set(n => n.CardLogId, wxdata.Id)
                        .Where(n => n.Id == info.Id)
                        .Succeed();
                    }
                    else
                    {
                        DbFactory.Default.Del(info);
                        throw new HimallException("同步微信卡券失败,请检查参数是否有错!");
                    }
                }
                #endregion
            });


            SaveCover(info);
        }
コード例 #26
0
ファイル: MarketService.cs プロジェクト: sky63886/Himall3.3
        public void OrderMarketService(int monthCount, long shopId, MarketType type)
        {
            if (shopId <= 0)
            {
                throw new HimallException("ShopId不能识别");
            }
            if (monthCount <= 0)
            {
                throw new HimallException("购买服务时长必须大于零");
            }
            var shop = DbFactory.Default.Get <ShopInfo>().Where(p => p.Id == shopId).FirstOrDefault();

            if (shop == null || shopId <= 0)
            {
                throw new HimallException("ShopId不能识别");
            }

            var price     = DbFactory.Default.Get <MarketSettingInfo>().Where(a => a.TypeId == type).Select(a => a.Price).FirstOrDefault <decimal>();
            var StartTime = DateTime.Now;
            MarketServiceRecordInfo model = new MarketServiceRecordInfo();

            model.StartTime = StartTime;
            model.Price     = price * monthCount;
            var shopAccount = DbFactory.Default.Get <ShopAccountInfo>().Where(a => a.ShopId == shopId).FirstOrDefault();//店铺帐户信息

            #region 它下面会取几次只,如为空会报异常,默认存入0的初始值
            if (shopAccount == null)
            {
                shopAccount                   = new ShopAccountInfo();
                shopAccount.ShopId            = shopId;
                shopAccount.ShopName          = shop.ShopName;
                shopAccount.Balance           = 0;
                shopAccount.PendingSettlement = 0;
                shopAccount.Settled           = 0;
                shopAccount.ReMark            = string.Empty;
                DbFactory.Default.Add(shopAccount);
            }
            #endregion

            if (shopAccount.Balance < model.Price) //店铺余额不足以支付服务费用
            {
                throw new HimallException("您的店铺余额为:" + shopAccount.Balance + "元,不足以支付此次营销服务购买费用,请先充值。");
            }

            DbFactory.Default.InTransaction(() =>
            {
                var market = DbFactory.Default.Get <ActiveMarketServiceInfo>().Where(a => a.ShopId == shopId && a.TypeId == type).FirstOrDefault();
                if (market != null)
                {
                    var maxTime = MarketApplication.GetServiceEndTime(market.Id);
                    if (maxTime > DateTime.Now) //如果结束时间大于当前时间,续费从结束时间加上购买月数,否则从当前时间加上购买月数
                    {
                        StartTime = maxTime;
                    }
                    model.StartTime = StartTime;
                    model.BuyTime   = DateTime.Now;
                    model.EndTime   = StartTime.AddMonths(monthCount);
                    // model.MarketServiceId = market.Id;
                    model.SettlementFlag  = 1;
                    model.MarketServiceId = market.Id;

                    DbFactory.Default.Add(model);
                }
                else
                {
                    model.StartTime      = StartTime;
                    model.EndTime        = StartTime.AddMonths(monthCount);
                    model.SettlementFlag = 1;
                    model.BuyTime        = DateTime.Now;

                    ActiveMarketServiceInfo activeMarketServiceInfo = new ActiveMarketServiceInfo();
                    activeMarketServiceInfo.ShopId   = shopId;
                    activeMarketServiceInfo.ShopName = shop.ShopName;
                    activeMarketServiceInfo.TypeId   = type;
                    DbFactory.Default.Add(activeMarketServiceInfo);

                    model.MarketServiceId = activeMarketServiceInfo.Id;
                    DbFactory.Default.Add(model);
                }

                var ShopAccount          = DbFactory.Default.Get <ShopAccountInfo>().Where(a => a.ShopId == shopId).FirstOrDefault();
                ShopAccountItemInfo info = new ShopAccountItemInfo();
                info.IsIncome            = false;
                info.ShopId          = shopId;
                info.DetailId        = model.Id.ToString();
                info.ShopName        = shop.ShopName;
                info.AccountNo       = shopId + info.DetailId + new Random().Next(10000);
                info.ReMark          = "店铺购买" + type.ToDescription() + "服务," + monthCount + "个月";
                info.TradeType       = ShopAccountType.MarketingServices;
                info.CreateTime      = DateTime.Now;
                info.Amount          = price * monthCount;
                info.AccoutID        = ShopAccount.Id;
                ShopAccount.Balance -= info.Amount;         //总余额减钱
                info.Balance         = ShopAccount.Balance; //变动后当前剩余金额

                DbFactory.Default.Add(info);
                DbFactory.Default.Update(ShopAccount);

                var platAccount = DbFactory.Default.Get <PlatAccountInfo>().FirstOrDefault();
                var pinfo       = new PlatAccountItemInfo
                {
                    IsIncome   = true,
                    DetailId   = model.Id.ToString(),
                    AccountNo  = info.AccountNo,
                    ReMark     = "店铺购买" + type.ToDescription() + "服务," + monthCount + "个月",
                    TradeType  = PlatAccountType.MarketingServices,
                    CreateTime = DateTime.Now,
                    Amount     = price * monthCount,
                    AccoutID   = platAccount.Id
                };
                platAccount.Balance += info.Amount;         //总余额加钱
                pinfo.Balance        = platAccount.Balance; //变动后当前剩余金额
                DbFactory.Default.Add(pinfo);
                DbFactory.Default.Update(platAccount);
            });
        }
コード例 #27
0
        public JsonResult AddActive(FightGroupActiveModel model)
        {
            var result = new Result {
                success = false, msg = "未知错误", status = -1
            };
            FightGroupActiveModel data = new FightGroupActiveModel();

            if (model.EndTime.Date < DateTime.Now.Date)
            {
                throw new MallException("错误的结束时间");
            }
            if (model.EndTime.Date < model.StartTime.Date)
            {
                throw new MallException("错误的结束时间");
            }
            var market = MarketApplication.GetMarketService(CurrentSellerManager.ShopId, MarketType.FightGroup);

            if (market != null)
            {
                var endtime = MarketApplication.GetServiceEndTime(market.Id);
                var newEnd  = DateTime.Parse(endtime.ToString("yyyy-MM-dd") + " 23:59:59");
                if (newEnd < model.EndTime.Date)
                {
                    throw new MallException(string.Format("活动结束时间不得超过服务到期时间,<br/>您的服务到期时间为{0}", newEnd.ToString("yyyy-MM-dd HH:mm:ss")));
                }
            }
            else
            {
                throw new MallException("您没有订购此服务");
            }
            //数据有效性验证
            model.CheckValidation();
            if (!FightGroupApplication.ProductCanJoinActive(model.ProductId))
            {
                throw new MallException("该商品已参与拼团或其他营销活动,请重新选择");
            }

            var skudata = FightGroupApplication.GetNewActiveItems(model.ProductId).skulist;

            foreach (var item in model.ActiveItems)
            {
                var cursku = skudata.FirstOrDefault(d => d.SkuId == item.SkuId);
                if (cursku != null)
                {
                    if (item.ActiveStock > cursku.ProductStock)
                    {
                        throw new MallException(item.SkuName + "错误的活动库存");
                    }
                }
                else
                {
                    model.ActiveItems.Remove(item);
                }
            }
            if (ModelState.IsValid)
            {
                TryUpdateModelAsync(data);
                data.ShopId  = CurShopId;
                data.IconUrl = SaveActiveIcon(data.IconUrl);
                model        = data;
                FightGroupApplication.AddActive(data);

                ProductManagerApplication.SaveCaculateMinPrice(model.ProductId, CurrentShop.Id);
                result = new Result {
                    success = true, msg = "操作成功", status = 1
                };
            }
            else
            {
                result = new Result {
                    success = false, msg = "数据异常,请检查数据有效性", status = -1
                };
            }
            return(Json(result));
        }