job limit
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AcceptMaxCount = 2
|
AcceptMaxCount = 2
|
||||||
|
CancelMaxCount = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
|
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) {
|
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)
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,3 +147,10 @@ func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
|
|||||||
job.JobSteps = jobSteps
|
job.JobSteps = jobSteps
|
||||||
return job, err
|
return job, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetJobOrders(db *DaoDB, jobID int, userID string, status int) (jobOrders []*model.JobOrder, err error) {
|
||||||
|
// sql := `
|
||||||
|
// SELECT
|
||||||
|
// `
|
||||||
|
return jobOrders, err
|
||||||
|
}
|
||||||
@@ -3,9 +3,15 @@ package model
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
JobStatusDoing = 0
|
JobStatusDoing = 0 //正在进行中
|
||||||
JobStatusFinished = 1
|
JobStatusFinished = 1 //任务所有都被完成
|
||||||
JobStatusFailed = -1
|
JobStatusFailed = -1 //任务发布失败
|
||||||
|
JobStatusOverdue = -2 //任务过期
|
||||||
|
|
||||||
|
JobLimitCountTypePO = 1 //每人一次
|
||||||
|
JobLimitCountTypePDO = 2 //每人每天一次
|
||||||
|
JobLimitCountTypePWO = 3 //每人每周一次
|
||||||
|
JobLimitCountTypeNoLimie = 4 //不限制
|
||||||
|
|
||||||
JobOrderStatusAccept = 5
|
JobOrderStatusAccept = 5
|
||||||
JobOrderStatusWaitAudit = 10
|
JobOrderStatusWaitAudit = 10
|
||||||
@@ -18,22 +24,26 @@ const (
|
|||||||
type Job struct {
|
type Job struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
UserID string `orm:"column(user_id)" json:"thingID"` //发布人ID
|
UserID string `orm:"column(user_id)" json:"thingID"` //发布人ID
|
||||||
JobCategoryID int `orm:"column(job_category_id)" json:"jobCategoryID"` //任务类型
|
JobCategoryID int `orm:"column(job_category_id)" json:"jobCategoryID"` //任务类型
|
||||||
JobSpan string `orm:"size(500)" json:"jobSpan"` //任务标签
|
JobSpan string `orm:"size(500)" json:"jobSpan"` //任务标签
|
||||||
Title string `orm:"size(255)" json:"title"` //任务标题
|
Title string `orm:"size(255)" json:"title"` //任务标题
|
||||||
Content string `orm:"size(500)" json:"content"` //任务内容
|
Content string `orm:"size(500)" json:"content"` //任务内容
|
||||||
Count int `json:"count"` //任务数量
|
Count int `json:"count"` //任务数量
|
||||||
AvgPrice int `json:"avgPrice"` //单个任务金额
|
SurplusCount int `json:"surplusCount"` //剩余数量
|
||||||
TotalPrice int `json:"totalPrice"` //任务总金额
|
AvgPrice int `json:"avgPrice"` //单个任务金额
|
||||||
Status int `json:"status"` //任务状态
|
TotalPrice int `json:"totalPrice"` //任务总金额
|
||||||
Address string `orm:"size(500)" json:"address"` //任务地址
|
Status int `json:"status"` //任务状态
|
||||||
Lng int `json:"lng"` //乘了10的6次方
|
Address string `orm:"size(500)" json:"address"` //任务地址
|
||||||
Lat int `json:"lat"` //乘了10的6次方
|
Lng int `json:"lng"` //乘了10的6次方
|
||||||
FinishedAt time.Time `json:"finishedAt"` //截止日期
|
Lat int `json:"lat"` //乘了10的6次方
|
||||||
StoreURL string `orm:"column(store_url)" json:"storeURL"` //门店链接
|
JobLimitAt int `json:"jobLimitAt"` //任务限时完成小时数
|
||||||
SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接
|
AuditLimitAt int `json:"auditLimitAt"` //任务审核限时小时数
|
||||||
JobSteps []*JobStep `orm:"-" json:"jobSteps"`
|
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 {
|
func (v *Job) TableIndex() [][]string {
|
||||||
@@ -63,6 +73,7 @@ type JobStep struct {
|
|||||||
StepCount int `json:"stepCount"` //步骤数
|
StepCount int `json:"stepCount"` //步骤数
|
||||||
Content string `orm:"size(500)" json:"content"` //步骤内容
|
Content string `orm:"size(500)" json:"content"` //步骤内容
|
||||||
Img string `orm:"size(500)" json:"img"` //步骤图片
|
Img string `orm:"size(500)" json:"img"` //步骤图片
|
||||||
|
Type int `json:"type"` //步骤类型,1为任务步骤,2为收集信息
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *JobStep) TableIndex() [][]string {
|
func (v *JobStep) TableIndex() [][]string {
|
||||||
@@ -74,13 +85,13 @@ func (v *JobStep) TableIndex() [][]string {
|
|||||||
type JobOrder struct {
|
type JobOrder struct {
|
||||||
ModelIDCUL
|
ModelIDCUL
|
||||||
|
|
||||||
JobID int `orm:"column(job_id)" json:"jobID"` //任务ID
|
JobID int `orm:"column(job_id)" json:"jobID"` //任务ID
|
||||||
UserID string `orm:"column(user_id)" json:"thingID"` //接任务人ID
|
UserID string `orm:"column(user_id)" json:"userID"` //接任务人ID
|
||||||
Status int `json:"status"` //任务订单状态,接单,待审核,已审核,已结算等
|
Status int `json:"status"` //任务订单状态,接单,待审核,已审核,已结算等
|
||||||
SubmitAuditAt time.Time `json:"submitAuditTime"` //提交审核日期
|
SubmitAuditAt time.Time `json:"submitAuditTime"` //提交审核日期
|
||||||
AuditAt time.Time `json:"auditAt"` //审核日期
|
AuditAt time.Time `json:"auditAt"` //审核日期
|
||||||
Content string `josn:"content"` //任务审核内容
|
Content string `josn:"content"` //任务审核内容
|
||||||
Img string `json:"img"` //任务审核图片
|
Img string `json:"img"` //任务审核图片
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *JobOrder) TableIndex() [][]string {
|
func (v *JobOrder) TableIndex() [][]string {
|
||||||
|
|||||||
@@ -92,7 +92,32 @@ func (c *JobController) GetJobDetail() {
|
|||||||
// @router /AcceptJob [post]
|
// @router /AcceptJob [post]
|
||||||
func (c *JobController) AcceptJob() {
|
func (c *JobController) AcceptJob() {
|
||||||
c.callAcceptJob(func(params *tJobAcceptJobParams) (retVal interface{}, errCode string, err error) {
|
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
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user