コード例 #1
0
        public JsonResult CanAdd(long productId)
        {
            Result result = new Result {
                success = false, msg = "该商品正在参加拼团活动,无法同时参加拼团活动"
            };

            if (FightGroupApplication.ProductCanJoinActive(productId))
            {
                if (_iLimitTimeBuyService.IsAdd(productId))
                {
                    result.success = true;
                    result.msg     = "";
                }
                else
                {
                    result = new Result {
                        success = false, msg = "该商品正在参加限时购活动,无法同时参加拼团活动"
                    };
                }
            }
            return(Json(result));
        }
コード例 #2
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));
        }
コード例 #3
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 HimallException("错误的结束时间");
            }
            if (model.EndTime.Date < model.StartTime.Date)
            {
                throw new HimallException("错误的结束时间");
            }
            //数据有效性验证
            model.CheckValidation();
            if (!FightGroupApplication.ProductCanJoinActive(model.ProductId.Value))
            {
                throw new HimallException("该商品已参与拼团或其他营销活动,请重新选择");
            }

            var skudata = FightGroupApplication.GetNewActiveItems(model.ProductId.Value).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 HimallException(item.SkuId + "错误的活动库存");
                    }
                }
                else
                {
                    model.ActiveItems.Remove(item);
                }
            }


            if (ModelState.IsValid)
            {
                UpdateModel(data);
                data.ShopId  = CurShopId;
                data.IconUrl = SaveActiveIcon(data.IconUrl);

                model = data;

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