- 梳理真实手机号相关的流程,ConsigneeMobile为真实手机号时ConsigneeMobile2也有值(之前不是这样的)
This commit is contained in:
@@ -52,6 +52,10 @@ func (c *OrderManager) LoadPendingOrders() []*model.GoodsOrder {
|
|||||||
// msgVendorStatus的意思是事件本身的类型,类似有时收到NewOrder事件去取,订单状态不一定就是New的
|
// msgVendorStatus的意思是事件本身的类型,类似有时收到NewOrder事件去取,订单状态不一定就是New的
|
||||||
// OnOrderAdjust也类似,而OrderStatus要记录的是消息,所以添加这个
|
// OnOrderAdjust也类似,而OrderStatus要记录的是消息,所以添加这个
|
||||||
func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, msgVendorStatus string) (err error) {
|
func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, msgVendorStatus string) (err error) {
|
||||||
|
if order.ConsigneeMobile2 == "" && !jxutils.IsMobileFake(order.ConsigneeMobile) {
|
||||||
|
order.ConsigneeMobile2 = order.ConsigneeMobile
|
||||||
|
}
|
||||||
|
|
||||||
// todo transaction
|
// todo transaction
|
||||||
db := orm.NewOrm()
|
db := orm.NewOrm()
|
||||||
if order.Status == model.OrderStatusUnknown {
|
if order.Status == model.OrderStatusUnknown {
|
||||||
@@ -74,6 +78,10 @@ func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, msgVendorStatus strin
|
|||||||
|
|
||||||
// todo 调整单的处理可能还需要再细化一点,当前只是简单的删除重建
|
// todo 调整单的处理可能还需要再细化一点,当前只是简单的删除重建
|
||||||
func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, msgVendorStatus string) (err error) {
|
func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, msgVendorStatus string) (err error) {
|
||||||
|
if order.ConsigneeMobile2 == "" && !jxutils.IsMobileFake(order.ConsigneeMobile) {
|
||||||
|
order.ConsigneeMobile2 = order.ConsigneeMobile
|
||||||
|
}
|
||||||
|
|
||||||
// todo transaction
|
// todo transaction
|
||||||
db := orm.NewOrm()
|
db := orm.NewOrm()
|
||||||
if order.Status == model.OrderStatusUnknown {
|
if order.Status == model.OrderStatusUnknown {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime ti
|
|||||||
order := batchItemList[0].(*model.GoodsOrder)
|
order := batchItemList[0].(*model.GoodsOrder)
|
||||||
mobile, err2 := handler.GetOrderRealMobile(ctx, order)
|
mobile, err2 := handler.GetOrderRealMobile(ctx, order)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
|
mobile = jxutils.FormalizeMobile(mobile)
|
||||||
if !jxutils.IsMobileFake(mobile) && strings.Index(order.ConsigneeMobile, mobile) == -1 {
|
if !jxutils.IsMobileFake(mobile) && strings.Index(order.ConsigneeMobile, mobile) == -1 {
|
||||||
order.ConsigneeMobile2 = mobile
|
order.ConsigneeMobile2 = mobile
|
||||||
_, err = dao.UpdateEntity(db, order, "ConsigneeMobile2")
|
_, err = dao.UpdateEntity(db, order, "ConsigneeMobile2")
|
||||||
|
|||||||
@@ -220,11 +220,12 @@ func Int2OneZero(value int) int {
|
|||||||
|
|
||||||
// 判断电话号码是否是假的,比如有****号
|
// 判断电话号码是否是假的,比如有****号
|
||||||
func IsMobileFake(mobile string) bool {
|
func IsMobileFake(mobile string) bool {
|
||||||
return utils.Str2Int64WithDefault(FormalizeMobile(mobile), 0) == 0
|
return len(mobile) > 13 || mobile == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormalizeMobile(mobile string) string {
|
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 {
|
func IsLegalStoreID(id int) bool {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(shopMap["id"]), 0)),
|
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(shopMap["id"]), 0)),
|
||||||
StoreName: shopMap["name"].(string),
|
StoreName: shopMap["name"].(string),
|
||||||
ConsigneeName: userMap["name"].(string),
|
ConsigneeName: userMap["name"].(string),
|
||||||
ConsigneeMobile: userMap["phone"].(string),
|
ConsigneeMobile: jxutils.FormalizeMobile(userMap["phone"].(string)),
|
||||||
ConsigneeAddress: userMap["address"].(string),
|
ConsigneeAddress: userMap["address"].(string),
|
||||||
CoordinateType: model.CoordinateTypeBaiDu,
|
CoordinateType: model.CoordinateTypeBaiDu,
|
||||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(orderMap["remark"])),
|
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) {
|
if jxutils.IsTimeEmpty(order.PickDeadline) && !jxutils.IsTimeEmpty(order.StatusTime) {
|
||||||
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay /* + time.Duration(rand.Intn(pickupOrderGap))*time.Second*/)
|
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 {
|
if mobileInfo, err := api.EbaiAPI.OrderPrivateInfo(vendorOrderID); err == nil {
|
||||||
order.ConsigneeMobile = mobileInfo.ShortNumber
|
order.ConsigneeMobile = jxutils.FormalizeMobile(mobileInfo.ShortNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if order.StoreID > math.MaxInt32 {
|
if order.StoreID > math.MaxInt32 {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["openId"]), 0)),
|
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["openId"]), 0)),
|
||||||
StoreName: result["shopName"].(string),
|
StoreName: result["shopName"].(string),
|
||||||
ConsigneeName: result["consignee"].(string),
|
ConsigneeName: result["consignee"].(string),
|
||||||
ConsigneeMobile: consigneeMobile,
|
ConsigneeMobile: jxutils.FormalizeMobile(consigneeMobile),
|
||||||
ConsigneeAddress: result["address"].(string),
|
ConsigneeAddress: result["address"].(string),
|
||||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["description"])),
|
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["description"])),
|
||||||
ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["deliverTime"]), utils.DefaultTimeValue),
|
ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["deliverTime"]), utils.DefaultTimeValue),
|
||||||
|
|||||||
@@ -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) {
|
func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, orderMap map[string]interface{}, err error) {
|
||||||
globals.SugarLogger.Debugf("jd GetOrder orderID:%s", orderID)
|
globals.SugarLogger.Debugf("jd GetOrder orderID:%s", orderID)
|
||||||
var (
|
if orderMap, err = api.JdAPI.QuerySingleOrder(orderID); err == nil {
|
||||||
result map[string]interface{}
|
order = c.Map2Order(orderMap)
|
||||||
result2 string
|
if jxutils.IsMobileFake(order.ConsigneeMobile) {
|
||||||
err2 error
|
if realMobile, err := api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误
|
||||||
)
|
order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
|
||||||
// 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 {
|
} else {
|
||||||
// globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2)
|
// 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) {
|
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)),
|
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["produceStationNoIsv"]), 0)),
|
||||||
StoreName: utils.Interface2String(result["produceStationName"]),
|
StoreName: utils.Interface2String(result["produceStationName"]),
|
||||||
ConsigneeName: utils.Interface2String(result["buyerFullName"]),
|
ConsigneeName: utils.Interface2String(result["buyerFullName"]),
|
||||||
ConsigneeMobile: utils.Interface2String(result["buyerMobile"]),
|
ConsigneeMobile: jxutils.FormalizeMobile(utils.Interface2String(result["buyerMobile"])),
|
||||||
ConsigneeAddress: utils.Interface2String(result["buyerFullAddress"]),
|
ConsigneeAddress: utils.Interface2String(result["buyerFullAddress"]),
|
||||||
CoordinateType: model.CoordinateTypeMars,
|
CoordinateType: model.CoordinateTypeMars,
|
||||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["orderBuyerRemark"])),
|
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["orderBuyerRemark"])),
|
||||||
|
|||||||
@@ -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)),
|
// StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["app_poi_code"]), 0)),
|
||||||
StoreName: result["wm_poi_name"].(string),
|
StoreName: result["wm_poi_name"].(string),
|
||||||
ConsigneeName: result["recipient_name"].(string),
|
ConsigneeName: result["recipient_name"].(string),
|
||||||
ConsigneeMobile: result["recipient_phone"].(string),
|
ConsigneeMobile: jxutils.FormalizeMobile(result["recipient_phone"].(string)),
|
||||||
ConsigneeAddress: result["recipient_address"].(string),
|
ConsigneeAddress: result["recipient_address"].(string),
|
||||||
CoordinateType: model.CoordinateTypeMars,
|
CoordinateType: model.CoordinateTypeMars,
|
||||||
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["caution"])),
|
BuyerComment: utils.TrimBlankChar(utils.Interface2String(result["caution"])),
|
||||||
|
|||||||
Reference in New Issue
Block a user