public async Task <string> VerifyForAssemble(string boxNumber, int assembleNumber)
        {
            //根据盒号检查是否存在关联订单
            var orderBox = _orderBoxRepository.GetOrderBox(boxNumber);

            if (orderBox == null)
            {
                return(await Task.FromResult("不存在的盒号,检查盒号是否正确"));
            }

            var orderId = orderBox.OrderId;

            //在组装完成前 判断是否重复扫
            List <string> hasFinishedBoxes = _assembleRepository.GetAssembleFinishedBoxes(orderId);

            if (hasFinishedBoxes.Contains(boxNumber))
            {
                return(await Task.FromResult("此盒已完成,勿重复扫!"));
            }

            var hasDoCount = _assembleRepository.GetAssembleCount(orderId);

            var orderCount = _orderRepository.GetOrderByOrderId(orderId);

            //此时完成的数量 加上数据库已经完成的 不能超过总数量
            if ((hasDoCount + assembleNumber) > orderCount.OnLineQuantity)
            {
                return(await Task.FromResult("完成后的总数量 超过下订单数量,请核实该盒完成数量"));
            }

            return(string.Empty);
        }
Esempio n. 2
0
        public async Task <SubmitResult> OrderAssemble(string boxNumber, byte assembleNumber)
        {
            var verifyResult = await _assembleVerifyService.VerifyForAssemble(boxNumber, assembleNumber);

            if (!string.IsNullOrEmpty(verifyResult))
            {
                return(new SubmitResult()
                {
                    IsSucceed = false, Message = verifyResult
                });
            }

            try
            {
                //添加组装记录
                var orderId = _orderBoxRepository.GetOrderBox(boxNumber).OrderId;

                _assembleRepository.AssembleOneBox(orderId, boxNumber, assembleNumber);

                //更改订单完成组装数量

                _orderRepository.OrderAssembleNumberAdd(orderId, assembleNumber);


                //更新今日完成数量
                _dayFinishedRepository.UpdateAssembleFinished(assembleNumber);


                return(new SubmitResult
                {
                    IsSucceed = _unitOfWork.SaveChanges()
                });
            }
            catch (Exception ex)
            {
                return(new SubmitResult()
                {
                    IsSucceed = false, Message = ex.Message
                });
            }
        }
Esempio n. 3
0
 public int GetOrderIdByOrderBoxNumber(string boxNumber)
 {
     return(_orderBoxRepository.GetOrderBox(boxNumber).OrderBoxId);
 }