diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index cbea17bcd..0cd1af7e2 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -19,6 +19,7 @@ import ( const ( AcceptMaxCount = 2 + CancelMaxCount = 5 ) func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) { @@ -106,3 +107,18 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) { func GetJobs(ctx *jxcontext.Context, userIDs []string, categoryIDs []int, includeStep bool, fromTime, toTime string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) { return dao.GetJobs(dao.GetDB(), userIDs, categoryIDs, includeStep, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset) } + +func AcceptJob(ctx *jxcontext.Context, jobID int) (err error) { + var ( + db = dao.GetDB() + // userID = ctx.GetUserID() + ) + job := &model.Job{} + job.ID = jobID + err = dao.GetEntity(db, &job) + if job.UserID == "" || job.Status == model.JobStatusFailed || job.FinishedAt.Sub(time.Now()) <= 0 { + return fmt.Errorf("未找到该任务或该任务状态不正常,无法接单!") + } + + return err +} diff --git a/business/model/dao/job.go b/business/model/dao/dao_job.go similarity index 96% rename from business/model/dao/job.go rename to business/model/dao/dao_job.go index 59d5ecf2a..98e29e32d 100644 --- a/business/model/dao/job.go +++ b/business/model/dao/dao_job.go @@ -147,3 +147,10 @@ func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) { job.JobSteps = jobSteps return job, err } + +func GetJobOrders(db *DaoDB, jobID int, userID string, status int) (jobOrders []*model.JobOrder, err error) { + // sql := ` + // SELECT + // ` + return jobOrders, err +} diff --git a/business/model/job.go b/business/model/job.go index 40d66c4cc..4b1fcda45 100644 --- a/business/model/job.go +++ b/business/model/job.go @@ -3,9 +3,15 @@ package model import "time" const ( - JobStatusDoing = 0 - JobStatusFinished = 1 - JobStatusFailed = -1 + JobStatusDoing = 0 //正在进行中 + JobStatusFinished = 1 //任务所有都被完成 + JobStatusFailed = -1 //任务发布失败 + JobStatusOverdue = -2 //任务过期 + + JobLimitCountTypePO = 1 //每人一次 + JobLimitCountTypePDO = 2 //每人每天一次 + JobLimitCountTypePWO = 3 //每人每周一次 + JobLimitCountTypeNoLimie = 4 //不限制 JobOrderStatusAccept = 5 JobOrderStatusWaitAudit = 10 @@ -18,22 +24,26 @@ const ( type Job struct { ModelIDCULD - UserID string `orm:"column(user_id)" json:"thingID"` //发布人ID - JobCategoryID int `orm:"column(job_category_id)" json:"jobCategoryID"` //任务类型 - JobSpan string `orm:"size(500)" json:"jobSpan"` //任务标签 - Title string `orm:"size(255)" json:"title"` //任务标题 - Content string `orm:"size(500)" json:"content"` //任务内容 - Count int `json:"count"` //任务数量 - AvgPrice int `json:"avgPrice"` //单个任务金额 - TotalPrice int `json:"totalPrice"` //任务总金额 - Status int `json:"status"` //任务状态 - Address string `orm:"size(500)" json:"address"` //任务地址 - Lng int `json:"lng"` //乘了10的6次方 - Lat int `json:"lat"` //乘了10的6次方 - FinishedAt time.Time `json:"finishedAt"` //截止日期 - StoreURL string `orm:"column(store_url)" json:"storeURL"` //门店链接 - SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接 - JobSteps []*JobStep `orm:"-" json:"jobSteps"` + UserID string `orm:"column(user_id)" json:"thingID"` //发布人ID + JobCategoryID int `orm:"column(job_category_id)" json:"jobCategoryID"` //任务类型 + JobSpan string `orm:"size(500)" json:"jobSpan"` //任务标签 + Title string `orm:"size(255)" json:"title"` //任务标题 + Content string `orm:"size(500)" json:"content"` //任务内容 + Count int `json:"count"` //任务数量 + SurplusCount int `json:"surplusCount"` //剩余数量 + AvgPrice int `json:"avgPrice"` //单个任务金额 + TotalPrice int `json:"totalPrice"` //任务总金额 + Status int `json:"status"` //任务状态 + Address string `orm:"size(500)" json:"address"` //任务地址 + Lng int `json:"lng"` //乘了10的6次方 + Lat int `json:"lat"` //乘了10的6次方 + JobLimitAt int `json:"jobLimitAt"` //任务限时完成小时数 + AuditLimitAt int `json:"auditLimitAt"` //任务审核限时小时数 + FinishedAt time.Time `json:"finishedAt"` //接单截止日期 + LimitCountType int `json:"limitCountType"` //任务限次类型,1为每人一次,2为每人每天一次,3为每人每周一次,4为不限制 + StoreURL string `orm:"column(store_url)" json:"storeURL"` //门店链接 + SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接 + JobSteps []*JobStep `orm:"-" json:"jobSteps"` } func (v *Job) TableIndex() [][]string { @@ -63,6 +73,7 @@ type JobStep struct { StepCount int `json:"stepCount"` //步骤数 Content string `orm:"size(500)" json:"content"` //步骤内容 Img string `orm:"size(500)" json:"img"` //步骤图片 + Type int `json:"type"` //步骤类型,1为任务步骤,2为收集信息 } func (v *JobStep) TableIndex() [][]string { @@ -74,13 +85,13 @@ func (v *JobStep) TableIndex() [][]string { type JobOrder struct { ModelIDCUL - JobID int `orm:"column(job_id)" json:"jobID"` //任务ID - UserID string `orm:"column(user_id)" json:"thingID"` //接任务人ID - Status int `json:"status"` //任务订单状态,接单,待审核,已审核,已结算等 - SubmitAuditAt time.Time `json:"submitAuditTime"` //提交审核日期 - AuditAt time.Time `json:"auditAt"` //审核日期 - Content string `josn:"content"` //任务审核内容 - Img string `json:"img"` //任务审核图片 + JobID int `orm:"column(job_id)" json:"jobID"` //任务ID + UserID string `orm:"column(user_id)" json:"userID"` //接任务人ID + Status int `json:"status"` //任务订单状态,接单,待审核,已审核,已结算等 + SubmitAuditAt time.Time `json:"submitAuditTime"` //提交审核日期 + AuditAt time.Time `json:"auditAt"` //审核日期 + Content string `josn:"content"` //任务审核内容 + Img string `json:"img"` //任务审核图片 } func (v *JobOrder) TableIndex() [][]string { diff --git a/controllers/job_controller.go b/controllers/job_controller.go index 0490ba4a3..134e8006c 100644 --- a/controllers/job_controller.go +++ b/controllers/job_controller.go @@ -92,7 +92,32 @@ func (c *JobController) GetJobDetail() { // @router /AcceptJob [post] func (c *JobController) AcceptJob() { c.callAcceptJob(func(params *tJobAcceptJobParams) (retVal interface{}, errCode string, err error) { - + err = cms.AcceptJob(params.Ctx, params.JobID) + return retVal, "", err + }) +} + +// @Title 查看接受的任务列表 +// @Description 查看接受的任务列表 +// @Param token header string true "认证token" +// @Param userID query string false "用户ID" +// @Param categoryID query string false "分类ID" +// @Param statuss query string false "状态s" +// @Param fromTime query string false "开始时间" +// @Param toTime query string false "结束时间" +// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" +// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetJobOrders [get] +func (c *JobController) GetJobOrders() { + c.callGetJobOrders(func(params *tJobGetJobOrdersParams) (retVal interface{}, errCode string, err error) { + var ( + statuss []int + ) + if err = jxutils.Strings2Objs(params.Statuss, statuss); err == nil { + // retVal, err = cms.GetJobs(params.Ctx, userIDs, categoryIDs, params.FromTime, params.ToTime, params.PageSize, params.Offset) + } return retVal, "", err }) }