Esempio n. 1
0
        /// <summary> 加入到待完成订单列表里(适合批量完成订单操作)
        /// </summary>
        /// <param name="orderNos"></param>
        /// <param name="errorMessage"></param>
        /// <param name="operatorId"></param>
        /// <param name="operatorName"></param>
        public bool JoinWaitConsignmentOrder(Guid operatorId, string operatorName, List <String> orderNos, out string errorMessage)
        {
            errorMessage = string.Empty;
            var orders = new List <GoodsOrderInfo>();

            foreach (var orderNo in orderNos)
            {
                var orderInfo = _goodsOrderDal.GetGoodsOrder(orderNo);
                if (orderInfo == null)
                {
                    errorMessage = ("无法完成操作,没找到订单信息!订单号:" + orderNo);

                    ERP.SAL.LogCenter.LogService.LogWarn(string.Format("订单未找到{0}", orderNo), "JoinWaitConsignmentOrder");
                    continue;
                }
                orders.Add(orderInfo);
            }
            if (orders.Count == 0)
            {
                return(true);
            }
            using (var tran = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    foreach (var order in orders)
                    {
                        var isSuccess = _goodsOrderDal.SetGoodsOrderToConsignmented(order.OrderNo);
                        if (!isSuccess)
                        {
                            errorMessage = "更新订单状态到完成失败!";
                            return(false);
                        }

                        var successInsertWait = _goodsOrderDal.InsertWaitConsignmentOrder(order.OrderId, (Int32)OrderState.Consignmented, "系统自动");
                        if (!successInsertWait)
                        {
                            errorMessage = "插入异步完成订单表数据失败!";
                            return(false);
                        }
                    }
                    tran.Complete();
                    return(true);
                }
                catch (Exception exp)
                {
                    errorMessage = "发生异常操作,异常消息:" + exp.Message + "\r\n" + exp.StackTrace;
                    throw exp;
                }
            }
        }
Esempio n. 2
0
        /// <summary>执行异步添加往来账
        /// </summary>
        /// <param name="readCount"></param>
        public void RunAsynAddTask(int readCount)
        {
            var asynList = _reckoningDao.GetAsynList(readCount);

            foreach (var asynInfo in asynList)
            {
                if (asynInfo.ReckoningFromType == Enum.ASYN.ASYNReckoningFromType.CompleteOrder.ToString())
                {
                    using (var tran = new System.Transactions.TransactionScope())
                    {
                        var orderInfo = _goodsOrder.GetGoodsOrder(asynInfo.IdentifyId);
                        if (orderInfo == null)
                        {
                            continue;
                        }
                        var    orderDetailList = _goodsOrderDetail.GetGoodsOrderDetailByOrderId(asynInfo.IdentifyId);
                        string errorMessage;
                        var    success = AddByCompleteOrder(orderInfo, orderDetailList, out errorMessage);
                        if (!success)
                        {
                            SAL.LogCenter.LogService.LogError(string.Format("异步添加往来帐失败! IdentifyId={0} {1}", asynInfo.IdentifyId, errorMessage), "往来账管理");
                            continue;
                        }
                        var successDel = _reckoningDao.DeleteAsyn(asynInfo.ID);
                        if (!successDel)
                        {
                            SAL.LogCenter.LogService.LogError(string.Format("删除异步往来帐数据失败! ID={0}", asynInfo.ID), "往来账管理");
                            continue;
                        }
                        tran.Complete();
                    }
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["OrderId"]))
            {
                OrderId = new Guid(Request.QueryString["OrderId"]);
            }
            GoodsOrderInfo goodsOrderInfo = _goodsOrder.GetGoodsOrder(OrderId);

            goodsOrderInfo.ExpressNo = goodsOrderInfo.ExpressNo;  //TODO WMS 老业务有展示物流信息。
            NonceGoodsOrderInfo      = goodsOrderInfo;
        }
        public FrameProcessCertificateInfo GetCertificateInfo(string processNo)
        {
            var info        = new FrameProcessCertificateInfo();
            var processInfo = _wmsSao.GetProcessOrder(processNo);

            if (processInfo != null)
            {
                var orderInfo = _goodsOrderWrite.GetGoodsOrder(processInfo.OrderNos.First());
                info.Optician      = processInfo.Processor;
                info.OperationTime = processInfo.ProcessDate;
                info.Consignee     = processInfo.Name;
                info.OrderId       = (orderInfo != null && orderInfo.OrderId != default(Guid)) ? orderInfo.OrderId : Guid.Empty;
                info.ProcessNo     = processInfo.ProcessNo;
                info.SaleFilialeID = processInfo.HostingFilialeId;
                var skuList = processInfo.SkuList;

                #region [右眼SKU处理]
                var rightBuilder = new StringBuilder();
                var rightInfo    = skuList.FirstOrDefault(ent => ent.Contains(RIGHT) || ent.Contains(RIGHT2));
                if (rightInfo != null)
                {
                    string[] spfArray = rightInfo.Split(' ');
                    rightBuilder.Append("右眼:").Append(spfArray[1].Substring(spfArray[1].IndexOf(':') + 1).Replace("无", "-"));
                    if (spfArray.Length >= 3)
                    {
                        rightBuilder.Append(" ");
                        rightBuilder.Append(spfArray[2].Replace("无", "-"));
                    }
                    if (spfArray.Length >= 4)
                    {
                        rightBuilder.Append(" ");
                        rightBuilder.Append(spfArray[3].Replace("无", "-"));
                    }
                    if (spfArray.Length >= 5)
                    {
                        if (string.IsNullOrEmpty(info.PD))
                        {
                            info.PD = spfArray[4].Trim();
                        }
                    }
                }
                info.RightEyeInfo = rightBuilder.ToString();
                #endregion

                #region [左眼SKU处理]
                var leftBuilder = new StringBuilder();
                var leftInfo    = skuList.FirstOrDefault(ent => ent.Contains(LEFT) || ent.Contains(LEFT2));
                if (leftInfo != null)
                {
                    var lspfArray = leftInfo.Split(' ');
                    leftBuilder.Append("左眼:").Append(lspfArray[1].Substring(lspfArray[1].IndexOf(':') + 1).Replace("无", "-"));
                    if (lspfArray.Length >= 3)
                    {
                        leftBuilder.Append(" ");
                        leftBuilder.Append(lspfArray[2].Replace("无", "-"));
                    }
                    if (lspfArray.Length >= 4)
                    {
                        leftBuilder.Append(" ");
                        leftBuilder.Append(lspfArray[3].Replace("无", "-"));
                    }
                }
                info.LeftEyeInfo = leftBuilder.ToString();
                #endregion
            }
            return(info);
        }
Esempio n. 5
0
        public static void RunWaitConsignmentOrderTask()
        {
            try
            {
                lock (_lockObj)
                {
                    if (_isRunningCompleteOrder)
                    {
                        return;
                    }
                }

                //验证时间
                var hour = DateTime.Now.Hour;
                if (!GlobalConfig.SecondConsignmentOrderHour.Contains(hour.ToString()))
                {
                    return;
                }

                //开始继续完成订单数据
                var waitConsignmentOrderList = _goodsOrder.GetWaitConsignmentOrder(GlobalConfig.ReadWaitConsignmentOrder);
                if (waitConsignmentOrderList.Count > 0)
                {
                    LogMessage("读取数据:" + waitConsignmentOrderList.Count);
                }
                lock (_lockObj)
                {
                    _isRunningCompleteOrder = true;
                }
                foreach (var waitInfo in waitConsignmentOrderList)
                {
                    GoodsOrderInfo orderInfo = null;
                    try
                    {
                        orderInfo = _goodsOrder.GetGoodsOrder(waitInfo.OrderId);
                        string errorMessage;
                        var    success = _orderManager.FinishConsignmentOrder(orderInfo, waitInfo.Operator, out errorMessage);
                        if (!success)
                        {
                            LogMessage("订单号:" + orderInfo.OrderNo + ",完成失败! 》》 " + errorMessage);
                        }
                    }
                    catch (Exception exp)
                    {
                        if (orderInfo != null)
                        {
                            LogMessage("订单号:" + orderInfo.OrderNo + ",完成失败! 》》 " + exp.Message, exp);
                        }
                        else
                        {
                            LogMessage("获取订单失败:" + waitInfo.OrderId + " ! 》》 " + exp.Message, exp);
                        }
                    }
                }
                lock (_lockObj)
                {
                    _isRunningCompleteOrder = false;
                }
            }
            catch (Exception exp)
            {
                LogMessage("发生错误异常" + exp.Message);
            }
        }
Esempio n. 6
0
        /// <summary>订单导入
        /// </summary>
        public bool AddOrderAndInvoice(GoodsOrderInfo goodsOrder, IList <GoodsOrderDetailInfo> goodsOrderDetailList, InvoiceInfo invoiceInfo, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (goodsOrderDetailList.Count == 0)
            {
                errorMessage = "订单明细没有数据!";
                return(false);
            }
            Boolean isEdit = false;

            #region 验证B2C订单信息  (订单目前是走推送服务)
            var filialeList = FilialeManager.GetB2CFilialeList();
            if (filialeList.Any(act => act.ID == goodsOrder.SaleFilialeId))
            {
                try
                {
                    var info = OrderSao.GetGoodsOrderInfo(goodsOrder.SaleFilialeId, goodsOrder.OrderId);
                    if (info == null)
                    {
                        errorMessage = "获取B2C订单信息不存在";
                        return(false);
                    }
                    if (info.OrderState == (int)OrderState.Cancellation)
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    errorMessage = "获取B2C订单信息异常" + ex.Message;
                    throw ex;
                }
            }
            #endregion

            var localGoodsOrderInfo = _goodsOrderDao.GetGoodsOrder(goodsOrder.OrderId);
            goodsOrder.HostingFilialeId = WMSSao.GetHostingFilialeIdByWarehouseIdGoodsTypes(goodsOrder.DeliverWarehouseId, goodsOrder.SaleFilialeId, goodsOrderDetailList.Select(ent => ent.GoodsType).Distinct());
            IList <GoodsOrderDetailInfo> localGoodsOrderDetails = new List <GoodsOrderDetailInfo>();
            if (localGoodsOrderInfo != null && localGoodsOrderInfo.OrderId != Guid.Empty)
            {
                isEdit = true;
                if (localGoodsOrderInfo.OrderState == (int)OrderState.Cancellation)
                {
                    return(true);
                }
                localGoodsOrderDetails = _goodsOrderDetailDao.GetGoodsOrderDetailList(goodsOrder.OrderId);
            }

            using (var ts = new TransactionScope(TransactionScopeOption.Required))
            {
                //1.订单导入,先删后插
                if (isEdit)
                {
                    var success = _goodsOrderDao.Delete(goodsOrder.OrderId);
                    if (!success)
                    {
                        errorMessage = "删除订单失败";
                        return(false);
                    }
                }

                //2.插入订单和订单明细
                var insertSuccess = _goodsOrderDao.Insert(goodsOrder, out errorMessage);
                if (!insertSuccess)
                {
                    errorMessage = string.Format("添加订单信息失败:{0}", errorMessage);
                    return(false);
                }
                var insertDetailSuccess = _goodsOrderDetailDao.Insert(goodsOrderDetailList, goodsOrder, out errorMessage);
                if (!insertDetailSuccess)
                {
                    errorMessage = string.Format("添加订单商品明细失败:{0}", errorMessage);
                    return(false);
                }

                //3.记录销量
                //异步销量
                if (goodsOrder.OrderState == (int)OrderState.WaitOutbound || goodsOrder.OrderState == (int)OrderState.StockUp || goodsOrder.OrderState == (int)OrderState.RequirePurchase || goodsOrder.OrderState == (int)OrderState.Redeploy)
                {
                    var orderJsonStr       = new Framework.Core.Serialize.JsonSerializer().Serialize(goodsOrder);
                    var orderDetailJsonStr = new Framework.Core.Serialize.JsonSerializer().Serialize(goodsOrderDetailList);
                    var asynGoodsDaySalesStatisticsInfo = isEdit ?
                                                          ASYN_GoodsDaySalesStatisticsInfo.EditGoodsDaySale(goodsOrder.OrderNo, orderJsonStr, orderDetailJsonStr, new Framework.Core.Serialize.JsonSerializer().Serialize(localGoodsOrderDetails)) :
                                                          ASYN_GoodsDaySalesStatisticsInfo.AddGoodsDaySale(goodsOrder.OrderNo, orderJsonStr, orderDetailJsonStr);
                    var asynResult = _goodsOrderDetailDao.InsertASYN_GoodsDaySalesStatisticsInfo(asynGoodsDaySalesStatisticsInfo);
                    if (!asynResult)
                    {
                        errorMessage = "销量记录到异步失败!";
                        return(false);
                    }
                }

                //4.发票插入
                if (invoiceInfo != null && invoiceInfo.InvoiceId != Guid.Empty)
                {
                    invoiceInfo.DeliverWarehouseId = goodsOrder.DeliverWarehouseId;
                    var insertInvoiceSuccess = _invoiceDao.Insert(invoiceInfo, new Dictionary <Guid, string> {
                        { goodsOrder.OrderId, goodsOrder.OrderNo }
                    });
                    if (!insertInvoiceSuccess)
                    {
                        errorMessage = "插入发票失败";
                        return(false);
                    }
                }
                //5.配货中,会员中心交互
                MemberCenterSao.OrderAllocateGoods(goodsOrder.SalePlatformId, goodsOrder.OrderId);
                //提交事务
                ts.Complete();
                return(true);
            }
        }