public JsonResult Create(OrderProductType obj) { try { NSession.SaveOrUpdate(obj); NSession.Flush(); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }
public string Zu1(OrderProductType item) { string str = " ExSKU:" + item.ExSKU + " 名称:" + item.Title + " SKU:" + item.SKU + " 数量:" + item.Qty + " 规格:" + item.Standard + " 价格:" + item.Price + " 网址:" + item.Url + " 描述:" + item.Remark + "<br>"; return str; }
public static void GetItem(OrderProductType item, ISession NSession) { if (item.SKU.IndexOf(":") != -1) { System.Text.RegularExpressions.Regex r1 = new System.Text.RegularExpressions.Regex(@":D(?<num>\d+)", System.Text.RegularExpressions.RegexOptions.None); System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@":A(?<desc>.+)", System.Text.RegularExpressions.RegexOptions.None); System.Text.RegularExpressions.Match mc1 = r1.Match(item.SKU); System.Text.RegularExpressions.Match mc2 = r2.Match(item.SKU); string[] cels = item.SKU.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (cels[0] != null) item.SKU = cels[0].Trim(); int fo = Utilities.ToInt(mc1.Groups["num"].ToString()); if (fo != 0) item.Qty = fo * item.Qty; try { item.Remark += mc2.Groups["desc"].Value; } catch (Exception) { item.Remark = ""; } } IList<ProductType> ps = NSession.CreateQuery("from ProductType where sku='" + item.SKU + "'").List<ProductType>(); if (ps.Count > 0) { item.Standard = ps[0].Standard; } }
private static void SplitProduct(OrderProductType product, ISession NSession, IList<ProductComposeType> products) { List<ProductComposeType> compose = products.Where(x => x.SKU.Trim().ToUpper() == product.SKU.Trim().ToUpper()).ToList(); if (compose.Count > 0) OrderHelper.SplitProduct(product, compose, NSession); }
public static void CreateOrderPruduct(OrderProductType product, ISession NSession) { IList<ProductComposeType> products = NSession.CreateQuery("from ProductComposeType").List<ProductComposeType>(); if (product.SKU == null) product.SKU = ""; if (product.SKU.IndexOf("+") != -1) { int qty = product.Qty; foreach (string fo in product.SKU.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries)) { product.Qty = qty; product.Id = 0; if (fo != null) product.SKU = fo.Trim(); GetItem(product, NSession); NSession.Save(product); NSession.Flush(); NSession.Clear(); SplitProduct(product, NSession, products); } } else { GetItem(product, NSession); NSession.Save(product); NSession.Flush(); SplitProduct(product, NSession, products); } }
/// <summary> /// 创建订单产品 /// </summary> /// <param name="sku"></param> /// <param name="qty"></param> /// <param name="name"></param> /// <param name="remark"></param> /// <param name="price"></param> /// <param name="url"></param> /// <param name="oid"></param> /// <param name="orderNo"></param> public static void CreateOrderPruduct(string exSKU, string sku, int qty, string name, string remark, double price, string url, int oid, string orderNo, ISession NSession) { OrderProductType product = new OrderProductType(); product.ExSKU = exSKU; if (sku != null) product.SKU = sku.Trim(); product.Qty = qty; product.Price = price; product.Title = name; product.Url = url; product.OId = oid; product.OrderNo = orderNo; product.Remark = remark; CreateOrderPruduct(product, NSession); }
public static void SplitProduct(OrderProductType orderProduct, List<ProductComposeType> productComposes, ISession NSession) { int qty = orderProduct.Qty; int id = orderProduct.Id; foreach (ProductComposeType productComposeType in productComposes) { orderProduct.SKU = productComposeType.SrcSKU; orderProduct.Qty = productComposeType.SrcQty * qty; orderProduct.Id = 0; NSession.Clear(); NSession.Save(orderProduct); NSession.Flush(); } NSession.Clear(); NSession.Delete(" from OrderProductType where Id=" + id); NSession.Flush(); }