aa
This commit is contained in:
@@ -1760,107 +1760,51 @@ type Store struct {
|
||||
|
||||
func TempJob() (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
ctx = jxcontext.AdminCtx
|
||||
storesJD []*Store
|
||||
// storesMT []*Store
|
||||
db = dao.GetDB()
|
||||
ctx = jxcontext.AdminCtx
|
||||
// storesJD []*Store
|
||||
storesMT []*Store
|
||||
)
|
||||
db.Db.Using("c4")
|
||||
sql := `
|
||||
SELECT a.*, b.vendor_store_id
|
||||
FROM store a
|
||||
JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 0 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
WHERE a.deleted_at = ?
|
||||
AND a.id <> 667281
|
||||
AND a.id = 667278
|
||||
AND a.status IN (1,0)
|
||||
`
|
||||
sqlParams := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
if err = dao.GetRows(db, &storesJD, sql, sqlParams); err != nil {
|
||||
return err
|
||||
}
|
||||
// sql2 := `
|
||||
// sql := `
|
||||
// SELECT a.*, b.vendor_store_id
|
||||
// FROM store a
|
||||
// JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 1 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
// JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 0 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
// WHERE a.deleted_at = ?
|
||||
// AND a.id <> 667281
|
||||
// AND a.id = 667278
|
||||
// AND a.status IN (1,0)
|
||||
// `
|
||||
// sqlParams2 := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
// if err = dao.GetRows(db, &storesMT, sql2, sqlParams2); err != nil {
|
||||
// sqlParams := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
// if err = dao.GetRows(db, &storesJD, sql, sqlParams); err != nil {
|
||||
// return err
|
||||
// }
|
||||
sql2 := `
|
||||
SELECT a.*, b.vendor_store_id
|
||||
FROM store a
|
||||
JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 1 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
WHERE a.deleted_at = ?
|
||||
AND a.id <> 667281
|
||||
AND a.id = 667278
|
||||
AND a.status IN (1,0)
|
||||
`
|
||||
sqlParams2 := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
if err = dao.GetRows(db, &storesMT, sql2, sqlParams2); err != nil {
|
||||
return err
|
||||
}
|
||||
db.Db.Using("default")
|
||||
task := tasksch.NewParallelTask("TempJob", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task2 *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
step := batchItemList[0].(int)
|
||||
switch step {
|
||||
case 0:
|
||||
task := tasksch.NewParallelTask("TempJob1", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*Store)
|
||||
job := &model.Job{
|
||||
UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
JobCategoryID: 3,
|
||||
Title: "京东(" + store.Name + ")",
|
||||
Content: "领取任务后,需要尽快去完成,并提交截图。如超时未完成,任务会被取消",
|
||||
Count: 1000,
|
||||
AvgPrice: 300,
|
||||
TotalPrice: 300000,
|
||||
Status: 0,
|
||||
Address: store.Address,
|
||||
StoreURL: store.VendorStoreID,
|
||||
SurplusCount: 1000,
|
||||
JobLimitAt: 72,
|
||||
AuditLimitAt: 168,
|
||||
LimitCountType: 3,
|
||||
VendorID: 0,
|
||||
CashbackType: 1,
|
||||
JobLat: jxutils.IntCoordinate2Standard(store.Lat),
|
||||
JobLng: jxutils.IntCoordinate2Standard(store.Lng),
|
||||
JobCityCode: store.CityCode,
|
||||
}
|
||||
finishAt := utils.Str2Time("2021-12-30 00:00:00")
|
||||
job.FinishedAt = &finishAt
|
||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, store.CityCode)
|
||||
job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
if err = dao.CreateEntity(db, job); err == nil {
|
||||
jobsteps, _ := dao.GetJobSteps(db, 171)
|
||||
for _, v := range jobsteps {
|
||||
jobStep := &model.JobStep{
|
||||
JobID: job.ID,
|
||||
StepCount: v.StepCount,
|
||||
Content: v.Content,
|
||||
Img: v.Img,
|
||||
Type: v.Type,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(jobStep, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, jobStep)
|
||||
}
|
||||
jobImgs, _ := dao.GetJobImgs(db, 171)
|
||||
for _, v := range jobImgs {
|
||||
jobImg := &model.JobImg{
|
||||
JobID: job.ID,
|
||||
Img: v.Img,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(jobImg, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, jobImg)
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, storesJD)
|
||||
tasksch.HandleTask(task, task2, true).Run()
|
||||
task.GetResult(0)
|
||||
case 1:
|
||||
// task := tasksch.NewParallelTask("TempJob2", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
// task := tasksch.NewParallelTask("TempJob1", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// store := batchItemList[0].(*Store)
|
||||
// job := &model.Job{
|
||||
// UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
// JobCategoryID: 3,
|
||||
// Title: "美团(" + store.Name + ")",
|
||||
// Title: "京东(" + store.Name + ")",
|
||||
// Content: "领取任务后,需要尽快去完成,并提交截图。如超时未完成,任务会被取消",
|
||||
// Count: 1000,
|
||||
// AvgPrice: 300,
|
||||
@@ -1872,17 +1816,17 @@ func TempJob() (err error) {
|
||||
// JobLimitAt: 72,
|
||||
// AuditLimitAt: 168,
|
||||
// LimitCountType: 3,
|
||||
// VendorID: 1,
|
||||
// VendorID: 0,
|
||||
// CashbackType: 1,
|
||||
// JobLat: jxutils.IntCoordinate2Standard(store.Lat),
|
||||
// JobLng: jxutils.IntCoordinate2Standard(store.Lng),
|
||||
// Lng: store.Lng,
|
||||
// Lat: store.Lat,
|
||||
// JobCityCode: store.CityCode,
|
||||
// }
|
||||
// finishAt := utils.Str2Time("2021-12-31 00:00:00")
|
||||
// job.FinishedAt = &finishAt
|
||||
// lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, store.CityCode)
|
||||
// job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
// job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
// dao.WrapAddIDCULDEntity(job, ctx.GetUserName())
|
||||
// if err = dao.CreateEntity(db, job); err == nil {
|
||||
// jobsteps, _ := dao.GetJobSteps(db, 171)
|
||||
// for _, v := range jobsteps {
|
||||
@@ -1907,9 +1851,66 @@ func TempJob() (err error) {
|
||||
// }
|
||||
// }
|
||||
// return retVal, err
|
||||
// }, storesMT)
|
||||
// }, storesJD)
|
||||
// tasksch.HandleTask(task, task2, true).Run()
|
||||
// task.GetResult(0)
|
||||
case 1:
|
||||
task := tasksch.NewParallelTask("TempJob2", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*Store)
|
||||
job := &model.Job{
|
||||
UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
JobCategoryID: 3,
|
||||
Title: "美团(" + store.Name + ")",
|
||||
Content: "领取任务后,需要尽快去完成,并提交截图。如超时未完成,任务会被取消",
|
||||
Count: 1000,
|
||||
AvgPrice: 300,
|
||||
TotalPrice: 300000,
|
||||
Status: 0,
|
||||
Address: store.Address,
|
||||
StoreURL: store.VendorStoreID,
|
||||
SurplusCount: 1000,
|
||||
JobLimitAt: 72,
|
||||
AuditLimitAt: 168,
|
||||
LimitCountType: 3,
|
||||
VendorID: 1,
|
||||
CashbackType: 1,
|
||||
JobLat: jxutils.IntCoordinate2Standard(store.Lat),
|
||||
JobLng: jxutils.IntCoordinate2Standard(store.Lng),
|
||||
Lng: store.Lng,
|
||||
Lat: store.Lat,
|
||||
JobCityCode: store.CityCode,
|
||||
}
|
||||
finishAt := utils.Str2Time("2021-12-31 00:00:00")
|
||||
job.FinishedAt = &finishAt
|
||||
dao.WrapAddIDCULDEntity(job, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, job); err == nil {
|
||||
jobsteps, _ := dao.GetJobSteps(db, 171)
|
||||
for _, v := range jobsteps {
|
||||
jobStep := &model.JobStep{
|
||||
JobID: job.ID,
|
||||
StepCount: v.StepCount,
|
||||
Content: v.Content,
|
||||
Img: v.Img,
|
||||
Type: v.Type,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(jobStep, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, jobStep)
|
||||
}
|
||||
jobImgs, _ := dao.GetJobImgs(db, 171)
|
||||
for _, v := range jobImgs {
|
||||
jobImg := &model.JobImg{
|
||||
JobID: job.ID,
|
||||
Img: v.Img,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(jobImg, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, jobImg)
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, storesMT)
|
||||
tasksch.HandleTask(task, task2, true).Run()
|
||||
task.GetResult(0)
|
||||
}
|
||||
return retVal, err
|
||||
}, []int{0, 1})
|
||||
|
||||
Reference in New Issue
Block a user