Ejemplo n.º 1
0
        /// <summary>
        /// 获取购物车商品列表 筛选 没有删除的商品,和 图片路径已经被格式化
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="guid">用户全局变量</param>
        /// <param name="channelId">渠道ID</param>
        /// <returns></returns>
        public static MResult <ShoppingCartResult> GetShoppingCartGoodsList(int userId, string guid, int channelId)
        {
            var result       = new MResult <ShoppingCartResult>(true);
            var shoppingCart = Factory.DALFactory.ShoppingCartDal();
            var goodsList    = shoppingCart.GetShoppingCartProductInfosByUserIDGuidChannelID(userId, guid, channelId);

            if (goodsList.Any())
            {
                result.info.shoppingcart_list = goodsList.FindAll(item => item.intIsDelete == 0);
                result.info.shoppingcart_list.ForEach(item =>
                {
                    item.vchPicURL = GoodsBLL.FormatProductPicUrl(item.vchPicURL);
                });
                result.info.shoppingcart_total = result.info.shoppingcart_list.Sum(item => item.intBuyCount * item.numSalePrice);
            }
            result.status = Core.Enums.MResultStatus.Success;
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取订单商品列表
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="uid"></param>
        /// <param name="userId"></param>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public static MResultList <ItemOrderGoods> GetOrderGoodsList(int sid, string uid, int userId, string orderCode)
        {
            var result = new MResultList <ItemOrderGoods>(true);

            try
            {
                #region 参数判断
                if (userId <= 0)
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "用户标识错误!";
                }
                if (string.IsNullOrEmpty(orderCode))
                {
                    result.status = MResultStatus.ParamsError;
                    result.msg    = "订单标识错误!";
                }
                #endregion

                var orderDal  = DALFactory.Order();
                var memberDal = DALFactory.Member();

                var memberInfo = memberDal.GetMemberInfo(userId);
                if (memberInfo == null || memberInfo.membNo <= 0)
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "用户不存在!";
                }
                var clusterId = MCvHelper.To(memberInfo.clusterId, 1);

                var orderGoodsList = orderDal.GetOrderGoodsList(userId, orderCode, clusterId);
                if (orderGoodsList.Any())
                {
                    orderGoodsList.ForEach(item =>
                    {
                        var goodsItem = new ItemOrderGoods()
                        {
                            gid         = item.intProductID,
                            title       = item.vchProductName,
                            price       = item.numSalePrice,
                            num         = item.intQty,
                            total       = item.numTotalAmount,
                            pic_url     = GoodsBLL.FormatProductPicUrl(item.PicUrl),
                            score       = item.intScores,
                            marketprice = MCvHelper.To <decimal>(item.numStandarPrice, item.numSalePrice),
                            productcode = item.vchProductPrinted
                        };
                        result.list.Add(goodsItem);
                    });
                    result.status = MResultStatus.Success;
                }
                else
                {
                    result.status = MResultStatus.Undefined;
                    result.msg    = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                result.status = MResultStatus.ExecutionError;
                MLogManager.Error(MLogGroup.Order.获取订单信息, null, "获取订单信息", ex);
            }

            return(result);
        }