diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index 7682288eb..22d03a5ea 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -34,39 +34,21 @@ const ( ) var ( - DayTimeBegin time.Time - DayTimeEnd time.Time - WeekTimeBegin time.Time - WeekTimeEnd time.Time - JobTimerMap map[int64]*time.Timer JobAuditTimerMap map[int64]*time.Timer ) func init() { - DayTimeBegin = utils.Str2Time(utils.Time2Str(utils.Time2Date(time.Now())) + " 00:00:00") - DayTimeEnd = DayTimeBegin.AddDate(0, 0, 1) - WeekTimeBegin, WeekTimeEnd = getWeekTime() - JobTimerMap = make(map[int64]*time.Timer) JobAuditTimerMap = make(map[int64]*time.Timer) } -func getWeekTime() (weekTimeBegin, weekTimeEnd time.Time) { - offset := int(time.Now().Weekday() - 1) - if offset == -1 { - offset = -6 - } - weekTimeBegin = time.Now().AddDate(0, 0, offset) - weekTimeEnd = weekTimeBegin.AddDate(0, 0, 7) - return weekTimeBegin, weekTimeEnd -} - func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, err error) { var ( - db = dao.GetDB() - job = &model.Job{} - finishedAt time.Time + db = dao.GetDB() + job = &model.Job{} + finishedAt time.Time + DayTimeBegin, DayTimeEnd = jxutils.GetDayTime() ) //需根据任务类型做一些参数判断,比如门店商品链接,地址 // switch job.JobCategoryID { @@ -234,9 +216,11 @@ func GetJobDetail(ctx *jxcontext.Context, jobID int, lng, lat float64) (job *dao func AcceptJob(ctx *jxcontext.Context, jobID int) (errCode string, err error) { var ( - db = dao.GetDB() - userID = ctx.GetUserID() - num int + db = dao.GetDB() + userID = ctx.GetUserID() + num int + DayTimeBegin, DayTimeEnd = jxutils.GetDayTime() + WeekTimeBegin, WeekTimeEnd = jxutils.GetWeekTime() ) job := &model.Job{} job.ID = jobID @@ -778,6 +762,7 @@ func CancelJdDelivery(ctx *jxcontext.Context, vendorWaybillID, reason string) (e dOrder = &model.DeliveryOrder{ VendorWaybillID: vendorWaybillID, } + DayTimeBegin, DayTimeEnd = jxutils.GetDayTime() ) err = dao.GetEntity(db, dOrder, "VendorWaybillID") userBill, err := dao.GetUserBill(db, ctx.GetUserID(), "") diff --git a/business/jxstore/cms/order.go b/business/jxstore/cms/order.go index c87392fd5..cb0609491 100644 --- a/business/jxstore/cms/order.go +++ b/business/jxstore/cms/order.go @@ -22,8 +22,9 @@ import ( func CreateOrder(ctx *jxcontext.Context, orderType int, way string, price int, lng, lat float64) (orderID, errCode string, err error) { var ( - db = dao.GetDB() - order *model.Order + db = dao.GetDB() + order *model.Order + DayTimeBegin, DayTimeEnd = jxutils.GetDayTime() ) if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil { return "", errCode, err diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go index b163934a9..d3ddf45bf 100644 --- a/business/jxutils/jxutils.go +++ b/business/jxutils/jxutils.go @@ -904,3 +904,19 @@ func GenRandomString(l int) string { } return string(result) } + +func GetDayTime() (dayTimeBegin, dayTimeEnd time.Time) { + dayTimeBegin = utils.Str2Time(utils.Time2Str(utils.Time2Date(time.Now())) + " 00:00:00") + dayTimeEnd = dayTimeBegin.AddDate(0, 0, 1) + return dayTimeBegin, dayTimeEnd +} + +func GetWeekTime() (weekTimeBegin, weekTimeEnd time.Time) { + offset := int(time.Now().Weekday() - 1) + if offset == -1 { + offset = -6 + } + weekTimeBegin = time.Now().AddDate(0, 0, offset) + weekTimeEnd = weekTimeBegin.AddDate(0, 0, 7) + return weekTimeBegin, weekTimeEnd +}