Exemple #1
0
        public bool InsertASYN_GoodsDaySalesStatisticsInfo(ASYN_GoodsDaySalesStatisticsInfo asynGoodsDaySalesStatisticsInfo)
        {
            try
            {
                const string sql = @"INSERT INTO [dbo].[ASYN_GoodsDaySalesStatistics]
                                                   ([ID]
                                                   ,[OrderNo]
                                                   ,[OrderJsonStr]
                                                   ,[OrderDetailJsonStr]
                                                   ,[OldOrderDetailJsonStr]
                                                   ,[HandlingStatus]
                                                   ,[CreateDate]
                                                   ,[IsExecuted])
                                                    VALUES (NEWID(),@OrderNo,@OrderJsonStr,@OrderDetailJsonStr,@OldOrderDetailJsonStr,@HandlingStatus,GETDATE(),0)";

                using (SqlConnection conn = Databases.GetSqlConnection(GlobalConfig.ERP_DB_NAME, false))
                {
                    return(conn.Execute(sql, new
                    {
                        OrderNo = asynGoodsDaySalesStatisticsInfo.OrderNo,
                        OrderJsonStr = asynGoodsDaySalesStatisticsInfo.OrderJsonStr,
                        OrderDetailJsonStr = asynGoodsDaySalesStatisticsInfo.OrderDetailJsonStr,
                        OldOrderDetailJsonStr = asynGoodsDaySalesStatisticsInfo.OldOrderDetailJsonStr,
                        HandlingStatus = asynGoodsDaySalesStatisticsInfo.HandlingStatus,
                    }) > 0);
                }
            }
            catch (Exception ex)
            {
                SAL.LogCenter.LogService.LogError("Error", "InsertASYN_GoodsDaySalesStatisticsInfo.Error", ex);
                return(false);
            }
        }
        static void JsonDeserialize(ASYN_GoodsDaySalesStatisticsInfo asynGoodsDaySalesStatisticsInfo, out GoodsOrderInfo orderInfo, out List <GoodsOrderDetailInfo> orderDetail, out List <GoodsOrderDetailInfo> oldOrderDetails)
        {
            var serrializer = new JsonSerializer();

            orderInfo       = serrializer.Deserialize <GoodsOrderInfo>(asynGoodsDaySalesStatisticsInfo.OrderJsonStr);
            orderDetail     = serrializer.Deserialize <List <GoodsOrderDetailInfo> >(asynGoodsDaySalesStatisticsInfo.OrderDetailJsonStr);
            oldOrderDetails = serrializer.Deserialize <List <GoodsOrderDetailInfo> >(asynGoodsDaySalesStatisticsInfo.OldOrderDetailJsonStr);
        }
Exemple #3
0
 /// <summary>
 /// WMS系统上线后,作废订单销量没有扣除
 /// </summary>
 public static void RunHistoryGoodsDaySalesStatisticsForZuoFeiTask()
 {
     try
     {
         var flag      = false;
         var startTime = Configuration.AppSettings["StartTime"];
         var pageSize  = Configuration.AppSettings["PageSize"];
         while (true)
         {
             if (DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) > DateTime.Parse(startTime))
             {
                 int i = 1;
                 while (DateTime.Now <= DateTime.Now.AddHours(7))
                 {
                     flag = true;
                     var goodsOrderInfoList = _goodsOrder.GetGoodsOrderInfoListForHistory(i, int.Parse(pageSize));
                     if (goodsOrderInfoList.Count == 0)
                     {
                         break;
                     }
                     foreach (var item in goodsOrderInfoList)
                     {
                         var  goodsOrderDetailInfoList        = _goodsOrderDetail.GetGoodsOrderDetailList(item.OrderId);
                         var  orderJsonStr                    = Serialization.JsonSerialize(item);
                         var  orderDetailJsonStr              = Serialization.JsonSerialize(goodsOrderDetailInfoList);
                         var  asynGoodsDaySalesStatisticsInfo = ASYN_GoodsDaySalesStatisticsInfo.DeleteGoodsDaySale(item.OrderNo, orderJsonStr, orderDetailJsonStr);
                         bool result = _goodsOrderDetail.InsertASYN_GoodsDaySalesStatisticsInfo(asynGoodsDaySalesStatisticsInfo);
                         if (result)
                         {
                             _goodsOrder.UpdateOrderIdTable(item.OrderId);
                         }
                     }
                     i++;
                 }
             }
             else if (flag)
             {
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         ERP.SAL.LogCenter.LogService.LogError("处理WMS上线之后作废订单的销量(历史数据)", "RunHistoryGoodsDaySalesStatisticsForZuoFeiTask.Error", ex);
     }
 }
Exemple #4
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);
            }
        }