/// <summary> /// POS系统减库存(维嘉项目) /// </summary> /// <param name="orderSysNo"></param> /// <param name="orderAmount"></param> /// <param name="db_no">单据标示</param> /// <remarks>2016-05-20 陈海裕 创建</remarks> public void ReducedPOSInventory(int orderSysNo, decimal orderAmount, string db_no = null) { Result result = new Result(); try { SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysNo); IList <SoOrderItem> orderItems = BLL.Order.SoOrderBo.Instance.GetOrderItemsByOrderId(orderSysNo); CBWhWarehouse warehouse = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo); Grand.Platform.Api.Contract.DataContract.LessProductStockRequest request = new Grand.Platform.Api.Contract.DataContract.LessProductStockRequest(); Grand.Platform.Api.Contract.Model.SheetMaster sheetMaster = new Grand.Platform.Api.Contract.Model.SheetMaster(); sheetMaster.trans_no = "00"; sheetMaster.branch_no = warehouse.ErpCode; sheetMaster.oper_date = DateTime.Now; sheetMaster.sheet_amt = orderAmount; sheetMaster.db_no = db_no; IList <Grand.Platform.Api.Contract.Model.SheetDetail> sheetDetailList = new List <Grand.Platform.Api.Contract.Model.SheetDetail>(); Grand.Platform.Api.Contract.Model.SheetDetail sheetDetail = null; foreach (var item in orderItems) { sheetDetail = new Grand.Platform.Api.Contract.Model.SheetDetail(); var tempProduct = BLL.Product.PdProductBo.Instance.GetProduct(item.ProductSysNo); sheetDetail.item_no = tempProduct.ErpCode; sheetDetail.real_qty = item.Quantity; sheetDetail.large_qty = item.Quantity; sheetDetail.valid_price = item.SalesUnitPrice; sheetDetail.sale_price = item.OriginalPrice; sheetDetail.sub_amt = item.SalesAmount; sheetDetailList.Add(sheetDetail); } request.SheetMaster = sheetMaster; request.SheetDetails = sheetDetailList; string json = Util.Serialization.JsonUtil.ToJson2(request); result.Status = this.LessProductStock(request); if (result.Status == false) { var queObj = DataAccess.Extra.IPosServiceDao.Instance.GetEntityByOrderSysNo(orderSysNo); if (queObj == null) { // 扣减库存失败,添加到队列表 ReducedPOSInventoryQueue model = new ReducedPOSInventoryQueue(); model.OrderSysNo = orderSysNo; model.JsonData = json; this.AddToReducedPOSInventoryQueue(model); } BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统减库存失败:ReducedPOSInventory", new Exception()); } } catch (Exception ex) { // 扣减库存失败,添加到队列表 ReducedPOSInventoryQueue model = new ReducedPOSInventoryQueue(); model.OrderSysNo = orderSysNo; model.Remark = ex.ToString(); this.AddToReducedPOSInventoryQueue(model); BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统减库存失败:ReducedPOSInventory", ex); } }
/// <summary> /// 退货入库 /// </summary> /// <param name="model">入库单</param> /// <remarks>2016-10-31 杨浩 创建</remarks> public void ReturnsIntoWarehouse(WhStockIn model) { var result = new Result(); try { var warehouse = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(model.WarehouseSysNo); var request = new Grand.Platform.Api.Contract.DataContract.LessProductStockRequest(); Grand.Platform.Api.Contract.Model.SheetMaster sheetMaster = new Grand.Platform.Api.Contract.Model.SheetMaster(); sheetMaster.trans_no = "00"; sheetMaster.branch_no = warehouse.ErpCode; sheetMaster.oper_date = DateTime.Now; sheetMaster.sheet_amt = 0; sheetMaster.db_no = "+"; IList <Grand.Platform.Api.Contract.Model.SheetDetail> sheetDetailList = new List <Grand.Platform.Api.Contract.Model.SheetDetail>(); Grand.Platform.Api.Contract.Model.SheetDetail sheetDetail = null; foreach (var item in model.ItemList) { sheetDetail = new Grand.Platform.Api.Contract.Model.SheetDetail(); var tempProduct = BLL.Product.PdProductBo.Instance.GetProduct(item.ProductSysNo); sheetDetail.item_no = tempProduct.ErpCode; sheetDetail.real_qty = item.RealStockInQuantity; sheetDetail.large_qty = item.RealStockInQuantity; sheetDetail.valid_price = 0; sheetDetail.sale_price = 0; sheetDetail.sub_amt = 0; sheetDetailList.Add(sheetDetail); } request.SheetMaster = sheetMaster; request.SheetDetails = sheetDetailList; string json = Util.Serialization.JsonUtil.ToJson2(request); result.Status = this.LessProductStock(request); if (result.Status == false) { //var queObj = DataAccess.Extra.IPosServiceDao.Instance.GetEntityByOrderSysNo(orderSysNo); //if (queObj == null) //{ // // 扣减库存失败,添加到队列表 // ReducedPOSInventoryQueue model1 = new ReducedPOSInventoryQueue(); // model.OrderSysNo = orderSysNo; // model.JsonData = json; // this.AddToReducedPOSInventoryQueue(model); //} BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统加库存失败:ReturnsIntoWarehouse", new Exception()); } } catch (Exception ex) { //// 扣减库存失败,添加到队列表 //ReducedPOSInventoryQueue model1 = new ReducedPOSInventoryQueue(); //model.OrderSysNo = orderSysNo; //model.Remark = ex.ToString(); //this.AddToReducedPOSInventoryQueue(model); BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "POS系统加库存失败:ReturnsIntoWarehouse", ex); } }