public ActionResult Dashboard() { string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); BShopStatistic statistic = shopManager.GetShopStatistic(0, true); return View(statistic); }
public ActionResult Child() { string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); List<Mall_Type> mtypes = shopManager.GetMallTypes(); ViewData["t"] = ""; return View(mtypes); }
public ApiMessage CreateExpressFees() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); string jsonStr = request["express"]; jsonStr = HttpUtility.UrlDecode(jsonStr); JObject json = JObject.Parse(jsonStr); int express_id = (int)json["id"]; BShopExpress express = new BShopExpress() { ID = express_id }; express.IsDefault = false; JArray fees = (JArray)json["fees"]; if (fees.Count > 0) { express.Fees = new List<BExpressFee>(); } for (int i = 0; i < fees.Count; i++) { JObject o = (JObject)fees[i]; int pid = (int)o["pid"]; int cid = (int)o["cid"]; double fee = (double)o["fee"]; int hid = (int)o["hid"]; BExpressFee feeObj = new BExpressFee() { Fee = fee, Province = new BArea() { ID = pid }, City = new BArea() { ID = cid }, StoreHouse = new BStoreHouse { ID = hid } }; express.Fees.Add(feeObj); } try { shopManager.CreateExpressFees(express); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } return message; }
public ApiMessage AddChildShop() { ApiMessage message = new ApiMessage() { Status="ok"}; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); string child_shop = request["shop_name"]; int mtype = 0; int.TryParse(request["type"],out mtype); try { if (shopManager.AddChildShop(mtype, child_shop)) { message.Status = "failed"; message.Message = "添加失败"; } else { message.Message = "添加子店铺请求已经发出,等待子店铺主账户登录进销存批准请求"; } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { message.Status = "failed"; message.Message = "未知错误,请联系管理员"; } finally { } return message; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); string user_id = filterContext.HttpContext.User.Identity.Name; if (string.IsNullOrEmpty(user_id)) { return; } //Verify if the cookie user is a valid user UserManagement userManagement = new UserManagement(); BUser loginuser = userManagement.GetUserInfo(int.Parse(user_id)); if (loginuser == null) { return; } if (!loginuser.IsSystemUser) { //normal user login UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(user, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); filterContext.Controller.ViewData["CurrentShop"] = userMgr.Shop; filterContext.Controller.ViewData["MainShop"] = userMgr.Main_Shop; filterContext.Controller.ViewData["ChildShop"] = userMgr.ChildShops; filterContext.Controller.ViewData["CurrentPermission"] = userMgr.CurrentUserPermission; filterContext.Controller.ViewData["CurrentUser"] = userMgr.CurrentUser; filterContext.Controller.ViewData["SPStatistic"] = shopManager.GetShopStatistic(0, true); } else { //system user login //filterContext.HttpContext.Response.Redirect("/Admin/Index"); filterContext.Controller.ViewData["CurrentUser"] = loginuser; } }
public ApiMessage SetDefaultExpress() { ApiMessage message = new ApiMessage(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int expId = 0; int.TryParse(request["express_id"], out expId); try { shopManager.SetDefaultExpress(expId); message.Status = "ok"; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { } finally { } return message; }
public PQGridData SearchShopUsers() { PQGridData data = new PQGridData(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int page = 1; int pageSize = 30; int shop_id = 0; int.TryParse(request["page"],out page); int.TryParse(request["pageSize"],out pageSize); int.TryParse(request["shop"], out shop_id); if (page <= 0) { page = 1; } if (pageSize <= 0) { pageSize = 30; } long total = 0; List<BUser> users = shopManager.SearchShopUsers(page, pageSize, out total, shop_id); data.data = users; data.curPage = page; data.totalRecords = total; return data; }
public PQGridData SearchSentChildRequets() { PQGridData data = new PQGridData(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); List<BAddChildRequest> requests = shopManager.SearchSentAddChildRequests(); data.data = requests; data.totalRecords = requests.Count; data.curPage = 1; return data; }
public PQGridData SearchOnSaleProducts() { PQGridData data = new PQGridData(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int total = 0; int page = 1; int pageSize = 30; bool? connected = null; int.TryParse(request["page"], out page); int.TryParse(request["pageSize"], out pageSize); string keyword=request["keyword"]; if (page <= 0) { page = 1; } if (pageSize <= 0) { pageSize = 30; } if (request["connected"] != null) { if (request["connected"] == "1") { connected = true; } else if (request["connected"] == "0") { connected = false; } } List<BMallProduct> products = shopManager.SearchOnSaleMallProducts(keyword, page, pageSize, out total, connected); data.data = products; data.curPage = page; data.totalRecords = total; return data; }
public ActionResult Product() { string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int total = 0; int page = 1; int pageSize = 30; bool? connected = null; int.TryParse(Request["page"],out page); int.TryParse(Request["pageSize"], out pageSize); string keyword = Request["txt_product_name"]; int shop = 0; int.TryParse(Request["txt_product_shop"],out shop); if (page <= 0) { page = 1; } if (pageSize <= 0) { pageSize = 30; } if (Request["connected"] != null) { if (Request["connected"] == "1") { connected = true; } else if (Request["connected"] == "0") { connected = false; } } BMallSync lastSync = shopManager.GetMallSync(0, 0); List<BMallProduct> products = shopManager.SearchOnSaleMallProducts(keyword, page, pageSize, out total, connected, shop); BPageData data = new BPageData(); data.Data = products; data.TotalRecords = total; data.Page = page; data.PageSize = pageSize; data.URL = Request.RawUrl; ViewData["LastSync"] = lastSync; ViewData["ChildShop"] = shopManager.ChildShops; ViewData["CurrentShop"] = shopManager.Shop; return View(data); }
public List<BStoreHouse> GetNonExpressedHouses() { HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int expId = 0; int.TryParse(request["express_id"],out expId); return shopManager.GetNonExpressedHouses(expId); }
public List<Express> GetNonAddedExpresses() { string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); return shopManager.GetNonAddedExpresses(); }
public ApiMessage CreateProductsByMallProducts() { ApiMessage message = new ApiMessage() {Status="ok" }; try { HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); string mIds=request["mall_products"]; string[] products = null; bool mapProduct = false; if (!string.IsNullOrEmpty(request["map_product"]) && request["map_product"] == "1") { mapProduct = true; } else { mapProduct = false; } if (!string.IsNullOrEmpty(mIds)) { products = mIds.Split(','); } if (products != null && products.Length > 0) { shopManager.CreateProductsByMallProducts(products, mapProduct); } else { message.Status = "failed"; message.Message = "请选择宝贝"; } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return message; }
public ApiMessage SyncMallSoldProducts() { ApiMessage message = new ApiMessage() { Status="ok"}; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); bool createdProduct = false; bool mapProduct = false; int shop_id = 0; try { if (!string.IsNullOrEmpty(request["create_product"]) && request["create_product"] == "1") { createdProduct = true; } if (!string.IsNullOrEmpty(request["map_product"]) && request["map_product"] == "1") { mapProduct = true; } List<BMallProduct> newProducts = shopManager.SyncMallOnSaleProducts(shop_id, createdProduct, mapProduct); message.Item = newProducts.Count; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch(Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } finally { } return message; }
public ApiMessage HandleAddChildRequest() { ApiMessage message = new ApiMessage() { Status="ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int reqId = 0; int status = 0; int.TryParse(request["reqId"],out reqId); int.TryParse(request["status"],out status); try { shopManager.HandleAddChildRequest(reqId, status); } catch (KMJXCException kex) { message.Message = kex.Message; message.Status = "failed"; } catch { } finally { } return message; }
public ApiMessage UpdateExpressFee() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int express_fee_id = 0; double fee = 0; int.TryParse(request["express_fee_id"],out express_fee_id); double.TryParse(request["fee"],out fee); try { shopManager.UpdateExpressFee(express_fee_id, fee); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误,请联系管理员"; } finally { } return message; }
public ApiMessage MapMallProductSku() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); ProductManager pdtManager = new ProductManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); try { string skuId = request["sku_id"]; int product_id; int.TryParse(request["product_id"], out product_id); bool result = shopManager.MapSku(skuId, product_id); if (!result) { message.Status = "failed"; message.Message = "未知错误,请联系客服"; } } catch (KMJXCException kex) { message.Message = kex.Message; message.Status = "failed"; } catch (Exception ex) { message.Message = ex.Message; message.Status = "failed"; } finally { } return message; }
public ApiMessage UpdateShopContactInfo() { ApiMessage message = new ApiMessage() {Status="ok"}; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); string phone = request["phone"]; string email = request["email"]; string address = request["address"]; string contact = request["contact"]; int shop_id = 0; int.TryParse(request["shop_id"],out shop_id); try { shopManager.UpdateShopContactInfo(0, phone, address, contact, email); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return message; }
public PQGridData SearchExpresses() { PQGridData data = new PQGridData(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); data.data = shopManager.SearchExpresses(); return data; }
// // GET: /Sale/ public ActionResult Search() { string sCreated = Request["trade_sdate"]; string sHours = Request["trade_sdate_hour"]; string sMinutes = Request["trade_sdate_minute"]; string eCreated = Request["trade_edate"]; string eHours = Request["trade_edate_hour"]; string eMinutes = Request["trade_edate_minute"]; string productName = Request["pdt_name"]; string buyer_nick = Request["buyer_nick"]; string trade_num = Request["trade_num"]; string trade_status = Request["trade_status"]; int shop = 0; int page = 1; int pageSize = 30; int.TryParse(Request["page"], out page); int.TryParse(Request["pagesize"], out pageSize); int.TryParse(Request["trade_shop"], out shop); if (page <= 0) { page = 1; } if (pageSize <= 0) { pageSize = 30; } DateTime sDate = DateTime.MinValue; DateTime eDate = DateTime.MinValue; if (!string.IsNullOrEmpty(sCreated) && !string.IsNullOrEmpty(sHours) && !string.IsNullOrEmpty(sMinutes)) { sDate = Convert.ToDateTime(sCreated); int h = 0; int m = 0; int.TryParse(sHours, out h); int.TryParse(sMinutes, out m); sDate = new DateTime(sDate.Year, sDate.Month, sDate.Day, h, m, 0); } if (!string.IsNullOrEmpty(eCreated) && !string.IsNullOrEmpty(eHours) && !string.IsNullOrEmpty(eMinutes)) { eDate = Convert.ToDateTime(eCreated); int h = 0; int m = 0; int.TryParse(eHours, out h); int.TryParse(eMinutes, out m); eDate = new DateTime(eDate.Year, eDate.Month, eDate.Day, h, m, 0); } string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int total = 0; long sTime = 0; long eTime = 0; if (sDate != DateTime.MinValue) { sTime = DateTimeUtil.ConvertDateTimeToInt(sDate); } if (eDate != DateTime.MinValue) { eTime = DateTimeUtil.ConvertDateTimeToInt(eDate); } string[] nums = null; if (!string.IsNullOrEmpty(trade_num)) { nums = trade_num.Split(','); } string[] status = null; if (!string.IsNullOrEmpty(trade_status)) { status = trade_status.Split(','); } List<BSale> sales = saleManager.SearchSales(null, productName, nums, status, null, buyer_nick, sTime, eTime, page, pageSize, out total, shop); BPageData data = new BPageData(); data.Data = sales; data.TotalRecords = total; data.Page = page; data.PageSize = pageSize; data.URL = Request.RawUrl; List<BShop> childShops = shopManager.SearchChildShops(); ViewData["ChildShop"] = childShops; ViewData["CurrentShop"] = userMgr.Shop; ViewData["MainShop"] = userMgr.Main_Shop; return View(data); }
/// <summary> /// /// </summary> /// <param name="trade_id"></param> /// <param name="order_id"></param> /// <param name="mall_product_id"></param> /// <param name="mall_sku_id"></param> /// <param name="parent_product_id"></param> /// <param name="product_id"></param> /// <param name="mapproduct"></param> public void CreateLeaveStockForMallTrade(string trade_id, string order_id, string mall_product_id, string mall_sku_id, int parent_product_id, int product_id, bool mapproduct = false) { if (string.IsNullOrEmpty(mall_product_id)) { throw new KMJXCException("丢失商城宝贝编号"); } using (KuanMaiEntities db = new KuanMaiEntities()) { Sale trade = (from t in db.Sale where t.Mall_Trade_ID == trade_id select t).FirstOrDefault<Sale>(); if (trade == null) { throw new KMJXCException("交易号为:" + trade_id + " 的交易不存在"); } Sale_Detail order = (from sd in db.Sale_Detail where sd.Mall_Order_ID == order_id && sd.Mall_Trade_ID == trade_id select sd).FirstOrDefault<Sale_Detail>(); if (order == null) { throw new KMJXCException("交易号为:" + trade_id + " 的交易不存在"); } Product dbproduct=(from p in db.Product where p.Product_ID==parent_product_id select p).FirstOrDefault<Product>(); if (dbproduct == null) { throw new KMJXCException("进销存产品编号为:" + parent_product_id + " 的产品不存在"); } order.Parent_Product_ID = parent_product_id; order.Product_ID = parent_product_id; if (!string.IsNullOrEmpty(mall_sku_id)) { if (product_id <= 0) { throw new KMJXCException("交易产品有SKU属性,更新库存时必须选择进销存产品对应的销售属性"); } Product childproduct = (from p in db.Product where p.Product_ID == product_id select p).FirstOrDefault<Product>(); if (childproduct == null) { throw new KMJXCException("进销存产品编号为:" + parent_product_id + ", 库存编号为:"+product_id+" 的产品不存在"); } order.Product_ID = product_id; } Leave_Stock leaveStock = (from ls in db.Leave_Stock where ls.Sale_ID == trade_id select ls).FirstOrDefault<Leave_Stock>(); if (leaveStock == null) { leaveStock = new Leave_Stock(); leaveStock.Sale_ID = trade_id; leaveStock.Leave_Date = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now); leaveStock.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now); leaveStock.Shop_ID = trade.Shop_ID; leaveStock.Status = 0; leaveStock.User_ID = this.CurrentUser.ID; db.Leave_Stock.Add(leaveStock); } Leave_Stock_Detail lsDetail = (from lsd in db.Leave_Stock_Detail where lsd.Order_ID == order_id select lsd).FirstOrDefault<Leave_Stock_Detail>(); if (lsDetail != null) { throw new KMJXCException("交易号为:" + trade_id + ",订单号为:" + order_id + " 的出库记录已经存在,不能重复出库"); } int[] csp_ids = (from child in this.DBChildShops select child.Shop_ID).ToArray<int>(); Store_House house = (from store in db.Store_House where store.Default == true && (store.Shop_ID == trade.Shop_ID || store.Shop_ID == this.Main_Shop.Shop_ID || csp_ids.Contains(store.Shop_ID)) select store).FirstOrDefault<Store_House>(); int stockPileProductId = parent_product_id; if (product_id > 0) { stockPileProductId = product_id; } Stock_Pile stockPile = null; lsDetail = new Leave_Stock_Detail(); if (house != null) { stockPile = (from sp in db.Stock_Pile where sp.Product_ID == stockPileProductId && sp.StockHouse_ID == house.StoreHouse_ID && sp.Quantity >= order.Quantity select sp).OrderBy(s=>s.Batch_ID).FirstOrDefault<Stock_Pile>(); } if (stockPile == null) { //get store house when it has the specific product var tmpstockPile = from sp in db.Stock_Pile where sp.Product_ID == stockPileProductId && sp.Quantity >= order.Quantity select sp; if (tmpstockPile.Count() > 0) { stockPile = tmpstockPile.OrderBy(s => s.Batch_ID).ToList<Stock_Pile>()[0]; Store_House tmpHouse = (from h in db.Store_House where h.StoreHouse_ID == stockPile.StockHouse_ID select h).FirstOrDefault<Store_House>(); if (tmpHouse != null) { house = tmpHouse; } } else { //cannot leave stock, no stock pile order.Status1 = (int)SaleDetailStatus.NO_ENOUGH_STOCK; order.SyncResultMessage = "没有足够的库存,不能出库"; } } //no stock cannot leave stock if (stockPile != null) { db.SaveChanges(); order.Status1 = (int)SaleDetailStatus.LEAVED_STOCK; order.SyncResultMessage = "出库仓库:" + house.Title; lsDetail.Leave_Stock_ID = leaveStock.Leave_Stock_ID; lsDetail.Quantity = order.Quantity; lsDetail.Price = order.Price; lsDetail.StoreHouse_ID = house.StoreHouse_ID; lsDetail.Order_ID = order_id; lsDetail.Amount = (double)order.Amount; lsDetail.Parent_Product_ID = parent_product_id; lsDetail.Product_ID = product_id; if (string.IsNullOrEmpty(mall_sku_id)) { lsDetail.Product_ID = parent_product_id; } lsDetail.StoreHouse_ID = stockPile.StockHouse_ID; lsDetail.Batch_ID = stockPile.Batch_ID; //Update stock stockPile.Quantity = stockPile.Quantity - order.Quantity; //Update stock field in Product table Product product = (from pdt in db.Product where pdt.Product_ID == lsDetail.Parent_Product_ID select pdt).FirstOrDefault<Product>(); if (product != null) { product.Quantity = product.Quantity - order.Quantity; } lsDetail.Order_ID = order_id; db.Leave_Stock_Detail.Add(lsDetail); base.CreateActionLog(new BUserActionLog() { Shop = new BShop { ID = leaveStock.Shop_ID }, Action = new BUserAction() { Action_ID = UserLogAction.CREATE_LEAVE_STOCK }, Description = "同步订单时未能成功自动出库更新库存,手动出库并更新库存" }); db.SaveChanges(); } if (mapproduct) { Mall_Product mallProduct=(from mp in db.Mall_Product where mp.Mall_ID==mall_product_id select mp).FirstOrDefault<Mall_Product>(); if (mallProduct != null) { ShopManager shopManager = new ShopManager(this.CurrentUser, this.Shop, this.CurrentUserPermission); if (shopManager.MapMallProduct(mall_product_id, parent_product_id)) { mallProduct.Outer_ID = order.Parent_Product_ID; if (!string.IsNullOrEmpty(mall_sku_id) && product_id>0) { Mall_Product_Sku sku = (from sk in db.Mall_Product_Sku where sk.Mall_ID == mallProduct.Mall_ID && sk.SKU_ID == mall_sku_id select sk).FirstOrDefault<Mall_Product_Sku>(); if (shopManager.MapSku(mall_sku_id, product_id)) { sku.Outer_ID = order.Product_ID; } } } } db.SaveChanges(); } } }