public BSyncTime GetLastSyncTime() { BSyncTime time = new BSyncTime(); 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; SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); time = saleManager.GetSyncTime(); return time; }
// // 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); }
public ActionResult Sync() { string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; SalesManager shopManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); ViewData["ChildShop"] = shopManager.ChildShops; ViewData["CurrentShop"] = shopManager.Shop; return View(); }
public ApiMessage HandleBackSaleDetail() { 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; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); string backSales = request["back_sales"]; int status=0; int.TryParse(request["status"],out status); if (string.IsNullOrEmpty(backSales)) { message.Status = "failed"; message.Message = "没有任何退货信息"; return message; } backSales = HttpUtility.UrlDecode(backSales); try { JArray jsons = JArray.Parse(backSales); if (jsons != null && jsons.Count > 0) { for (int i = 0; i < jsons.Count; i++) { JObject json = (JObject)jsons[i]; int back_Sale_ID = (int)json["back_sale_id"]; JArray orders=(JArray)json["orders"]; List<BOrder> bOrders = new List<BOrder>(); for(int j = 0; j < orders.Count; j++) { JObject o=(JObject)orders[j]; string order_id=(string)o["order_id"]; int quantity = (int)o["quantity"]; bOrders.Add(new BOrder() { Order_ID=order_id,Quantity=quantity}); } switch (status) { case 1: saleManager.HandleBackSaleDetail_BackStock(back_Sale_ID, bOrders, status); break; case 2: saleManager.HandleBackSaleDetail_PartialWaste(back_Sale_ID, bOrders, status); break; case 3: saleManager.HandleWastageBackSale_TotalWaste(back_Sale_ID, bOrders, status); break; default: break; } } } message.Status = "ok"; } catch (KM.JXC.Common.KMException.KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = ex.Message; } finally { } return message; }
public ApiMessage SyncMallTrades() { 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; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int start = 0; int end = 0; int syncType = 0; int shop = 0; string status = request["status"]; int.TryParse(request["start"],out start); int.TryParse(request["end"], out end); int.TryParse(request["syncType"],out syncType); int.TryParse(request["shop"], out shop); try { saleManager.SyncMallTrades(start, end, status, syncType, shop); message.Status = "ok"; } catch (KMJXCMallException mex) { message.Status = "failed"; message.Message = mex.Message; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return message; }
public PQGridData SearchTradeSyncLog() { 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; SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int page = 1; int.TryParse(request["page"],out page); if (page == 0) { page = 1; } int pageSize = 20; int.TryParse(request["pageSize"],out pageSize); if (pageSize == 0) { pageSize = 20; } int total = 0; data.data = saleManager.SearchTradeSyncLog(0, 0, 0, null, page, pageSize, out total); data.totalRecords = total; data.curPage = page; return data; }
public PQGridData SearchSales() { 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; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int page = 1; int pageSize = 30; long stime = 0; long etime = 0; if (!string.IsNullOrEmpty(request["sdate"])) { DateTime sdate = DateTime.MinValue; DateTime.TryParse(request["sdate"], out sdate); if (sdate != DateTime.MinValue) { stime = DateTimeUtil.ConvertDateTimeToInt(sdate); } } if (!string.IsNullOrEmpty(request["edate"])) { DateTime edate = DateTime.MinValue; DateTime.TryParse(request["edate"], out edate); if (edate != DateTime.MinValue) { etime = DateTimeUtil.ConvertDateTimeToInt(edate); } } int.TryParse(request["page"], out page); int.TryParse(request["pageSize"], out pageSize); int total = 0; data.data = saleManager.SearchSales(null,null,null,null, null,null, stime, etime, page, pageSize, out total); data.totalRecords = total; return data; }
public PQGridData SearchBackSaleDetails() { 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; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); SalesManager saleManager = new SalesManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int page = 1; int pageSize = 30; int sale_id = 0; int back_id = 0; int uid = 0; long stime = 0; long etime = 0; int? status = null; int status1 = 0; string state=request["status"]; if (!string.IsNullOrEmpty(state)) { int.TryParse(state, out status1); status = status1; } if (!string.IsNullOrEmpty(request["sdate"])) { DateTime sdate = DateTime.MinValue; DateTime.TryParse(request["sdate"], out sdate); if (sdate != DateTime.MinValue) { stime = DateTimeUtil.ConvertDateTimeToInt(sdate); } } if (!string.IsNullOrEmpty(request["edate"])) { DateTime edate = DateTime.MinValue; DateTime.TryParse(request["edate"], out edate); if (edate != DateTime.MinValue) { etime = DateTimeUtil.ConvertDateTimeToInt(edate); } } int.TryParse(request["page"], out page); int.TryParse(request["pageSize"], out pageSize); int.TryParse(request["sale_id"], out sale_id); int.TryParse(request["back_id"], out back_id); int.TryParse(request["user_id"], out uid); int total = 0; int[] backids = null; if (back_id > 0) { backids = new int[] { back_id }; } int[] userids = null; if (uid > 0) { userids = new int[] { uid }; } string[] saleids = null; if (sale_id > 0) { saleids = new string[] { sale_id.ToString() }; } data.data = saleManager.SearchBackSaleDetails(saleids, userids,status, stime, etime, page, pageSize, out total); data.curPage = page; data.totalRecords = total; return data; }