Exemplo n.º 1
0
 /// <summary>
 /// 配送方式相关
 /// </summary>
 public ShipmentInfoDTO()
 {
     HasSelfTakeFunc = false;
     ShipmentWays    = 1;
     AppSelfTakeStationDefaultInfo = new AppSelfTakeStationDefaultInfoDTO();
     DefaultAddressInfo            = new AddressSDTO();
 }
Exemplo n.º 2
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO ValidAddressNew(Jinher.AMP.BTP.Deploy.CustomDTO.AddressSDTO addressDTO)
        {
            ResultDTO result = ValidAddress(addressDTO);

            if (result.ResultCode != 0)
            {
                return(result);
            }
            if (string.IsNullOrWhiteSpace(addressDTO.ProvinceCode))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "参数错误,省编码不能为空!"
                });
            }
            else if (string.IsNullOrWhiteSpace(addressDTO.CityCode))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "参数错误,市编码不能为空!"
                });
            }
            else if (string.IsNullOrWhiteSpace(addressDTO.DistrictCode))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "参数错误,地区编码不能为空!"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加收货地址
        /// </summary>
        /// <param name="addressDTO">地址实体</param>
        /// <param name="appId">APPId</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveDeliveryAddressExt(Jinher.AMP.BTP.Deploy.CustomDTO.AddressSDTO addressDTO)
        {
            try
            {
                ResultDTO result = ValidAddress(addressDTO);
                if (result.ResultCode != 0)
                {
                    return(result);
                }

                DeliveryAddressDTO deliveryAddressDTO = new DeliveryAddressDTO();
                ContextSession     contextSession     = ContextFactory.CurrentThreadContext;
                deliveryAddressDTO.EntityState        = System.Data.EntityState.Added;
                deliveryAddressDTO.Id                 = Guid.NewGuid();
                deliveryAddressDTO.AppId              = addressDTO.AppId;
                deliveryAddressDTO.Name               = "收货地址";
                deliveryAddressDTO.RecipientsUserName = addressDTO.ReceiptUserName;
                deliveryAddressDTO.UserId             = addressDTO.UserId;
                deliveryAddressDTO.RecipientsPhone    = addressDTO.ReceiptPhone;
                deliveryAddressDTO.RecipientsAddress  = addressDTO.ReceiptAddress;
                deliveryAddressDTO.Province           = addressDTO.Province;
                deliveryAddressDTO.City               = addressDTO.City;
                deliveryAddressDTO.District           = addressDTO.District;
                deliveryAddressDTO.Street             = addressDTO.Street;
                deliveryAddressDTO.ProvinceCode       = addressDTO.ProvinceCode;
                deliveryAddressDTO.CityCode           = addressDTO.CityCode;
                deliveryAddressDTO.DistrictCode       = addressDTO.DistrictCode;
                deliveryAddressDTO.StreetCode         = addressDTO.StreetCode;
                deliveryAddressDTO.RecipientsZipCode  = addressDTO.RecipientsZipCode;
                deliveryAddressDTO.IsDefault          = addressDTO.IsDefault == 1 ? true : false;
                DeliveryAddress deliveryAddress = new DeliveryAddress().FromEntityData(deliveryAddressDTO);
                if (addressDTO.IsDefault == 1)
                {
                    DeliveryAddress.ObjectSet().Context.ExecuteStoreCommand("update DeliveryAddress  set IsDefault=0 where UserId='" + deliveryAddress.UserId + "'");
                }
                contextSession.SaveObject(deliveryAddress);
                contextSession.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加收货地址服务异常。addressDTO:{0}", JsonHelper.JsonSerializer(addressDTO)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "添加收货地址异常!"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }
Exemplo n.º 4
0
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO ValidAddress(Jinher.AMP.BTP.Deploy.CustomDTO.AddressSDTO addressDTO)
 {
     if (addressDTO == null)
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,参数不能为空!"
         });
     }
     if (string.IsNullOrWhiteSpace(addressDTO.ReceiptUserName))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,收货人不能为空!"
         });
     }
     else if (string.IsNullOrWhiteSpace(addressDTO.ReceiptPhone))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,手机号不能为空!"
         });
     }
     else if (string.IsNullOrWhiteSpace(addressDTO.ReceiptAddress))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,收货地址不能为空!"
         });
     }
     else if (string.IsNullOrWhiteSpace(addressDTO.Province))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,省不能为空!"
         });
     }
     else if (string.IsNullOrWhiteSpace(addressDTO.City))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,市不能为空!"
         });
     }
     else if (string.IsNullOrWhiteSpace(addressDTO.District))
     {
         return(new ResultDTO {
             ResultCode = 1, Message = "参数错误,区不能为空!"
         });
     }
     return(new ResultDTO {
         ResultCode = 0, Message = "Success"
     });
 }
Exemplo n.º 5
0
        /// <summary>
        /// 保存(添加或修改)收货地址
        /// <para>Service Url: http://devbtp.sv.iuoooo.com/Jinher.AMP.BTP.SV.DeliveryAddressSV.svc/SaveDeliveryAddressNew
        /// </para>
        /// </summary>
        /// <param name="addressDTO">地址实体</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveDeliveryAddressNewExt(Jinher.AMP.BTP.Deploy.CustomDTO.AddressSDTO addressDTO)
        {
            try
            {
                ResultDTO result = ValidAddressNew(addressDTO);
                if (result.ResultCode != 0)
                {
                    return(result);
                }

                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                DeliveryAddress deliveryAddress = null;
                if (addressDTO.AddressId != Guid.Empty)
                {
                    deliveryAddress = DeliveryAddress.ObjectSet().Where(n => n.Id == addressDTO.AddressId).FirstOrDefault();
                }

                if (deliveryAddress == null)
                {
                    deliveryAddress    = DeliveryAddress.CreateDeliveryAddress();
                    deliveryAddress.Id = Guid.NewGuid();
                }
                else
                {
                    deliveryAddress.EntityState = System.Data.EntityState.Modified;
                }
                deliveryAddress.Name = "";
                if (addressDTO.UserId != Guid.Empty)
                {
                    deliveryAddress.UserId = addressDTO.UserId;
                }

                deliveryAddress.AppId = addressDTO.AppId;
                deliveryAddress.RecipientsUserName = addressDTO.ReceiptUserName;
                deliveryAddress.RecipientsPhone    = addressDTO.ReceiptPhone;
                deliveryAddress.RecipientsAddress  = addressDTO.ReceiptAddress;
                deliveryAddress.Province           = addressDTO.Province;
                deliveryAddress.City              = addressDTO.City;
                deliveryAddress.District          = addressDTO.District;
                deliveryAddress.Street            = addressDTO.Street;
                deliveryAddress.RecipientsZipCode = addressDTO.RecipientsZipCode;
                deliveryAddress.ProvinceCode      = addressDTO.ProvinceCode;
                deliveryAddress.CityCode          = addressDTO.CityCode;
                deliveryAddress.DistrictCode      = addressDTO.DistrictCode;
                deliveryAddress.StreetCode        = addressDTO.StreetCode;
                deliveryAddress.IsDefault         = addressDTO.IsDefault == 1 ? true : false;
                if (addressDTO.IsDefault == 1)
                {
                    DeliveryAddress.ObjectSet().Context.ExecuteStoreCommand("update DeliveryAddress  set IsDefault=0 where UserId='" + deliveryAddress.UserId + "'");
                }
                contextSession.SaveObject(deliveryAddress);
                contextSession.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("SaveDeliveryAddressNewExt异常。addressDTO:{0},异常信息:{1}", addressDTO, ex));
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }