Example #1
0
        public object GetActiveList(int pageIndex, int auditStatus, long shopId, string productName)
        {//-1,0,1表示售完,正常,下架
            int pagesize = 5;
            List <FightGroupActiveStatus> seastatus = new List <FightGroupActiveStatus>();

            seastatus.Add(FightGroupActiveStatus.Ongoing);
            seastatus.Add(FightGroupActiveStatus.WillStart);

            var data = ServiceProvider.Instance <IFightGroupService> .Create.GetActives(null, null, null, productName, null, shopId, pageIndex, pagesize, auditStatus);

            var datalist = data.Models.ToList();

            foreach (FightGroupActiveInfo item in datalist)
            {
                /*if (!string.IsNullOrWhiteSpace(item.IconUrl))
                 *  item.IconUrl = Core.HimallIO.GetRomoteImagePath(item.IconUrl);*/
                FightGroupActiveImgInfo imgInfo = FightGroupApplication.XcxGetActiveImg(item.Id);
                if (imgInfo != null)
                {
                    item.ProductDefaultImage   = imgInfo.ProductDefaultImage;
                    item.ProductImages         = imgInfo.ProductImages.Split(',').ToList();
                    item.ShowMobileDescription = imgInfo.ShowMobileDescription;
                    item.IconUrl = imgInfo.ProductDefaultImage;
                }

                item.ActiveItems = FightGroupApplication.GetActiveItemsInfos(item.Id);
            }
            return(Json(new { Total = data.Total, Data = datalist }));
        }
Example #2
0
        public object GetActiveById(int id)
        {
            try
            {
                //CheckUserLogin();
                FightGroupActiveModel data = FightGroupApplication.XcxGetActive(id, false);
                if (data == null)
                {
                    throw new HimallException("错误的活动信息");
                }
                //data.InitProductImages();
                FightGroupActiveImgInfo imgInfo = FightGroupApplication.XcxGetActiveImg(id);
                AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>();

                FightGroupActiveDetailModel model = AutoMapper.Mapper.Map <FightGroupActiveDetailModel>(data);
                model.ShareTitle = data.ActiveStatus == FightGroupActiveStatus.WillStart ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行";

                if (imgInfo != null)
                {
                    model.ProductDefaultImage   = imgInfo.ProductDefaultImage;
                    model.ProductImages         = imgInfo.ProductImages.Split(',').ToList();
                    model.ShowMobileDescription = imgInfo.ShowMobileDescription;
                    model.ShareImage            = imgInfo.ProductDefaultImage;
                    model.IconUrl = imgInfo.ProductDefaultImage;
                }
                model.GroupNotice = data.GroupNotice;
                model.ShareDesc   = data.ProductName;
                model.ReturnMoney = data.ReturnMoney;

                /*if (!string.IsNullOrWhiteSpace(model.ShareImage))
                 * {
                 *  if (model.ShareImage.Substring(0, 4) != "http")
                 *  {
                 *      model.ShareImage = HimallIO.GetRomoteImagePath(model.ShareImage);
                 *  }
                 * }*/

                /*if (model.IconUrl.Substring(0, 4) != "http")
                 * {
                 *  model.IconUrl = HimallIO.GetRomoteImagePath(model.IconUrl);
                 * }
                 * if (model.ProductImgPath.Substring(0, 4) != "http")
                 * {
                 *  model.ProductImgPath = HimallIO.GetRomoteImagePath(model.ProductImgPath);
                 * }
                 * if (model.ProductDefaultImage.Substring(0, 4) != "http")
                 * {
                 *  model.ProductDefaultImage = HimallIO.GetRomoteImagePath(model.ProductDefaultImage);
                 * }
                 * for (int i = 0; i < model.ProductImages.Count; i++)
                 * {
                 *  model.ProductImages[i] = HimallIO.GetRomoteImagePath(model.ProductImages[i]);
                 * }*/


                /*if (!string.IsNullOrWhiteSpace(data.ProductShortDescription))
                 * {
                 *  model.ShareDesc += ",(" + data.ProductShortDescription + ")";
                 * }
                 * var ProductDescription = ServiceHelper.Create<IProductService>().GetProductDescription(model.ProductId.Value);
                 * if (ProductDescription == null)
                 * {
                 *  throw new Himall.Core.HimallException("错误的商品编号");
                 * }
                 * model.ShowMobileDescription = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/",
                 *  "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/"));
                 * model.GroupNotice = "1、活动结束后将从拼单成功的所有订单中,随机选取1名使用者赠送。\n2、一等奖为iPhoneX,二等奖为88元优惠券。";//TODO 功能待实现data.GroupNotice;*/
                /*if (model.ProductId.HasValue)
                 * {
                 *  //统计商品浏览量、店铺浏览人数
                 *  StatisticApplication.StatisticVisitCount(model.ProductId.Value, model.ShopId);
                 * }
                 * IProductService _iProductService = ServiceProvider.Instance<IProductService>.Create;
                 * bool isSub = _iProductService.IsFavorite((long)model.ProductId, CurrentUserId);
                 * model.IsSubscribe = isSub ? 1 : 0;*/
                //model.IsVirtualProduct = 1;
                List <FightGroupActiveItemInfo>  sourceList = FightGroupApplication.GetActiveItemsInfos(model.Id);
                List <FightGroupActiveItemModel> targetList = new List <FightGroupActiveItemModel>();
                foreach (var itemInfo in sourceList)
                {
                    FightGroupActiveItemModel m = new FightGroupActiveItemModel();
                    m.Id               = itemInfo.Id;
                    m.ActiveId         = itemInfo.ActiveId.Value;
                    m.ActivePrice      = itemInfo.ActivePrice;
                    m.ActiveStock      = itemInfo.ActiveStock;
                    m.BuyCount         = itemInfo.BuyCount;
                    m.Color            = itemInfo.Color;
                    m.ProductCostPrice = itemInfo.ProductCostPrice;
                    m.ProductId        = itemInfo.ProductId.Value;
                    m.ProductPrice     = itemInfo.ProductPrice;
                    m.ProductStock     = itemInfo.ProductStock;
                    m.ShowPic          = itemInfo.ShowPic;
                    m.Size             = itemInfo.Size;
                    m.SkuName          = itemInfo.SkuName;
                    m.SkuId            = itemInfo.SkuId;
                    m.Version          = itemInfo.Version;
                    targetList.Add(m);
                }
                model.ActiveItems = targetList;
                return(Json(new { Status = "OK", FightGroupDetail = model }));
            }
            catch (Exception ex)
            {
                return(Json(new { Status = "Error", Msg = ex.Message }));
            }
        }