diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 5080ab442..53daff08a 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -52,6 +52,10 @@ func (c *OrderManager) LoadPendingOrders() []*model.GoodsOrder { // msgVendorStatus的意思是事件本身的类型,类似有时收到NewOrder事件去取,订单状态不一定就是New的 // OnOrderAdjust也类似,而OrderStatus要记录的是消息,所以添加这个 func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, msgVendorStatus string) (err error) { + if order.ConsigneeMobile2 == "" && !jxutils.IsMobileFake(order.ConsigneeMobile) { + order.ConsigneeMobile2 = order.ConsigneeMobile + } + // todo transaction db := orm.NewOrm() if order.Status == model.OrderStatusUnknown { @@ -74,6 +78,10 @@ func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, msgVendorStatus strin // todo 调整单的处理可能还需要再细化一点,当前只是简单的删除重建 func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, msgVendorStatus string) (err error) { + if order.ConsigneeMobile2 == "" && !jxutils.IsMobileFake(order.ConsigneeMobile) { + order.ConsigneeMobile2 = order.ConsigneeMobile + } + // todo transaction db := orm.NewOrm() if order.Status == model.OrderStatusUnknown { diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 2834f33cf..1bce22d9f 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -60,6 +60,7 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti order := batchItemList[0].(*model.GoodsOrder) mobile, err2 := handler.GetOrderRealMobile(ctx, order) if err = err2; err == nil { + mobile = jxutils.FormalizeMobile(mobile) if !jxutils.IsMobileFake(mobile) && strings.Index(order.ConsigneeMobile, mobile) == -1 { order.ConsigneeMobile2 = mobile _, err = dao.UpdateEntity(db, order, "ConsigneeMobile2") diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 573acd7de..058164407 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -220,11 +220,12 @@ func Int2OneZero(value int) int { // 判断电话号码是否是假的,比如有****号 func IsMobileFake(mobile string) bool { - return utils.Str2Int64WithDefault(FormalizeMobile(mobile), 0) == 0 + return len(mobile) > 13 || mobile == "" } func FormalizeMobile(mobile string) string { - return strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1) + mobile = TrimDecorationChar(mobile) + return strings.Replace(strings.Replace(mobile, "-", ",", -1), "_", ",", -1) } func IsLegalStoreID(id int) bool { diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 5805b0942..ff56a50e5 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -78,7 +78,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(shopMap["id"]), 0)), StoreName: shopMap["name"].(string), ConsigneeName: userMap["name"].(string), - ConsigneeMobile: userMap["phone"].(string), + ConsigneeMobile: jxutils.FormalizeMobile(userMap["phone"].(string)), ConsigneeAddress: userMap["address"].(string), CoordinateType: model.CoordinateTypeBaiDu, BuyerComment: utils.TrimBlankChar(utils.Interface2String(orderMap["remark"])), @@ -94,9 +94,9 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo if jxutils.IsTimeEmpty(order.PickDeadline) && !jxutils.IsTimeEmpty(order.StatusTime) { order.PickDeadline = order.StatusTime.Add(pickupOrderDelay /* + time.Duration(rand.Intn(pickupOrderGap))*time.Second*/) } - if jxutils.IsMobileFake(order.ConsigneeMobile) { + if order.ConsigneeMobile == "" { if mobileInfo, err := api.EbaiAPI.OrderPrivateInfo(vendorOrderID); err == nil { - order.ConsigneeMobile = mobileInfo.ShortNumber + order.ConsigneeMobile = jxutils.FormalizeMobile(mobileInfo.ShortNumber) } } if order.StoreID > math.MaxInt32 { diff --git a/business/partner/purchase/elm/order.go b/business/partner/purchase/elm/order.go index 14b2e3c0d..29b9fbddb 100644 --- a/business/partner/purchase/elm/order.go +++ b/business/partner/purchase/elm/order.go @@ -147,7 +147,7 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["openId"]), 0)), StoreName: result["shopName"].(string), ConsigneeName: result["consignee"].(string), - ConsigneeMobile: consigneeMobile, + ConsigneeMobile: jxutils.FormalizeMobile(consigneeMobile), ConsigneeAddress: result["address"].(string), BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["description"])), ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["deliverTime"]), utils.DefaultTimeValue), diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index bd9f750c0..5734d4857 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -63,35 +63,17 @@ func (c *PurchaseHandler) onOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, orderMap map[string]interface{}, err error) { globals.SugarLogger.Debugf("jd GetOrder orderID:%s", orderID) - var ( - result map[string]interface{} - result2 string - err2 error - ) - // task := tasksch.NewParallelTask("jd GetOrder", nil, model.AdminName, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, errInner error) { - // taskIndex := batchItemList[0].(int) - // switch taskIndex { - // case 0: - // result, err = api.JdAPI.QuerySingleOrder(orderID) - // case 1: - // result2, err2 = api.JdAPI.GetRealMobile4Order(orderID, "") - // } - // return nil, nil - // }, []int{0, 1}) - // task.Run() - // task.GetResult(0) - if result, err = api.JdAPI.QuerySingleOrder(orderID); err == nil { - result2, err2 = api.JdAPI.GetRealMobile4Order(orderID, utils.Interface2String(result["produceStationNo"])) - } - if err == nil { - order = c.Map2Order(result) - if err2 == nil { - order.ConsigneeMobile2 = result2 - } else { - // globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2) + if orderMap, err = api.JdAPI.QuerySingleOrder(orderID); err == nil { + order = c.Map2Order(orderMap) + if jxutils.IsMobileFake(order.ConsigneeMobile) { + if realMobile, err := api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误 + order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile) + } else { + // globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2) + } } } - return order, result, err + return order, orderMap, err } func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err error) { @@ -114,7 +96,7 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["produceStationNoIsv"]), 0)), StoreName: utils.Interface2String(result["produceStationName"]), ConsigneeName: utils.Interface2String(result["buyerFullName"]), - ConsigneeMobile: utils.Interface2String(result["buyerMobile"]), + ConsigneeMobile: jxutils.FormalizeMobile(utils.Interface2String(result["buyerMobile"])), ConsigneeAddress: utils.Interface2String(result["buyerFullAddress"]), CoordinateType: model.CoordinateTypeMars, BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["orderBuyerRemark"])), diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index b6541f41c..24b45f8eb 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -80,7 +80,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo // StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["app_poi_code"]), 0)), StoreName: result["wm_poi_name"].(string), ConsigneeName: result["recipient_name"].(string), - ConsigneeMobile: result["recipient_phone"].(string), + ConsigneeMobile: jxutils.FormalizeMobile(result["recipient_phone"].(string)), ConsigneeAddress: result["recipient_address"].(string), CoordinateType: model.CoordinateTypeMars, BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["caution"])),