public static string OrderSplitToTemp(OrderInfo OldOrderInfo, string skuid, string neworderid, int itemid) { string result = string.Empty; string orderId = OldOrderInfo.OrderId; string text = string.Empty; string text2 = string.Empty; if (OldOrderInfo != null) { if (neworderid == "0") { IList <OrderSplitInfo> orderSplitItems = new OrderSplitDao().GetOrderSplitItems(orderId); if (orderSplitItems.Count == 0) { foreach (LineItemInfo current in OldOrderInfo.LineItems.Values) { if (current.ID == itemid) { text = current.ID.ToString(); } else { text2 = text2 + "," + current.ID.ToString(); } } text2 = text2.Trim(new char[] { ',' }); OrderSplitInfo orderSplitInfo = new OrderSplitInfo(); int num = 1; orderSplitInfo.OldOrderId = orderId; orderSplitInfo.OrderIDNum = num; orderSplitInfo.ItemList = text2; orderSplitInfo.UpdateTime = DateTime.Now; orderSplitInfo.AdjustedFreight = OldOrderInfo.AdjustedFreight; new OrderSplitDao().NewOrderSplit(orderSplitInfo); orderSplitInfo.ItemList = text; orderSplitInfo.OrderIDNum = num + 1; orderSplitInfo.UpdateTime = DateTime.Now; orderSplitInfo.AdjustedFreight = 0m; new OrderSplitDao().NewOrderSplit(orderSplitInfo); result = "1"; } else { string text3 = string.Empty; int id = 0; foreach (OrderSplitInfo current2 in orderSplitItems) { if (current2.OrderIDNum == 1) { text3 = current2.ItemList; id = current2.Id; break; } } LineItemInfo returnMoneyByOrderIDAndProductID = new LineItemDao().GetReturnMoneyByOrderIDAndProductID(orderId, skuid, itemid); if (returnMoneyByOrderIDAndProductID != null && ("," + text3 + ",").Contains("," + returnMoneyByOrderIDAndProductID.ID + ",")) { decimal d = 0m; decimal num2 = 0m; string[] array = text3.Split(new char[] { ',' }); if (array.Length > 1) { string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; LineItemInfo lineItemInfo = new LineItemDao().GetLineItemInfo(Globals.ToNum(s), orderId); if (lineItemInfo != null) { decimal num3 = 0m; if (lineItemInfo.Type == 0) { num3 = lineItemInfo.ItemAdjustedPrice * lineItemInfo.Quantity - lineItemInfo.ItemAdjustedCommssion - lineItemInfo.DiscountAverage; } if (lineItemInfo.ID == itemid) { num2 = num3; text = lineItemInfo.ID.ToString(); } d += num3; } } if (d > num2 && num2 > 0m) { OrderSplitInfo orderSplitInfo = new OrderSplitInfo(); int num = new OrderSplitDao().GetMaxOrderIDNum(orderId); orderSplitInfo.Id = id; orderSplitInfo.OldOrderId = orderId; orderSplitInfo.OrderIDNum = 1; orderSplitInfo.ItemList = ("," + text3 + ",").Replace("," + returnMoneyByOrderIDAndProductID.ID.ToString() + ",", ",").Trim(new char[] { ',' }); orderSplitInfo.UpdateTime = DateTime.Now; orderSplitInfo.AdjustedFreight = OldOrderInfo.AdjustedFreight; new OrderSplitDao().UpdateOrderSplitInfo(orderSplitInfo); orderSplitInfo.AdjustedFreight = 0m; orderSplitInfo.ItemList = returnMoneyByOrderIDAndProductID.ID.ToString(); orderSplitInfo.OrderIDNum = num + 1; orderSplitInfo.UpdateTime = DateTime.Now; new OrderSplitDao().NewOrderSplit(orderSplitInfo); result = "1"; } else { result = "-3"; } } else { result = "-1"; } } else { result = "-2"; } } } else { IList <OrderSplitInfo> orderSplitItems = new OrderSplitDao().GetOrderSplitItems(orderId); if (orderSplitItems.Count > 0) { string text3 = string.Empty; int id = 0; int id2 = 0; int orderIDNum = 0; string str = string.Empty; int num4 = 0; foreach (OrderSplitInfo current2 in orderSplitItems) { if (current2.OrderIDNum == 1) { text3 = current2.ItemList; id = current2.Id; num4++; } if (current2.Id.ToString() == neworderid) { str = current2.ItemList; id2 = current2.Id; orderIDNum = current2.OrderIDNum; num4++; } if (num4 == 2) { break; } } decimal d = 0m; decimal num2 = 0m; string[] array = text3.Split(new char[] { ',' }); if (array.Length > 1) { string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; LineItemInfo lineItemInfo = new LineItemDao().GetLineItemInfo(Globals.ToNum(s), orderId); if (lineItemInfo != null) { decimal num3 = 0m; if (lineItemInfo.Type == 0) { num3 = lineItemInfo.ItemAdjustedPrice * lineItemInfo.Quantity - lineItemInfo.ItemAdjustedCommssion - lineItemInfo.DiscountAverage; } if (lineItemInfo.ID == itemid) { num2 = num3; text = lineItemInfo.ID.ToString(); } d += num3; } } if (d > num2 && num2 > 0m) { OrderSplitInfo orderSplitInfo = new OrderSplitInfo(); orderSplitInfo.Id = id; orderSplitInfo.OldOrderId = orderId; orderSplitInfo.OrderIDNum = 1; orderSplitInfo.ItemList = ("," + text3 + ",").Replace("," + text + ",", ",").Trim(new char[] { ',' }); orderSplitInfo.UpdateTime = DateTime.Now; orderSplitInfo.AdjustedFreight = OldOrderInfo.AdjustedFreight; new OrderSplitDao().UpdateOrderSplitInfo(orderSplitInfo); orderSplitInfo.Id = id2; orderSplitInfo.AdjustedFreight = 0m; orderSplitInfo.ItemList = str + "," + text; orderSplitInfo.OrderIDNum = orderIDNum; orderSplitInfo.UpdateTime = DateTime.Now; new OrderSplitDao().UpdateOrderSplitInfo(orderSplitInfo); result = "1"; } else { result = "-3"; } } else { result = "-1"; } } else { result = "-2"; } } } return(result); }
public static string OrderSplitToTemp(OrderInfo OldOrderInfo, string skuid, string neworderid, int itemid) { IList <OrderSplitInfo> orderSplitItems; OrderSplitInfo info2; string itemList; int id; decimal num3; decimal num4; string[] strArray; LineItemInfo lineItemInfo; decimal num5; int num6; int orderIDNum; string str7; string str = string.Empty; string orderId = OldOrderInfo.OrderId; string str3 = string.Empty; string str4 = string.Empty; if (OldOrderInfo == null) { return(str); } if (!(neworderid == "0")) { orderSplitItems = new OrderSplitDao().GetOrderSplitItems(orderId); if (orderSplitItems.Count <= 0) { return("-2"); } itemList = string.Empty; id = 0; num6 = 0; orderIDNum = 0; str7 = string.Empty; int num8 = 0; foreach (OrderSplitInfo info3 in orderSplitItems) { if (info3.OrderIDNum == 1) { itemList = info3.ItemList; id = info3.Id; num8++; } if (info3.Id.ToString() == neworderid) { str7 = info3.ItemList; num6 = info3.Id; orderIDNum = info3.OrderIDNum; num8++; } if (num8 == 2) { break; } } } else { int maxOrderIDNum; orderSplitItems = new OrderSplitDao().GetOrderSplitItems(orderId); if (orderSplitItems.Count == 0) { foreach (LineItemInfo info in OldOrderInfo.LineItems.Values) { if (info.ID == itemid) { str3 = info.ID.ToString(); } else { str4 = str4 + "," + info.ID.ToString(); } } str4 = str4.Trim(new char[] { ',' }); info2 = new OrderSplitInfo(); maxOrderIDNum = 1; info2.OldOrderId = orderId; info2.OrderIDNum = maxOrderIDNum; info2.ItemList = str4; info2.UpdateTime = DateTime.Now; info2.AdjustedFreight = OldOrderInfo.AdjustedFreight; new OrderSplitDao().NewOrderSplit(info2); info2.ItemList = str3; info2.OrderIDNum = maxOrderIDNum + 1; info2.UpdateTime = DateTime.Now; info2.AdjustedFreight = 0M; new OrderSplitDao().NewOrderSplit(info2); return("1"); } itemList = string.Empty; id = 0; foreach (OrderSplitInfo info3 in orderSplitItems) { if (info3.OrderIDNum == 1) { itemList = info3.ItemList; id = info3.Id; break; } } LineItemInfo info4 = new LineItemDao().GetReturnMoneyByOrderIDAndProductID(orderId, skuid, itemid); if ((info4 != null) && ("," + itemList + ",").Contains("," + info4.ID + ",")) { num3 = 0M; num4 = 0M; strArray = itemList.Split(new char[] { ',' }); if (strArray.Length > 1) { foreach (string str6 in strArray) { lineItemInfo = new LineItemDao().GetLineItemInfo(Globals.ToNum(str6), orderId); if (lineItemInfo != null) { num5 = 0M; if (lineItemInfo.Type == 0) { num5 = ((lineItemInfo.ItemAdjustedPrice * lineItemInfo.Quantity) - lineItemInfo.ItemAdjustedCommssion) - lineItemInfo.DiscountAverage; } if (lineItemInfo.ID == itemid) { num4 = num5; str3 = lineItemInfo.ID.ToString(); } num3 += num5; } } if ((num3 > num4) && (num4 > 0M)) { info2 = new OrderSplitInfo(); maxOrderIDNum = new OrderSplitDao().GetMaxOrderIDNum(orderId); info2.Id = id; info2.OldOrderId = orderId; info2.OrderIDNum = 1; info2.ItemList = ("," + itemList + ",").Replace("," + info4.ID.ToString() + ",", ",").Trim(new char[] { ',' }); info2.UpdateTime = DateTime.Now; info2.AdjustedFreight = OldOrderInfo.AdjustedFreight; new OrderSplitDao().UpdateOrderSplitInfo(info2); info2.AdjustedFreight = 0M; info2.ItemList = info4.ID.ToString(); info2.OrderIDNum = maxOrderIDNum + 1; info2.UpdateTime = DateTime.Now; new OrderSplitDao().NewOrderSplit(info2); return("1"); } return("-3"); } return("-1"); } return("-2"); } num3 = 0M; num4 = 0M; strArray = itemList.Split(new char[] { ',' }); if (strArray.Length > 1) { foreach (string str6 in strArray) { lineItemInfo = new LineItemDao().GetLineItemInfo(Globals.ToNum(str6), orderId); if (lineItemInfo != null) { num5 = 0M; if (lineItemInfo.Type == 0) { num5 = ((lineItemInfo.ItemAdjustedPrice * lineItemInfo.Quantity) - lineItemInfo.ItemAdjustedCommssion) - lineItemInfo.DiscountAverage; } if (lineItemInfo.ID == itemid) { num4 = num5; str3 = lineItemInfo.ID.ToString(); } num3 += num5; } } if ((num3 > num4) && (num4 > 0M)) { info2 = new OrderSplitInfo { Id = id, OldOrderId = orderId, OrderIDNum = 1, ItemList = ("," + itemList + ",").Replace("," + str3 + ",", ",").Trim(new char[] { ',' }), UpdateTime = DateTime.Now, AdjustedFreight = OldOrderInfo.AdjustedFreight }; new OrderSplitDao().UpdateOrderSplitInfo(info2); info2.Id = num6; info2.AdjustedFreight = 0M; info2.ItemList = str7 + "," + str3; info2.OrderIDNum = orderIDNum; info2.UpdateTime = DateTime.Now; new OrderSplitDao().UpdateOrderSplitInfo(info2); return("1"); } return("-3"); } return("-1"); }