Exemplo n.º 1
0
        public static void GetMall_ShipRateDetailByCardIDList(int ProductID, List <int> CartIDList, int OrderID, out List <Dictionary <string, object> > list, int ProvinceID = 0, int Quantity = 0, int UserID = 0)
        {
            list = new List <Dictionary <string, object> >();
            var ship_rate_list = Mall_ShipRate.GetMall_ShipRates().ToArray();

            if (ProductID > 0)
            {
                var data = Mall_Product.GetMall_Product(ProductID);
                CalculateRateByProductOutDic(ship_rate_list, out list, ProvinceID: ProvinceID, Quantity: Quantity, BusinessID: data.BusinessID);
                return;
            }
            if (OrderID > 0)
            {
                var orderitem_list = Mall_OrderItem.GetMall_OrderItemListByOrderID(OrderID);
                if (orderitem_list.Length == 0)
                {
                    return;
                }
                var product_list  = Mall_Product.GetMall_ProductListByIDList(orderitem_list.Select(p => p.ProductID).ToList());
                int TotalQuantity = orderitem_list.Sum(p => p.Quantity);
                CalculateRateByProductOutDic(ship_rate_list, out list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: orderitem_list[0].BusinessID);
                return;
            }
            if (CartIDList.Count > 0)
            {
                var     cart_list      = Foresight.DataAccess.Mall_ShoppingCart.GetMall_ShoppingCartListByIDList(CartIDList, UserID);
                var     product_list   = Foresight.DataAccess.Mall_ProductDetail.GetMall_ProductDetailListByIDList(cart_list.Select(p => p.ProductID).ToList());
                var     variant_list   = Foresight.DataAccess.Mall_Product_VariantDetail.GetMall_Product_VariantDetailListByIDList(cart_list.Select(p => p.VariantID).ToList());
                var     business_list  = Foresight.DataAccess.Mall_Business.GetMall_BusinessListByIDList(product_list.Select(p => p.BusinessID).ToList());
                decimal totalprice     = 0;
                int     totalsalepoint = 0;
                int     TotalQuantity  = 0;
                string  totalpricedesc = string.Empty;
                var     productlist    = Mall_ShoppingCart.getshoppingcartitems(cart_list, product_list, variant_list, 0, string.Empty, out totalprice, out totalsalepoint, out TotalQuantity, out totalpricedesc);
                var     my_list        = new List <Dictionary <string, object> >();
                CalculateRateByProductOutDic(ship_rate_list, out my_list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: 0);
                list.AddRange(my_list);
                foreach (var business in business_list)
                {
                    totalprice     = 0;
                    totalsalepoint = 0;
                    TotalQuantity  = 0;
                    totalpricedesc = string.Empty;
                    productlist    = Mall_ShoppingCart.getshoppingcartitems(cart_list, product_list, variant_list, business.ID, string.Empty, out totalprice, out totalsalepoint, out TotalQuantity, out totalpricedesc);
                    my_list        = new List <Dictionary <string, object> >();
                    CalculateRateByProductOutDic(ship_rate_list, out my_list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: business.ID);
                    list.AddRange(my_list);
                }
            }
            return;
        }
Exemplo n.º 2
0
 public static void GetMall_ShipRateDetailByKeywords(int ProductID, List <int> CartIDList, int OrderID, out string RateTitle, out decimal RateAmount, out int RateID, out int RateType, int ProvinceID = 0, int Quantity = 0, int UserID = 0)
 {
     RateTitle  = "快递 免邮";
     RateAmount = 0;
     RateID     = 0;
     RateType   = 0;
     if (ProductID > 0)
     {
         var data = Mall_Product.GetMall_Product(ProductID);
         CalculateRateByProduct(data, out RateTitle, out RateAmount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: Quantity);
         return;
     }
     if (OrderID > 0)
     {
         var orderitem_list = Mall_OrderItem.GetMall_OrderItemListByOrderID(OrderID);
         var product_list   = Mall_Product.GetMall_ProductListByIDList(orderitem_list.Select(p => p.ProductID).ToList());
         foreach (var item in orderitem_list)
         {
             var     product        = product_list.FirstOrDefault(p => p.ID == item.ProductID);
             decimal my_rate_amount = 0;
             string  my_rate_title  = string.Empty;
             CalculateRateByProduct(product, out my_rate_title, out my_rate_amount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: item.Quantity);
             RateAmount += my_rate_amount;
             RateTitle  += my_rate_title + " ";
         }
         return;
     }
     if (CartIDList.Count > 0)
     {
         var cartitem_list = Mall_ShoppingCart.GetMall_ShoppingCartListByIDList(CartIDList, UserID);
         var product_list  = Mall_Product.GetMall_ProductListByIDList(cartitem_list.Select(p => p.ProductID).ToList());
         foreach (var item in cartitem_list)
         {
             var     product        = product_list.FirstOrDefault(p => p.ID == item.ProductID);
             decimal my_rate_amount = 0;
             string  my_rate_title  = string.Empty;
             CalculateRateByProduct(product, out my_rate_title, out my_rate_amount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: item.Quantity);
             RateAmount += my_rate_amount;
             RateTitle  += my_rate_title + " ";
         }
         return;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 消费处理
        /// </summary>
        /// <param name="order"></param>
        /// <param name="payment"></param>
        public static void GetEarnThroughBuy(Mall_Order order = null, Payment payment = null)
        {
            //消费赠与处理
            if (order == null)
            {
                return;
            }
            int[] ProductIDList = Mall_OrderItem.GetProductIDListByOrderID(order.ID, IsProduct: true);
            int[] ServiceIDList = Mall_OrderItem.GetProductIDListByOrderID(order.ID, IsService: true);
            if (payment == null)
            {
                payment = Payment.GetPaymentByTradeNo(order.TradeNo);
            }
            decimal TotalCost = order.TotalCost;

            if (payment != null)
            {
                TotalCost = payment.Amount / 100;
            }
            Dictionary <string, object> BackObject = new Dictionary <string, object>();

            Mall_AmountRule.GetBackAmountPoint(TotalCost, out BackObject, ProductIDList, ServiceIDList, AmountType: 2, UserID: order.UserID);
            string Title        = "消费赠与";
            int    CategoryType = 6;

            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    decimal  BackAmount            = Utility.Tools.GetValueFromDic <decimal>(BackObject, "BackAmount");
                    int      AmountRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "AmountRuleID");
                    bool     AmountIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "AmountIsSendNow");
                    DateTime AmountIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "AmountIsReadySendTime");
                    if (BackAmount > 0 && AmountRuleID > 0)
                    {
                        Insert_Mall_UserBalance(order.UserID, 1, BackAmount, Title, "BalaceID:" + order.ID, CategoryType, "System", 1, "", RelatedID: order.ID, AmountRuleID: AmountRuleID, helper: helper, PaymentMethod: order.PaymentMethod, IsSent: AmountIsSendNow, IsReadySendTime: AmountIsReadySendTime);
                    }
                    int      BackPoint            = Utility.Tools.GetValueFromDic <int>(BackObject, "BackPoint");
                    int      PointRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "PointRuleID");
                    bool     PointIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "PointIsSendNow");
                    DateTime PointIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "PointIsReadySendTime");
                    if (BackPoint > 0 && PointRuleID > 0)
                    {
                        Mall_UserPoint.Insert_Mall_UserPoint(order.UserID, 1, 0, Title, "BalaceID:" + order.ID, CategoryType, "System", 1, "", 0, helper, RelatedID: order.ID, PointValue: BackPoint, AmountRuleID: PointRuleID, IsSent: PointIsSendNow, IsReadySendTime: PointIsReadySendTime);
                    }
                    if (order.TotalOrderPointCost > 0)
                    {
                        Mall_UserPoint.Insert_Mall_UserPoint(order.UserID, 2, 0, "购买商品", "OrderID:" + order.ID, 1, "System", 1, order.TradeNo, order.ID, helper, RelatedID: order.ID, PointValue: -order.TotalOrderPointCost, AmountRuleID: 0);
                    }

                    List <int> CouponIDList          = Utility.Tools.GetValueFromDic <List <int> >(BackObject, "CouponIDList");
                    int        CouponRuleID          = Utility.Tools.GetValueFromDic <int>(BackObject, "CouponRuleID");
                    bool       CouponIsSendNow       = Utility.Tools.GetValueFromDic <bool>(BackObject, "CouponIsSendNow");
                    DateTime   CouponIsReadySendTime = Utility.Tools.GetValueFromDic <DateTime>(BackObject, "CouponIsReadySendTime");
                    int        SendCouponCount       = Utility.Tools.GetValueFromDic <int>(BackObject, "SendCouponCount");
                    if (CouponIDList != null && CouponIDList.Count > 0 && CouponRuleID > 0)
                    {
                        foreach (var CouponID in CouponIDList)
                        {
                            for (int i = 0; i < SendCouponCount; i++)
                            {
                                Mall_CouponUser.Insert_Mall_CouponUser(order.UserID, CouponID, 3, CouponRuleID, CouponIsReadySendTime, helper: helper, IsSent: CouponIsSendNow);
                            }
                        }
                    }
                    if (payment != null)
                    {
                        payment.Save(helper);
                    }
                    if (order != null)
                    {
                        order.Save(helper);
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    Utility.LogHelper.WriteError("Mall_UserBalance.cs", "GetEarnThroughBuy", ex);
                }
            }
        }