From ada0dbc4f3b75f403deb94100fae37ee41a392d9 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 17 Jul 2018 22:18:38 +0800 Subject: [PATCH] - handle utf8mb4 in elm and jd order. --- business/controller/elm/order.go | 17 ++++++++--------- business/controller/jd/order.go | 8 ++++---- legacy/elm/controller/order.go | 2 +- legacy/jd/controller/order.go | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/business/controller/elm/order.go b/business/controller/elm/order.go index c3f10d245..f51662031 100644 --- a/business/controller/elm/order.go +++ b/business/controller/elm/order.go @@ -118,17 +118,16 @@ func (c *OrderController) getOrderInfo(orderID string) (order *model.GoodsOrder, VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shopId"])), StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["openId"]), 0)), StoreName: result["shopName"].(string), - ConsigneeName: result["consignee"].(string), + ConsigneeName: utils.FilterMb4(result["consignee"].(string)), ConsigneeMobile: consigneeMobile, - ConsigneeAddress: result["address"].(string), - BuyerComment: strings.Trim(utils.Interface2String(result["description"]), "\n\r\t "), + ConsigneeAddress: utils.FilterMb4(result["address"].(string)), + BuyerComment: utils.FilterMb4(strings.Trim(utils.Interface2String(result["description"]), "\n\r\t ")), ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["deliverTime"]), utils.DefaultTimeValue), - // 取订单的原始status,不合并消息类型(因为当前消息类型没有意义) - VendorStatus: utils.Interface2String(result["status"]), - OrderSeq: int(utils.MustInterface2Int64(result["daySn"])), - OrderCreatedAt: utils.Str2Time(result["createdAt"].(string)), - OriginalData: string(utils.MustMarshal(result)), - Skus: []*model.OrderSku{}, + VendorStatus: utils.Interface2String(result["status"]), // 取订单的原始status,不合并消息类型(因为当前消息类型没有意义) + OrderSeq: int(utils.MustInterface2Int64(result["daySn"])), + OrderCreatedAt: utils.Str2Time(result["createdAt"].(string)), + OriginalData: utils.FilterMb4(string(utils.MustMarshal(result))), + Skus: []*model.OrderSku{}, } deliveryGeo := strings.Split(utils.Interface2String(result["deliveryGeo"]), ",") if len(deliveryGeo) == 2 { diff --git a/business/controller/jd/order.go b/business/controller/jd/order.go index 44d889138..f30d65b7a 100644 --- a/business/controller/jd/order.go +++ b/business/controller/jd/order.go @@ -68,16 +68,16 @@ func (c *OrderController) getOrderInfo(msg *jdapi.CallbackOrderMsg) (order *mode VendorStoreID: result["produceStationNo"].(string), StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["produceStationNoIsv"]), 0)), StoreName: result["produceStationName"].(string), - ConsigneeName: result["buyerFullName"].(string), + ConsigneeName: utils.FilterMb4(result["buyerFullName"].(string)), ConsigneeMobile: result["buyerMobile"].(string), - ConsigneeAddress: result["buyerFullAddress"].(string), + ConsigneeAddress: utils.FilterMb4(result["buyerFullAddress"].(string)), CoordinateType: model.CoordinateTypeMars, - BuyerComment: strings.Trim(utils.Interface2String(result["orderBuyerRemark"]), "\n\r\t "), + BuyerComment: utils.FilterMb4(strings.Trim(utils.Interface2String(result["orderBuyerRemark"]), "\n\r\t ")), ExpectedDeliveredTime: utils.Str2TimeWithDefault(utils.Interface2String(result["orderPreEndDeliveryTime"]), utils.DefaultTimeValue), VendorStatus: msg.StatusID, OrderSeq: int(utils.MustInterface2Int64(result["orderNum"])), OrderCreatedAt: utils.Str2Time(result["orderStartTime"].(string)), - OriginalData: string(utils.MustMarshal(result)), + OriginalData: utils.FilterMb4(string(utils.MustMarshal(result))), Skus: []*model.OrderSku{}, } coordinateType := utils.Interface2Int64WithDefault(result["buyerCoordType"], 1) diff --git a/legacy/elm/controller/order.go b/legacy/elm/controller/order.go index fc6a1ec22..e08bae5e1 100644 --- a/legacy/elm/controller/order.go +++ b/legacy/elm/controller/order.go @@ -85,7 +85,7 @@ func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string, user if err != nil { retVal = errResponseCallELMAPIError } else { - rec.Data = string(utils.MustMarshal(result)) + rec.Data = utils.FilterMb4(string(utils.MustMarshal(result))) rec.Consignee = result["consignee"].(string) rec.Mobile = userMobile if createdAt, ok := result["createdAt"].(string); ok { diff --git a/legacy/jd/controller/order.go b/legacy/jd/controller/order.go index 2c5bacd51..5d08470d2 100644 --- a/legacy/jd/controller/order.go +++ b/legacy/jd/controller/order.go @@ -175,7 +175,7 @@ func newOrder(msg *jdapi.CallbackOrderMsg) error { rec.OrderStatusTime = resultList0["orderStatusTime"].(string) resultByteArr := utils.MustMarshal(data) - rec.Data = string(resultByteArr) + rec.Data = utils.FilterMb4(string(resultByteArr)) rec.Data4Json = data userMobile = resultList0["buyerMobile"].(string) err = utils.CallFuncLogError(func() error {