Exemple #1
0
        /// <summary>
        /// 订单商品LIST方法
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="appId"></param>
        /// <returns></returns>
        public Dictionary <Guid, List <CommodityForOrderDTO> > GetAllOrderItemsExt(System.Guid userId, System.Guid appId, List <Guid> commodityOrderIds)
        {
            //获取商品信息
            var query = (from o in OrderItem.ObjectSet()
                         where commodityOrderIds.Contains(o.CommodityOrderId)
                         select new CommodityOrderItemDTO
            {
                Id = o.Id,
                PicturesPath = o.PicturesPath,
                Name = o.Name,
                Price = o.CurrentPrice,         //o.CommodityOrder.Price,单价
                Intensity = o.Intensity,
                Number = o.Number,              //数量
                CommodityOrderId = o.CommodityOrderId,
                ComAttributeIds = o.ComAttributeIds,
                CommodityAttributes = o.CommodityAttributes,
                CommodityId = o.CommodityId
                              //OrderState = o.CommodityOrder.State
            }).ToList();

            //查询待付款的商品ID
            List <Guid> commodityIds = query.Where(o => o.OrderState == 0).Select(o => o.CommodityId).ToList();

            Dictionary <Guid, decimal> promotionDic = new Dictionary <Guid, decimal>();

            //判断促销信息
            if (commodityIds.Count > 0)
            {
                PromotionItems promotionItems = new PromotionItems();
                //获取折扣信息
                promotionDic = promotionItems.GetIntensity(commodityIds);
            }
            Jinher.JAP.Common.Loging.LogHelper.Error("GetAllOrderItemsExt方法:");
            List <CommodityForOrderDTO> commoditySDTOList = new List <CommodityForOrderDTO>();

            //遍历订单待付款的
            foreach (CommodityOrderItemDTO commodityOrderItemDTO in query)
            {
                decimal?realIntensity = null;
                //待付款
                if (commodityOrderItemDTO.OrderState == 0)
                {
                    Guid commodityId = commodityOrderItemDTO.CommodityId;
                    if (promotionDic != null && promotionDic.ContainsKey(commodityId))
                    {
                        realIntensity = promotionDic[commodityId];
                    }
                    else
                    {
                        realIntensity = 10;
                    }
                }
                else
                {
                    realIntensity = commodityOrderItemDTO.Intensity;
                }
                CommodityForOrderDTO commoditySDTO = new CommodityForOrderDTO();
                commoditySDTO.Id    = commodityOrderItemDTO.Id;
                commoditySDTO.Pic   = commodityOrderItemDTO.PicturesPath;
                commoditySDTO.Name  = commodityOrderItemDTO.Name;
                commoditySDTO.Price = commodityOrderItemDTO.Price;

                Jinher.JAP.Common.Loging.LogHelper.Error("商品价格为:" + commodityOrderItemDTO.Price);
                Jinher.JAP.Common.Loging.LogHelper.Error("realIntensity商品折扣为:" + realIntensity);
                Jinher.JAP.Common.Loging.LogHelper.Error("commodityOrderItemDTO.Intensity商品折扣为:" + commodityOrderItemDTO.Intensity);

                commoditySDTO.Intensity          = commodityOrderItemDTO.Intensity;// realIntensity;
                commoditySDTO.CommodityNumber    = commodityOrderItemDTO.Number;
                commoditySDTO.OrderId            = commodityOrderItemDTO.CommodityOrderId;
                commoditySDTO.AttributesString   = commodityOrderItemDTO.ComAttributeIds;
                commoditySDTO.SelectedAttributes = Util.ConvertToAttributeList(commodityOrderItemDTO.CommodityAttributes);

                commoditySDTOList.Add(commoditySDTO);
            }
            return(commoditySDTOList.GroupBy(c => c.OrderId, (key, group) => new { OrderId = key, CommodityList = group }).ToDictionary(c => c.OrderId, c => c.CommodityList.ToList()));
        }
Exemple #2
0
        /// <summary>
        /// 订单商品LIST方法
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="appId"></param>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityForOrderDTO> GetOrderItemsExt(System.Guid userId, System.Guid appId, Guid commodityOrderId, int state)
        {
            var commodityOrderList = (from o in OrderItem.ObjectSet()
                                      where o.CommodityOrderId == commodityOrderId
                                      select new CommodityOrderItemDTO
            {
                Id = o.Id,
                PicturesPath = o.PicturesPath,
                Name = o.Name,
                Price = o.CurrentPrice,                          // o.CommodityOrder.Price, 商品单价
                Intensity = o.Intensity,                         //折扣
                Number = o.Number,                               //数量
                CommodityOrderId = o.CommodityOrderId,
                ComAttributeIds = o.ComAttributeIds,
                CommodityAttributes = o.CommodityAttributes,
                CommodityId = o.CommodityId,
                HasReview = o.AlreadyReview,
                RealPrice = o.CurrentPrice,                           // 原价
                DiscountPrice = o.DiscountPrice
            }).ToList();

            Dictionary <Guid, decimal> promotionDic = new Dictionary <Guid, decimal>();

            if (state == 0)
            {
                List <Guid> commodityIds = commodityOrderList.Select(o => o.CommodityId).ToList();
                if (commodityIds.Count > 0)
                {
                    PromotionItems promotionItems = new PromotionItems();
                    promotionDic = promotionItems.GetIntensity(commodityIds);
                }
            }

            List <CommodityForOrderDTO> commoditySDTOList = new List <CommodityForOrderDTO>();

            foreach (CommodityOrderItemDTO commodityOrderItemDTO in commodityOrderList)
            {
                decimal?realIntensity = null;
                CommodityForOrderDTO commoditySDTO = new CommodityForOrderDTO();

                commoditySDTO.Id   = commodityOrderItemDTO.Id;
                commoditySDTO.Pic  = commodityOrderItemDTO.PicturesPath;
                commoditySDTO.Name = commodityOrderItemDTO.Name;

                //待付款
                if (state == 0)
                {
                    Guid commodityId = commodityOrderItemDTO.CommodityId;
                    if (promotionDic != null && promotionDic.ContainsKey(commodityId))
                    {
                        realIntensity = promotionDic[commodityId];
                    }
                    else
                    {
                        realIntensity = commodityOrderItemDTO.Intensity;
                    }
                    commoditySDTO.Price     = commodityOrderItemDTO.Price;
                    commoditySDTO.Intensity = realIntensity;
                }
                else
                {
                    commoditySDTO.Price     = commodityOrderItemDTO.RealPrice;
                    commoditySDTO.Intensity = commodityOrderItemDTO.Intensity;//折扣
                }

                commoditySDTO.CommodityNumber    = commodityOrderItemDTO.Number;
                commoditySDTO.OrderId            = commodityOrderItemDTO.CommodityOrderId;
                commoditySDTO.AttributesString   = commodityOrderItemDTO.ComAttributeIds;
                commoditySDTO.HasReview          = commodityOrderItemDTO.HasReview;
                commoditySDTO.SelectedAttributes = Util.ConvertToAttributeList(commodityOrderItemDTO.CommodityAttributes);

                commoditySDTOList.Add(commoditySDTO);
            }
            return(commoditySDTOList);
        }