示例#1
0
        /// <summary>
        /// 从购物车中转为订单
        /// </summary>
        /// <typeparam name="TMain"></typeparam>
        /// <param name="order"></param>
        /// <param name="catrType"></param>
        /// <param name="groupBySupplier">true时会按商家分为不同订单</param>
        /// <returns></returns>
        public static bool SubmitOrder <TMain>(TMain order, int catrType, bool groupBySupplier)
            where TMain : IProductOrder, new()
        {
            string userId = order.UserId;
            Dictionary <int, List <ShoppingCart.ICartItem> > list = ShoppingCart.CartAction <TType> .Query(catrType, userId, groupBySupplier);

            if (list.Count == 0)
            {
                return(false);
            }
            //购物车类型转为订单详细
            List <Attribute.FieldAttribute> typeArry = Base.GetProperties(typeof(ShoppingCart.ICartItem), false);

            foreach (KeyValuePair <int, List <ShoppingCart.ICartItem> > v in list)
            {
                var cartItems = v.Value;
                cartItems.RemoveAll(b => b.Selected == false);//移除未选中的
                List <IOrderDetail> details = new List <IOrderDetail>();

                details          = ObjectConvert.CloneToSimple <IOrderDetail, ShoppingCart.ICartItem>(cartItems);
                order.SupplierId = v.Key;
                SubmitOrder <TMain>(order, details);
            }
            //清空购物车
            ShoppingCart.CartAction <TType> .RemoveAll(userId, catrType);

            return(true);
        }
示例#2
0
        /// <summary>
        /// 总是返回简单结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parame"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <IProductBase> QuerySimpleListByPage <T>(ParameCollection parame, out int count) where T : IProductBase, new()
        {
            parame.Remove("Fields");
            parame.SetQueryFields(@"[AddTime]
      ,[CategoryCode]
      ,[Id]
      ,[ProductImage]
      ,[ProductName]
      ,[SettlementPrice]
      ,[SoldPrice]
      ,[SupplierId],[ProductStatus]");
            List <T> list = QueryListByPage <T>(parame, out count);

            return(ObjectConvert.CloneToSimple <IProductBase, T>(list));
        }