- fix bug in TransferLegacyJdOrder and TransferLegacyElmOrder

This commit is contained in:
gazebo
2019-02-11 16:57:19 +08:00
parent 86f6d25849
commit 325a3eb870

View File

@@ -3,7 +3,6 @@ package tempop
import (
"fmt"
"math"
"runtime"
"strings"
"time"
@@ -276,7 +275,7 @@ func TransferLegacyJdOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
SELECT t1.*
FROM jdorder t1
LEFT JOIN goods_order_original t2 ON t2.vendor_order_id = t1.vendor_order_id
WHERE t2.id IS NULL
WHERE t2.id IS NULL AND LENGTH(t1.data) > 10 AND t1.cityname = 'all'
ORDER BY t1.orderstatustime
LIMIT ?
`
@@ -290,25 +289,23 @@ func TransferLegacyJdOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
var orderDetailList []*model.GoodsOrderOriginal
for _, v := range batchItemList {
jdOrder := v.(*legacymodel2.Jdorder)
if len(jdOrder.Data) > 10 {
var detail map[string]interface{}
if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(jdOrder.Data, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
return nil, err
}
resultList := detail["result"].(map[string]interface{})["resultList"].([]interface{})
if len(resultList) > 0 {
originalData := resultList[0].(map[string]interface{})
orgCode := originalData["orgCode"].(string)
if orgCode == "320406" {
orderDetail := &model.GoodsOrderOriginal{
VendorOrderID: jdOrder.VendorOrderID,
VendorID: model.VendorIDJD,
AccountNo: orgCode,
OrderCreatedAt: utils.Str2Time(originalData["orderPurchaseTime"].(string)),
OriginalData: string(utils.MustMarshal(originalData)),
}
orderDetailList = append(orderDetailList, orderDetail)
var detail map[string]interface{}
if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(jdOrder.Data, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
return nil, err
}
resultList := detail["result"].(map[string]interface{})["resultList"].([]interface{})
if len(resultList) > 0 {
originalData := resultList[0].(map[string]interface{})
orgCode := originalData["orgCode"].(string)
if orgCode == "320406" {
orderDetail := &model.GoodsOrderOriginal{
VendorOrderID: jdOrder.VendorOrderID,
VendorID: model.VendorIDJD,
AccountNo: orgCode,
OrderCreatedAt: utils.Str2Time(originalData["orderPurchaseTime"].(string)),
OriginalData: string(utils.MustMarshal(originalData)),
}
orderDetailList = append(orderDetailList, orderDetail)
}
}
}
@@ -320,7 +317,6 @@ func TransferLegacyJdOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
// rootTask.AddChild(task).Run()
task.Run()
_, err = task.GetResult(0)
runtime.GC()
} else {
rootTask.Cancel()
}
@@ -342,7 +338,7 @@ func TransferLegacyElmOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
SELECT t1.*
FROM elemeorder t1
LEFT JOIN goods_order_original t2 ON t2.vendor_order_id = t1.orderid
WHERE t2.id IS NULL
WHERE t2.id IS NULL AND LENGTH(t1.data) > 10
ORDER BY t1.order_created_at
LIMIT ?
`
@@ -379,7 +375,6 @@ func TransferLegacyElmOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
// rootTask.AddChild(task).Run()
task.Run()
_, err = task.GetResult(0)
runtime.GC()
} else {
rootTask.Cancel()
}