Ejemplo n.º 1
0
        public TResult Print(string orderNo, string printKey)
        {
            var result = new TResult();

            try
            {
                var printConfigData = _printGateway.Get(printKey);
                if (printConfigData == null)
                {
                    return(result.FailureResult("打印机编号不存在,请进行补打"));
                }
                var tbl_Order = _orderService.Get(orderNo);
                if (tbl_Order == null)
                {
                    return(result.FailureResult("订单不存在"));
                }
                var tbl_Scenic       = _scenicService.Get(tbl_Order.ScenicId);
                var tbl_OrderDetails = _orderDetailService.GetList(orderNo);

                foreach (var row in tbl_OrderDetails)
                {
                    Print(printConfigData, tbl_Scenic, row);
                }
                return(result.SuccessResult());
            }
            catch (Exception e)
            {
                return(result.FailureResult("打印系统繁忙,请稍后进行补打."));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建订单基础数据验证
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public DataValidResult ValidDataForOrderCreateRequest(OrderCreateRequest request, OrderCreateResponse response)
        {
            var orderInfo = request.Body.OrderInfo;
            var result    = new DataValidResult {
                Status = false
            };

            if (orderInfo.ContactPerson == null)
            {
                result.Code    = "113001";
                result.Message = "创建订单异常,取票人信息为空";
                return(result);
            }
            if (string.IsNullOrEmpty(orderInfo.ContactPerson.Name))
            {
                result.Code    = "113002";
                result.Message = "创建订单异常,取票人姓名不能为空";
                return(result);
            }
            if (string.IsNullOrEmpty(orderInfo.ContactPerson.Mobile))
            {
                result.Code    = "113003";
                result.Message = "创建订单异常,取票人手机号码不能为空";
                return(result);
            }
            if (!RegexValidation.IsCellPhone(orderInfo.ContactPerson.Mobile))
            {
                result.Code    = "113004";
                result.Message = "创建订单异常,取票人手机号码异常";
                return(result);
            }
            if (!string.IsNullOrEmpty(orderInfo.ContactPerson.CardType))
            {
                if (orderInfo.ContactPerson.CardType.ToUpper() == "ID_CARD" && !string.IsNullOrEmpty(orderInfo.ContactPerson.CardNo))
                {
                    if (!RegexValidation.IsIdCard(orderInfo.ContactPerson.CardNo))
                    {
                        result.Code    = "113005";
                        result.Message = "创建订单异常,游客身份证信息输入有误";
                        return(result);
                    }
                }
            }

            if (string.IsNullOrEmpty(orderInfo.OrderOtaId))
            {
                result.Code    = "113006";
                result.Message = "创建订单异常,OTA订单id不能为空";
                return(result);
            }
            if (orderInfo.OrderPrice <= 0)
            {
                result.Code    = "113007";
                result.Message = "创建订单异常,订单总金额不能小于0";
                return(result);
            }
            if (orderInfo.OrderQuantity <= 0)
            {
                result.Code    = "113008";
                result.Message = "创建订单异常,订票总数量不能小于1";
                return(result);
            }
            if (!orderInfo.VisitDate.IsDataTime())
            {
                result.Code    = "113009";
                result.Message = "创建订单异常,游玩日期格式不合法";
                return(result);
            }
            if (orderInfo.TicketList == null || orderInfo.TicketList.Count <= 0)
            {
                result.Code    = "113010";
                result.Message = "创建订单异常,购买产品的数量不能小于1";
                return(result);
            }
            if (orderInfo.TicketList.Sum(a => a.Quantity) != orderInfo.OrderQuantity)
            {
                result.Code    = "113011";
                result.Message = "创建订单异常,购买产品的总数量和订票总数量不符";
                return(result);
            }
            if (orderInfo.TicketList.Sum(a => a.SellPrice * a.Quantity) != orderInfo.OrderPrice)
            {
                result.Code    = "113012";
                result.Message = "创建订单异常,购买产品的总金额和订票总金额不符";
                return(result);
            }
            foreach (var row in orderInfo.TicketList)
            {
                if (row.Quantity <= 0)
                {
                    result.Code    = "113013";
                    result.Message = "创建订单异常,购买产品的游客人数不能小于1";
                    return(result);
                }
                if (row.ProductId <= 0)
                {
                    result.Code    = "113014";
                    result.Message = "创建订单异常,购买产品的id不合法";
                    return(result);
                }
                if (orderInfo.TicketList == null)
                {
                    result.Code    = "113015";
                    result.Message = "创建订单异常,购买产品的数据不合法";
                    return(result);
                }
                if (row.SellPrice <= 0)
                {
                    result.Code    = "113016";
                    result.Message = "创建订单异常,购买产品的金额不合法";
                    return(result);
                }
            }

            if (orderInfo.OrderPayStatus > 1 || orderInfo.OrderPayStatus < 0)
            {
                result.Code    = "113017";
                result.Message = "创建订单异常,是否收款超出范围";
                return(result);
            }
            //验证OTA订单id是否已存在
            var tbl_Order = GetOrderBy(request.Body.OrderInfo.OrderOtaId);

            if (tbl_Order != null)
            {
                var tbl_OrderDetails = _orderDetailService.GetList(tbl_Order.OrderNo);
                result.Code    = "000000";
                result.Message = "成功,重复提交订单";
                response.Body  = new OrderCreateInfo
                {
                    OtaOrderId  = tbl_Order.OTAOrderNo,
                    OrderId     = tbl_Order.OrderNo,
                    OrderStatus = "OREDER_SUCCESS",
                    Item        = new List <OrderCreateItem>()
                };
                foreach (var row in tbl_OrderDetails)
                {
                    response.Body.Item.Add(new OrderCreateItem
                    {
                        OtaOrderDetailId = row.OtaOrderDetailId,
                        ProductId        = row.TicketId.ToString(),
                        useDate          = row.ValidityDateStart.ToString("yyyy-MM-dd"),
                        CertificateNo    = row.CertificateNO,
                        quantity         = 500000
                    });
                }
                return(result);
            }
            result.Status = true;
            return(result);
        }