This commit is contained in:
suyl
2021-08-10 15:32:40 +08:00
parent c82ee269cd
commit 0b2d728ae3

View File

@@ -2149,9 +2149,9 @@ func GetVendorMatterRcmmd(ctx *jxcontext.Context, vendorID int, goodsID string,
func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) { func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
var ( var (
db = dao.GetDB() db = dao.GetDB()
actMap = make(map[int]*mtunionapi.ActivityListResult) actMap = make(map[int]*partner.ActivityList)
jobMap = make(map[int]*dao.GetJobsResult) jobMap = make(map[int]*dao.GetJobsResult)
addList []*mtunionapi.ActivityListResult addList []*partner.ActivityList
now = time.Now() now = time.Now()
) )
//先找出美团联盟所有发布任务(此任务只用于显示) //先找出美团联盟所有发布任务(此任务只用于显示)
@@ -2160,18 +2160,15 @@ func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
return err return err
} }
//再查美团联盟上的所有活动 //再查美团联盟上的所有活动
acts, err := mt.GetAPI().ActivityList(1, 20, 0) handler := partner.GetHandler(model.VendorIDMTWM)
acts, err := handler.GetUnionActList(ctx, 1)
if err != nil { if err != nil {
return err return err
} }
for _, v := range acts { for _, v := range acts {
if v.DateBound != "" { //在有效期内
dateBegin := utils.Str2Time(v.DateBound[:strings.LastIndex(v.DateBound, "至")-1]) if now.Sub(v.DateBegin) > 0 && v.DateEnd.Sub(now) > 0 {
dateEnd := utils.Str2Time(v.DateBound[strings.LastIndex(v.DateBound, "至")+4:]) actMap[v.ActID] = v
//在有效期内
if now.Sub(dateBegin) > 0 && dateEnd.Sub(now) > 0 {
actMap[v.ID] = v
}
} }
} }
//筛一下 //筛一下
@@ -2189,7 +2186,6 @@ func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
//推广规则 //推广规则
storeURL := "" storeURL := ""
percentage := 0 percentage := 0
dateEnd := v.DateBound[strings.LastIndex(v.DateBound, "至")+4:]
if v.ActRule != "" { if v.ActRule != "" {
if storeURLs := regexp.MustCompile(`href=\\\\\\"(.*?)"\\\\\\`).FindStringSubmatch(v.ActRule); len(storeURLs) > 0 { if storeURLs := regexp.MustCompile(`href=\\\\\\"(.*?)"\\\\\\`).FindStringSubmatch(v.ActRule); len(storeURLs) > 0 {
fmt.Println("storeURLs .........................", storeURLs) fmt.Println("storeURLs .........................", storeURLs)
@@ -2202,7 +2198,7 @@ func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
} }
} }
PublishJob(ctx, &model.JobExt{ PublishJob(ctx, &model.JobExt{
FinishedAtStr: dateEnd, FinishedAtStr: utils.Time2Str(v.DateEnd),
Job: model.Job{ Job: model.Job{
VendorID: model.VendorIDMTWM, VendorID: model.VendorIDMTWM,
Title: v.ActName, Title: v.ActName,
@@ -2218,9 +2214,9 @@ func MtUnionJobAutoUpdate(ctx *jxcontext.Context) (err error) {
Type: model.JobTypeOther, Type: model.JobTypeOther,
CashbackType: 1, CashbackType: 1,
JobCityCode: 999, JobCityCode: 999,
UnionImg: v.URL, UnionImg: v.Img,
UnionQrcodePosition: "SouthEast", UnionQrcodePosition: "SouthEast",
UnionActID: utils.Int2Str(v.ID), UnionActID: utils.Int2Str(v.ActID),
Percentage: percentage, Percentage: percentage,
}, },
}) })