/// <summary> /// 餐饮菜品获取拼团详情 /// </summary> /// <param name="good"></param> /// <param name="rid"></param> public void GetFoodGoodGroup(ref FoodGoods good, int rid) { if (good == null || good.goodtype != (int)EntGoodsType.拼团产品) { return; } //获取开团成功的数据 List <EntGroupSponsor> entsponsorlist = EntGroupSponsorBLL.SingleModel.GetListByGoodRid(good.EntGroups.Id, 0, 0); //团ID string groupids = string.Join(",", entsponsorlist.Select(s => s.Id).Distinct()); //判断是否是拼团产品 good.EntGroups = GetModelByGroupGoodType(good.Id, rid); if (good.EntGroups == null) { log4net.LogHelper.WriteInfo(this.GetType(), "餐饮获取菜品拼团详情位空"); return; } if (groupids != null && groupids.Length > 0) { good.EntGroups.GroupUserList = FoodGoodsOrderBLL.SingleModel.GetPersonByGroup(groupids); } good.EntGroups.GroupsNum = FoodGoodsOrderBLL.SingleModel.GetGroupPersonCount(0, good.Id) + good.EntGroups.InitSaleCount;//加上初始化销售量 good.EntGroups.GroupSponsorList = EntGroupSponsorBLL.SingleModel.GetHaveSuccessGroup(good.EntGroups.Id, 10, good.Id, (int)TmpType.小程序餐饮模板); }
/// <summary> /// 处理计算商品的会员价格(餐饮-MiniappFoodGoods) /// </summary> /// <param name="good">要计算的商品</param> /// <param name="vipLevel">会员等级Model</param> public void CalculateVipGoodPrice(FoodGoods good, VipLevel userVipLevel) { CalculateVipGoodsPrice(new List <FoodGoods>() { good }, userVipLevel, true); }
public EntGroupSponsor GetGroupDetail(int groupid, int type) { EntGroupSponsor model = GetModel(groupid); if (model == null) { return(model); } EntGroupsRelation entgroup = EntGroupsRelationBLL.SingleModel.GetModel(model.EntGoodRId); if (entgroup == null) { return(new EntGroupSponsor()); } int groupnum = 0; model.GroupPrice = entgroup.GroupPriceStr; model.OriginalPrice = entgroup.OriginalPriceStr; switch (type) { case (int)TmpType.小程序专业模板: EntGoods entgood = EntGoodsBLL.SingleModel.GetModel(entgroup.EntGoodsId); if (entgood == null) { return(new EntGroupSponsor()); } model.GroupName = entgood.name; model.GoodId = entgood.id; EntGoodsOrder order = EntGoodsOrderBLL.SingleModel.GetModel($"ordertype = 3 and groupid = {groupid}"); model.GroupImage = ImgHelper.ResizeImg(entgood.img, 220, 220); if (order != null) { EntGoodsCart goodOrderDtl = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(order.Id); if (goodOrderDtl != null && !string.IsNullOrEmpty(goodOrderDtl.SpecImg)) { model.GroupImage = ImgHelper.ResizeImg(goodOrderDtl.SpecImg, 220, 220); } } ; model.GroupUserList = EntGoodsOrderBLL.SingleModel.GetPersonByGroup(groupid.ToString(), ref groupnum); break; case (int)TmpType.小程序餐饮模板: groupnum = FoodGoodsOrderBLL.SingleModel.GetGroupPersonCount(0, entgroup.EntGoodsId); model.GroupUserList = FoodGoodsOrderBLL.SingleModel.GetPersonByGroup(groupid.ToString()); FoodGoods foodgood = FoodGoodsBLL.SingleModel.GetModel(entgroup.EntGoodsId); if (foodgood == null) { return(new EntGroupSponsor()); } model.GroupName = foodgood.GoodsName; model.GoodId = foodgood.Id; model.GroupImage = ImgHelper.ResizeImg(foodgood.ImgUrl, 220, 220);; break; } model.GroupNum = groupnum + entgroup.InitSaleCount;//加上初始化销售量 return(model); }
/// <summary> /// 下单时判断是否是拼团 /// </summary> /// <param name="isgroup"></param> /// <param name="groupid"></param> /// <param name="goodscar"></param> /// <param name="grouperprice"></param> /// <param name="groupmodel"></param> /// <returns></returns> public string CommandEntGroup(int isgroup, int groupid, int userid, int storeid, int goodid, ref int grouperprice, ref EntGroupsRelation groupmodel, int type, int buyCount) { if (isgroup <= 0 && groupid <= 0) { return(""); } if (isgroup > 0 && groupid > 0) { return("拼团参数错误"); } groupmodel = GetModelByGroupGoodType(goodid, groupmodel.RId, storeid); if (groupmodel == null) { return("产品匹配不到拼团信息"); } #region 判断开团时,库存是否满足成团 int stock = 0; //已团件数 int groupnum = 0; switch (type) { case (int)TmpType.小程序餐饮模板: FoodGoods entgood = FoodGoodsBLL.SingleModel.GetModel(groupmodel.EntGoodsId); if (entgood == null) { return("拼团产品已下架,请浏览其它团商品"); } stock = entgood.Stock; groupnum = 0; //判断是否已参加该团 if (groupid > 0) { List <FoodGoodsOrder> entgoodorder = FoodGoodsOrderBLL.SingleModel.GetListGroupOrder(groupid.ToString(), userid); if (entgoodorder != null && entgoodorder.Count > 0) { return("您已经参加过该拼团了,请浏览其它团商品"); } } break; } if (groupmodel.LimitNum > 0 && groupnum > groupmodel.LimitNum) { return("您已超出购买限额,请浏览其它团商品"); } //拼团商品下单后剩下的数量必须能成团,如: 2个人能成团,此时下单剩余数据必须>=1件(能让多一个人下单的数量) if (isgroup > 0 && stock - buyCount < groupmodel.GroupSize - 1) { return("拼团商品库存不足,无法成团"); } #endregion //判断是否是团长,团员不减团长优惠价 if (isgroup <= 0) { grouperprice = 0; } else { grouperprice = groupmodel.HeadDeduct; } return(""); }