// POST: api/DeliveryorderQuery
        public DeliveryorderQueryResponseModel Post([FromBody] DeliveryorderQueryRequestModel model)
        {
            DeliveryorderQueryResponseModel response = new DeliveryorderQueryResponseModel();

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                DbSet <SHIPMENT_HEADER> dbSet0 = dbContext.Set <SHIPMENT_HEADER>();
                DbSet <SHIPMENT_DETAIL> dbSet1 = dbContext.Set <SHIPMENT_DETAIL>();
                SHIPMENT_HEADER         header = dbSet0.FirstOrDefault(h => h.SHIPMENT_ID == model.OrderCode && h.COMPANY == model.OwnerCode);
                if (header == null)
                {
                    response.Flag       = "failure";
                    response.Code       = "-1";
                    response.Message    = "无此出库单";
                    response.TotalLines = 0;
                    return(response);
                }
                int page     = (int)model.Page;
                int pageSize = (int)model.PageSize;

                response.Flag       = "success";
                response.Code       = "1";
                response.Message    = "查询成功";
                response.TotalLines = header.SHIPMENT_DETAIL.Count();
                DeliveryorderQueryResponseModel.DeliveryOrderDomain    deliveryOrder = new DeliveryorderQueryResponseModel.DeliveryOrderDomain();
                DeliveryorderQueryResponseModel.PackageDomain          package       = new DeliveryorderQueryResponseModel.PackageDomain();
                List <DeliveryorderQueryResponseModel.PackageDomain>   packages      = new List <DeliveryorderQueryResponseModel.PackageDomain>();
                DeliveryorderQueryResponseModel.OrderLineDomain        orderLine     = new DeliveryorderQueryResponseModel.OrderLineDomain();
                List <DeliveryorderQueryResponseModel.OrderLineDomain> orderLines    = new List <DeliveryorderQueryResponseModel.OrderLineDomain>();

                deliveryOrder.DeliveryOrderCode = header.SHIPMENT_ID;
                deliveryOrder.DeliveryOrderId   = header.INTERNAL_SHIPMENT_NUM.ToString();
                deliveryOrder.WarehouseCode     = header.WAREHOUSE;
                deliveryOrder.OrderType         = header.SHIPMENT_TYPE;
                if (header.LEADING_STS == 900 && header.TRAILING_STS == 900)
                {
                    deliveryOrder.Status = DeliveryorderQueryStatusEnum.DELIVERED.ToString();
                }
            }
            return(response);
        }
예제 #2
0
        // POST: api/OrderCancel
        public OrderCancelResponseModel Post([FromBody] OrderCancelRequestModel model, string customerId)
        {
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            OrderCancelResponseModel response = new OrderCancelResponseModel();

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "OrderCancel";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                //DbSet<RECEIPT_HEADER> dbSet0 = dbContext.Set<RECEIPT_HEADER>();
                //DbSet<SHIPMENT_HEADER> dbSet1 = dbContext.Set<SHIPMENT_HEADER>();

                RECEIPT_HEADER  rHeader = dbContext.RECEIPT_HEADER.FirstOrDefault(r => r.RECEIPT_ID == model.OrderCode && r.COMPANY == customerId);
                SHIPMENT_HEADER sHeader = dbContext.SHIPMENT_HEADER.FirstOrDefault(r => r.SHIPMENT_ID == model.OrderCode && r.COMPANY == customerId);

                if (sHeader != null)
                {
                    if (sHeader.TRAILING_STS >= 750)
                    {
                        response.Flag    = "failure";
                        response.Code    = "-1";
                        response.Message = model.OrderCode + ":当前状态不允许取消";
                        return(response);
                    }

                    if (sHeader.PROCESS_TYPE.Equals("CANCEL", StringComparison.OrdinalIgnoreCase))
                    {
                        response.Flag    = "success";
                        response.Code    = "0";
                        response.Message = model.OrderCode + ":该订单已经取消";
                        return(response);
                    }
                    else
                    {
                        sHeader.PROCESS_TYPE       = "CANCEL";
                        sHeader.SHIPMENT_CATEGORY6 = "Cancel";
                    }
                }
                else if (rHeader != null)
                {
                    //response.Flag = "failure";
                    //response.Code = "-1";
                    //response.Message = model.OrderCode + ":入库单取消,请联系商务";
                    //return response;
                    if (rHeader.LEADING_STS == 100 && rHeader.TRAILING_STS == 100)
                    {
                        rHeader.LEADING_STS  = 900;
                        rHeader.TRAILING_STS = 900;
                        rHeader.USER_DEF8    = "Cancel";
                        //rHeader.CLOSE_DATE = DateTime.Now.AddHours(-4);
                    }
                    else
                    {
                        response.Flag    = "failure";
                        response.Code    = "-1";
                        response.Message = model.OrderCode + "已收货不允许取消";
                        return(response);
                    }
                }

                if (dbContext.SaveChanges() >= 0)
                {
                    response.Flag    = "success";
                    response.Code    = "0";
                    response.Message = model.OrderCode + ":取消成功";
                }
                else
                {
                    response.Flag    = "failure";
                    response.Code    = "-1";
                    response.Message = model.OrderCode + ":取消失败";
                }
            }

            return(response);
        }
예제 #3
0
        // POST: api/DeliveryorderCreate
        public DeliveryorderCreateResponseModel Post([FromBody] DeliveryorderCreateRequestModel model, string customerId)
        {
            DeliveryorderCreateResponseModel response = new DeliveryorderCreateResponseModel();

            if (customerId == "CH1")
            {
                customerId = "CH";
            }

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "DeliveryorderCreate";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                //DbSet<SHIPMENT_HEADER> dbSet0 = dbContext.Set<SHIPMENT_HEADER>();
                //DbSet<SHIPMENT_DETAIL> dbSet1 = dbContext.Set<SHIPMENT_DETAIL>();
                DbSet <ITEM> dbSetItem = dbContext.Set <ITEM>();

                if (dbContext.SHIPMENT_HEADER.Where(h => h.SHIPMENT_ID == model.DeliveryOrder.DeliveryOrderCode && h.COMPANY == customerId).Any())
                {
                    response.Flag            = "success";
                    response.Code            = "0";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":单号重复";
                    response.DeliveryOrderId = "";
                    return(response);
                }

                SHIPMENT_HEADER header = new SHIPMENT_HEADER();
                header.WAREHOUSE = "LK01";
                header.COMPANY   = customerId;

                header.USER_DEF2     = model.DeliveryOrder.ShopNick;
                header.SHIPMENT_NOTE = model.DeliveryOrder.SellerMessage;
                header.SHIPMENT_TYPE = model.DeliveryOrder.OrderType;
                header.SHIPMENT_ID   = model.DeliveryOrder.DeliveryOrderCode;
                DateTime time;
                if (DateTime.TryParse(model.DeliveryOrder.CreateTime, out time))
                {
                    header.CREATE_DATE_TIME = time;
                }
                header.LEADING_STS      = 100;
                header.TRAILING_STS     = 100;
                header.SHIP_TO_NAME     = model.DeliveryOrder.ReceiverInfo.Name;
                header.SHIP_TO_MOBILE   = model.DeliveryOrder.ReceiverInfo.Mobile;
                header.SHIP_TO_DISTRICT = model.DeliveryOrder.ReceiverInfo.Area;
                header.SHIP_TO_CITY     = model.DeliveryOrder.ReceiverInfo.City;
                header.SHIP_TO_STATE    = model.DeliveryOrder.ReceiverInfo.Province;
                //header.SHIPMENT_NOTE = model.DeliveryOrder.ReceiverInfo.Remark;
                header.SHIP_TO_ADDRESS1 = model.DeliveryOrder.ReceiverInfo.DetailAddress;
                header.PROCESS_TYPE     = "NORMAL";
                header.CARRIER          = model.DeliveryOrder.LogisticsCode;
                header.CREATE_USER      = "******";
                header.TOTAL_LINES      = model.OrderLines.Count();
                int totalQty = 0;

                foreach (var item in model.OrderLines)
                {
                    SHIPMENT_DETAIL detail = new SHIPMENT_DETAIL();
                    detail.WAREHOUSE   = "LK01";
                    detail.COMPANY     = item.OwnerCode;
                    detail.SHIPMENT_ID = model.DeliveryOrder.DeliveryOrderCode;
                    detail.ITEM        = item.ItemCode;
                    ITEM sItem = dbSetItem.Where(t => t.ITEM1 == item.ItemCode).FirstOrDefault();
                    if (sItem != null)
                    {
                        detail.ITEM_DESC = sItem.ITEM_DESC;
                    }
                    //detail.ITEM_DESC = item.ItemName;
                    detail.REQUEST_QTY     = Convert.ToInt32(item.PlanQty);
                    detail.QUANTITY_UM     = "EA";
                    detail.DATE_TIME_STAMP = time;
                    if (item.InventoryType == null)
                    {
                        detail.INVENTORY_STS = "合格";
                    }
                    else
                    {
                        if (string.Equals("ZP", item.InventoryType, StringComparison.CurrentCultureIgnoreCase))
                        {
                            detail.INVENTORY_STS = "合格";
                        }
                        else
                        {
                            detail.INVENTORY_STS = "不合格";
                        }
                    }


                    //detail.INVENTORY_STS = item.InventoryType;
                    detail.STATUS = 100;
                    totalQty     += Convert.ToInt32(item.PlanQty);
                    header.SHIPMENT_DETAIL.Add(detail);
                }

                header.TOTAL_QTY = totalQty;

                dbContext.SHIPMENT_HEADER.Add(header);

                if (dbContext.SaveChanges() > 0)
                {
                    response.Flag            = "success";
                    response.Code            = "1";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":创建成功";
                    response.DeliveryOrderId = header.INTERNAL_SHIPMENT_NUM.ToString();
                }
                else
                {
                    response.Flag            = "failure";
                    response.Code            = "-1";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":创建失败";
                    response.DeliveryOrderId = "";
                }
            }

            return(response);
        }