/// <summary> /// /// </summary> /// <param name="billNo"></param> /// <param name="message"></param> /// <returns></returns> public bool ScanBillNo(string billNo, out string message) { SaleOrderEntity orderEntity = billNo.ToLower().StartsWith("so") ? _orderBll.GetSaleOrder(billNo) : _orderBll.GetSaleOrderByExpressNum(billNo); if (orderEntity == null) { message = string.Format("无效的物流单号或订单号[{0}]", billNo); return(false); } if (string.IsNullOrWhiteSpace(orderEntity.ExpressNum)) { message = string.Format("订单[{0}]没有匹配物流单号不能出库校验", orderEntity.OrderNo); return(false); } if (orderEntity.Status != (int)OrderStatus.WaitOutStock) { message = string.Format("订单[{0}]不是待拣货状态,不能出库校验", orderEntity.OrderNo); return(false); } message = ""; return(true); }
/// <summary> /// /// </summary> /// <param name="shipTypeId"></param> /// <param name="expressNum"></param> /// <param name="createUserId"></param> /// <param name="message"></param> /// <returns></returns> public bool ScanExpressNum(string shipTypeId, string expressNum, string createUserId, out string message) { var handover = _handoverBll.GetUnPrintHandoverByShipType(shipTypeId, createUserId); if (handover == null) { handover = new HandoverEntity(); handover.Create(); handover.HandoverNo = ""; handover.IsPrinted = 0; handover.ShipTypeId = shipTypeId; _handoverBll.Repository().Insert(handover); } SaleOrderEntity orderEntity = _saleOrderBll.GetSaleOrderByExpressNum(expressNum); if (orderEntity == null) { message = string.Format("无效的物流单号[{0}]", expressNum); return(false); } if (orderEntity.Status != (int)OrderStatus.OutStock && orderEntity.Status != (int)OrderStatus.Handover) { message = string.Format("订单[{0}]不是已出库或已交接状态,不能交接扫描", orderEntity.OrderNo); return(false); } if (orderEntity.ShipTypeId != shipTypeId) { message = string.Format("物流单号[{0}]与所选物流方式不一致,不能扫描", orderEntity.ExpressNum); return(false); } if (orderEntity.IsSuspended) { message = string.Format("订单[{0}]已被挂起,不能与配送商交接", orderEntity.OrderNo); return(false); } HandoverItemEntity itemEntity = _handoverBll.GetHandOverItem(expressNum); IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { var picks = _pickItemBll.GetPickItemListByOrderNo(orderEntity.OrderNo); message = string.Empty; if (itemEntity == null) { HandoverItemEntity handoverItemEntity = new HandoverItemEntity(); handoverItemEntity.Create(); handoverItemEntity.HandoverId = handover.HandoverId; handoverItemEntity.ExpressNum = expressNum; handoverItemEntity.OrderNo = orderEntity.OrderNo; handoverItemEntity.ScanedTime = DateTime.Now; _handoverItemBll.Repository().Insert(handoverItemEntity, isOpenTrans); orderEntity.Status = (int)OrderStatus.Handover; bool flag = _saleOrderBll.UpdateStatus(orderEntity, OrderStatus.OutStock, isOpenTrans); if (!flag) { throw new Exception("修改订单状态出现异常,请重新操作"); } //foreach (var item in picks) //{ // bool moveIn = _inventoryLocationBLL.UpdateInventoryByMoveIn(orderEntity.WarehouseId, item.ProductId, item.ToLocationCode, item.Qty, isOpenTrans); // if (!moveIn) // { // throw new Exception("更新目的储位库存失败"); // } //} } else { if (itemEntity.HandoverId == handover.HandoverId) { if (_handoverBll.CancelItem(handover.HandoverId, itemEntity.ExpressNum)) { orderEntity.Status = (int)OrderStatus.OutStock; bool flag = _saleOrderBll.UpdateStatus(orderEntity, OrderStatus.Handover, isOpenTrans); if (!flag) { throw new Exception("修改订单状态出现异常,请重新操作"); } message = string.Format("物流单号[{0}]已取消扫描", orderEntity.ExpressNum); } else { throw new Exception(string.Format("物流单号[{0}]取消扫描失败", orderEntity.ExpressNum)); } } else { throw new Exception(string.Format("物流单号[{0}]已扫入其他交接单", orderEntity.ExpressNum)); } //foreach (var item in picks) //{ // bool moveIn = _inventoryLocationBLL.UpdateInventoryByMoveIn(orderEntity.WarehouseId, item.ProductId, item.ToLocationCode, -1 * item.Qty, isOpenTrans); // if (!moveIn) // { // throw new Exception("更新目的储位库存失败"); // } //} } database.Commit(); return(true); } catch (Exception ex) { database.Rollback(); message = string.Format("订单交接扫描异常:{0}", ex.Message); return(false); } }