shan
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
@@ -14,9 +15,16 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
const (
|
||||
AcceptMaxCount = 2
|
||||
)
|
||||
|
||||
func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
db = dao.GetDB()
|
||||
timeNow = utils.Time2Date(time.Now())
|
||||
fromTime = utils.Time2Str(timeNow) + "00:00:00"
|
||||
toTime = utils.Time2Str(timeNow) + "23:59:59"
|
||||
)
|
||||
//需根据任务类型做一些参数判断,比如门店商品链接,地址
|
||||
// switch job.JobCategoryID {
|
||||
@@ -28,6 +36,19 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
|
||||
if job.Count <= 0 {
|
||||
return fmt.Errorf("任务数量不能为0!")
|
||||
}
|
||||
if job.UserID == "" {
|
||||
return fmt.Errorf("任务发起人不能为空!")
|
||||
}
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, utils.Str2Time(fromTime), utils.Str2Time(toTime), false)
|
||||
if len(jobs) > 0 {
|
||||
members, err := dao.GetUserMember(db, job.UserID, 0, 0, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(members) <= 0 {
|
||||
return fmt.Errorf("非会员一天只能发布一起任务,请确认!")
|
||||
}
|
||||
}
|
||||
if job.Address != "" && (job.Lng == 0 || job.Lat == 0) {
|
||||
lng, lat, err := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user