aa
This commit is contained in:
@@ -117,29 +117,26 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
if job.Count <= 0 {
|
||||
return errCode, fmt.Errorf("任务数量不能为0!")
|
||||
}
|
||||
fmt.Println("1111111111111111111111111111111111", ctx.GetToken())
|
||||
job.SurplusCount = job.Count
|
||||
if job.UserID == "" {
|
||||
return errCode, fmt.Errorf("任务发起人不能为空!")
|
||||
}
|
||||
var (
|
||||
userBill *model.UserBill
|
||||
)
|
||||
|
||||
if ctx.GetToken() != jxcontext.RsmDefultToken {
|
||||
if ctx.GetUserID() != job.UserID {
|
||||
return errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
||||
}
|
||||
if job.FinishedAt.Sub(time.Now()) <= 0 {
|
||||
return errCode, fmt.Errorf("任务截止日期必须大于今天!")
|
||||
}
|
||||
if job2, _ := dao.GetJobWithTitle(db, job.Title); job2 != nil {
|
||||
return errCode, fmt.Errorf("任务标题重复,请重新输入!")
|
||||
}
|
||||
if job.JobCityCode != model.JobCountrywideCode {
|
||||
_, _, job.JobCityCode, err = getAddressInfoFromCoord(db, job.JobLng, job.JobLat)
|
||||
}
|
||||
|
||||
//验证微信绑定
|
||||
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
||||
return "", err
|
||||
}
|
||||
fmt.Println("1111111111111111111111111111111111", ctx.GetLoginType())
|
||||
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
||||
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
||||
userBill, _ = dao.GetUserBill(db, job.UserID, "")
|
||||
if userBill == nil {
|
||||
return errCode, fmt.Errorf("未查询到该用户的账单!")
|
||||
}
|
||||
@@ -147,8 +144,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
if userBill.AccountBalance < job.TotalPrice {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
||||
}
|
||||
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
||||
jobs, _ := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
||||
if len(jobs) > 0 {
|
||||
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
||||
if err != nil {
|
||||
@@ -166,6 +162,17 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
}
|
||||
}
|
||||
if job.FinishedAt.Sub(time.Now()) <= 0 {
|
||||
return errCode, fmt.Errorf("任务截止日期必须大于今天!")
|
||||
}
|
||||
if job2, _ := dao.GetJobWithTitle(db, job.Title); job2 != nil {
|
||||
return errCode, fmt.Errorf("任务标题重复,请重新输入!")
|
||||
}
|
||||
if job.JobCityCode != model.JobCountrywideCode {
|
||||
_, _, job.JobCityCode, err = getAddressInfoFromCoord(db, job.JobLng, job.JobLat)
|
||||
}
|
||||
|
||||
dao.WrapAddIDCULDEntity(job, ctx.GetUserName())
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
@@ -193,13 +200,14 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
return
|
||||
}
|
||||
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
||||
if err == nil && job.Status != model.JobStatusFailed {
|
||||
if err == nil && job.Status != model.JobStatusFailed && ctx.GetToken() != jxcontext.RsmDefultToken {
|
||||
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypeDeposit, job.TotalPrice, job.ID); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return
|
||||
}
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
if ctx.GetToken() != jxcontext.RsmDefultToken {
|
||||
content := new(strings.Builder)
|
||||
content.WriteString("您的任务:")
|
||||
content.WriteString(job.Title)
|
||||
@@ -207,6 +215,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
content.WriteString(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(job.TotalPrice))))
|
||||
content.WriteString("元")
|
||||
event.SendSysMessageSimple(content.String(), job.UserID)
|
||||
}
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user