This commit is contained in:
suyl
2021-10-18 11:27:03 +08:00
parent b65ab472ea
commit 2a8015f740
2 changed files with 33 additions and 0 deletions

View File

@@ -1911,6 +1911,38 @@ func RefreshOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID,
return num, err return num, err
} }
func UpdateJdsOrdersStatus(ctx *jxcontext.Context, orderCreatedStart, orderCreatedEnd time.Time) (err error) {
var (
pageSize = 20
orderIDs []int64
)
orderResult, err := jdshop.CurPurchaseHandler.GetJdsOrders(ctx, utils.Time2Str(orderCreatedStart), utils.Time2Str(orderCreatedEnd), 1, pageSize)
if orderResult.TotalCount > pageSize {
for pageNO := 2; pageNO < orderResult.TotalCount/pageSize+1; pageNO++ {
orderResult, _ := jdshop.CurPurchaseHandler.GetJdsOrders(ctx, utils.Time2Str(orderCreatedStart), utils.Time2Str(orderCreatedEnd), pageNO, pageSize)
for _, order := range orderResult.OrderList {
if order.OrderStatus == jdshopapi.OrderStatusCancelm2 {
orderIDs = append(orderIDs, order.OrderID)
}
}
}
}
for _, orderID := range orderIDs {
var goodsOrder *model.GoodsOrder
sql := `
SELECT * FROM goods_order WHERE vendor_order_id2 = ?
`
sqlParams := []interface{}{orderID}
if dao.GetRow(dao.GetDB(), &goodsOrder, sql, sqlParams); goodsOrder != nil {
if goodsOrder.Status != model.OrderStatusCanceled {
goodsOrder.Status = model.OrderStatusCanceled
dao.UpdateEntity(dao.GetDB(), goodsOrder, "Status")
}
}
}
return err
}
func SaveJdsOrders(ctx *jxcontext.Context, orderCreatedStart, orderCreatedEnd time.Time) (err error) { func SaveJdsOrders(ctx *jxcontext.Context, orderCreatedStart, orderCreatedEnd time.Time) (err error) {
var ( var (
pageSize = 20 pageSize = 20

View File

@@ -182,6 +182,7 @@ func Init() {
ScheduleTimerFuncByInterval(func() { ScheduleTimerFuncByInterval(func() {
orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-30*time.Minute), time.Now()) orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-30*time.Minute), time.Now())
orderman.UpdateJdsOrdersStatus(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -1), time.Now())
}, 5*time.Second, 5*time.Minute) }, 5*time.Second, 5*time.Minute)
ScheduleTimerFuncByInterval(func() { ScheduleTimerFuncByInterval(func() {