From c659732c5de30726acb30964bb2a41f00133ef1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Jan 2021 14:47:14 +0800 Subject: [PATCH] aa --- business/jxstore/cms/job.go | 22 +++++++++++++--------- business/model/dao/dao_job.go | 2 +- business/model/dao/dao_order.go | 2 +- business/model/job.go | 6 ++++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index cc81b6a59..e133fd725 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -166,12 +166,12 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e dao.Rollback(db) return } - for _, v := range job.JobSteps { + for _, v := range jobExt.JobSteps { dao.WrapAddIDCULDEntity(v, ctx.GetUserName()) v.JobID = job.ID err = dao.CreateEntity(db, v) } - for _, v := range job.JobImgs { + for _, v := range jobExt.JobImgs { dao.WrapAddIDCULEntity(v, ctx.GetUserName()) v.JobID = job.ID err = dao.CreateEntity(db, v) @@ -1567,10 +1567,14 @@ func AddressDistinguish(ctx *jxcontext.Context, address string) (result *txcloud func UpdateJob(ctx *jxcontext.Context, payload map[string]interface{}) (err error) { var ( - db = dao.GetDB() - job = &model.Job{} + db = dao.GetDB() + jobExt = &model.JobExt{} + job = &model.Job{} ) - utils.Map2StructByJson(payload, &job, false) + utils.Map2StructByJson(payload, &jobExt, false) + if data, err := json.Marshal(jobExt); err == nil { + json.Unmarshal(data, &job) + } valid := dao.StrictMakeMapByStructObject(payload, job, ctx.GetUserName()) if len(valid) > 0 { dao.Begin(db) @@ -1584,23 +1588,23 @@ func UpdateJob(ctx *jxcontext.Context, payload map[string]interface{}) (err erro dao.Rollback(db) return err } - if len(job.JobSteps) > 0 { + if len(jobExt.JobSteps) > 0 { steps, _ := dao.GetJobSteps(db, job.ID) for _, v := range steps { v.DeletedAt = time.Now() dao.UpdateEntity(db, v, "DeletedAt") } - if err = dao.CreateMultiEntities(db, job.JobSteps); err != nil { + if err = dao.CreateMultiEntities(db, jobExt.JobSteps); err != nil { dao.Rollback(db) return err } } - if len(job.JobImgs) > 0 { + if len(jobExt.JobImgs) > 0 { imgs, _ := dao.GetJobImgs(db, job.ID) for _, v := range imgs { dao.DeleteEntity(db, v) } - if err = dao.CreateMultiEntities(db, job.JobImgs); err != nil { + if err = dao.CreateMultiEntities(db, jobExt.JobImgs); err != nil { dao.Rollback(db) return err } diff --git a/business/model/dao/dao_job.go b/business/model/dao/dao_job.go index 5a3e06f0c..3a65a86d4 100644 --- a/business/model/dao/dao_job.go +++ b/business/model/dao/dao_job.go @@ -32,7 +32,7 @@ func GetJobCategories(db *DaoDB, name string) (jobCategories []*model.JobCategor } type GetJobsResult struct { - model.Job + model.JobExt CategoryName string `json:"categoryName"` //分类名 IndexImg string `json:"indexImg"` //任务封面 Distance float64 `json:"distance"` //距用户距离 diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 9ca24a2e9..b526abdac 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -211,7 +211,7 @@ func GetPayStatistics(db *DaoDB, userID string, pop int, cityCodes []int, mobile sql += ` (SELECT SUM(IFNULL(b.pay_price,0)) total_pay FROM user a - JOIN ` + "`order` b" + `ON b.user_id = a.user_id AND b.type = ? AND b.status = ? ` + getWhereSql(sqlP) + ` + JOIN ` + "`order` b " + `ON b.user_id = a.user_id AND b.type = ? AND b.status = ? ` + getWhereSql(sqlP) + ` ` sqlP = append(sqlP, orderType, status) if mobile != "" { diff --git a/business/model/job.go b/business/model/job.go index 6d5f0e6bc..878ee420f 100644 --- a/business/model/job.go +++ b/business/model/job.go @@ -122,8 +122,8 @@ type Job struct { SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接 Type int `json:"type"` //任务类型,0为普通任务,1为特殊任务 BrowseCount int `json:"browseCount"` //任务浏览量,点一下加一下 - JobSteps []*JobStep `orm:"-" json:"jobSteps"` - JobImgs []*JobImg `orm:"-" json:"jobImgs"` + // JobSteps []*JobStep `orm:"-" json:"jobSteps"` + // JobImgs []*JobImg `orm:"-" json:"jobImgs"` } func (v *Job) TableIndex() [][]string { @@ -136,6 +136,8 @@ func (v *Job) TableIndex() [][]string { type JobExt struct { FinishedAtStr string `json:"finishedAtStr"` //接单截止日期 Job + JobSteps []*JobStep `orm:"-" json:"jobSteps"` + JobImgs []*JobImg `orm:"-" json:"jobImgs"` } type JobImg struct {