From b485bb7beca31b4a356f0f47901387ed81d97c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 29 Oct 2020 14:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=99=E9=A2=9D=E4=B8=8D=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/job.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index 38dd946e3..ff24a9529 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -61,7 +61,7 @@ func getWeekTime() (weekTimeBegin, weekTimeEnd time.Time) { return weekTimeBegin, weekTimeEnd } -func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (err error) { +func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, err error) { var ( db = dao.GetDB() job = &model.Job{} @@ -78,42 +78,40 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (err error) { json.Unmarshal(data, &job) } if job.UserID == "" { - return fmt.Errorf("参数有误!") + return errCode, fmt.Errorf("参数有误!") } if ctx.GetUserID() != job.UserID { - return fmt.Errorf("用户信息已过期,请重新登录!") + return errCode, fmt.Errorf("用户信息已过期,请重新登录!") } //发布任务要扣除任务总额的保证金,不够扣就要进行充值 userBill, err := dao.GetUserBill(db, job.UserID, "") if userBill == nil { - return fmt.Errorf("未查询到该用户的账单!") + return errCode, fmt.Errorf("未查询到该用户的账单!") } job.TotalPrice = job.Count * job.AvgPrice if userBill.AccountBalance < job.TotalPrice { - job.Status = model.JobStatusFailed - } else { - job.Status = model.JobStatusDoing + return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!") } if job.Count <= 0 { - return fmt.Errorf("任务数量不能为0!") + return errCode, fmt.Errorf("任务数量不能为0!") } if job.UserID == "" { - return fmt.Errorf("任务发起人不能为空!") + return errCode, fmt.Errorf("任务发起人不能为空!") } jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, DayTimeBegin, DayTimeEnd, false) if len(jobs) > 0 { members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal) if err != nil { - return err + return errCode, err } if len(members) <= 0 { - return fmt.Errorf("非会员一天只能发布一起任务,请确认!") + return errCode, fmt.Errorf("非会员一天只能发布一起任务,请确认!") } } if job.Address != "" && (job.Lng == 0 || job.Lat == 0) { lng, lat, err := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address) if err != nil { - return err + return errCode, err } job.Lng = jxutils.StandardCoordinate2Int(lng) job.Lat = jxutils.StandardCoordinate2Int(lat) @@ -147,7 +145,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (err error) { } } dao.Commit(db) - return err + return errCode, err } func CancelPublishJob(ctx *jxcontext.Context, jobID int) (err error) {