aa
This commit is contained in:
@@ -95,6 +95,10 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
job.LimitCountType = model.JobLimitCountTypeNoLimit
|
job.LimitCountType = model.JobLimitCountTypeNoLimit
|
||||||
job.JobLimitAt = 0
|
job.JobLimitAt = 0
|
||||||
job.AuditLimitAt = 0
|
job.AuditLimitAt = 0
|
||||||
|
case model.JobCategoryIDUnion:
|
||||||
|
if job.UnionImg == "" || job.UnionQrcodePosition == "" {
|
||||||
|
return errCode, fmt.Errorf("联盟任务发布请输入分享的背景图和二维码图方位!")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID)
|
return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID)
|
||||||
}
|
}
|
||||||
@@ -108,8 +112,12 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
default:
|
default:
|
||||||
return errCode, fmt.Errorf("暂不支持的返现类型! %v", job.CashbackType)
|
return errCode, fmt.Errorf("暂不支持的返现类型! %v", job.CashbackType)
|
||||||
}
|
}
|
||||||
|
if job.Count <= 0 {
|
||||||
|
return errCode, fmt.Errorf("任务数量不能为0!")
|
||||||
|
}
|
||||||
|
job.SurplusCount = job.Count
|
||||||
if job.UserID == "" {
|
if job.UserID == "" {
|
||||||
return errCode, fmt.Errorf("参数有误!")
|
return errCode, fmt.Errorf("任务发起人不能为空!")
|
||||||
}
|
}
|
||||||
if ctx.GetUserID() != job.UserID {
|
if ctx.GetUserID() != job.UserID {
|
||||||
return errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
return errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
||||||
@@ -127,6 +135,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
fmt.Println("1111111111111111111111111111111111", ctx.GetLoginType())
|
||||||
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
||||||
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
||||||
if userBill == nil {
|
if userBill == nil {
|
||||||
@@ -136,13 +145,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
if userBill.AccountBalance < job.TotalPrice {
|
if userBill.AccountBalance < job.TotalPrice {
|
||||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
||||||
}
|
}
|
||||||
if job.Count <= 0 {
|
|
||||||
return errCode, fmt.Errorf("任务数量不能为0!")
|
|
||||||
}
|
|
||||||
job.SurplusCount = job.Count
|
|
||||||
if job.UserID == "" {
|
|
||||||
return errCode, fmt.Errorf("任务发起人不能为空!")
|
|
||||||
}
|
|
||||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
||||||
if len(jobs) > 0 {
|
if len(jobs) > 0 {
|
||||||
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
||||||
@@ -169,19 +172,19 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if err = dao.CreateEntity(db, job); err != nil {
|
if err = dao.CreateEntityTx(txDB, job); err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range jobExt.JobSteps {
|
for _, v := range jobExt.JobSteps {
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
v.JobID = job.ID
|
v.JobID = job.ID
|
||||||
err = dao.CreateEntity(db, v)
|
err = dao.CreateEntityTx(txDB, v)
|
||||||
}
|
}
|
||||||
for _, v := range jobExt.JobImgs {
|
for _, v := range jobExt.JobImgs {
|
||||||
dao.WrapAddIDCULEntity(v, ctx.GetUserName())
|
dao.WrapAddIDCULEntity(v, ctx.GetUserName())
|
||||||
v.JobID = job.ID
|
v.JobID = job.ID
|
||||||
err = dao.CreateEntity(db, v)
|
err = dao.CreateEntityTx(txDB, v)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dao.Rollback(db, txDB)
|
dao.Rollback(db, txDB)
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ type Job struct {
|
|||||||
SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接
|
SkuURL string `orm:"column(sku_url)" json:"skuURL"` //商品优惠券链接
|
||||||
Type int `json:"type"` //任务类型,0为普通任务,1为特殊任务
|
Type int `json:"type"` //任务类型,0为普通任务,1为特殊任务
|
||||||
BrowseCount int `json:"browseCount"` //任务浏览量,点一下加一下
|
BrowseCount int `json:"browseCount"` //任务浏览量,点一下加一下
|
||||||
|
UnionImg string `json:"unionImg"` //联盟任务分享链接的背景图
|
||||||
|
UnionQrcodePosition string `json:"unionQrcodePosition"` //联盟任务分享链接的二维码图的方位
|
||||||
// JobSteps []*JobStep `orm:"-" json:"jobSteps"`
|
// JobSteps []*JobStep `orm:"-" json:"jobSteps"`
|
||||||
// JobImgs []*JobImg `orm:"-" json:"jobImgs"`
|
// JobImgs []*JobImg `orm:"-" json:"jobImgs"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user