public ActionResult Print()
        {
            string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();

            entity.OrderNum = orderNum;
            entity          = bill.GetOrder(entity);
            entity          = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity  = entity;

            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.OrderNum = orderNum;
            List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);

            listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult;
            OrderProvider orderProvider = new OrderProvider();

            foreach (OutStoDetailEntity item in listResult)
            {
                OrderDetailEntity orderDetail = new OrderDetailEntity();
                orderDetail.Where(a => a.SnNum == item.ContractSn).And(a => a.OrderNum == item.ContractOrder);
                orderDetail = orderProvider.GetOrderDetail(orderDetail);
                if (orderDetail != null)
                {
                    item.Qty = orderDetail.Num;
                }
            }
            ViewBag.Detail = listResult;
            return(View());
        }
Exemple #2
0
        /// <summary>
        /// 修改出库单的数量
        /// </summary>
        /// <param name="snNum"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public int EditInOrderNum(string snNum, double num)
        {
            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail = new OutStoDetailEntity();
            detail.Include(a => new { a.OrderNum, a.Num, a.OutPrice, a.Amount });
            detail.Where(a => a.SnNum == snNum);
            detail = this.OutStoDetail.GetSingle(detail);

            int line = 0;

            if (detail != null)
            {
                string             orderNum   = detail.OrderNum;
                OutStoDetailEntity editDetail = new OutStoDetailEntity();
                editDetail.Num    = num;
                editDetail.Amount = editDetail.Num * editDetail.OutPrice;
                editDetail.IncludeNum(true).IncludeAmount(true);
                editDetail.Where(a => a.SnNum == snNum);
                line = this.OutStoDetail.Update(editDetail);

                OutStoDetailEntity orderDetail = new OutStoDetailEntity();
                orderDetail.Include(a => new { a.Num, a.Amount });
                orderDetail.Where(a => a.OrderNum == orderNum);
                List <OutStoDetailEntity> list = this.OutStoDetail.GetList(orderDetail);

                OutStorageEntity entity = new OutStorageEntity();
                entity.Num    = list.Sum(a => a.Num);
                entity.Amount = list.Sum(a => a.Amount);
                entity.IncludeNum(true).IncludeAmount(true);
                entity.Where(a => a.OrderNum == orderNum);
                line += this.OutStorage.Update(entity);
            }
            return(line);
        }
Exemple #3
0
        /// <summary>
        /// 查询出库单详细分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDetailList()
        {
            string CompanyID   = WebUtil.GetFormValue <string>("CompanyID");
            string OrderNum    = WebUtil.GetFormValue <string>("OrderNum");
            string BarCode     = WebUtil.GetFormValue <string>("BarCode");
            string ProductName = WebUtil.GetFormValue <string>("ProductName");
            string StorageNum  = WebUtil.GetFormValue <string>("StorageNum");
            string CusNum      = WebUtil.GetFormValue <string>("CusNum");
            string CusName     = WebUtil.GetFormValue <string>("CusName");
            string BeginTime   = WebUtil.GetFormValue <string>("BeginTime");
            string EndTime     = WebUtil.GetFormValue <string>("EndTime");
            int    Status      = WebUtil.GetFormValue <int>("Status", 0);
            int    OutType     = WebUtil.GetFormValue <int>("OutType", 0);
            string CarrierNum  = WebUtil.GetFormValue <string>("CarrierNum");
            string CarrierName = WebUtil.GetFormValue <string>("CarrierName");
            string LogisticsNo = WebUtil.GetFormValue <string>("LogisticsNo");

            int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);

            OutStoDetailEntity entity = new OutStoDetailEntity();

            entity.CompanyID   = CompanyID;
            entity.BarCode     = BarCode;
            entity.ProductName = ProductName;
            entity.StorageNum  = StorageNum;
            entity.CusNum      = CusNum;
            entity.CusName     = CusName;
            entity.BeginTime   = BeginTime;
            entity.EndTime     = EndTime;
            entity.Status      = Status;
            entity.OutType     = OutType;
            entity.OrderNum    = OrderNum;
            entity.CarrierNum  = CarrierNum;
            entity.CarrierName = CarrierName;
            entity.LogisticsNo = LogisticsNo;


            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = PageIndex, PageSize = PageSize
            };
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(CompanyID);
            List <OutStoDetailEntity>           listResult   = bill.GetDetailList(entity, ref pageInfo);
            DataListResult <OutStoDetailEntity> dataResult   = new DataListResult <OutStoDetailEntity>()
            {
                Code     = (int)EResponseCode.Success,
                Message  = "响应成功",
                Result   = listResult,
                PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
        public ActionResult AddProduct([ModelBinder(typeof(JsonBinder <List <LocalProductEntity> >))] List <LocalProductEntity> list)
        {
            List <OutStoDetailEntity> ListCache = Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] as List <OutStoDetailEntity>;

            ListCache = ListCache.IsNull() ? new List <OutStoDetailEntity>() : ListCache;
            if (!list.IsNullOrEmpty())
            {
                List <ProductEntity> ListSource = new ProductProvider().GetListByCache();
                foreach (LocalProductEntity item in list)
                {
                    ProductEntity product = ListSource.FirstOrDefault(a => a.SnNum == item.ProductNum);
                    if (product.IsNotNull())
                    {
                        if (!ListCache.Exists(a => a.ProductNum == item.ProductNum && a.BatchNum == item.BatchNum && a.LocalNum == item.LocalNum))
                        {
                            OutStoDetailEntity entity = new OutStoDetailEntity();
                            entity.SnNum       = SequenceProvider.GetSequence(typeof(OutStoDetailEntity));
                            entity.ProductName = product.ProductName;
                            entity.BarCode     = product.BarCode;
                            entity.BatchNum    = item.BatchNum;
                            entity.ProductNum  = product.SnNum;
                            entity.LocalNum    = item.LocalNum;
                            entity.LocalName   = item.LocalName;
                            entity.Color       = item.Color;
                            entity.Count       = item.Count;
                            entity.StorageNum  = this.DefaultStore;
                            entity.Num         = item.Num;
                            entity.IsPick      = (int)EBool.No;
                            entity.Size        = item.Size;
                            entity.RealNum     = 0;
                            entity.OutPrice    = product.InPrice;
                            entity.Amount      = product.InPrice * entity.Num;
                            entity.CreateTime  = DateTime.Now;
                            ListCache.Add(entity);
                        }
                        else
                        {
                            OutStoDetailEntity entity = ListCache.First(a => a.ProductNum == item.ProductNum && a.BatchNum == item.BatchNum && a.LocalNum == item.LocalNum);
                            entity.Num       += item.Num;
                            entity.OutPrice   = product.InPrice;
                            entity.Amount     = product.InPrice * entity.Num;
                            entity.CreateTime = DateTime.Now;
                        }
                    }
                }
            }
            if (!ListCache.IsNullOrEmpty())
            {
                Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = ListCache;
            }
            return(Content(string.Empty));
        }
        public ActionResult Load()
        {
            string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty);

            if (!OrderNum.IsEmpty())
            {
                ReturnProvider    provider   = new ReturnProvider();
                ReturnOrderEntity backEntity = provider.CheckOrder(OrderNum);
                if (backEntity != null && backEntity.Status == (int)EAudite.Wait)
                {
                    this.ReturnJson.AddProperty("d", "1001");
                    return(Content(this.ReturnJson.ToString()));
                }
                Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
                OutStorageEntity entity = new OutStorageEntity();
                entity.OrderNum = OrderNum;
                entity          = bill.GetOrder(entity);
                if (entity.IsNotNull())
                {
                    if (entity.Status != (int)EAudite.Pass)
                    {
                        this.ReturnJson.AddProperty("d", "1002");
                        return(Content(this.ReturnJson.ToString()));
                    }
                    this.ReturnJson.AddProperty("CusNum", entity.CusNum);
                    this.ReturnJson.AddProperty("CusName", entity.CusName);
                    this.ReturnJson.AddProperty("Address", entity.Address);
                    this.ReturnJson.AddProperty("Contact", entity.Contact);
                    this.ReturnJson.AddProperty("Phone", entity.Phone);
                    //加载详细内容
                    OutStoDetailEntity detail = new OutStoDetailEntity();
                    detail.OrderNum = OrderNum;
                    List <OutStoDetailEntity> list = bill.GetOrderDetail(detail);
                    list = list.IsNull() ? new List <OutStoDetailEntity>() : list;
                    //获得已经退货的数量
                    List <ReturnDetailEntity> listResult = provider.GetDetailByOrder(OrderNum);
                    if (!listResult.IsNullOrEmpty())
                    {
                        list.ForEach(a =>
                        {
                            double qty = listResult.Where(b => b.BarCode == a.BarCode && b.ProductNum == a.ProductNum && b.LocalNum == a.LocalNum && b.StorageNum == a.StorageNum && b.BatchNum == a.BatchNum).Sum(b => b.BackNum);
                            a.BackNum  = qty;
                        });
                    }
                    Session[CacheKey.TEMPDATE_CACHE_RETURNPRODUCTDETAIL] = list;
                    string json = ConvertJson.ListToJson <OutStoDetailEntity>(list, "List");
                    this.ReturnJson.AddProperty("data", json);
                }
            }
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult Detail()
        {
            string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty);
            string flag     = WebUtil.GetQueryStringValue <string>("flag", string.Empty);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();

            entity.OrderNum = orderNum;
            entity          = bill.GetOrder(entity);
            entity          = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity  = entity;
            ViewBag.OutType = EnumHelper.GetEnumDesc <EOutType>(entity.OutType);
            ViewBag.Status  = EnumHelper.GetEnumDesc <EAudite>(entity.Status);


            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.OrderNum = orderNum;
            List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);

            listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult;

            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();

            list = list.IsNull() ? new List <ProductEntity>() : list;
            listResult.ForEach(a =>
            {
                ProductEntity product = null;
                if (a.BarCode.IsEmpty())
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum);
                }
                else
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum && b.BarCode == a.BarCode);
                }
                if (product.IsNotNull())
                {
                    a.Size = product.Size.IsEmpty() ? "" : product.Size;
                }
                else
                {
                    a.Size = "";
                }
            });
            ViewBag.Detail = listResult;
            ViewBag.Flag   = flag;
            return(View());
        }
        public ActionResult Edit()
        {
            //退货单号
            string OrderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty);

            if (!OrderNum.IsEmpty())
            {
                //退货单部分
                Bill <ReturnOrderEntity, ReturnDetailEntity> bill = new ReturnOrder();
                ReturnOrderEntity entity = new ReturnOrderEntity();
                entity.OrderNum = OrderNum;
                entity          = bill.GetOrder(entity);
                if (entity.Status != (int)EAudite.Wait)
                {
                    this.ReturnJson.AddProperty("d", "1001");
                    return(Content(this.ReturnJson.ToString()));
                }
                ReturnDetailEntity detail = new ReturnDetailEntity();
                detail.OrderNum = OrderNum;
                List <ReturnDetailEntity> listDetails = bill.GetOrderDetail(detail);
                //出货单部分
                Bill <OutStorageEntity, OutStoDetailEntity> provider = new OutStorageOrder();
                OutStoDetailEntity items = new OutStoDetailEntity();
                items.OrderNum = entity.ContractOrder;
                List <OutStoDetailEntity> list = provider.GetOrderDetail(items);

                //已经退货部分
                ReturnProvider            returnProvider = new ReturnProvider();
                List <ReturnDetailEntity> listResult     = returnProvider.GetDetailByOrder(entity.ContractOrder);

                if (!list.IsNullOrEmpty())
                {
                    list.ForEach(a =>
                    {
                        ReturnDetailEntity item = listDetails.FirstOrDefault(b => b.BarCode == a.BarCode && b.ProductNum == a.ProductNum && b.LocalNum == a.LocalNum && b.StorageNum == a.StorageNum);
                        if (item != null)
                        {
                            a.Qty = item.BackNum;
                        }
                        a.BackNum = listResult.Where(b => b.BarCode == a.BarCode && b.ProductNum == a.ProductNum && b.LocalNum == a.LocalNum && b.StorageNum == a.StorageNum).Sum(b => b.BackNum);
                    });
                }
                Session[CacheKey.TEMPDATE_CACHE_RETURNPRODUCTDETAIL] = list;
                string json = ConvertJson.ListToJson <OutStoDetailEntity>(list, "List");
                this.ReturnJson.AddProperty("data", json);
            }
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult Edit()
        {
            string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();

            entity.OrderNum     = orderNum;
            entity              = bill.GetOrder(entity);
            entity              = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity      = entity;
            ViewBag.OutType     = EnumHelper.GetOptions <EInType>(entity.OutType, "请选择入库单类型");
            ViewBag.ProductType = EnumHelper.GetOptions <EProductType>(entity.ProductType, "请选择入库产品类型");

            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.OrderNum = orderNum;
            List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);

            listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult;

            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();

            list = list.IsNull() ? new List <ProductEntity>() : list;
            listResult.ForEach(a =>
            {
                ProductEntity product = null;
                if (a.BarCode.IsEmpty())
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum);
                }
                else
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum && b.BarCode == a.BarCode);
                }
                a.OutPrice = product != null ? product.OutPrice : 0;
                if (product != null)
                {
                    a.Size = product.Size.IsEmpty() ? "" : product.Size;
                }
                else
                {
                    a.Size = "";
                }
            });
            Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = listResult;
            return(View());
        }
        public ActionResult AddOrderDetailProduct([ModelBinder(typeof(JsonBinder <string[]>))] string[] ProductItems,
                                                  [ModelBinder(typeof(JsonBinder <string[]>))] string[] SnItems,
                                                  [ModelBinder(typeof(JsonBinder <int[]>))] int[] QtyItems)
        {
            List <OutStoDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] as List <OutStoDetailEntity>;

            list = list.IsNull() ? new List <OutStoDetailEntity>() : list;

            OrderProvider provider = new OrderProvider();

            for (int i = 0; i < ProductItems.Length; i++)
            {
                string            snNum      = SnItems[i];
                int               qty        = QtyItems[i];
                string            productNum = ProductItems[i];
                OrderDetailEntity detail     = provider.GetOrderDetailBySnNum(snNum);
                detail = detail.IsNull() ? new OrderDetailEntity() : detail;
                if (detail.IsNotNull())
                {
                    list.Remove(a => a.ContractSn == detail.SnNum);
                    OutStoDetailEntity entity = new OutStoDetailEntity();
                    entity.SnNum         = SequenceProvider.GetSequence(typeof(OutStoDetailEntity));
                    entity.ProductName   = detail.ProductName;
                    entity.BarCode       = detail.BarCode;
                    entity.ContractOrder = detail.OrderNum;
                    entity.ContractSn    = detail.SnNum;
                    entity.BatchNum      = "";
                    entity.ProductNum    = detail.ProductNum;
                    entity.LocalNum      = ResourceManager.GetSettingEntity("STORE_DEFAULT_MATERIAL_LocalNum").Value;  //detail.LocalNum;
                    entity.LocalName     = ResourceManager.GetSettingEntity("STORE_DEFAULT_MATERIAL_LocalName").Value; //detail.LocalName;
                    entity.StorageNum    = this.DefaultStore;
                    entity.Num           = qty;
                    entity.IsPick        = (int)EBool.No;
                    entity.Size          = detail.Size.IsEmpty() ? "" : detail.Size;
                    entity.RealNum       = detail.RealNum;
                    entity.OutPrice      = 0; //detail.InPrice;
                    entity.Amount        = 0; //detail.InPrice * entity.Num;
                    entity.CreateTime    = DateTime.Now;
                    list.Add(entity);
                }
            }
            if (!list.IsNullOrEmpty())
            {
                Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = list;
            }
            return(Content(string.Empty));
        }
Exemple #10
0
        /// <summary>
        /// 根据出库单唯一编号查询出库单详细列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDetail()
        {
            string             SnNum     = WebUtil.GetFormValue <string>("SnNum");
            string             CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            OutStoDetailEntity entity    = new OutStoDetailEntity();

            entity.OrderSnNum = SnNum;
            entity.CompanyID  = CompanyID;
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(CompanyID);
            List <OutStoDetailEntity> list = bill.GetOrderDetail(entity);

            DataResult <List <OutStoDetailEntity> > dataResult = new DataResult <List <OutStoDetailEntity> >();

            dataResult.Code    = (int)EResponseCode.Success;
            dataResult.Message = "响应成功";
            dataResult.Result  = list;
            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
        public ActionResult EditNum()
        {
            string             snNum    = WebUtil.GetFormValue <string>("SnNum", string.Empty);
            double             num      = WebUtil.GetFormValue <double>("num", 0);
            OutStorageProvider provider = new OutStorageProvider();
            int line = provider.EditInOrderNum(snNum, num);
            List <OutStoDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] as List <OutStoDetailEntity>;

            if (!list.IsNullOrEmpty())
            {
                if (list.Exists(a => a.SnNum == snNum))
                {
                    OutStoDetailEntity detail = list.First(a => a.SnNum == snNum);
                    detail.Num    = num;
                    detail.Amount = detail.OutPrice * detail.Num;
                }
            }
            return(Content(string.Empty));
        }
Exemple #12
0
        /// <summary>
        /// 编辑出库单详细信息
        /// </summary>
        /// <returns></returns>
        public ActionResult EditDetail()
        {
            string             CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            OutStoDetailEntity entity    = WebUtil.GetFormObject <OutStoDetailEntity>("Entity");
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(CompanyID);
            string     returnValue = bill.EditDetail(entity);
            DataResult result      = new DataResult();

            if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "出库单详细项编辑成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "出库单详细项编辑失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Exemple #13
0
        /// <summary>
        /// 获得订单详细查询
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public List <OutStoDetailEntity> GetOrderDetail(OutStoDetailEntity entity)
        {
            entity.IncludeAll();
            List <OutStoDetailEntity> list = this.OutStoDetail.GetList(entity);

            if (!list.IsNullOrEmpty())
            {
                List <LocationEntity> listLocation = new LocationProvider().GetList();
                listLocation = listLocation == null ? new List <LocationEntity>() : listLocation;
                foreach (OutStoDetailEntity item in list)
                {
                    LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.LocalNum);
                    item.LocalName = location == null ? "" : location.LocalName;
                    if (item.Amount == 0)
                    {
                        item.Amount = item.OutPrice * item.Num;
                    }
                }
            }
            return(list);
        }
Exemple #14
0
        public static OutStoDetail_CE ToCE(OutStoDetailEntity item)
        {
            OutStoDetail_CE target = new OutStoDetail_CE();

            target.ID          = item.ID;
            target.SnNum       = item.SnNum;
            target.OrderNum    = item.OrderNum;
            target.ProductName = item.ProductName;
            target.BarCode     = item.BarCode;
            target.ProductNum  = item.ProductNum;
            target.BatchNum    = item.BatchNum;
            target.LocalNum    = item.LocalNum;
            target.StorageNum  = item.StorageNum;
            target.Num         = item.Num;
            target.IsPick      = item.IsPick;
            target.RealNum     = item.RealNum;
            target.OutPrice    = item.OutPrice;
            target.Amount      = item.Amount;
            target.CreateTime  = item.CreateTime;
            return(target);
        }
        public ActionResult GetList()
        {
            int      Status    = WebUtil.GetFormValue <int>("Status", 0);
            string   OrderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   CusName   = WebUtil.GetFormValue <string>("CusName", string.Empty);
            string   beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime   = WebUtil.GetFormValue <string>("endTime", string.Empty);
            string   order     = WebUtil.GetFormValue <string>("order", string.Empty);
            int      OutType   = WebUtil.GetFormValue <int>("OutType", 0);
            string   planNum   = WebUtil.GetFormValue <string>("planNum");
            int      pageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            int      pageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            PageInfo pageInfo  = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            OutStorageEntity entity = new OutStorageEntity();

            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!CusName.IsEmpty())
            {
                entity.Begin <OutStorageEntity>()
                .And <OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%")
                .Or <OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%")
                .End <OutStorageEntity>()
                ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            if (!order.IsEmpty())
            {
                OrderProvider orderProvider     = new OrderProvider();
                List <string> listContractOrder = orderProvider.GetOrderPlan(order);
                listContractOrder = listContractOrder.IsNull() ? new List <string>() : listContractOrder;
                if (listContractOrder.Count == 0)
                {
                    listContractOrder.Add(order);
                }
                entity.And("ContractOrder", ECondition.In, listContractOrder.ToArray());
            }
            if (OutType > 0)
            {
                entity.And(a => a.OutType == OutType);
            }
            if (!planNum.IsEmpty())
            {
                OutStoDetailEntity detail = new OutStoDetailEntity();
                detail.Where("ContractOrder", ECondition.Like, "%" + planNum + "%");
                entity.Left <OutStoDetailEntity>(detail, new Params <string, string>()
                {
                    Item1 = "OrderNum", Item2 = "OrderNum"
                });
            }
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            List <OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <OutStorageEntity>() : listResult;
            string json = ConvertJson.ListToJson <OutStorageEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", json);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Exemple #16
0
        /// <summary>
        /// 根据销售订单转换为出库单
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public DataResult ToOutStorage(string SnNum, List <SaleDetailEntity> list, string StorageNum)
        {
            SaleOrderEntity entity = new SaleOrderEntity();

            entity.SnNum = SnNum;
            entity       = this.GetOrder(entity);
            DataResult result = new DataResult();

            if (entity == null)
            {
                result.Code    = 1001;
                result.Message = "销售订单不存在";
                return(result);
            }

            if (entity.Status == (int)EOrderStatus.CreateOrder)
            {
                result.Code    = 1001;
                result.Message = "销售订单审核流程不正确,不能生成出库单";
                return(result);
            }

            if (entity.Status == (int)EPurchaseStatus.AllIn)
            {
                result.Code    = 1002;
                result.Message = "销售订单已经全部出库,请勿重新出库";
                return(result);
            }

            if (entity.Status == (int)EPurchaseStatus.OrderCancel)
            {
                result.Code    = 1003;
                result.Message = "订单已经被取消,不能出库";
                return(result);
            }

            SaleDetailEntity detailEntity = new SaleDetailEntity();

            detailEntity.OrderSnNum = SnNum;
            List <SaleDetailEntity> listSource = this.GetOrderDetail(detailEntity);

            if (listSource.IsNullOrEmpty())
            {
                result.Code    = 1004;
                result.Message = "销售订单中不存在出库货品";
                return(result);
            }


            //检查入库产品是否在采购单内
            List <SaleDetailEntity> listExists = new List <SaleDetailEntity>();

            foreach (SaleDetailEntity item in list)
            {
                if (!listSource.Exists(a => a.SnNum == item.SnNum))
                {
                    //不存在添加到集合
                    listExists.Add(item);
                }
            }
            if (!listExists.IsNullOrEmpty())
            {
                string content = listExists.Select(a => string.Format("[{0}]{1}", a.BarCode, a.ProductName)).ToArray().ToString();
                result.Code    = 1005;
                result.Message = content + " 不在销售订单[" + entity.OrderNum + "]中,请重新确认再出库";
                return(result);
            }

            List <LocalProductEntity> listResult = new List <LocalProductEntity>();

            //拣货
            foreach (SaleDetailEntity item in list)
            {
                Proc_PickProductEntity pickEntity = new Proc_PickProductEntity();
                pickEntity.InStorageNum = StorageNum;
                pickEntity.InProductNum = item.ProductNum;
                pickEntity.InCompanyID  = this.CompanyID;
                pickEntity.InNum        = item.Qty;

                List <LocalProductEntity> listPickResult = this.Proc_PickProduct.ExceuteEntityList <LocalProductEntity>(pickEntity);
                if (listPickResult.IsNullOrEmpty() || listPickResult.Sum(a => a.Num) < item.Qty)
                {
                    result.Code    = 1006;
                    result.Message = string.Format("货品[{0}]拣货数 {1} 不满足要求数 {2},请确保仓库有足够的货品", item.ProductName, listPickResult.Sum(a => a.Num).ToString("0.00"), item.Qty.ToString("0.00"));
                    return(result);
                }

                listResult.AddRange(listPickResult);
            }

            OutStorageEntity outEntity = new OutStorageEntity();

            outEntity.SnNum         = ConvertHelper.NewGuid();
            outEntity.OutType       = (int)EOutType.Sell;
            outEntity.ProductType   = (int)EProductType.Goods;
            outEntity.StorageNum    = StorageNum;
            outEntity.CusSnNum      = entity.CusSnNum;
            outEntity.CusNum        = entity.CusNum;
            outEntity.CusName       = entity.CusName;
            outEntity.Contact       = entity.Contact;
            outEntity.Phone         = entity.Phone;
            outEntity.Address       = entity.Address;
            outEntity.ContractOrder = entity.SnNum;
            outEntity.SendDate      = entity.SendDate;
            outEntity.Status        = (int)EAudite.Wait;
            outEntity.IsDelete      = (int)EIsDelete.NotDelete;
            outEntity.CreateTime    = DateTime.Now;
            outEntity.CreateUser    = entity.CreateUser;
            outEntity.OperateType   = (int)EOpType.PC;
            outEntity.EquipmentNum  = "";
            outEntity.EquipmentCode = "";
            outEntity.CompanyID     = this.CompanyID;

            List <OutStoDetailEntity> listDetails = new List <OutStoDetailEntity>();

            foreach (LocalProductEntity item in listResult)
            {
                OutStoDetailEntity detail = new OutStoDetailEntity();
                detail.SnNum       = ConvertHelper.NewGuid();
                detail.OrderSnNum  = outEntity.SnNum;
                detail.ProductName = item.ProductName;
                detail.ProductNum  = item.ProductNum;
                detail.BarCode     = item.BarCode;
                detail.BatchNum    = item.BatchNum;
                detail.LocalNum    = item.LocalNum;
                detail.StorageNum  = item.StorageNum;
                detail.Num         = item.Num;
                detail.IsPick      = (int)EBool.No;
                detail.RealNum     = 0;

                SaleDetailEntity saleEntity = list.FirstOrDefault(a => a.ProductNum == item.ProductNum);
                if (saleEntity != null)
                {
                    detail.OutPrice      = saleEntity.Price;
                    detail.Amount        = detail.OutPrice * detail.Num;
                    detail.ContractOrder = entity.OrderNum;
                    detail.ContractSn    = saleEntity.SnNum;
                }
                detail.LocalSn    = item.Sn;
                detail.CreateTime = DateTime.Now;
                detail.CompanyID  = this.CompanyID;

                listDetails.Add(detail);
            }

            string returnValue = string.Empty;

            using (TransactionScope ts = new TransactionScope())
            {
                Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorage.OutStorageOrder(this.CompanyID);
                returnValue = bill.Create(outEntity, listDetails);

                if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue)
                {
                    foreach (SaleDetailEntity item in list)
                    {
                        if (item.RealNum + item.Qty >= item.Num)
                        {
                            item.Status   = (int)EOrderStatus.AllDelivery;
                            item.RealNum += item.Qty;
                        }
                        else if ((item.RealNum + item.Qty) < item.Num && (item.RealNum + item.Qty) > 0)
                        {
                            item.Status   = (int)EOrderStatus.PartialDelivery;
                            item.RealNum += item.Qty;
                        }
                        item.Include(a => new { a.RealNum, a.Status });
                        item.Where(a => a.SnNum == item.SnNum);
                        this.SaleDetail.Update(item);
                    }

                    //再次查询校验状态
                    detailEntity            = new SaleDetailEntity();
                    detailEntity.OrderSnNum = SnNum;
                    listSource = this.GetOrderDetail(detailEntity);
                    if (!listSource.IsNullOrEmpty())
                    {
                        if (listSource.Count(a => a.Status == (int)EOrderStatus.PartialDelivery) > 0 ||
                            (listSource.Count(a => a.Status == (int)EOrderStatus.AllDelivery) < listSource.Count() && listSource.Count(a => a.Status == (int)EOrderStatus.AllDelivery) > 0)
                            )
                        {
                            entity.Status = (int)EOrderStatus.PartialDelivery;
                        }
                        else if (listSource.Count(a => a.Status == (int)EOrderStatus.AllDelivery) == listSource.Count())
                        {
                            entity.Status = (int)EOrderStatus.AllDelivery;
                        }
                        entity.IncludeStatus(true);
                        entity.Where(a => a.SnNum == entity.SnNum);
                        this.SaleOrder.Update(entity);
                    }
                    result.Code    = (int)EResponseCode.Success;
                    result.Message = "出库单创建成功";
                }
                else
                {
                    result.Code    = (int)EResponseCode.Exception;
                    result.Message = "出库单创建失败";
                }

                ts.Complete();
            }
            return(result);
        }
        public ActionResult Create([ModelBinder(typeof(JsonBinder <List <ReturnDetailEntity> >))] List <ReturnDetailEntity> list)
        {
            string   OrderNum      = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            int      ReturnType    = WebUtil.GetFormValue <int>("ReturnType", (int)EReturnType.Sell);
            int      ProductType   = WebUtil.GetFormValue <int>("ProductType", (int)EProductType.Goods);
            string   ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty);
            string   CusNum        = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            string   CusName       = WebUtil.GetFormValue <string>("CusName", string.Empty);
            string   Contact       = WebUtil.GetFormValue <string>("Contact", string.Empty);
            string   Phone         = WebUtil.GetFormValue <string>("Phone", string.Empty);
            string   Address       = WebUtil.GetFormValue <string>("Address", string.Empty);
            DateTime CreateTime    = WebUtil.GetFormValue <DateTime>("CreateTime", DateTime.Now);
            string   Remark        = WebUtil.GetFormValue <string>("Remark", string.Empty);

            ReturnOrderEntity entity = new ReturnOrderEntity();

            entity.OrderNum = OrderNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReturnOrderEntity)) : OrderNum;
            List <OutStoDetailEntity> listOrder = Session[CacheKey.TEMPDATE_CACHE_RETURNPRODUCTDETAIL] as List <OutStoDetailEntity>;
            string StorageNum = ResourceManager.GetSettingEntity("STORE_DEFAULT_PRODUCT").Value;

            if (!list.IsNullOrEmpty() && !listOrder.IsNullOrEmpty())
            {
                list.ForEach(a =>
                {
                    OutStoDetailEntity detail = listOrder.SingleOrDefault(b => b.ProductNum == a.ProductNum && b.BarCode == a.BarCode && b.LocalNum == a.LocalNum && b.StorageNum == StorageNum && b.BatchNum == a.BatchNum);
                    if (detail != null)
                    {
                        a.ProductName   = detail.ProductName;
                        a.BatchNum      = detail.BatchNum;
                        a.OutPrice      = detail.OutPrice;
                        a.Num           = detail.Num;
                        a.Amount        = detail.Amount;
                        a.BackAmount    = a.OutPrice * a.BackNum;
                        a.CreateTime    = DateTime.Now;
                        a.StorageNum    = StorageNum;
                        a.ContractOrder = ContractOrder;
                    }
                    a.SnNum = SequenceProvider.GetSequence(typeof(ReturnDetailEntity));
                });
                entity.ReturnType    = ReturnType;
                entity.ProductType   = ProductType;
                entity.CusNum        = CusNum;
                entity.CusName       = CusName;
                entity.Phone         = Phone;
                entity.Contact       = Contact;
                entity.Address       = Address;
                entity.Num           = list.Sum(a => a.BackNum);
                entity.Amount        = list.Sum(a => a.BackAmount);
                entity.Status        = (int)EAudite.Wait;
                entity.IsDelete      = (int)EIsDelete.NotDelete;
                entity.CreateTime    = CreateTime;
                entity.CreateUser    = this.LoginUser.UserCode;
                entity.OperateType   = (int)EOpType.PC;
                entity.EquipmentNum  = string.Empty;
                entity.EquipmentCode = string.Empty;
                entity.Remark        = Remark;
                entity.ContractOrder = ContractOrder;
                entity.StorageNum    = this.DefaultStore;

                Bill <ReturnOrderEntity, ReturnDetailEntity> bill = new ReturnOrder();
                //如果单号不存在则为创建
                if (OrderNum.IsEmpty())
                {
                    string returnValue = bill.Create(entity, list);
                    if (returnValue == EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success))
                    {
                        this.ReturnJson.AddProperty("d", "1000");
                    }
                    else
                    {
                        this.ReturnJson.AddProperty("d", "1001");
                    }
                }
                else
                {
                    string returnValue = bill.EditOrder(entity, list);
                    this.ReturnJson.AddProperty("d", returnValue);
                }
            }
            else
            {
                this.ReturnJson.AddProperty("d", "1005");
            }
            return(Content(this.ReturnJson.ToString()));
        }