示例#1
0
        public ResResultModel SaveOrderMake(OrderMakeFmModel model)
        {
            try
            {
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                DateTime takeTime = DateTime.MinValue;
                if (model.TakeTime != null)
                {
                    DateTime.TryParse(model.TakeTime, out takeTime);
                }
                if (takeTime == DateTime.MinValue)
                {
                    takeTime = DateTime.Parse("1754-01-01");
                }
                DateTime reachTime = DateTime.MinValue;
                if (!string.IsNullOrWhiteSpace(model.ReachTime))
                {
                    DateTime.TryParse(model.ReachTime, out reachTime);
                }
                if (reachTime == DateTime.MinValue)
                {
                    reachTime = DateTime.Parse("1754-01-01");
                }
                int pieceQty = 0;
                if (!string.IsNullOrWhiteSpace(model.PieceQty))
                {
                    int.TryParse(model.PieceQty, out pieceQty);
                }
                double weight = 0d;
                if (!string.IsNullOrWhiteSpace(model.Weight))
                {
                    double.TryParse(model.Weight, out weight);
                }
                decimal tranPrice = 0;
                if (!string.IsNullOrWhiteSpace(model.TranPrice))
                {
                    decimal.TryParse(model.TranPrice, out tranPrice);
                }
                decimal increServicePrice = 0;
                if (!string.IsNullOrWhiteSpace(model.IncreServicePrice))
                {
                    decimal.TryParse(model.IncreServicePrice, out increServicePrice);
                }
                decimal totalPrice = 0;
                if (!string.IsNullOrWhiteSpace(model.TotalPrice))
                {
                    decimal.TryParse(model.TotalPrice, out totalPrice);
                }
                var currTime = DateTime.Now;
                var userId   = WebCommon.GetUserId();

                CustomProfileCommon Profile = new CustomProfileCommon();
                var upi = JsonConvert.DeserializeObject <UserProfileInfo>(Profile.UserInfo);

                var modelInfo = new OrderMakeInfo(Id, upi.SiteCode, userId, model.CustomerCode, model.OrderCode, model.FromName, model.FromAddress, model.FromPhone, model.ToCity, model.ToName, model.ToAddress, model.ToPhone, model.StaffCode, model.StaffCodeOfTake, takeTime, reachTime, model.CargoName, model.ServiceProduct, pieceQty, weight, tranPrice, increServicePrice, totalPrice, model.PayWay, model.Remark, currTime, currTime);

                var bll    = new OrderMake();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    effect = bll.Insert(modelInfo);
                }
                else
                {
                    var oldInfo = bll.GetModel(Id);
                    modelInfo.RecordDate = oldInfo.RecordDate;
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
示例#2
0
        public string SaveOrderScan(string orderCode, string customerCode, string orderStep, string loginId, string deviceId, string latlng)
        {
            try
            {
                new CustomException(string.Format("SaveOrderScan--orderCode:{0}--customerCode:{1}--orderStep:{2}--loginId:{3}--deviceId:{4}--latlng:{5}", orderCode, customerCode, orderStep, loginId, deviceId, latlng));

                orderCode    = orderCode.Trim();
                customerCode = customerCode.Trim();
                orderStep    = orderStep.Trim();
                loginId      = loginId.Trim();
                deviceId     = deviceId.Trim();
                latlng       = latlng.Trim();
                var ip              = HttpClientHelper.GetClientIp(HttpContext.Current);
                var currTime        = DateTime.Now;
                var latlngPlace     = string.Empty;
                var ipPlace         = string.Empty;
                var orderId         = Guid.Empty;
                var staffCodeOfTake = string.Empty;
                var staffCode       = string.Empty;
                var takeTime        = DateTime.Parse("1754-01-01");
                var reachTime       = takeTime;
                if (orderStep == "已取件")
                {
                    staffCode = loginId;
                    takeTime  = currTime;
                }
                else if (orderStep == "已送达")
                {
                    staffCodeOfTake = loginId;
                    reachTime       = currTime;
                }


                var oBll         = new OrderMake();
                var opBll        = new OrderProcess();
                var effect       = 0;
                var oldOrderInfo = oBll.GetModel(orderCode, customerCode);
                if (oldOrderInfo != null)
                {
                    orderId = oldOrderInfo.Id;
                    if (orderStep == "已送达")
                    {
                        oldOrderInfo.StaffCodeOfTake = staffCodeOfTake;
                        oldOrderInfo.ReachTime       = reachTime;
                        oBll.Update(oldOrderInfo);
                    }
                }
                else
                {
                    var userId = WebCommon.GetUserId();
                    if (userId.Equals(Guid.Empty))
                    {
                        throw new ArgumentException(MC.Login_NotExist);
                    }
                    var appCode = Auth.AppCode;
                    var fuInfo  = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        appCode = fuInfo.SiteCode;
                    }

                    orderId      = Guid.NewGuid();
                    oldOrderInfo = new OrderMakeInfo(orderId, appCode, userId, customerCode, orderCode, "", "", "", "", "", "", "", staffCode, staffCodeOfTake, takeTime, reachTime, "", "", 0, 0, 0, 0, 0, "", "", currTime, currTime);
                    effect       = oBll.InsertByOutput(oldOrderInfo);
                }
                var opInfo    = new OrderProcessInfo(Guid.Empty, orderId, loginId, orderStep, "", deviceId, latlng, latlngPlace, ip, ipPlace, currTime, currTime);
                var oldOpInfo = opBll.GetModel(orderId, orderStep);
                if (oldOpInfo != null)
                {
                    opInfo.Id       = oldOpInfo.Id;
                    opInfo.Pictures = oldOpInfo.Pictures;
                    if (oldOpInfo.Ip == ip)
                    {
                        opInfo.IpPlace = oldOpInfo.IpPlace;
                    }
                    if (oldOpInfo.Latlng == latlng)
                    {
                        opInfo.LatlngPlace = oldOpInfo.LatlngPlace;
                    }
                    effect = opBll.Update(opInfo);
                }
                else
                {
                    opInfo.Id = Guid.NewGuid();
                    effect    = opBll.InsertByOutput(opInfo);
                }
                if (string.IsNullOrWhiteSpace(opInfo.IpPlace) || string.IsNullOrWhiteSpace(opInfo.LatlngPlace))
                {
                    new RunQueueAsyn().Insert(new RunQueueInfo(EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), string.Format(@"{{""Latlng"":""{0}"",""Ip"":""{1}"",""OrderProcessId"":""{2}""}}", latlng, ip, opInfo.Id), EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), 0));
                }
                if (effect > 0)
                {
                    return(ResResult.ResJsonString(true, "", opInfo.Id));
                }
                else
                {
                    return(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
                }
            }
            catch (Exception ex)
            {
                new CustomException("SaveOrderScan--", ex);
                return(ResResult.ResJsonString(false, ex.Message, ""));
            }
        }