修复显示等相关bug
This commit is contained in:
1 parent
3281fe7885
commit
7cc4f5d856
8 files changed
+163
-63
No files matched your search
@@ -249,11 +249,16 @@ namespace _29WxOrderWpf.Windows.OrderWindows
|
||||
{
|
||||
aftersaleAddress = OrderItem?.DirectPddBuyerAfterSale?.afterSaleAddress;
|
||||
}
|
||||
var receiver = AddressAnalysis(aftersaleAddress.ParseToString());
|
||||
var receiver = PddAddressAnalysis(aftersaleAddress.ParseToString());
|
||||
// 单号不存在或者地址识别失败的直接返回
|
||||
if (wxExpressName.IsNullOrEmpty() || OrderItem.ItemRefund.return_waybill_id.IsNullOrEmpty() || receiver.receiver_name.IsNullOrEmpty() || receiver.receiver_phone.IsNullOrEmpty() ||
|
||||
receiver.receiver_province.IsNullOrEmpty() || receiver.receiver_city.IsNullOrEmpty() || receiver.receiver_area.IsNullOrEmpty() || receiver.receiver_address.IsNullOrEmpty())
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(aftersaleAddress))
|
||||
{
|
||||
// todo 提示地址解析失败请手动提交
|
||||
OrderItem.AddEditTransitWarehouseReturnOrderStr = "解析失败请手动添加";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,7 +357,7 @@ namespace _29WxOrderWpf.Windows.OrderWindows
|
||||
|
||||
private void btnAddressAnalysis_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var receiver = AddressAnalysis(txtAddressAnalysis.Text.Trim());
|
||||
var receiver = PddAddressAnalysis(txtAddressAnalysis.Text.Trim());
|
||||
this.txtUser.Text = receiver.receiver_name;
|
||||
this.txtMobile.Text = receiver.receiver_phone;
|
||||
this.txtProvince.Text = receiver.receiver_province;
|
||||
@@ -361,7 +366,7 @@ namespace _29WxOrderWpf.Windows.OrderWindows
|
||||
this.txtDetailAddress.Text = receiver.receiver_address;
|
||||
}
|
||||
|
||||
public static distrib_receiver_info AddressAnalysis(string AddressText)
|
||||
public static distrib_receiver_info WxAddressAnalysis(string AddressText)
|
||||
{
|
||||
distrib_receiver_info receiver = new distrib_receiver_info();
|
||||
|
||||
@@ -415,5 +420,60 @@ namespace _29WxOrderWpf.Windows.OrderWindows
|
||||
|
||||
return receiver;
|
||||
}
|
||||
}
|
||||
|
||||
public static distrib_receiver_info PddAddressAnalysis(string AddressText)
|
||||
{
|
||||
distrib_receiver_info receiver = new distrib_receiver_info();
|
||||
|
||||
var txt = AddressText;
|
||||
txt = txt.Replace("\r", "").Replace("\n", "");
|
||||
|
||||
|
||||
// 定义座机号的正则表达式
|
||||
string landlinePattern = @"\d{3}-\d{8}|\d{4}-\d{7}";
|
||||
// 定义手机号的正则表达式
|
||||
string mobilePattern = @"1[3-9]\d{9}";
|
||||
|
||||
// 使用正则表达式匹配座机号和手机号
|
||||
Match landlineMatch = Regex.Match(txt, landlinePattern);
|
||||
Match mobileMatch = Regex.Match(txt, mobilePattern);
|
||||
|
||||
var phone = "";
|
||||
if (landlineMatch.Success)
|
||||
{
|
||||
phone = landlineMatch.Value;
|
||||
txt = txt.Replace(phone, " ");
|
||||
}
|
||||
if (mobileMatch.Success)
|
||||
{
|
||||
phone = mobileMatch.Value;
|
||||
txt = txt.Replace(phone, " ");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(phone))
|
||||
{
|
||||
receiver.receiver_phone = phone;
|
||||
}
|
||||
|
||||
var province = GlobalConfig.PddDivisions.FirstOrDefault(d => txt.Contains(d.name));
|
||||
if (province == null)
|
||||
return receiver;
|
||||
receiver.receiver_province = province.name;
|
||||
var city = province.children.FirstOrDefault(c => txt.Contains(c.name));
|
||||
if (city == null)
|
||||
return receiver;
|
||||
receiver.receiver_city = city.name;
|
||||
var county = city.children.FirstOrDefault(c => txt.Contains(c.name));
|
||||
if (county == null)
|
||||
return receiver;
|
||||
receiver.receiver_area = county.name;
|
||||
txt = txt.Replace(county.name, " ").Replace(city.name, " ").Replace(province.name, " ");
|
||||
|
||||
var tArr = txt.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
tArr = tArr.OrderBy(t => t.Length).ToArray();
|
||||
receiver.receiver_name = tArr.FirstOrDefault();
|
||||
receiver.receiver_address = string.Join("", tArr).Replace(receiver.receiver_name, "");
|
||||
|
||||
return receiver;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user