@@ -120,6 +120,7 @@ func initTasks() { | |||||
jobs[taskMd.ZhimengCronKuaishouOrder] = taskKuaishouOrder // | jobs[taskMd.ZhimengCronKuaishouOrder] = taskKuaishouOrder // | ||||
jobs[taskMd.ZhimengCronKuaishouAuth] = taskKuaishouAuth // | jobs[taskMd.ZhimengCronKuaishouAuth] = taskKuaishouAuth // | ||||
jobs[taskMd.ZhimengCronMeituanOrder] = taskMeituanOrder // | jobs[taskMd.ZhimengCronMeituanOrder] = taskMeituanOrder // | ||||
jobs[taskMd.ZhimengCronMeituanStoreOrder] = taskMeituanStoreOrder // | |||||
jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle // | jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle // | ||||
} | } |
@@ -41,6 +41,7 @@ const ( | |||||
ZhimengCronHwTourismOrder = "zhimeng_cron_hw_tourism_order" | ZhimengCronHwTourismOrder = "zhimeng_cron_hw_tourism_order" | ||||
ZhimengCronKuaishouOrder = "zhimeng_cron_kuaishou_order" | ZhimengCronKuaishouOrder = "zhimeng_cron_kuaishou_order" | ||||
ZhimengCronMeituanOrder = "zhimeng_cron_meituan_order" | ZhimengCronMeituanOrder = "zhimeng_cron_meituan_order" | ||||
ZhimengCronMeituanStoreOrder = "zhimeng_cron_meituan_store_order" | |||||
ZhimengCronKuaishouAuth = "zhimeng_cron_kuaishou_auth" | ZhimengCronKuaishouAuth = "zhimeng_cron_kuaishou_auth" | ||||
ZhimengCronTikTokLocalLifeOrder = "zhimeng_cron_tik_tok_local_life_order" | ZhimengCronTikTokLocalLifeOrder = "zhimeng_cron_tik_tok_local_life_order" | ||||
ZhimengCronCsjpLocalLifeOrder = "zhimeng_cron_csjp_local_life_order" | ZhimengCronCsjpLocalLifeOrder = "zhimeng_cron_csjp_local_life_order" | ||||
@@ -63,7 +63,7 @@ func MeituanOrder() { | |||||
if pageNo == 1 { | if pageNo == 1 { | ||||
nextPositionIndex = "" | nextPositionIndex = "" | ||||
} | } | ||||
count, positionIndex = OrdersMeituanGet(nextPositionIndex, pageSize, beginTime, endTime, "update", 0) | |||||
count, positionIndex = OrdersMeituanGet(nextPositionIndex, pageSize, beginTime, endTime, "update", 1) | |||||
if count == 0 { | if count == 0 { | ||||
nextPositionIndex = "" | nextPositionIndex = "" | ||||
goto ChkArg | goto ChkArg | ||||
@@ -106,6 +106,7 @@ func OrdersMeituanGet(nextPositionIndex string, pageSize int, sTime, eTime int64 | |||||
"startTime": sTime, // | "startTime": sTime, // | ||||
"endTime": eTime, // | "endTime": eTime, // | ||||
"limit": pageSize, | "limit": pageSize, | ||||
"platform": pvd, | |||||
"scrollId": nextPositionIndex, | "scrollId": nextPositionIndex, | ||||
} | } | ||||
method1 := "query_order" | method1 := "query_order" | ||||
@@ -0,0 +1,91 @@ | |||||
package svc | |||||
import ( | |||||
offical "applet/app/db/official" | |||||
"applet/app/utils" | |||||
"fmt" | |||||
"strings" | |||||
"time" | |||||
) | |||||
func MeituanStoreOrder() { | |||||
pvdTimeKey := "meituan_store_time" | |||||
// 获得最后时间 | |||||
latest := offical.SysCfgByKey(pvdTimeKey) | |||||
if latest == nil { | |||||
offical.DbsSysCfgInserts(pvdTimeKey, time.Now().String()) | |||||
latest = offical.SysCfgByKey(pvdTimeKey) | |||||
} | |||||
// 所有时间都是在操作秒数 | |||||
now := time.Now().Unix() | |||||
strs := strings.Split(latest.V, ":") | |||||
timeStr := latest.V | |||||
if len(strs) == 3 { | |||||
timeStr = strs[0] + ":" + strs[1] + ":00" | |||||
} | |||||
fmt.Println(timeStr) | |||||
past := utils.TimeParseStd(timeStr).Unix() | |||||
// 如果上次记录超过30天或者 过去时间大于当前时间戳, 把时间设置为此前20分钟 | |||||
if past < now-180*86400 || past > now { | |||||
past = now | |||||
} | |||||
var ( | |||||
beginTime int64 = 0 | |||||
endTime int64 = 0 | |||||
pageNo int = 1 | |||||
pageSize int = 50 | |||||
nextPositionIndex string = "" | |||||
) | |||||
//怕时间不是走最新的 | |||||
leave := now - past | |||||
if leave > 500 { | |||||
leave = 0 | |||||
} | |||||
past = past + leave | |||||
beginTime = past - 300 | |||||
endTime = past | |||||
if endTime > now { | |||||
endTime = now | |||||
} | |||||
for { | |||||
count := 0 | |||||
var positionIndex = "" | |||||
if pageNo == 1 { | |||||
nextPositionIndex = "" | |||||
} | |||||
count, positionIndex = OrdersMeituanGet(nextPositionIndex, pageSize, beginTime, endTime, "update", 2) | |||||
if count == 0 { | |||||
nextPositionIndex = "" | |||||
goto ChkArg | |||||
} | |||||
// 判断是否分页已经全部取完了 | |||||
if count <= pageSize { | |||||
nextPositionIndex = positionIndex | |||||
pageNo++ | |||||
fmt.Println("========下一页========" + utils.IntToStr(pageNo)) | |||||
count = 0 | |||||
continue | |||||
} | |||||
ChkArg: | |||||
nextPositionIndex = "" | |||||
// 查询完后重置时间, 最后查询时间 | |||||
if endTime < now { | |||||
pageNo = 1 | |||||
offical.DbsSysCfgUpdate(pvdTimeKey, utils.TimeToStr(endTime)) | |||||
beginTime = endTime | |||||
endTime = endTime + 300 | |||||
if endTime > now { | |||||
endTime = now | |||||
} | |||||
count = 0 | |||||
continue | |||||
} | |||||
count = 0 | |||||
break | |||||
} | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package task | |||||
import ( | |||||
"applet/app/task/svc" | |||||
"math/rand" | |||||
"time" | |||||
) | |||||
func taskMeituanStoreOrder() { | |||||
for { | |||||
if len(ch) > workerNum { | |||||
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) | |||||
} else { | |||||
goto START | |||||
} | |||||
} | |||||
START: | |||||
ch <- 1 | |||||
svc.MeituanStoreOrder() | |||||
<-ch | |||||
} |