- Change2JDSPU4Store

This commit is contained in:
gazebo
2019-01-11 18:52:58 +08:00
parent f79ee7808e
commit 7d5c49c52f
4 changed files with 44 additions and 8 deletions

View File

@@ -111,7 +111,19 @@ func TransferLegacyElmOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError
return hint, err
}
func saveJdOrderList(existJdIDMap map[string]int, jdOrderList []interface{}) (err error) {
func saveJdOrderList(existJdIDMap map[string]int, jdOrderList []interface{}, jdStoreOrderList []map[string]interface{}) (err error) {
var storeOrderList []*model.TempGoodsOrderMobile
for _, v := range jdStoreOrderList {
order := &model.TempGoodsOrderMobile{
VendorOrderID: v["orderId"].(string),
VendorID: model.VendorIDJD,
AccountNo: v["venderId"].(string),
OrderCreatedAt: utils.Timestamp2Time(utils.MustInterface2Int64(v["orderPaidTime"]) / 1000),
Mobile: v["mobile"].(string),
}
storeOrderList = append(storeOrderList, order)
}
var orderDetailList []*model.GoodsOrderOriginal
for _, v := range jdOrderList {
orderMap := v.(map[string]interface{})
@@ -128,12 +140,15 @@ func saveJdOrderList(existJdIDMap map[string]int, jdOrderList []interface{}) (er
orderDetailList = append(orderDetailList, orderDetail)
}
}
if len(orderDetailList) > 0 {
// for _, v := range orderDetailList {
// globals.SugarLogger.Debug(v.VendorOrderID)
// }
if len(orderDetailList) > 0 || len(storeOrderList) > 0 {
db := dao.GetDB()
err = dao.CreateMultiEntities(db, orderDetailList)
if len(orderDetailList) > 0 {
err = dao.CreateMultiEntities(db, orderDetailList)
}
if len(storeOrderList) > 0 {
err = dao.CreateMultiEntities(db, storeOrderList)
}
}
return err
}
@@ -155,6 +170,9 @@ func PullJdOrder(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, is
pageSize := 100
hourGap := 1
gapCount := int((toTime.Sub(fromTime)-time.Hour*time.Duration(hourGap))/(time.Hour*time.Duration(hourGap)) + 1)
if gapCount <= 0 {
gapCount = 1
}
gapList := make([]int, gapCount)
for k := range gapList {
gapList[k] = k
@@ -176,11 +194,15 @@ func PullJdOrder(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, is
"orderPurchaseTime_begin": utils.Time2Str(subFromTime),
"orderPurchaseTime_end": utils.Time2Str(subToTime),
}
globals.SugarLogger.Debugf("PullJdOrder, commonParams=%s", utils.Format4Output(commonParams, false))
orderList, totalCount, err := api.JdAPI.OrderQuery(utils.MergeMaps(commonParams, utils.Params2Map("pageNo", 0)))
if err != nil {
return "", err
}
if err = saveJdOrderList(existJdIDMap, orderList); err != nil {
storeOrderList, err := api.JdAPI.GetStoreOrderInfoList(utils.Time2Str(subFromTime), utils.Time2Str(subToTime))
if err != nil {
}
if err = saveJdOrderList(existJdIDMap, orderList, storeOrderList); err != nil {
return "", err
}
if false {