From a84286df4f6e602c8d993fe6a435ceed247ad70a Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 14 Nov 2018 15:05:40 +0800 Subject: [PATCH] - handle ebai fake mobile(IsMobileFake) --- business/jxutils/jxutils_cms.go | 5 +++++ business/jxutils/jxutils_cms_test.go | 15 +++++++++++++++ business/partner/purchase/ebai/order.go | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index ba5d0934d..baddaf962 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -187,3 +187,8 @@ func Int2OneZero(value int) int { } return 0 } + +// 判断电话号码是否是假的,比如有****号 +func IsMobileFake(mobile string) bool { + return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0 +} diff --git a/business/jxutils/jxutils_cms_test.go b/business/jxutils/jxutils_cms_test.go index c5dd426e3..67ee2ac7b 100644 --- a/business/jxutils/jxutils_cms_test.go +++ b/business/jxutils/jxutils_cms_test.go @@ -46,3 +46,18 @@ func TestFakeID(t *testing.T) { t.Fatalf("wrong result for id:%d", id) } } + +func TestIsMobileFake(t *testing.T) { + if IsMobileFake("13888888888") { + t.Fatal("wrong 1") + } + if IsMobileFake("13888888888-123") { + t.Fatal("wrong 2") + } + if IsMobileFake("13888888888,123") { + t.Fatal("wrong 3") + } + if !IsMobileFake("138****8888") { + t.Fatal("wrong 4") + } +} diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 2aa9d04d0..7d6d8835b 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -59,6 +59,11 @@ func (p *PurchaseHandler) GetOrder(vendorOrderID string) (order *model.GoodsOrde ActualPayPrice: utils.MustInterface2Int64(orderMap["user_fee"]), Skus: []*model.OrderSku{}, } + if jxutils.IsMobileFake(order.ConsigneeMobile) { + if mobileInfo, err := api.EbaiAPI.OrderPrivateInfo(vendorOrderID); err == nil { + order.ConsigneeMobile = mobileInfo.ShortNumber + } + } if order.StoreID > math.MaxInt32 { order.StoreID = 0 }