public static IList <CategoryInfo> GetMaxMainCategories(int maxNum = 1000) { IList <CategoryInfo> list = new List <CategoryInfo>(); System.Data.DataTable categories = CategoryBrowser.GetCategories(); System.Data.DataRow[] array = categories.Select("Depth = 1"); int num = 0; while (num < maxNum && num < array.Length) { list.Add(DataMapper.ConvertDataRowToProductCategory(array[num])); num++; } return(list); }
public static bool InsertCalculationCommission(string orderid) { OrderInfo orderInfo = GetOrderInfo(orderid); DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(orderInfo.ReferralUserId); bool flag = false; if (userIdDistributors != null) { Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; LineItemInfo info3 = new LineItemInfo(); DataView defaultView = CategoryBrowser.GetAllCategories().DefaultView; string str2 = null; string str3 = null; string str4 = null; decimal subTotal = 0M; foreach (KeyValuePair <string, LineItemInfo> pair in lineItems) { string key = pair.Key; info3 = pair.Value; DataTable productCategories = ProductBrowser.GetProductCategories(info3.ProductId); if ((productCategories.Rows.Count > 0) && (productCategories.Rows[0][0].ToString() != "0")) { defaultView.RowFilter = " CategoryId=" + productCategories.Rows[0][0]; str2 = defaultView[0]["FirstCommission"].ToString(); str3 = defaultView[0]["SecondCommission"].ToString(); str4 = defaultView[0]["ThirdCommission"].ToString(); if ((!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3)) && !string.IsNullOrEmpty(str4)) { ArrayList referralBlanceList = new ArrayList(); ArrayList userIdList = new ArrayList(); ArrayList ordersTotalList = new ArrayList(); subTotal = info3.GetSubTotal(); if (string.IsNullOrEmpty(userIdDistributors.ReferralPath)) { referralBlanceList.Add((decimal.Parse(str4) / 100M) * info3.GetSubTotal()); userIdList.Add(orderInfo.ReferralUserId); ordersTotalList.Add(subTotal); } else { string[] strArray = userIdDistributors.ReferralPath.Split(new char[] { '|' }); if (strArray.Length == 1) { referralBlanceList.Add((decimal.Parse(str3) / 100M) * info3.GetSubTotal()); userIdList.Add(strArray[0]); ordersTotalList.Add(subTotal); referralBlanceList.Add((decimal.Parse(str4) / 100M) * info3.GetSubTotal()); userIdList.Add(orderInfo.ReferralUserId); ordersTotalList.Add(subTotal); } if (strArray.Length == 2) { referralBlanceList.Add((decimal.Parse(str2) / 100M) * info3.GetSubTotal()); userIdList.Add(strArray[0]); ordersTotalList.Add(subTotal); referralBlanceList.Add((decimal.Parse(str3) / 100M) * info3.GetSubTotal()); userIdList.Add(strArray[1]); ordersTotalList.Add(subTotal); referralBlanceList.Add((decimal.Parse(str4) / 100M) * info3.GetSubTotal()); userIdList.Add(orderInfo.ReferralUserId); ordersTotalList.Add(subTotal); } } flag = InsertCalculationCommission(userIdList, referralBlanceList, orderInfo.OrderId, ordersTotalList, orderInfo.UserId.ToString()); } } } } return(flag); }
public static bool UpdateCalculationCommission(OrderInfo order) { DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId); bool flag = false; if (userIdDistributors != null) { Dictionary <string, LineItemInfo> lineItems = order.LineItems; LineItemInfo info2 = new LineItemInfo(); DataView defaultView = CategoryBrowser.GetAllCategories().DefaultView; string str2 = null; string str3 = null; string str4 = null; decimal subTotal = 0M; foreach (KeyValuePair <string, LineItemInfo> pair in lineItems) { string key = pair.Key; info2 = pair.Value; DataTable productCategories = ProductBrowser.GetProductCategories(info2.ProductId); if ((productCategories.Rows.Count > 0) && (productCategories.Rows[0][0].ToString() != "0")) { defaultView.RowFilter = " CategoryId=" + productCategories.Rows[0][0]; str2 = defaultView[0]["FirstCommission"].ToString(); str3 = defaultView[0]["SecondCommission"].ToString(); str4 = defaultView[0]["ThirdCommission"].ToString(); //计算分销 一口价 减 成本价 乘以 佣金比例 if ((!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3)) && !string.IsNullOrEmpty(str4)) { ArrayList referralBlanceList = new ArrayList(); ArrayList userIdList = new ArrayList(); ArrayList ordersTotalList = new ArrayList(); subTotal = info2.GetSubTotal(); //三级分店 referralBlanceList.Add((decimal.Parse(str2.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubCommission()); userIdList.Add(order.ReferralUserId); ordersTotalList.Add(subTotal); if (userIdDistributors.ParentUserId > 0) { referralBlanceList.Add((decimal.Parse(str3.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubCommission()); userIdList.Add(userIdDistributors.ParentUserId); ordersTotalList.Add(subTotal); if (userIdDistributors.ReferralUserId2 > 0) { referralBlanceList.Add((decimal.Parse(str4.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubCommission()); userIdList.Add(userIdDistributors.ReferralUserId2); ordersTotalList.Add(subTotal); } } flag = new DistributorsDao().UpdateCalculationCommission(userIdList, referralBlanceList, order.OrderId, ordersTotalList, order.UserId.ToString()); } } } flag = new DistributorsDao().UpdateDistributorsOrderNum(order.ReferralUserId.ToString(), order.GetTotal().ToString()); RemoveDistributorCache(userIdDistributors.UserId); } return(flag); }