- 梳理真实手机号相关的流程,ConsigneeMobile为真实手机号时ConsigneeMobile2也有值(之前不是这样的)

This commit is contained in:
gazebo
2019-03-28 15:54:21 +08:00
parent 24af4bc330
commit 4897c87bc1
7 changed files with 27 additions and 35 deletions

View File

@@ -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 {

View File

@@ -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")

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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),

View File

@@ -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
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"])),

View File

@@ -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"])),