diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 92b7e74a2..1792f0aed 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -308,10 +308,10 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, fromDateStr, toDateStr keywordLike := "%" + keyword + "%" sqlWhere += ` AND (t1.store_name LIKE ? OR t1.vendor_order_id LIKE ? OR t1.vendor_store_id LIKE ? - OR t1.consignee_name LIKE ? OR t1.consignee_mobile LIKE ? OR t1.consignee_address LIKE ? + OR t1.consignee_name LIKE ? OR t1.consignee_mobile LIKE ? OR t1.consignee_mobile2 LIKE ? OR t1.consignee_address LIKE ? OR t2.vendor_waybill_id LIKE ? OR t2.courier_name LIKE ? OR t2.courier_mobile LIKE ? ` - sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike) + sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike) if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil { sqlWhere += " OR t1.store_id = ? OR t1.jx_store_id = ?" sqlParams = append(sqlParams, keywordInt64, keywordInt64) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index a85a8ac4f..522bb8fe0 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -199,7 +199,11 @@ func init() { Timeout: 1 * time.Second, TimeoutAction: func(savedOrderInfo *WatchOrderInfo) (err error) { order := savedOrderInfo.order - _ = sch.handleAutoAcceptOrder(order.VendorOrderID, order.VendorID, order.ConsigneeMobile, jxutils.GetJxStoreIDFromOrder(order), nil, func(isAcceptIt bool) error { + mobile := order.ConsigneeMobile + if order.ConsigneeMobile2 != "" { + mobile = order.ConsigneeMobile2 + } + _ = sch.handleAutoAcceptOrder(order.VendorOrderID, order.VendorID, mobile, jxutils.GetJxStoreIDFromOrder(order), nil, func(isAcceptIt bool) error { if err = sch.AcceptOrRefuseOrder(order, isAcceptIt, ""); err != nil && err != scheduler.ErrOrderStatusAlreadySatisfyCurOperation { // 为了解决京东新消息与接单消息乱序的问题 if errWithCode, ok := err.(*utils.ErrorWithCode); ok && errWithCode.Level() == 1 && errWithCode.IntCode() == -1 { diff --git a/business/jxstore/promotion/promotion.go b/business/jxstore/promotion/promotion.go index 2fb9f8039..a2af2dea4 100644 --- a/business/jxstore/promotion/promotion.go +++ b/business/jxstore/promotion/promotion.go @@ -30,10 +30,10 @@ func SendAdvertingByGoodsOrder(ctx *jxcontext.Context, advertising string, days } sqlParams := []interface{}{} sql1 := ` - SELECT consignee_mobile mobile + SELECT IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) mobile FROM goods_order t1 - LEFT JOIN black_client t2 ON t1.consignee_mobile = t2.mobile - WHERE consignee_mobile IS NOT NULL AND consignee_mobile <> '' AND t2.id IS NULL AND LENGTH(consignee_mobile) = 11 AND LEFT(consignee_mobile, 1) = '1' + LEFT JOIN black_client t2 ON IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) = t2.mobile + WHERE IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) <> '' AND t2.id IS NULL AND LENGTH(IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile)) = 11 AND LEFT(IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile), 1) = '1' ` sql2 := ` SELECT buyer_mobile mobile diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index bf6b70005..d02f12838 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -190,7 +190,11 @@ func Int2OneZero(value int) int { // 判断电话号码是否是假的,比如有****号 func IsMobileFake(mobile string) bool { - return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0 + return utils.Str2Int64WithDefault(FormalizeMobile(mobile), 0) == 0 +} + +func FormalizeMobile(mobile string) string { + return strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1) } func IsLegalStoreID(id int) bool { diff --git a/business/model/order.go b/business/model/order.go index c7bc75b50..88a85d1ca 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -22,6 +22,7 @@ type GoodsOrder struct { Weight int `json:"weight"` // 单位为克 ConsigneeName string `orm:"size(32)" json:"consigneeName"` ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"` + ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"` ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"` CoordinateType int `json:"-"` ConsigneeLng int `json:"-"` // 坐标 * (10的六次方) diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 93158117c..dfd15cefc 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -84,8 +84,8 @@ func (p *PurchaseHandler) GetOrder(vendorOrderID string) (order *model.GoodsOrde } deliveryGeo := userMap["coord"].(map[string]interface{}) - originalLng := utils.MustInterface2Float64(deliveryGeo["longitude"]) - originalLat := utils.MustInterface2Float64(deliveryGeo["latitude"]) + originalLng := utils.Interface2FloatWithDefault(deliveryGeo["longitude"], 0.0) // 饿百的订单在过一段时间后,经纬度信息会变成字符串"**" + originalLat := utils.Interface2FloatWithDefault(deliveryGeo["latitude"], 0.0) lng, lat, err2 := api.AutonaviAPI.CoordinateConvert(originalLng, originalLat, autonavi.CoordSysBaidu) if err2 == nil { originalLng = lng diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index d8a8dc273..34f83fbd2 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" + "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" @@ -60,7 +61,23 @@ func (c *PurchaseHandler) onOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err error) { globals.SugarLogger.Debugf("jd GetOrder orderID:%s", orderID) - result, err := api.JdAPI.QuerySingleOrder(orderID) + var ( + result map[string]interface{} + result2 string + err2 error + ) + task := tasksch.NewParallelTask("jd GetOrder", nil, "admin", func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err 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 err == nil { order = &model.GoodsOrder{ VendorOrderID: orderID, @@ -81,6 +98,11 @@ func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err ActualPayPrice: utils.MustInterface2Int64(result["orderBuyerPayableMoney"]), Skus: []*model.OrderSku{}, } + if err2 == nil { + order.ConsigneeMobile2 = result2 + } else { + // globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2) + } order.Status = c.GetStatusFromVendorStatus(order.VendorStatus) businessTage := utils.Interface2String(result["businessTag"]) if strings.Index(businessTage, "dj_aging_immediately") >= 0 { diff --git a/business/partner/purchase/jd/order_legacy_comment.go b/business/partner/purchase/jd/order_legacy_comment.go index 5aa6a8e62..0b47dbfd4 100644 --- a/business/partner/purchase/jd/order_legacy_comment.go +++ b/business/partner/purchase/jd/order_legacy_comment.go @@ -157,8 +157,10 @@ func (c *PurchaseHandler) replyOrderComment(intOrderID int64, jdStoreNo string, // } // return nil // }, "replyOrderComment %d", intOrderID) - err2 := api.JdAPI.OrgReplyComment(intOrderID, jdStoreNo, content, utils.GetAPIOperator("")) - globals.SugarLogger.Debugf("replyOrderComment orderID:%d, error:%v", intOrderID, err2) + if globals.ReallySendWeixinMsg { + err2 := api.JdAPI.OrgReplyComment(intOrderID, jdStoreNo, content, utils.GetAPIOperator("")) + globals.SugarLogger.Debugf("replyOrderComment orderID:%d, error:%v", intOrderID, err2) + } }) return nil } diff --git a/conf/app.conf b/conf/app.conf index 3f37c395d..3ae9aff8c 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -40,6 +40,8 @@ showAppSecret = "384f911735334bf7a150f3bd3bdf0c1e" weixinMiniAppID = "wx4b5930c13f8b1170" weixinMiniSecret = "2a57228a716ce991a52739f0ff41111d" +jdStorePageCookie = "AG37MCRDYAEOMUXKENJQ4QYZIYHYPVUX7CAXNBWPW777UQDYQ6N7HO7XXVQPYJISZMYRMOJXIM4Q35YTUFDGQMW3GQU6625AAJ7IQTUX23DKGA5NOYSENMJHDGM4HO4AHIAWZ7PTJGVBBT5OGAOFABPOHPZRYZ6MH6GL5QTVSIMCARP2IGG6DIB5ZUI5HQSTAJMJVRGRMUM5YT4TVA4NH65A6J6IFPRW7GAESIY" + [dev] jdToken = "c8854ef2-f80a-45ee-aceb-dc8014d646f8" jdAppKey = "06692746f7224695ad4788ce340bc854" @@ -134,7 +136,7 @@ enableStore = true enableStoreWrite = true [test] -jdToken = "91633f2a-c5f5-4982-a925-a220d19095c3" +jdToken = "ccb10daf-e6f5-4a58-ada5-b97f9073a137" jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" diff --git a/globals/api/api.go b/globals/api/api.go index fe18e336b..5fdf766b9 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -39,6 +39,7 @@ var ( func Init() { if !beego.AppConfig.DefaultBool("disableJd", false) { JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret")) + JdAPI.SetStoreCookie(beego.AppConfig.DefaultString("jdStorePageCookie", "")) } if !beego.AppConfig.DefaultBool("disableElm", false) { initElm()