public HttpResponseMessage SendNewOrderToOperators(OrderDTO data)
 {
     //OrderDTO o = order as OrderDTO;
     //var i = 0;
     OperatorMessagesHelper.SendNewOrderToOperators(data);
     return Request.CreateResponse(HttpStatusCode.OK, true);
 }
Exemplo n.º 2
0
		public static void SendNewOrderToOperators(OrderDTO order)
		{

			//operatorContext.Clients.All.newOrderFromClient(new OrderDTO());


			operatorContext.Clients.All.newOrderFromClient(order);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="VMPerformOrder"/> class.
 /// </summary>
 public VMPerformOrder()
 {
     if (!DesignTimeHelper.IsDesignTime)
     {
         this._currentOrder = new OrderDTO();
         GetCustomers();
         GetProducts();
     }
 }
Exemplo n.º 4
0
        public async Task<IHttpActionResult> Get(int id)
        {
            var order = await _dbSet.Where(p => p.OrderID == id).SingleOrDefaultAsync();

            if (order == null)
                return NotFound();

            var orderDTO = new OrderDTO().InjectFrom(order);

            return Ok(orderDTO);
        }
Exemplo n.º 5
0
        public async Task<IHttpActionResult> RegiterNew(OrderDTO orderDTO)
        {
            var order = new Order(orderDTO.CustomerName, orderDTO.CustomerPhone, orderDTO.PizzaID);

            _dbSet.Add(order);
            await _context.SaveChangesAsync();

            orderDTO = (OrderDTO)new OrderDTO().InjectFrom(order);
            orderDTO.StatusDescription = ((OrderStatus)order.Status).ToString();

            return Created(new Uri(_baseUri + orderDTO.OrderID), orderDTO);
        }
Exemplo n.º 6
0
 public OrderVM(OrderDTO row)
 {
     OrderId   = row.OrderId;
     UserId    = row.UserId;
     CreatedAt = row.CreatedAt;
 }
Exemplo n.º 7
0
 public bool UpdateOrder(OrderDTO order, List <OrderLine> orderedItems, Customer customer, int order_no, ref string msg)
 {
     return(DataAccessManager.UpdateOrder(order, orderedItems, customer, order_no, ref msg));
 }
Exemplo n.º 8
0
        /// <summary>
        /// 订单商品来自京东仓,商品ID需要做对应关系
        /// </summary>
        /// <param name="db"></param>
        /// <param name="orderDTO"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        protected bool InputProductInfoWithoutSaveChange_JD(OMSContext db, OrderDTO orderDTO, OrderEntity item)
        {
            ProductDictionary pd = null;

            pd = db.ProductDictionarySet.FirstOrDefault(p => p.ProductId.Trim() == orderDTO.productsku.Trim() && orderDTO.productsku != null && p.ProductCode != null);
            if (pd == null)
            {
                OnUIMessageEventHandle($"订单文件:{orderDTO.fileName}中平台单号:{orderDTO.sourceSN}({orderDTO.productsku})录入失败");
                InputExceptionOrder(orderDTO, ExceptionType.ProductIdUnKnown);
                if (db.ProductDictionarySet.FirstOrDefault(p => p.ProductId == orderDTO.productsku) == null)
                {
                    ProductDictionary productDictionary = new ProductDictionary()
                    {
                        ProductId             = orderDTO.productsku,
                        Source                = orderDTO.source,
                        ProductNameInPlatform = orderDTO.productName.Trim()
                    };
                    db.ProductDictionarySet.Add(productDictionary);
                    db.SaveChanges();
                }
                return(false);
            }
            string temp = pd.ProductCode.Trim();//"S0010040003\t"
            var    foo  = db.ProductsSet.Include(p => p.weightModel).FirstOrDefault(p => p.sku.Trim() == temp);



            if (foo == null)
            {
                OnUIMessageEventHandle($"订单文件:{orderDTO.fileName}中平台单号:{orderDTO.sourceSN}({orderDTO.productsku})对应ERP商品记录未找到");
                InputExceptionOrder(orderDTO, ExceptionType.ProductCodeUnKnown);
                return(false);
            }

            /*
             * 订单来源是ERP,同时商品SKU是周期购商品的SKU,判定为周期购日常发货订单
             * 周期购日常发货订单不纳入日常统计中,为了和客户下的周期购订单区分开
             * 统计报表中只统计销售订单
             *
             */
            if (foo.sku == "S0010030002" || foo.sku == "S0010040002")//标识该订单是周期购订单
            {
                item.OrderType += 4;
            }
            var     bar    = item.Products.FirstOrDefault(p => p.sku == foo.sku);
            decimal weight = foo == null ? 0 : foo.QuantityPerUnit * orderDTO.count;

            if (bar == null)
            {
                OrderProductInfo orderProductInfo = new OrderProductInfo()
                {
                    ProductPlatId   = orderDTO.productsku,
                    ProductPlatName = orderDTO.productName,
                    //   Warehouse = item.OrderLogistics.Logistics,
                    MonthNum       = orderDTO.createdDate.Month,
                    weightCode     = foo.weightModel == null ? 0 : foo.weightModel.Code,
                    weightCodeDesc = foo.weightModel == null ? string.Empty : $"{foo.weightModel.Value}g",
                    OrderSn        = orderDTO.orderSN,
                    TotalAmount    = orderDTO.totalAmount,
                    DiscountFee    = orderDTO.discountFee,
                    AmounPerUnit   = orderDTO.pricePerUnit,
                    ProductCount   = orderDTO.count,
                    ProductWeight  = weight,
                    Source         = orderDTO.source,
                    sku            = foo.sku
                };
                item.Products.Add(orderProductInfo);
            }
            else
            {
                bar.ProductWeight += weight;
                bar.ProductCount  += orderDTO.count;
            }



            OnUIMessageEventHandle($"订单文件:{orderDTO.fileName}中平台单号:{orderDTO.sourceSN}({orderDTO.productsku})解析完毕");
            return(true);
        }
Exemplo n.º 9
0
        private OrderEntity ResolveOrdersFromJD(CsvReader csv, OrderDTO orderDTO, List <OrderEntity> items)
        {
            orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, DateTime.Now.ToString("yyyyMMdd"));
            var orderDate = csv.GetField <string>("付款确认时间");

            if (string.IsNullOrEmpty(orderDate))
            {
                orderDate = csv.GetField <string>("下单时间");
            }

            orderDTO.createdDate = DateTime.Parse(orderDate);


            orderDTO.productName = csv.GetField <string>("商品名称").Trim();
            orderDTO.productsku  = csv.GetField <string>("商品ID").Trim();
            var quantity = orderDTO.count = csv.GetField <string>("订购数量").ToInt();

            // decimal weight = csv.GetField<string>("总重量").ToInt();
            orderDTO.consigneeName       = csv.GetField <string>("客户姓名").Trim();
            orderDTO.consigneePersonCard = csv.GetField <string>("下单帐号").Trim();
            orderDTO.consigneePhone      = string.Empty;
            //京东天猫订单独有的金额信息
            orderDTO.pricePerUnit = csv.GetField <decimal>("京东价") / quantity;
            orderDTO.totalAmount  = csv.GetField <decimal>("应付金额");
            orderDTO.discountFee  = csv.GetField <decimal>("订单金额") - orderDTO.totalAmount;

            orderDTO.consigneeAddress = csv.GetField <string>("客户地址").Trim();


            var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress);

            orderDTO.consigneeProvince = addrInfo.Province;
            orderDTO.consigneeCity     = addrInfo.City;
            orderDTO.consigneeCounty   = addrInfo.County;
            //   consigneeAddress = addrInfo.Address;

            orderDTO.consigneeZipCode = string.Empty;
            //int weightcode = 0;
            //csv.TryGetField<int>("规格代码", out weightcode);
            //orderDTO.weightCode = weightcode;
            //orderDTO.weightCodeDesc = csv.GetField<string>("规格名称");

            orderDTO.OrderComeFrom = 0;


            /* 生成订单对象,从items集合中查找是否已经录入该订单对象
             * 如果items中已经有该订单对象则创建商品子对象及物流商品对象
             * 如果items中没有该订单对象则创建并关联各个子对象,将订单对象录入items
             * 重要提示:本方法解析csv对象,并转化为全新的订单对象,需要将订单的所有内容(重点是商品对象)都完整录入OMS系统中
             *
             */
            var item = items.Find(o => o.OrderSn == orderDTO.orderSN);

            if (item == null)//集合中不存在该订单对象
            {
                var orderItem = OrderEntityService.CreateOrderEntity(orderDTO);
                orderItem.Consignee.PersonCard = orderDTO.consigneePersonCard;

                if (orderItem.OrderType == 0)
                {
                    using (var db = new OMSContext())
                    {
                        //查找联系人
                        if (!string.IsNullOrEmpty(orderItem.Consignee.Phone) || !string.IsNullOrEmpty(orderItem.Consignee.PersonCard))
                        {
                            OrderEntityService.InputConsigneeInfo(orderItem, db);
                        }
                        else //异常订单
                        {
                            InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull);
                            return(null);
                        }



                        if (!InputProductInfoWithoutSaveChange_JD(db, orderDTO, orderItem))
                        {
                            return(null);
                        }

                        db.OrderRepurchases.Add(orderItem.OrderRepurchase);
                        db.OrderDateInfos.Add(orderItem.OrderDateInfo);

                        //  db.OrderProductSet.Add(orderProductInfo);
                        db.SaveChanges();
                        items.Add(orderItem);
                        return(orderItem);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                orderDTO.consigneeName  = csv.GetField <string>("客户姓名").Trim();
                orderDTO.consigneePhone = string.Empty;

                orderDTO.count = csv.GetField <string>("订购数量").ToInt();

                using (var db = new OMSContext())
                {
                    InputProductInfoWithoutSaveChange_JD(db, orderDTO, item);
                }
                return(null);
            }
        }
Exemplo n.º 10
0
        public static List <OrderDTO> GetPreviousOrdersAdmin(OrderDTO orderdetinput)
        {
            List <OrderDTO> orderDTOList = new List <OrderDTO>();
            OrderDTO        orderDTO;

            try
            {
                //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB", false);
                LinqToSqlDataContext db = new LinqToSqlDataContext();
                // var OrderDtls ;


                var OrderDtls = (from order in db.Orders
                                 join orditem in db.OrderItems
                                 on order.OrderId equals orditem.OrderId
                                 join arc in db.ARCs
                                 on order.ARCId equals arc.ARCId
                                 join status in db.OrderStatusMasters
                                 on order.OrderStatusId equals status.OrderStatusId
                                 join oid in db.OrderItemDetails on orditem.OrderItemId equals oid.OrderItemId
                                 where order.OrderStatusId != 1 &&
                                 ((order.OrderDate.Date <= orderdetinput.ordertodate) && (order.OrderDate.Date >= orderdetinput.orderfromdate)) &&
                                 (orderdetinput.orderctgid == -1 || orditem.CategoryId == orderdetinput.orderctgid) &&
                                 (orderdetinput.orderprodid == -1 || orditem.ProductId == orderdetinput.orderprodid) &&
                                 (orderdetinput.orderarcid == -1 || order.ARCId == orderdetinput.orderarcid) &&
                                 (orderdetinput.CSLOrderNo == string.Empty || order.OrderNo == orderdetinput.CSLOrderNo) &&
                                 (orderdetinput.ChipNo == string.Empty || oid.GPRSNo == orderdetinput.ChipNo)
                                 select new
                {
                    order.UserId,
                    order.UserEmail,
                    order.OrderId,
                    order.OrderDate,
                    order.OrderNo,
                    order.OrderRefNo,
                    order.DeliveryCost,
                    order.Amount,
                    order.OrderTotalAmount,
                    order.VATRate,
                    ARCDisp = arc.CompanyName + "[" + arc.ARC_Code + "] ",
                    status.OrderStatus
                }).Distinct().OrderByDescending(x => x.OrderDate).Take(200);



                foreach (var o in OrderDtls)
                {
                    orderDTO                  = new OrderDTO();
                    orderDTO.OrderId          = o.OrderId;
                    orderDTO.OrderDate        = o.OrderDate;
                    orderDTO.CSLOrderNo       = o.OrderNo;
                    orderDTO.ARCOrderRefNo    = o.OrderRefNo;
                    orderDTO.ARCDisp          = o.ARCDisp;
                    orderDTO.UserEmail        = o.UserEmail;
                    orderDTO.TotalAmountToPay = Math.Round(((o.Amount + o.DeliveryCost) + (o.Amount + o.DeliveryCost) * o.VATRate), 2).ToString();
                    orderDTO.OrderStatus      = o.OrderStatus;
                    var orderItem = (from oi in db.OrderItems
                                     where oi.OrderId == o.OrderId
                                     group oi by oi.OrderId into qty
                                     select new
                    {
                        ProductQty = qty.Sum(oi => oi.ProductQty)
                    }
                                     ).FirstOrDefault();

                    if (orderItem != null)
                    {
                        orderDTO.OrderQty = orderItem.ProductQty.ToString();
                    }
                    else
                    {
                        orderDTO.OrderQty = "0.00";
                    }

                    orderDTOList.Add(orderDTO);
                }
            }
            catch (Exception objException)
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("ARC Ordering", "GetPreviousOrdersAdmin", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, null);
            }

            return(orderDTOList);
        }
Exemplo n.º 11
0
        protected List <OrderEntity> ResolveOrders(DataTable excelTable, string file, List <OrderEntity> items)
        {
            OrderDTO orderDTO = new OrderDTO();

            orderDTO.orderStatus = OrderStatus.Confirmed;
            orderDTO.fileName    = file;
            orderDTO.orderType   = 0;



            for (int i = 0; i < excelTable.Rows.Count; i++)
            {
                var row = excelTable.Rows[i];

                var orderDateStr = Convert.ToString(row[0]); //订单创建时间
                orderDTO.createdDate = DateTime.Parse(orderDateStr);

                orderDTO.source     = OrderSource.CIBAPP;
                orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.CIBAPP);

                orderDTO.sourceSN = Convert.ToString(row[1]); //订单号
                if (string.IsNullOrEmpty(orderDTO.sourceSN))
                {
                    InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull);
                    continue;
                }


                orderDTO.productName = Convert.ToString(row[3]); //商品名称
                orderDTO.productsku  = Convert.ToString(row[2]); //商品编号
                orderDTO.count       = Convert.ToInt32(row[4]);  //数量


                orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd"));
                if (CheckOrderInDataBase(orderDTO))//是否是重复订单
                {
                    continue;
                }
                var item = items.Find(o => o.OrderSn == orderDTO.orderSN);
                if (item == null)
                {
                    // var productProps = Convert.ToString(row[5]); //商品属性


                    orderDTO.consigneeName   = Convert.ToString(row[6]); //收件人
                    orderDTO.consigneePhone  = Convert.ToString(row[7]); //联系电话
                    orderDTO.consigneePhone2 = string.Empty;


                    orderDTO.consigneeProvince = string.Empty;
                    orderDTO.consigneeCity     = string.Empty;
                    orderDTO.consigneeCounty   = string.Empty;
                    orderDTO.consigneeAddress  = Convert.ToString(row[8]); //收货地区+详细地址
                    orderDTO.consigneeZipCode  = Convert.ToString(row[9]); //邮编

                    //
                    if (string.IsNullOrEmpty(orderDTO.consigneeProvince) &&
                        string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress))
                    {
                        var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress);
                        orderDTO.consigneeProvince = addrInfo.Province;
                        orderDTO.consigneeCity     = addrInfo.City;
                        orderDTO.consigneeCounty   = addrInfo.County;
                        //   consigneeAddress = addrInfo.Address;
                    }


                    var totalQuantity = orderDTO.count;


                    //是否需要发票
                    var invoiceFlag = Convert.ToString(row["是否需要发票"]); //是否需要发票
                    var invoiceType = string.Empty;
                    var invoiceName = Convert.ToString(row["发票抬头"]);   //发票抬头
                    if (invoiceFlag.Equals("否"))
                    {
                        invoiceType = invoiceName = string.Empty;
                    }
                    string paystr = Convert.ToString(row["支付方式"]);
                    switch (paystr)
                    {
                    case "积分支付":
                        orderDTO.PayType = PayType.Integral;

                        break;

                    case "积分+自付金支付":
                        orderDTO.PayType    = PayType.IntegralAndMoney;
                        orderDTO.source     = OrderSource.CIBEVT;
                        orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.CIBEVT);

                        break;

                    case "分期支付":
                        orderDTO.PayType    = PayType.installments;
                        orderDTO.source     = OrderSource.CIBSTM;
                        orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.CIBSTM);

                        break;

                    default:
                        orderDTO.PayType = PayType.None;
                        break;
                    }
                    OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO);
                    using (var db = new OMSContext())
                    {
                        //查找联系人
                        if (!string.IsNullOrEmpty(orderItem.Consignee.Phone))
                        {
                            OrderEntityService.InputConsigneeInfo(orderItem, db);
                        }
                        else //异常订单
                        {
                            InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull);
                            continue;
                        }

                        if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem))
                        {
                            continue;
                        }
                        items.Add(orderItem);
                        if (orderItem.OrderRepurchase == null)
                        {
                            orderItem.OrderRepurchase = new OrderRepurchase();
                        }
                        db.OrderRepurchases.Add(orderItem.OrderRepurchase);
                        db.OrderDateInfos.Add(orderItem.OrderDateInfo);

                        db.SaveChanges();
                    }
                }
                else
                {
                    orderDTO.productName = Convert.ToString(row[3]); //商品名称
                    orderDTO.productsku  = Convert.ToString(row[2]); //商品编号

                    orderDTO.count = Convert.ToInt32(row[4]);        //数量

                    using (var db = new OMSContext())
                    {
                        InputProductInfoWithoutSaveChange(db, orderDTO, item);
                    }
                }
            }

            return(items);
        }
Exemplo n.º 12
0
 public static OrderDTO GetCurrentOrder()
 {
     var session = HttpContext.Current.Session;
     var order = (OrderDTO)session[OrderDTO.Order];
     if (order == null)
     {
         order = new OrderDTO();
         session[OrderDTO.Order] = order;
     }
     return order;
 }
        private Order MappingOrder(OrderDTO orderDTO)
        {
            var mapper = new MapperConfiguration(conf => conf.CreateMap <OrderDTO, Order>()).CreateMapper();

            return(mapper.Map <Order>(orderDTO));
        }
Exemplo n.º 14
0
        protected List <OrderEntity> ResolveOrders(DataTable excelTable, string file, List <OrderEntity> items)
        {
            OrderDTO orderDTO = new OrderDTO();

            orderDTO.orderStatus = OrderStatus.Predelivery;
            orderDTO.fileName    = file;
            orderDTO.orderType   = 0;



            for (int i = 0; i < excelTable.Rows.Count; i++)
            {
                var row = excelTable.Rows[i];


                orderDTO.source     = Name;
                orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(Name);

                orderDTO.sourceSN = Convert.ToString(row["订单编号"]); //订单号
                if (string.IsNullOrEmpty(orderDTO.sourceSN))
                {
                    InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull);
                    continue;
                }
                var orderDateStr = Convert.ToString(row["支付时间"]); //订单创建时间04-9月-2020
                orderDTO.createdDate = DateTime.ParseExact(orderDateStr, "dd-M月-yyyy", CultureInfo.InvariantCulture);


                orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称
                // orderDTO.productsku = Convert.ToString(row[2]); //商品编号
                orderDTO.count = Convert.ToInt32(row["商品数量"]);        //数量


                orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd"));
                if (CheckOrderInDataBase(orderDTO))//是否是重复订单
                {
                    continue;
                }
                var item = items.Find(o => o.OrderSn == orderDTO.orderSN);
                if (item == null)
                {
                    // var productProps = Convert.ToString(row[5]); //商品属性


                    orderDTO.consigneeName   = Convert.ToString(row["收货人姓名"]);  //收件人
                    orderDTO.consigneePhone  = Convert.ToString(row["收货人手机号"]); //联系电话
                    orderDTO.consigneePhone2 = string.Empty;


                    orderDTO.consigneeProvince = Convert.ToString(row["收货人所在省份"]);
                    orderDTO.consigneeCity     = Convert.ToString(row["收货人所在城市"]);
                    orderDTO.consigneeCounty   = Convert.ToString(row["收货人所在区/县"]);
                    orderDTO.consigneeAddress  = Convert.ToString(row["收货人详细地址"]); //收货地区+详细地址
                    orderDTO.consigneeZipCode  = Convert.ToString(row["邮编"]);      //邮编

                    //
                    if (string.IsNullOrEmpty(orderDTO.consigneeProvince) &&
                        string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress))
                    {
                        var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress);
                        orderDTO.consigneeProvince = addrInfo.Province;
                        orderDTO.consigneeCity     = addrInfo.City;
                        orderDTO.consigneeCounty   = addrInfo.County;
                        //   consigneeAddress = addrInfo.Address;
                    }


                    var totalQuantity = orderDTO.count;



                    string paystr = Convert.ToString(row["支付方式"]);
                    switch (paystr)
                    {
                    case "积分支付":
                        orderDTO.PayType = PayType.Integral;

                        break;

                    case "积分+自付金支付":
                        orderDTO.PayType = PayType.IntegralAndMoney;


                        break;

                    case "分期支付":
                        orderDTO.PayType = PayType.installments;

                        break;

                    case "微信支付":
                        orderDTO.PayType = PayType.WeChatPay;
                        break;

                    default:
                        orderDTO.PayType = PayType.None;
                        break;
                    }
                    OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO);
                    using (var db = new OMSContext())
                    {
                        //查找联系人
                        if (!string.IsNullOrEmpty(orderItem.Consignee.Phone))
                        {
                            OrderEntityService.InputConsigneeInfo(orderItem, db);
                        }
                        else //异常订单
                        {
                            InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull);
                            continue;
                        }

                        if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem))
                        {
                            continue;
                        }
                        items.Add(orderItem);
                        if (orderItem.OrderRepurchase == null)
                        {
                            orderItem.OrderRepurchase = new OrderRepurchase();
                        }
                        db.OrderRepurchases.Add(orderItem.OrderRepurchase);
                        db.OrderDateInfos.Add(orderItem.OrderDateInfo);

                        db.SaveChanges();
                    }
                }
                else
                {
                    orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称

                    orderDTO.count = Convert.ToInt32(row["商品数量"]);        //数量

                    using (var db = new OMSContext())
                    {
                        InputProductInfoWithoutSaveChange(db, orderDTO, item);
                    }
                }
            }

            return(items);
        }
Exemplo n.º 15
0
        public async Task <ApiResult> RePay(OrderReApplysModel model)
        {
            //long orderStateId = await idNameService.GetIdByNameAsync("待付款");
            User user = JwtHelper.JwtDecrypt <User>(ControllerContext);

            OrderDTO order = await orderService.GetModelAsync(model.OrderId);

            if (order == null)
            {
                return(new ApiResult {
                    status = 0, msg = "订单不存在"
                });
            }
            long id = await orderService.ValidOrder(order.Id);

            if (id == -1)
            {
                return(new ApiResult {
                    status = 0, msg = "订单不存在"
                });
            }
            if (id == -2)
            {
                return(new ApiResult {
                    status = 0, msg = "会员不存在", data = order.Id
                });
            }
            if (id == -4)
            {
                return(new ApiResult {
                    status = 0, msg = "订单中有商品已经下架,请重新下单", data = order.Id
                });
            }
            if (id == -3)
            {
                return(new ApiResult {
                    status = 0, msg = "商品库存不足", data = order.Id
                });
            }
            if (id == -6)
            {
                return(new ApiResult {
                    status = 0, msg = "用户账户已经冻结", data = id
                });
            }
            WeChatPay weChatPay = new WeChatPay();

            weChatPay.body         = "订单支付";
            weChatPay.out_trade_no = order.Code;
            weChatPay.openid       = user.Code.Substring(3, 28);
            weChatPay.total_fee    = Math.Truncate(order.Amount * 100).ToString();
            string parm = HttpClientHelper.BuildParam(weChatPay);
            string key  = System.Configuration.ConfigurationManager.AppSettings["KEY"];

            parm = parm + "&key=" + key;
            string     sign       = CommonHelper.GetMD5(parm);
            HttpClient httpClient = new HttpClient();
            string     xml        = HttpClientHelper.ObjSerializeXml(weChatPay, sign);

            //CacheHelper.SetCache("App_Order_Pay" + weChatPay.out_trade_no, sign, DateTime.UtcNow.AddMinutes(2), TimeSpan.Zero);

            string res = await HttpClientHelper.GetResponseByPostXMLAsync(httpClient, xml, "https://api.mch.weixin.qq.com/pay/unifiedorder");

            if (!res.Contains("SUCCESS"))
            {
                return(new ApiResult {
                    status = 0, msg = res
                });
            }
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(res);
            XmlNode Child = xmlDoc.SelectSingleNode("xml/prepay_id");

            log.DebugFormat($"待支付订单微信支付统一下单,时间:{DateTime.Now}");

            TimeSpan  ts        = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            GetWechat getWeChat = new GetWechat();

            getWeChat.timeStamp = Convert.ToInt64(ts.TotalSeconds).ToString();
            getWeChat.package   = "prepay_id" + Child.InnerText;
            parm = HttpClientHelper.BuildParam(getWeChat);
            parm = parm.Replace("prepay_id", "prepay_id=");
            parm = parm + "&key=" + key;
            string paySign = CommonHelper.GetMD5(parm);

            GetWechat1 getWeChat1 = new GetWechat1();

            getWeChat1.appId     = getWeChat.appId;
            getWeChat1.nonceStr  = getWeChat.nonceStr;
            getWeChat1.package   = "prepay_id=" + Child.InnerText;
            getWeChat1.signType  = getWeChat.signType;
            getWeChat1.timeStamp = getWeChat.timeStamp;
            getWeChat1.paySign   = paySign;
            getWeChat1.orderId   = order.Id;

            return(new ApiResult {
                status = 1, data = getWeChat1
            });
        }
Exemplo n.º 16
0
        public async Task <ApiResult> Pay(OrderPayModel model)
        {
            int  orderStateId = (int)OrderStateEnum.待付款;
            User user         = JwtHelper.JwtDecrypt <User>(ControllerContext);
            var  dtos         = await orderApplyService.GetModelListAsync(user.Id);

            if (dtos.OrderApplies.Count() <= 0)
            {
                return(new ApiResult {
                    status = 0, msg = "下单列表无商品"
                });
            }
            long id = await orderService.AddAsync(model.DeliveryTypeId, 0, user.Id, model.AddressId, model.PayTypeId, orderStateId, dtos.OrderApplies);

            if (id <= 0)
            {
                if (id == -4)
                {
                    return(new ApiResult {
                        status = 0, msg = "订单中有商品已经下架,请重新下单", data = 0
                    });
                }
                if (id == -6)
                {
                    return(new ApiResult {
                        status = 0, msg = "用户账户已经冻结", data = id
                    });
                }
                return(new ApiResult {
                    status = 0, msg = "生成订单失败"
                });
            }
            OrderDTO order = await orderService.GetModelAsync(id);

            await goodsCarService.DeleteListAsync(user.Id);

            await orderApplyService.DeleteListAsync(user.Id);

            int payTypeId1 = (int)PayTypeEnum.微信;

            if (payTypeId1 != model.PayTypeId)
            {
                return(new ApiResult {
                    status = 0, msg = "请选择微信支付"
                });
            }

            WeChatPay weChatPay = new WeChatPay();

            weChatPay.body         = "订单支付";
            weChatPay.out_trade_no = order.Code;
            weChatPay.openid       = user.Code.Substring(3, 28);
            weChatPay.total_fee    = Math.Truncate(order.Amount * 100).ToString();
            string parm = HttpClientHelper.BuildParam(weChatPay);
            string key  = System.Configuration.ConfigurationManager.AppSettings["KEY"];

            parm = parm + "&key=" + key;
            string     sign       = CommonHelper.GetMD5(parm);
            HttpClient httpClient = new HttpClient();
            string     xml        = HttpClientHelper.ObjSerializeXml(weChatPay, sign);

            //CacheHelper.SetCache("App_Order_Pay" + weChatPay.out_trade_no, sign, DateTime.UtcNow.AddMinutes(2), TimeSpan.Zero);

            string res = await HttpClientHelper.GetResponseByPostXMLAsync(httpClient, xml, "https://api.mch.weixin.qq.com/pay/unifiedorder");

            if (!res.Contains("SUCCESS"))
            {
                return(new ApiResult {
                    status = 0, msg = res + "参数:" + parm
                });
            }
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(res);
            XmlNode Child = xmlDoc.SelectSingleNode("xml/prepay_id");

            TimeSpan  ts        = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            GetWechat getWeChat = new GetWechat();

            getWeChat.timeStamp = Convert.ToInt64(ts.TotalSeconds).ToString();
            getWeChat.package   = "prepay_id" + Child.InnerText;
            parm = HttpClientHelper.BuildParam(getWeChat);
            parm = parm.Replace("prepay_id", "prepay_id=");
            parm = parm + "&key=" + key;
            string paySign = CommonHelper.GetMD5(parm);

            GetWechat1 getWeChat1 = new GetWechat1();

            getWeChat1.appId     = getWeChat.appId;
            getWeChat1.nonceStr  = getWeChat.nonceStr;
            getWeChat1.package   = "prepay_id=" + Child.InnerText;
            getWeChat1.signType  = getWeChat.signType;
            getWeChat1.timeStamp = getWeChat.timeStamp;
            getWeChat1.paySign   = paySign;
            getWeChat1.orderId   = id;

            log.DebugFormat($"微信支付统一下单:时间{DateTime.Now},回调地址:{weChatPay.notify_url}");
            return(new ApiResult {
                status = 1, data = getWeChat1
            });
        }
Exemplo n.º 17
0
        public async Task <ApiResult> Applys(OrderApplysModel model)
        {
            int  orderStateId = (int)OrderStateEnum.待付款;
            User user         = JwtHelper.JwtDecrypt <User>(ControllerContext);
            var  dtos         = await orderApplyService.GetModelListAsync(user.Id);

            if (dtos.OrderApplies.Count() <= 0)
            {
                return(new ApiResult {
                    status = 0, msg = "下单列表无商品"
                });
            }
            long id = await orderService.AddAsync(model.DeliveryTypeId, 0, user.Id, model.AddressId, model.PayTypeId, orderStateId, dtos.OrderApplies);

            if (id <= 0)
            {
                if (id == -4)
                {
                    return(new ApiResult {
                        status = 0, msg = "订单中有商品已经下架,请重新下单", data = 0
                    });
                }
                if (id == -6)
                {
                    return(new ApiResult {
                        status = 0, msg = "用户账户已经冻结", data = id
                    });
                }
                return(new ApiResult {
                    status = 0, msg = "生成订单失败"
                });
            }
            await goodsCarService.DeleteListAsync(user.Id);

            await orderApplyService.DeleteListAsync(user.Id);

            OrderDTO dto = await orderService.GetModelAsync(id);

            if (model.PayTypeId == (int)PayTypeEnum.微信)//余额
            {
                long payResId = await userService.BalancePayAsync(id);

                if (payResId == -1)
                {
                    return(new ApiResult {
                        status = 0, msg = "订单不存在"
                    });
                }
                if (payResId == -2)
                {
                    return(new ApiResult {
                        status = 0, msg = "用户不存在", data = id
                    });
                }
                if (payResId == -3)
                {
                    return(new ApiResult {
                        status = 0, msg = "商品库存不足", data = id
                    });
                }
                if (payResId == -4)
                {
                    return(new ApiResult {
                        status = 0, msg = "用户账户余额不足", data = id
                    });
                }
                if (id == -6)
                {
                    return(new ApiResult {
                        status = 0, msg = "用户账户已经冻结", data = id
                    });
                }
            }
            return(new ApiResult {
                status = 1, msg = "支付成功", data = id
            });
        }
Exemplo n.º 18
0
        public OrderAddResponseDTO Add(OrderDTO orderDto, string role)
        {
            var order = new Order
            {
                EmployeeId  = orderDto.EmployeeId,
                IsDelivered = orderDto.IsDelivered,
                PlanId      = orderDto.PlanId,
                Shift       = orderDto.Shift,
                Plan        = _planRepository.GetById(orderDto.PlanId)
            };

            if ((DateTime.Now > order.Plan.EditableFrom && DateTime.Now <= order.Plan.EditableTo.AddHours(23).AddMinutes(59).AddSeconds(59)))
            {
                var orderDb = _orderRepository.GetByDateAndEmployee(order);
                if (orderDb == null)
                {
                    _orderRepository.Add(order);
                    return(new OrderAddResponseDTO {
                        Message = ""
                    });
                }
                else
                {
                    order.Id = orderDb.Id;
                    var differentShift = order.Shift != orderDb.Shift;

                    _orderRepository.Update(order);

                    if (differentShift)
                    {
                        return(new OrderAddResponseDTO {
                            Message = "Променет оброк за истиот датум од друга смена"
                        });
                    }
                    else
                    {
                        return(new OrderAddResponseDTO {
                            Message = ""
                        });
                    }
                }
            }
            else if (role == "HR")
            {
                var orderDb  = _orderRepository.GetByDateAndEmployee(order);
                var employee = _employeeRepository.GetById(order.EmployeeId);

                if (orderDb == null)
                {
                    _orderRepository.Add(order);
                    var emailBody = _emailManager.PrepareAddEmail(employee.Rfid, order.Plan.Date, order.Plan.Meal.Name, employee.Company.Name);
                    _emailManager.SendEmail("Додаден оброк", emailBody, employee.User.Email);
                    _emailManager.SendEmail("Додаден оброк", emailBody, "*****@*****.**");
                }
                else
                {
                    order.Id = orderDb.Id;
                    var oldMeal = orderDb.Plan.Meal.Name;

                    _orderRepository.Update(order);
                    var emailBody = _emailManager.PrepareEditEmail(employee.Rfid, order.Plan.Date, oldMeal, order.Plan.Meal.Name, employee.Company.Name);
                    _emailManager.SendEmail("Променет оброк", emailBody, employee.User.Email);
                    _emailManager.SendEmail("Додаден оброк", emailBody, "*****@*****.**");
                }


                return(new OrderAddResponseDTO {
                    Message = "Променет оброк надвор од периодот за промени"
                });
            }
            else
            {
                throw new Exception("Моментално сте надвор од периодот за избирање на овој оброк");
            }
        }
Exemplo n.º 19
0
        private void SaveExecute()
        {
            if (SelectedCustomer == null) return;

            try
            {
                var client = new ERPModuleServiceClient();

                client.AddNewOrderCompleted += delegate(object sender, AddNewOrderCompletedEventArgs e)
                {
                    if (e.Error == null)
                    {
                        if (e.Result == null)
                        {
                            MessageBox.Show("Order exceeds the maximum allowed amount", "Unable to perform the order", MessageBoxButton.OK);
                        }
                        else
                        {
                            Order = new OrderDTO();
                            SelectedCustomer = null;
                            VisualStateManager.GoToState(((MainPage)App.Current.RootVisual), "ToOrderList", true);
                            MessageDispatcher.NotifyColleagues(DispatcherMessages.RefreshOrders,null);
                        }
                    }
                    else if (e.Error is FaultException<ServiceError>)
                    {
                        var fault = e.Error as FaultException<ServiceError>;
                        MessageBox.Show(fault.Detail.ErrorMessage, "Error", MessageBoxButton.OK);
                    }
                    else
                    {
                        Debug.WriteLine("GetOrders: Error at Service:" + e.Error.ToString());
                    }
                };

                Order.CustomerId = SelectedCustomer.Id;
                Order.OrderDate = DateTime.Now;

                client.AddNewOrderAsync(Order);
            }
            catch (FaultException<ServiceError> excep)
            {
                Debug.WriteLine("GetOrders: Error at Service:" + excep.ToString());
            }
        }
Exemplo n.º 20
0
 public int tblOrder_insert(OrderDTO dt)
 {
     return oDao.tblOrder_insert(dt);
 }
Exemplo n.º 21
0
 private void AcceptsOrderDTO(OrderDTO dto)
 {
 }
 public ActionResult <int> Post([FromBody] OrderDTO dto)
 {
     return(Ok(orderService.PlaceOrder(new Order(dto))));
 }
Exemplo n.º 23
0
 private void AcceptsOrderDTO_Query([FromQuery] OrderDTO dto)
 {
 }
Exemplo n.º 24
0
        public static List <OrderDTO> GetPreviousOrdersByDate(string UserId, DateTime?fromDate, DateTime?toDate)
        {
            List <OrderDTO> orderDTOList = new List <OrderDTO>();
            OrderDTO        orderDTO;

            try
            {
                //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB", false);
                LinqToSqlDataContext db = new LinqToSqlDataContext();

                var OrderDtls = (from order in db.Orders
                                 join Ins in db.Installers on order.InstallerId equals Ins.InstallerCompanyID
                                 where
                                 ((fromDate == null || toDate == null) ||
                                  (order.OrderDate <= toDate) && (order.OrderDate >= fromDate)) &&
                                 order.OrderStatusId != 1 && order.UserId == new Guid(UserId)
                                 select new
                {
                    order.OrderId,
                    order.OrderDate,
                    order.OrderNo,
                    order.OrderRefNo,
                    order.DeliveryCost,
                    order.Amount,
                    order.OrderTotalAmount,
                    order.VATRate,
                    Ins.CompanyName
                }).OrderByDescending(x => x.OrderDate).Take(200);

                foreach (var o in OrderDtls)
                {
                    orderDTO                  = new OrderDTO();
                    orderDTO.OrderId          = o.OrderId;
                    orderDTO.OrderDate        = o.OrderDate;
                    orderDTO.CSLOrderNo       = o.OrderNo;
                    orderDTO.ARCOrderRefNo    = o.OrderRefNo;
                    orderDTO.CompanyName      = o.CompanyName.Length > 20 ? o.CompanyName.Substring(0, 17) + "..." : o.CompanyName;
                    orderDTO.TotalAmountToPay = Math.Round(((o.Amount + o.DeliveryCost) + (o.Amount + o.DeliveryCost) * o.VATRate), 2).ToString();

                    var orderItem = (from oi in db.OrderItems
                                     where oi.OrderId == o.OrderId
                                     group oi by oi.OrderId into qty
                                     select new
                    {
                        ProductQty = qty.Sum(oi => oi.ProductQty)
                    }
                                     ).FirstOrDefault();

                    if (orderItem != null)
                    {
                        orderDTO.OrderQty = orderItem.ProductQty.ToString();
                    }
                    else
                    {
                        orderDTO.OrderQty = "0.00";
                    }

                    orderDTOList.Add(orderDTO);
                }
            }
            catch (Exception objException)
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("ARC Ordering", "GetPreviousOrdersByDate", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, null);
            }

            return(orderDTOList);
        }
Exemplo n.º 25
0
 public static void Update(int id, OrderDTO order, JewelleryDBEntities db)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 26
0
        /// <summary>
        /// 解析订单,订单来源京东仓,抓不到用户手机号
        /// </summary>
        /// <param name="csv"></param>
        /// <param name="file"></param>
        /// <param name="items"></param>
        protected void ResolveOrders_NoPhone(CsvReader csv, string file, ref List <OrderEntity> items)
        {
            csv.Read();
            csv.ReadHeader();

            OrderDTO orderDTO = new OrderDTO();

            orderDTO.fileName = file;
            List <string> badRecord = new List <string>();

            csv.Configuration.BadDataFound = context => badRecord.Add(context.RawRecord);
            while (csv.Read())
            {
                using (var db = new OMSContext())
                {
                    orderDTO.sourceSN = csv.GetField <string>("订单号").Trim();//京东订单号已科学计数的格式显示,需要变回数值
                    orderDTO.sourceSN = decimal.Parse(orderDTO.sourceSN, NumberStyles.Float).ToString();
                    var status = csv.GetField <string>("订单状态").Trim();

                    if (string.IsNullOrEmpty(orderDTO.sourceSN))
                    {
                        //TODO:
                        InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull);
                        continue;
                    }
                    else if (status == "(删除)等待出库")
                    {
                        continue;
                    }
                    string ordertype = csv.GetField <string>("订单类型").Trim();

                    orderDTO.fileName   = file;
                    orderDTO.source     = OrderSource.JINGDONG;
                    orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.JINGDONG);


                    switch (ordertype)
                    {
                    case "销售订单":
                        orderDTO.orderType   = 0;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;

                    case "换货订单":
                    case "补发货订单":
                        orderDTO.orderType   = 1;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;

                    case "退货退钱订单":
                        orderDTO.orderType   = 2;
                        orderDTO.orderStatus = OrderStatus.Cancelled;
                        break;

                    default:
                        orderDTO.orderType   = 0;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;
                    }

                    var order = db.OrderSet.FirstOrDefault(o => o.SourceSn == orderDTO.sourceSN && o.Source == orderDTO.source);

                    if (order == null)//新增订单信息
                    {
                        // Util.Logs.Log.GetLog(nameof(AppServer)).Error($"ERP导出单:{file}。该文件中订单编号:{sn}在OMS系统中不存在");

                        ResolveOrdersFromJD(csv, orderDTO, items);
                    }
                    else
                    {
                    }
                    OnUIMessageEventHandle($"ERP导出单:{file}。该文件中订单编号:{orderDTO.sourceSN}解析完毕");
                }
            }


            if (badRecord.Count > 0)
            {
                foreach (var item in badRecord)
                {
                    Util.Logs.Log.GetLog(nameof(ERPExcelOrderOption)).Debug(item);
                }
            }
        }
Exemplo n.º 27
0
        public async Task <OrderDTO> GetSubmitOrderData(SubmitOrderRequest request)
        {
            Customer customer = kenticoUsers.GetCurrentCustomer();

            var notificationEmails = request.EmailConfirmation.Union(new[] { customer.Email });

            if ((request?.DeliveryAddress?.Id ?? 0) < 0)
            {
                shoppingCart.SetShoppingCartAddress(request.DeliveryAddress);
                customer.FirstName = request.DeliveryAddress.CustomerName;
                customer.LastName  = string.Empty;
                customer.Email     = request.DeliveryAddress.Email;
                customer.Phone     = request.DeliveryAddress.Phone;
            }

            var shippingAddress = shoppingCart.GetCurrentCartShippingAddress();

            shippingAddress.Country = localization.GetCountries().FirstOrDefault(c => c.Id == shippingAddress.Country.Id);
            shippingAddress.State   = localization.GetStates().FirstOrDefault(c => c.Id == shippingAddress.State.Id);
            var billingAddress = shoppingCart.GetDefaultBillingAddress();
            var billingState   = localization.GetStates().FirstOrDefault(c => c.Id == billingAddress.StateId);
            var site           = siteProvider.GetKenticoSite();
            var paymentMethod  = shoppingCart.GetPaymentMethod(request.PaymentMethod.Id);
            var cartItems      = shoppingCart.GetShoppingCartItems();
            var currency       = siteProvider.GetSiteCurrency();
            var totals         = shoppingCart.GetShoppingCartTotals();

            totals.TotalTax = await taxService.EstimateTotalTax(shippingAddress);

            if (string.IsNullOrWhiteSpace(customer.Company))
            {
                customer.Company = settings.DefaultCustomerCompanyName;
            }

            foreach (var item in cartItems.Where(i => i.IsTemplated))
            {
                var taskId = await CallRunGeneratePdfTask(item);

                item.DesignFilePathTaskId = taskId;
            }

            var orderDto = new OrderDTO()
            {
                BillingAddress  = orderDataFactory.CreateBillingAddress(billingAddress, billingState?.StateDisplayName),
                ShippingAddress = orderDataFactory.CreateShippingAddress(shippingAddress, customer),
                Customer        = orderDataFactory.CreateCustomer(customer),
                OrderDate       = DateTime.Now,
                PaymentOption   = orderDataFactory.CreatePaymentOption(paymentMethod, request),
                Site            = new SiteDTO()
                {
                    KenticoSiteID   = site.Id,
                    KenticoSiteName = site.Name,
                    ErpCustomerId   = site.ErpCustomerId
                },
                OrderCurrency = new CurrencyDTO()
                {
                    CurrencyCode      = currency.Code,
                    KenticoCurrencyID = currency.Id
                },
                OrderStatus = new OrderStatusDTO()
                {
                    KenticoOrderStatusID = kenticoOrder.GetOrderStatusId("Pending"),
                    OrderStatusName      = "PENDING"
                },
                TotalPrice        = totals.TotalItemsPrice,
                TotalShipping     = totals.TotalShipping,
                TotalTax          = totals.TotalTax,
                Items             = cartItems.Select(item => MapCartItemTypeToOrderItemType(item)),
                NotificationsData = notificationEmails.Select(e => new NotificationInfoDto
                {
                    Email    = e,
                    Language = customer.PreferredLanguage
                })
            };

            // If only mailing list items in cart, we are not picking any delivery option
            if (!cartItems.All(i => i.IsMailingList))
            {
                var deliveryMethod = shoppingCart.GetShippingOption(request.DeliveryMethod);
                orderDto.ShippingOption = new ShippingOptionDTO()
                {
                    KenticoShippingOptionID = deliveryMethod.Id,
                    CarrierCode             = deliveryMethod.SAPName,
                    ShippingCompany         = deliveryMethod.CarrierCode,
                    ShippingService         = deliveryMethod.Service.Replace("#", "")
                };
            }

            return(orderDto);
        }
Exemplo n.º 28
0
        protected override bool InputProductInfoWithoutSaveChange(OMSContext db, OrderDTO orderDTO, OrderEntity item)
        {
            if (string.IsNullOrEmpty(orderDTO.productsku))//京东订单的productsku===sku,若值为null ,意味着用户取消了订单,这个订单不计入OMS
            {
                return(false);
            }
            var foo = db.ProductsSet.Include(p => p.weightModel).FirstOrDefault(p => p.sku.Trim() == orderDTO.productsku);



            if (foo == null)
            {
                OnUIMessageEventHandle($"订单文件:{orderDTO.fileName}中平台单号:{orderDTO.sourceSN}({orderDTO.productsku})对应ERP商品记录未找到");
                InputExceptionOrder(orderDTO, ExceptionType.ProductCodeUnKnown);
                return(false);
            }

            /*
             * 订单来源是ERP,同时商品SKU是周期购商品的SKU,判定为周期购日常发货订单
             * 周期购日常发货订单不纳入日常统计中,为了和客户下的周期购订单区分开
             * 统计报表中只统计销售订单
             *
             */
            if (foo.sku == "S0010030002" || foo.sku == "S0010040002")//标识该订单是周期购订单
            {
                item.OrderType += 4;
            }
            var     bar    = item.Products.FirstOrDefault(p => p.sku == foo.sku);
            decimal weight = foo == null ? 0 : foo.QuantityPerUnit * orderDTO.count;

            if (bar == null)
            {
                OrderProductInfo orderProductInfo = new OrderProductInfo()
                {
                    ProductPlatId   = orderDTO.productsku,
                    ProductPlatName = orderDTO.productName,
                    //   Warehouse = item.OrderLogistics.Logistics,
                    MonthNum       = orderDTO.createdDate.Month,
                    weightCode     = foo.weightModel == null ? 0 : foo.weightModel.Code,
                    weightCodeDesc = foo.weightModel == null ? string.Empty : $"{foo.weightModel.Value}g",
                    OrderSn        = orderDTO.orderSN,
                    TotalAmount    = orderDTO.totalAmount,
                    DiscountFee    = orderDTO.discountFee,
                    AmounPerUnit   = orderDTO.pricePerUnit,
                    ProductCount   = orderDTO.count,
                    ProductWeight  = weight,
                    Source         = orderDTO.source,
                    sku            = foo.sku
                };
                item.Products.Add(orderProductInfo);
            }
            else
            {
                bar.ProductWeight += weight;
                bar.ProductCount  += orderDTO.count;
            }



            OnUIMessageEventHandle($"订单文件:{orderDTO.fileName}中平台单号:{orderDTO.sourceSN}({orderDTO.productsku})解析完毕");
            return(true);
        }
Exemplo n.º 29
0
 public async Task Insert(OrderDTO obj)
 {
     var model = _mapper.Map <OrderDTO, Order>(obj);
     await UOW.OrderRepository.Insert(model);
 }
Exemplo n.º 30
0
        /// <summary>
        /// 解析订单,订单来源ERP导出单
        /// </summary>
        /// <param name="csv">待解析目标对象</param>
        /// <param name="file">待解析目标文件名</param>
        /// <param name="items">已解析订单集合</param>
        protected void ResolveOrders(CsvReader csv, string file, ref List <OrderEntity> items)
        {
            csv.Read();
            csv.ReadHeader();

            OrderDTO orderDTO = new OrderDTO();

            orderDTO.fileName = file;
            List <string> badRecord = new List <string>();

            csv.Configuration.BadDataFound = context => badRecord.Add(context.RawRecord);
            while (csv.Read())
            {
                using (var db = new OMSContext())
                {
                    var desc = csv.GetField <string>("店铺名称").Trim();

                    var config = AppServer.Instance.ConfigDictionary.Values.FirstOrDefault(c => c.Tag.Contains(desc));
                    if (config == null)
                    {
                        OnUIMessageEventHandle($"ERP导出单:{file}。未识别的订单渠道:{desc}");

                        continue;
                    }
                    else if (config.Name != OrderSource.JINGDONG && config.Name != OrderSource.TIANMAO)
                    {
                        continue;
                    }

                    orderDTO.sourceSN = csv.GetField <string>("平台单号").Trim();


                    if (string.IsNullOrEmpty(orderDTO.sourceSN))
                    {
                        //TODO:
                        InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull);
                        continue;
                    }
                    string ordertype = csv.GetField <string>("订单类型").Trim();

                    orderDTO.fileName   = file;
                    orderDTO.source     = config.Name;
                    orderDTO.sourceDesc = desc;
                    orderDTO.sourceSN   = csv.GetField <string>("平台单号").Trim();

                    switch (ordertype)
                    {
                    case "销售订单":
                        orderDTO.orderType   = 0;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;

                    case "换货订单":
                    case "补发货订单":
                        orderDTO.orderType   = 1;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;

                    case "退货退钱订单":
                        orderDTO.orderType   = 2;
                        orderDTO.orderStatus = OrderStatus.Cancelled;
                        break;

                    default:
                        orderDTO.orderType   = 0;
                        orderDTO.orderStatus = OrderStatus.Delivered;
                        break;
                    }

                    var order = db.OrderSet.FirstOrDefault(o => o.SourceSn == orderDTO.sourceSN);

                    if (order == null)//新增订单信息
                    {
                        // Util.Logs.Log.GetLog(nameof(AppServer)).Error($"ERP导出单:{file}。该文件中订单编号:{sn}在OMS系统中不存在");

                        ResolveOrdersFromERPExcel(csv, orderDTO, items);
                    }
                    else
                    {
                    }
                    OnUIMessageEventHandle($"ERP导出单:{file}。该文件中订单编号:{orderDTO.sourceSN}解析完毕");
                }
            }


            if (badRecord.Count > 0)
            {
                foreach (var item in badRecord)
                {
                    Util.Logs.Log.GetLog(nameof(ERPExcelOrderOption)).Debug(item);
                }
            }
        }
Exemplo n.º 31
0
 public async Task Update(OrderDTO obj)
 {
     var model = _mapper.Map <OrderDTO, Order>(obj);
     await UOW.OrderRepository.Update(model);
 }
Exemplo n.º 32
0
        public async Task <ActionResult> CheckoutCart([Bind(Include = "address, payment")] OrderDTO order,
                                                      string listObject, string firstname, string lastname, string email)
        {
            IEnumerable <ToyDTO> listToy = JsonConvert.DeserializeObject <IEnumerable <ToyDTO> >(listObject);

            if (Session["USER"] != null)
            {
                string username = Session["USER"].ToString();
                order.cusID = username;
                HttpResponseMessage response = await client.PostAsJsonAsync(baseURL + "Orders", order);

                string strResponse = response.Content.ReadAsStringAsync().Result;
                int    orderID     = JsonConvert.DeserializeObject <int>(strResponse);
                List <OrderDetailDTO> listDetail = new List <OrderDetailDTO>();
                foreach (ToyDTO item in listToy)
                {
                    listDetail.Add(new OrderDetailDTO
                    {
                        name     = item.name,
                        orderID  = orderID,
                        price    = item.price,
                        toyID    = item.id,
                        quantity = item.quantity
                    });
                }
                response = await client.PostAsJsonAsync(baseURL + "OrderDetails", listDetail);

                if (response.StatusCode == HttpStatusCode.Created)
                {
                    return(RedirectToAction("TransactionHistory", "tblCustomers"));
                }
            }
            else
            {
                string      randomUser = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                CustomerDTO cus        = new CustomerDTO
                {
                    username  = randomUser,
                    firstname = email,
                    lastname  = firstname + " " + lastname
                };
                HttpResponseMessage response = await client.PostAsJsonAsync(baseURL + "Customers", cus);

                if (response.IsSuccessStatusCode)
                {
                    string      stringResponse = response.Content.ReadAsStringAsync().Result;
                    CustomerDTO customer       = JsonConvert.DeserializeObject <CustomerDTO>(stringResponse);
                    if (customer != null)
                    {
                        order.cusID = randomUser;
                        response    = await client.PostAsJsonAsync(baseURL + "Orders", order);

                        string strResponse = response.Content.ReadAsStringAsync().Result;
                        int    orderID     = JsonConvert.DeserializeObject <int>(strResponse);
                        List <OrderDetailDTO> listDetail = new List <OrderDetailDTO>();
                        foreach (ToyDTO item in listToy)
                        {
                            listDetail.Add(new OrderDetailDTO
                            {
                                name     = item.name,
                                orderID  = orderID,
                                price    = item.price,
                                toyID    = item.id,
                                quantity = item.quantity
                            });
                        }
                        response = await client.PostAsJsonAsync(baseURL + "OrderDetails", listDetail);

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 33
0
 public IHttpActionResult Put([FromBody] OrderDTO dto)
 {
     _logic.Update(dto);
     return(Ok());
 }
Exemplo n.º 34
0
 public string AddOrder(OrderDTO order)
 {
     return(orderManager.Add(order));
 }
Exemplo n.º 35
0
 public static OrderDTO CreateOrderDTO(int ID, int version, int currencyId, global::System.DateTime orderDate, int status, int supplierId, global::System.Collections.ObjectModel.ObservableCollection<OrderLineDTO> orderLines)
 {
     OrderDTO orderDTO = new OrderDTO();
     orderDTO.Id = ID;
     orderDTO.Version = version;
     orderDTO.CurrencyId = currencyId;
     orderDTO.OrderDate = orderDate;
     orderDTO.Status = status;
     orderDTO.SupplierId = supplierId;
     if ((orderLines == null))
     {
         throw new global::System.ArgumentNullException("orderLines");
     }
     orderDTO.OrderLines = orderLines;
     return orderDTO;
 }
Exemplo n.º 36
0
 private OrderDTO GetOrderDTO()
 {
     OrderDTO oDTO = new OrderDTO();
     oDTO.CustomerID = CustomerID;
     oDTO.OrderID = this.txtOrderID.Text;
     oDTO.PersonCreate = this.txtPersonCreate.Text;
     oDTO.CreateDate = convertStringToDate(this.txtCreateDate.Text);
     oDTO.DeliveryDate = convertStringToDate(txtDeliveryDate.Text);
     oDTO.DeliveryMethod = txtDiliveryMethod.Text;
     oDTO.PaymentMethod = txtPaymentMethod.Text;
     oDTO.Status = bool.Parse(drlStatus.SelectedValue);
     oDTO.HandSel = float.Parse(txtHandsel.Text);
     return oDTO;
 }
Exemplo n.º 37
0
 public int tblOrder_insert(OrderDTO dt)
 {
     string sql = "INSERT INTO tblOrder(OrderID, CreateDate, CustomerID, PersonCreate, Status, DeliveryDate, DeliveryMethod, PaymentMethod, HandSel) " +
                  "VALUES(@OrderID, @CreateDate, @CustomerID, @PersonCreate, @Status, @DeliveryDate, @DeliveryMethod, @PaymentMethod, @HandSel)";
     SqlCommand cmd = new SqlCommand(sql, ConnectionData._MyConnection, ConnectionData._MyTransaction);
     cmd.CommandType = CommandType.Text;
     cmd.Parameters.Add("@OrderID", SqlDbType.NVarChar).Value = dt.OrderID;
     cmd.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value = dt.CreateDate;
     cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = dt.CustomerID;
     cmd.Parameters.Add("@PersonCreate", SqlDbType.NVarChar).Value = dt.PersonCreate;
     cmd.Parameters.Add("@Status", SqlDbType.Bit).Value = dt.Status;
     cmd.Parameters.Add("@DeliveryDate", SqlDbType.DateTime).Value = dt.DeliveryDate;
     cmd.Parameters.Add("@DeliveryMethod", SqlDbType.NVarChar).Value = dt.DeliveryMethod;
     cmd.Parameters.Add("@PaymentMethod", SqlDbType.NVarChar).Value = dt.PaymentMethod;
     cmd.Parameters.Add("@HandSel", SqlDbType.Float).Value = dt.HandSel;
     if (ConnectionData._MyConnection.State == ConnectionState.Closed)
     {
         ConnectionData._MyConnection.Open();
     }
      int  row = cmd.ExecuteNonQuery();
      cmd.Dispose();
      return row;
 }
Exemplo n.º 38
0
 public int tblOrder_update(OrderDTO dt)
 {
     return oDao.tblOrder_update(dt);
 }
Exemplo n.º 39
0
 protected override void Because_of()
 {
     var orderModel = new OrderModel()
     {
         Number = "1",
         Vendor = null
     };
     _dto = Mapper.Map<OrderDTO>(orderModel);
 }
Exemplo n.º 40
0
 public void AddToOrders(OrderDTO orderDTO)
 {
     base.AddObject("Orders", orderDTO);
 }
Exemplo n.º 41
0
        public Order(OrderDTO orderDTO)
        {
            this.Books = new List <Book>();

            // TODO: Make order from orderDTO
        }
Exemplo n.º 42
0
 public void AssignedOrder(OrderDTO order)
 {
     Clients.Group("Operator").assignedDrOrder(order);
 }
Exemplo n.º 43
0
 public void ComplexModel([FromQuery] OrderDTO order)
 {
 }
Exemplo n.º 44
0
    public int tblOrder_update(OrderDTO dt)
    {
        string sql = "UPDATE tblOrder SET "+
                "CreateDate = @CreateDate, "+
                "CustomerID = @CustomerID, "+
                "PersonCreate = @PersonCreate, "+
                "Status = @Status, "+
                "DeliveryDate = @DeliveryDate, "+
                "DeliveryMethod = @DeliveryMethod, " +
                "HandSel = @HandSel, " +
                "PaymentMethod = @PaymentMethod " +
                "WHERE OrderID = @OrderID ";

        SqlCommand cmd = new SqlCommand(sql, ConnectionData._MyConnection,ConnectionData._MyTransaction);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.Add("@OrderID", SqlDbType.NVarChar).Value = dt.OrderID;
        cmd.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value = dt.CreateDate;
        cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = dt.CustomerID;
        cmd.Parameters.Add("@PersonCreate", SqlDbType.NVarChar).Value = dt.PersonCreate;
        cmd.Parameters.Add("@Status", SqlDbType.Bit).Value = dt.Status;
        cmd.Parameters.Add("@DeliveryDate", SqlDbType.DateTime).Value = dt.DeliveryDate;
        cmd.Parameters.Add("@DeliveryMethod", SqlDbType.NVarChar).Value = dt.DeliveryMethod;
        cmd.Parameters.Add("@PaymentMethod", SqlDbType.NVarChar).Value = dt.PaymentMethod;
        cmd.Parameters.Add("@HandSel", SqlDbType.Float).Value = dt.HandSel;
        if (ConnectionData._MyConnection.State == ConnectionState.Closed)
        {
            ConnectionData._MyConnection.Open();
        }
        int row = cmd.ExecuteNonQuery();
        cmd.Dispose();
        return row;
    }
Exemplo n.º 45
0
        public static OrderDTO GetOrderDetail(int orderId)
        {
            OrderDTO orderDTO = new OrderDTO();

            try
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB", false);
                LinqToSqlDataContext db = new LinqToSqlDataContext();

                var OrderDtls = (from order in db.Orders
                                 join dlvry in db.DeliveryTypes on order.DeliveryTypeId equals dlvry.DeliveryTypeId
                                 where order.OrderId == orderId
                                 select new
                {
                    order.InstallerId,
                    order.UserName,
                    order.UserEmail,
                    order.CreatedBy,
                    order.OrderDate,
                    order.OrderNo,
                    order.OrderRefNo,
                    order.SpecialInstructions,
                    order.DeliveryCost,
                    order.Amount,
                    order.OrderTotalAmount,
                    order.VATRate,
                    dlvry.DeliveryCompanyName,
                    dlvry.DeliveryShortDesc,
                    dlvry.DeliveryPrice,
                    order.UserId,
                    order.InstallationAddressID
                }).SingleOrDefault();

                var orderItem = (from oi in db.OrderItems
                                 where oi.OrderId == orderId
                                 group oi by oi.OrderId into qty
                                 select new
                {
                    ProductQty = qty.Sum(oi => oi.ProductQty)
                }
                                 ).FirstOrDefault();

                orderDTO.UserName            = OrderDtls.UserName;
                orderDTO.UserEmail           = OrderDtls.UserEmail;
                orderDTO.OrderDate           = OrderDtls.OrderDate;
                orderDTO.CSLOrderNo          = OrderDtls.OrderNo;
                orderDTO.ARCOrderRefNo       = OrderDtls.OrderRefNo;
                orderDTO.CreatedBy           = OrderDtls.CreatedBy;
                orderDTO.InstallerId         = OrderDtls.InstallerId.ToString();
                orderDTO.SpecialInstructions = OrderDtls.SpecialInstructions;
                orderDTO.DeliveryCost        = Math.Round(OrderDtls.DeliveryCost, 2).ToString();
                orderDTO.OrderTotal          = Math.Round(OrderDtls.Amount, 2).ToString();
                orderDTO.DeliveryType        = OrderDtls.DeliveryCompanyName + " - " + OrderDtls.DeliveryShortDesc + " - " + OrderDtls.DeliveryPrice.ToString("c");
                orderDTO.VATAmount           = Math.Round((OrderDtls.Amount + OrderDtls.DeliveryCost) * OrderDtls.VATRate, 2).ToString();
                orderDTO.TotalAmountToPay    = Math.Round(((OrderDtls.Amount + OrderDtls.DeliveryCost) + (OrderDtls.Amount + OrderDtls.DeliveryCost) * OrderDtls.VATRate), 2).ToString();
                orderDTO.UserId = (Guid)OrderDtls.UserId;
                orderDTO.InstallationAddressId = OrderDtls.InstallationAddressID;
                if (orderItem != null)
                {
                    orderDTO.OrderQty = orderItem.ProductQty.ToString();
                }
                else
                {
                    orderDTO.OrderQty = "0.00";
                }
            }
            catch (Exception objException)
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("ARC Ordering", "GetOrderDetail", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, null);
            }

            return(orderDTO);
        }
 private void AcceptsOrderDTO(OrderDTO dto)
 {
 }
Exemplo n.º 47
0
        public static List <OrderDTO> GetPreviousOrders(String UserId)
        {
            List <OrderDTO> orderDTOList = new List <OrderDTO>();
            OrderDTO        orderDTO;
            DateTime        toDate   = DateTime.Now;
            DateTime        fromDate = DateTime.Now.AddDays(-1);

            try
            {
                Guid userID             = new Guid(UserId);
                LinqToSqlDataContext db = new LinqToSqlDataContext();
                bool arc_Manager        = false;
                if (Roles.GetRolesForUser().Contains("ARC_Manager"))
                {
                    arc_Manager = true;
                }
                int ARCID = (from arc in db.ARC_User_Maps
                             where arc.UserId == userID
                             select arc.ARCId).FirstOrDefault();

                var OrderDtls = (from order in db.Orders
                                 join Ins in db.Installers on order.InstallerId equals Ins.InstallerCompanyID

                                 where order.OrderStatusId != 1 &&
                                 order.UserId == (arc_Manager ? order.UserId : userID) &&
                                 order.ARCId == ARCID
                                 select new
                {
                    order.OrderId,
                    order.OrderDate,
                    order.OrderNo,
                    order.OrderRefNo,
                    order.DeliveryCost,
                    order.Amount,
                    order.OrderTotalAmount,
                    order.VATRate,
                    Ins.CompanyName,
                }).OrderByDescending(x => x.OrderDate).Take(200);

                foreach (var o in OrderDtls)
                {
                    orderDTO                  = new OrderDTO();
                    orderDTO.OrderId          = o.OrderId;
                    orderDTO.OrderDate        = o.OrderDate;
                    orderDTO.CSLOrderNo       = o.OrderNo;
                    orderDTO.ARCOrderRefNo    = o.OrderRefNo;
                    orderDTO.CompanyName      = o.CompanyName.Length > 20 ? o.CompanyName.Substring(0, 17) + "..." : o.CompanyName;
                    orderDTO.TotalAmountToPay = Math.Round(((o.Amount + o.DeliveryCost) + (o.Amount + o.DeliveryCost) * o.VATRate), 2).ToString();
                    var orderItem = (from oi in db.OrderItems
                                     where oi.OrderId == o.OrderId
                                     group oi by oi.OrderId into qty
                                     select new
                    {
                        ProductQty = qty.Sum(oi => oi.ProductQty)
                    }
                                     ).FirstOrDefault();

                    if (orderItem != null)
                    {
                        orderDTO.OrderQty = orderItem.ProductQty.ToString();
                    }
                    else
                    {
                        orderDTO.OrderQty = "0.00";
                    }

                    orderDTOList.Add(orderDTO);
                }
            }
            catch (Exception objException)
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("ARC Ordering", "GetPreviousOrders", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, null);
            }

            return(orderDTOList);
        }