/// <summary> /// 获取拼团活动 /// </summary> /// <param name="id"></param> /// <param name="needGetProductCommentNumber">是否需要同步获取商品的评价数量</param> /// <param name="isLoadItems">是否加载节点信息</param> /// <returns></returns> public static FightGroupActiveModel GetActive(long id, bool needGetProductCommentNumber = false, bool isLoadItems = true) { FightGroupActiveInfo source = _iFightGroupService.GetActive(id, needGetProductCommentNumber, isLoadItems, true); Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>(); Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>(); FightGroupActiveModel model = Mapper.Map <FightGroupActiveInfo, FightGroupActiveModel>(source); if (model != null) { model.ProductDefaultImage = HimallIO.GetProductSizeImage(source.ProductImgPath, 1, 350); if (!string.IsNullOrWhiteSpace(model.IconUrl)) { model.IconUrl = HimallIO.GetImagePath(model.IconUrl, null); } if (model.ActiveItems == null) { return(model); } foreach (FightGroupActiveItemModel model2 in model.ActiveItems) { if (!string.IsNullOrWhiteSpace(model2.ShowPic)) { model2.ShowPic = HimallIO.GetImagePath(model2.ShowPic, null); } } } return(model); }
public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value) { this.CheckUserLogin(); if (value.CapitalAmount > new Decimal(0) && !string.IsNullOrEmpty(value.PayPwd) && !MemberApplication.VerificationPayPwd(this.CurrentUser.Id, value.PayPwd)) { return((object)this.Json(new { Success = "false", Msg = "预付款支付密码错误" })); } string skuId = value.skuId; long count = value.count; long recieveAddressId = value.recieveAddressId; long groupActionId = value.GroupActionId; long groupId = value.GroupId; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; string invoiceCode = value.invoiceCode; string orderRemarks = ""; List <FightGroupOrderJoinStatus> list = new List <FightGroupOrderJoinStatus>() { FightGroupOrderJoinStatus.Ongoing, FightGroupOrderJoinStatus.JoinSuccess }; FightGroupActiveInfo active = Instance <IFightGroupService> .Create.GetActive(groupActionId, false, false, true); long num = count; int? limitQuantity = active.LimitQuantity; if ((num <= (long)limitQuantity.GetValueOrDefault() ? 0 : (limitQuantity.HasValue ? 1 : 0)) != 0) { return((object)this.Json(new { Success = "false", Msg = string.Format("每人限购数量:{0}!", (object)active.LimitQuantity) })); } try { OrderCreateModel groupOrder = OrderApplication.GetGroupOrder(this.CurrentUser.Id, skuId, count.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceCode, invoiceContext, groupActionId, PlatformType.Android, groupId, isCashOnDelivery, orderRemarks, new Decimal(0)); OrderShop[] orderShopArray = JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); groupOrder.OrderShops = orderShopArray; groupOrder.OrderRemarks = (IEnumerable <string>)Enumerable.ToArray <string>(Enumerable.Select <OrderShop, string>((IEnumerable <OrderShop>)orderShopArray, (Func <OrderShop, string>)(p => p.Remark))); OrderReturnModel orderReturnModel = OrderApplication.OrderSubmit(groupOrder, ""); this.AddVshopBuyNumber((IEnumerable <long>)orderReturnModel.OrderIds); return((object)this.Json(new { Success = "true", OrderIds = orderReturnModel.OrderIds })); } catch (HimallException ex) { return((object)this.Json(new { Success = "false", Msg = ex.Message })); } catch (Exception ex) { return((object)this.Json(new { Success = "false", Msg = "提交订单异常" })); } }
public object GetUserCollectionProduct(int pageNo, int pageSize = 16) { CheckUserLogin(); if (CurrentUser != null) { var model = ServiceProvider.Instance <IProductService> .Create.GetUserConcernProducts(CurrentUser.Id, pageNo, pageSize); DataTable dt = new DataTable(); dt.Columns.Add("ActiveId"); dt.Columns.Add("ProductId"); dt.Columns.Add("Image"); dt.Columns.Add("ProductName"); dt.Columns.Add("SalePrice"); dt.Columns.Add("GroupPrice"); dt.Columns.Add("Description"); IFightGroupService fightGroupService = ServiceProvider.Instance <IFightGroupService> .Create; IProductService productService = ServiceProvider.Instance <IProductService> .Create; DataRow dr; FightGroupActiveInfo fightGroupInfo = null; ProductInfo productInfo = null; foreach (var fightGroupModel in model.Models) { dr = dt.NewRow(); fightGroupInfo = fightGroupService.GetActiveByProId(fightGroupModel.ProductId); if (fightGroupInfo == null) { continue; } productInfo = productService.GetProduct(fightGroupModel.ProductId); if (productInfo == null) { continue; } dr["ActiveId"] = fightGroupInfo.Id; dr["ProductId"] = fightGroupModel.ProductId; dr["Image"] = Core.HimallIO.GetRomoteProductSizeImage(productInfo.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220); dr["ProductName"] = productInfo.ProductName; dr["SalePrice"] = productInfo.MinSalePrice.ToString("F2"); dr["GroupPrice"] = fightGroupInfo.MiniGroupPrice; dr["Description"] = productInfo.ShortDescription; dt.Rows.Add(dr); } //var result = model.Models.ToArray().Select(item => new //{ // ActiveId = ServiceProvider.Instance<IFightGroupService>.Create.GetActiveByProId(item.ProductId).Id, // ProductId = item.ProductId, // Image = Core.HimallIO.GetRomoteProductSizeImage(item.ProductInfo.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220), // ProductName = item.ProductInfo.ProductName, // SalePrice = item.ProductInfo.MinSalePrice.ToString("F2"), // GroupPrice = ServiceProvider.Instance<IFightGroupService>.Create.GetActiveByProId(item.ProductId).MiniGroupPrice, // Description = item.ProductInfo.ShortDescription //}); return(Json(new { Success = true, Data = dt, Total = dt.Rows.Count })); } else { return(Json(new { Success = false, Message = "未登录" })); } }