This commit is contained in:
苏尹岚
2020-11-03 14:23:05 +08:00
parent dc1829de5a
commit 686416521a
2 changed files with 26 additions and 3 deletions

View File

@@ -273,6 +273,7 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
if user != nil && user.GetID() != "" {
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
}
globals.SugarLogger.Debugf("tetetetet", utils.Format4Output(user, false))
//如果是小程序
if authType == "weixinmini" || authType == "weixinapp" {
appID := strings.Split(authSecret, ",")[0]

View File

@@ -10,6 +10,11 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
)
const (
sortTypeDistance = 1 //距离
sortTypeAvgPrice = 4 //奖励高低
)
func GetJobCategories(db *DaoDB, name string) (jobCategories []*model.JobCategory, err error) {
sql := `
SELECT * FROM job_category WHERE deleted_at = ?
@@ -31,14 +36,26 @@ type GetJobsResult struct {
}
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types []int, includeStep bool, fromTime, toTime time.Time, lng, lat float64, sortType, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
var jobs []*GetJobsResult
var (
jobs []*GetJobsResult
distanceFlag bool
sqlParams = []interface{}{}
)
if lng != 0 && lat != 0 && (sortType == sortTypeDistance || sortType == -sortTypeDistance) {
distanceFlag = true
}
sql := `
SELECT SQL_CALC_FOUND_ROWS a.*, b.name
FROM job a
`
if distanceFlag {
sql += `, ROUND(POWER((POWER(a.lng,2)-POWER(?,2))+(POWER(a.lat,2)-POWER(?,2)),1/2)) distance`
sqlParams = append(sqlParams, lng, lat)
}
sql += ` FROM job a
JOIN job_category b ON b.id = a.job_category_id AND b.deleted_at = ?
WHERE 1 = 1
`
sqlParams := []interface{}{utils.DefaultTimeValue}
sqlParams = append(sqlParams, utils.DefaultTimeValue)
if len(userIDs) > 0 {
sql += ` AND a.user_id IN (` + GenQuestionMarks(len(userIDs)) + `)`
sqlParams = append(sqlParams, userIDs)
@@ -67,6 +84,11 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
sql += ` AND a.created_at <= ?`
sqlParams = append(sqlParams, toTime)
}
if sortType != 0 {
if sortType == sortTypeDistance || sortType == -sortTypeDistance {
sql += ` ORDER distance`
}
}
sql += " LIMIT ? OFFSET ?"
pageSize = jxutils.FormalizePageSize(pageSize)
sqlParams = append(sqlParams, pageSize, offset)