|
@@ -429,14 +429,14 @@ func ParticipateListSql(in *bxcore.ParticipateListReq) string {
|
|
|
now := time.Now()
|
|
|
nowDate := date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
//查询tidb base_service.project
|
|
|
- sql := ` `
|
|
|
+ conditionSql := ` WHERE 1=1 `
|
|
|
//地区
|
|
|
if in.Area != "" {
|
|
|
- sql += fmt.Sprintf(" AND pt.area IN ('%s') ", strings.ReplaceAll(in.Area, ",", "','"))
|
|
|
+ conditionSql += fmt.Sprintf(" AND pt.area IN ('%s') ", strings.ReplaceAll(in.Area, ",", "','"))
|
|
|
}
|
|
|
//城市
|
|
|
if in.City != "" {
|
|
|
- sql += fmt.Sprintf(" AND pt.city IN ('%s') ", strings.ReplaceAll(in.City, ",", "','"))
|
|
|
+ conditionSql += fmt.Sprintf(" AND pt.city IN ('%s') ", strings.ReplaceAll(in.City, ",", "','"))
|
|
|
}
|
|
|
//关键词
|
|
|
if in.Keywords != "" {
|
|
@@ -448,28 +448,88 @@ func ParticipateListSql(in *bxcore.ParticipateListReq) string {
|
|
|
kSql += " pt.name like '%" + kv + "%'"
|
|
|
}
|
|
|
kSql += `)`
|
|
|
- sql += kSql
|
|
|
+ conditionSql += kSql
|
|
|
}
|
|
|
//招标日期
|
|
|
if in.BidTime != "" && strings.Contains(in.BidTime, "-") {
|
|
|
startTime := strings.Split(in.BidTime, "-")[0]
|
|
|
entTime := strings.Split(in.BidTime, "-")[1]
|
|
|
if startTime != "" {
|
|
|
- sql += ` AND pt.bid_time > ` + startTime
|
|
|
+ startTimeInt, _ := strconv.ParseInt(startTime, 10, 64)
|
|
|
+ conditionSql += ` AND pt.bid_time > '` + date.FormatDateByInt64(&startTimeInt, date.Date_Full_Layout) + `'`
|
|
|
}
|
|
|
if entTime != "" {
|
|
|
- sql += ` AND pt.bid_time < ` + entTime
|
|
|
+ entTimeInt, _ := strconv.ParseInt(entTime, 10, 64)
|
|
|
+ conditionSql += ` AND pt.bid_time < '` + date.FormatDateByInt64(&entTimeInt, date.Date_Full_Layout) + `'`
|
|
|
}
|
|
|
}
|
|
|
//招标截止日期
|
|
|
if in.BidEndTime != "" {
|
|
|
+ //投标截止日期规则:
|
|
|
+ //1、开始时间小于当前时间 ,结束时间大于当前时间,投标截止状态按钮未截止和已截止可用;
|
|
|
+ //2、结束时间小于当前时间|开始时间大于当前时间,投标截止状态按钮未截止和已截止不可用;
|
|
|
+ //3、需要前端做成连动
|
|
|
startTime := strings.Split(in.BidEndTime, "-")[0]
|
|
|
- entTime := strings.Split(in.BidEndTime, "-")[1]
|
|
|
- if startTime != "" {
|
|
|
- sql += ` AND pt.bid_end_time > ` + startTime
|
|
|
+ endTime := strings.Split(in.BidEndTime, "-")[1]
|
|
|
+ startTimeInt, _ := strconv.ParseInt(startTime, 10, 64)
|
|
|
+ endTimeInt, _ := strconv.ParseInt(endTime, 10, 64)
|
|
|
+ if startTimeInt > 0 && endTimeInt > 0 && startTimeInt > endTimeInt {
|
|
|
+ logx.Info(fmt.Sprintf("投标截止日期 %d 开始时间 大于 结束时间%d!!!", startTimeInt, endTimeInt))
|
|
|
+ } else {
|
|
|
+ switch in.BidEndStatus {
|
|
|
+ case 0:
|
|
|
+ if startTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time > '` + date.FormatDateByInt64(&startTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ }
|
|
|
+ if endTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time < '` + date.FormatDateByInt64(&endTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ }
|
|
|
+ case 1: //投标截止状态:1:未截止;2:已截止;3:终止参标
|
|
|
+ //未截止:
|
|
|
+ var (
|
|
|
+ endBool = true
|
|
|
+ )
|
|
|
+ //如果结束时间存在且小于当前时间,投标截止日期 范围都是已截止 不会存在未截止的数据
|
|
|
+ if endTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time < '` + date.FormatDateByInt64(&endTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ endBool = endTimeInt > now.Unix()
|
|
|
+ }
|
|
|
+ //开始时间小于 当前时间
|
|
|
+ if endBool && now.Unix() > startTimeInt {
|
|
|
+ startTimeInt = now.Unix()
|
|
|
+ }
|
|
|
+ //存在开始时间为0的情况
|
|
|
+ if startTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time > '` + date.FormatDateByInt64(&startTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ }
|
|
|
+ case 2: //投标截止状态:1:未截止;2:已截止;3:终止参标
|
|
|
+ //如果开始时间存在且大于当前时间,投标截止日期 范围都是未截止 不会存在已截止的数据
|
|
|
+ var (
|
|
|
+ startBool = true
|
|
|
+ )
|
|
|
+ if startTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time > '` + date.FormatDateByInt64(&startTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ startBool = startTimeInt < now.Unix()
|
|
|
+ }
|
|
|
+ if startBool && (endTimeInt == 0 || now.Unix() < endTimeInt) {
|
|
|
+ endTimeInt = now.Unix()
|
|
|
+ }
|
|
|
+ //存在结束时间为0的情况
|
|
|
+ if endTimeInt > 0 {
|
|
|
+ conditionSql += ` AND pt.bid_end_time < '` + date.FormatDateByInt64(&endTimeInt, date.Date_Full_Layout) + `'`
|
|
|
+ }
|
|
|
+ case 3:
|
|
|
+ conditionSql += ` AND pug.state < 0 `
|
|
|
+ }
|
|
|
}
|
|
|
- if entTime != "" {
|
|
|
- sql += ` AND pt.bid_end_time < ` + entTime
|
|
|
+ } else if in.BidEndStatus > 0 { //投标截止状态1:未截止;2:已截止;3:终止参标
|
|
|
+ switch in.BidEndStatus {
|
|
|
+ case 1:
|
|
|
+ conditionSql += ` AND pt.bid_end_time > '` + nowDate + `'`
|
|
|
+ case 2:
|
|
|
+ conditionSql += ` AND pt.bid_end_time < '` + nowDate + `'`
|
|
|
+ case 3:
|
|
|
+ conditionSql += ` AND pug.state < 0 `
|
|
|
}
|
|
|
}
|
|
|
//开标时间
|
|
@@ -477,51 +537,49 @@ func ParticipateListSql(in *bxcore.ParticipateListReq) string {
|
|
|
startTime := strings.Split(in.BidOpenTime, "-")[0]
|
|
|
entTime := strings.Split(in.BidOpenTime, "-")[1]
|
|
|
if startTime != "" {
|
|
|
- sql += ` AND pt.bid_open_time > ` + startTime
|
|
|
+ startTimeInt, _ := strconv.ParseInt(startTime, 10, 64)
|
|
|
+ conditionSql += ` AND pt.bid_open_time > '` + date.FormatDateByInt64(&startTimeInt, date.Date_Full_Layout) + `'`
|
|
|
}
|
|
|
if entTime != "" {
|
|
|
- sql += ` AND pt.bid_open_time < ` + entTime
|
|
|
- }
|
|
|
- }
|
|
|
- //投标截止状态1:未截止;2:已截止;3:终止参标
|
|
|
- if in.BidEndStatus > 0 {
|
|
|
- switch in.BidEndStatus {
|
|
|
- case 1:
|
|
|
- sql += ` AND pt.bid_end_time > ` + nowDate
|
|
|
- case 2:
|
|
|
- sql += ` AND pt.bid_end_time < ` + nowDate
|
|
|
- case 3:
|
|
|
- sql += ` AND pug.state < 0 `
|
|
|
+ entTimeInt, _ := strconv.ParseInt(entTime, 10, 64)
|
|
|
+ conditionSql += ` AND pt.bid_open_time < '` + date.FormatDateByInt64(&entTimeInt, date.Date_Full_Layout) + `'`
|
|
|
}
|
|
|
}
|
|
|
//开标状态1:未开标;2:已开标
|
|
|
if in.BidOpenStatus > 0 {
|
|
|
switch in.BidOpenStatus {
|
|
|
case 1:
|
|
|
- sql += ` AND pt.bid_open_time > ` + nowDate
|
|
|
+ conditionSql += ` AND pt.bid_open_time > '` + nowDate + `'`
|
|
|
case 2:
|
|
|
- sql += ` AND pt.bid_open_time < ` + nowDate
|
|
|
+ conditionSql += ` AND pt.bid_open_time < '` + nowDate + `'`
|
|
|
}
|
|
|
}
|
|
|
//参标人 管理员权限
|
|
|
if in.EntUserIds != "" && in.PositionType > 0 {
|
|
|
- sql += ` AND pug.ent_user_id in ('` + strings.ReplaceAll(in.EntUserIds, ",", "','") + `')`
|
|
|
+ conditionSql += ` AND (`
|
|
|
+ for k, v := range strings.Split(in.EntUserIds, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ conditionSql += " OR "
|
|
|
+ }
|
|
|
+ conditionSql += ` FIND_IN_SET(` + v + ` , pug.ent_user_id) `
|
|
|
+ }
|
|
|
+ conditionSql += `)`
|
|
|
}
|
|
|
//默认按照投标截止日期正序排列、1:开标时间正序、2:更新状态时间倒序
|
|
|
switch in.OrderNum {
|
|
|
case 1:
|
|
|
- sql += ` ORDER BY pug.update_date DESC`
|
|
|
+ conditionSql += ` ORDER BY pt.bid_open_time ASC`
|
|
|
case 2:
|
|
|
- sql += ` ORDER BY pt.bid_time ASC`
|
|
|
+ conditionSql += ` ORDER BY pug.update_date DESC`
|
|
|
default:
|
|
|
- sql += ` ORDER BY pt.bid_end_time ASC`
|
|
|
+ conditionSql += ` ORDER BY pt.bid_end_time ASC`
|
|
|
}
|
|
|
- logx.Info(sql)
|
|
|
- return sql
|
|
|
+ logx.Info(conditionSql)
|
|
|
+ return conditionSql
|
|
|
}
|
|
|
|
|
|
//个人或员工查询参标列表
|
|
|
-func SingleParticipateList(in *bxcore.ParticipateListReq, otherSql string) (data *bxcore.ParticipateData, err error) {
|
|
|
+func SingleParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (data *bxcore.ParticipateData, err error) {
|
|
|
defer MC.Catch()
|
|
|
data = &bxcore.ParticipateData{
|
|
|
Count: 0,
|
|
@@ -529,7 +587,7 @@ func SingleParticipateList(in *bxcore.ParticipateListReq, otherSql string) (data
|
|
|
}
|
|
|
//员工|个人列表
|
|
|
singlePersonSql := `SELECT %s FROM ` + ParticipateUserTable + ` pug LEFT JOIN project pt ON pug.project_id = pt.id WHERE pug.position_id = ? `
|
|
|
- singlePersonSql += otherSql
|
|
|
+ singlePersonSql += conditionSql
|
|
|
countSql := fmt.Sprintf(singlePersonSql, " COUNT(pt.id) ")
|
|
|
count := IC.BaseMysql.CountBySql(countSql, in.PositionId)
|
|
|
if count > 0 {
|
|
@@ -560,19 +618,19 @@ func SingleParticipateList(in *bxcore.ParticipateListReq, otherSql string) (data
|
|
|
}
|
|
|
|
|
|
//管理员获取参标列表数据
|
|
|
-func AdminParticipateList(in *bxcore.ParticipateListReq, otherSql string) (data *bxcore.ParticipateData, err error) {
|
|
|
+func AdminParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (data *bxcore.ParticipateData, err error) {
|
|
|
defer MC.Catch()
|
|
|
data = &bxcore.ParticipateData{
|
|
|
Count: 0,
|
|
|
List: []*bxcore.ParticipateList{},
|
|
|
}
|
|
|
- adminSql := `SELECT %s FROM (SELECT pu.ent_id, pu.project_id, GROUP_CONCAT(pu.ent_user_id SEPARATOR ',') ent_user_id, MAX(pu.update_date) update_date FROM ` + ParticipateUserTable + ` pu WHERE pu.ent_id = ? AND NOT EXISTS ( SELECT 1 FROM ` + ParticipateUserTable + ` WHERE project_id = pu.project_id AND state > pu. state ) GROUP BY pu.project_id ) pug LEFT JOIN project pt ON pug.project_id = pt.id`
|
|
|
- adminSql += otherSql
|
|
|
- adminCountSql := fmt.Sprintf(adminSql, "COUNT(pt.id)")
|
|
|
+ adminSql := `SELECT %s FROM (SELECT pu.ent_id, pu.project_id, GROUP_CONCAT(pu.ent_user_id SEPARATOR ',') ent_user_id, MAX(pu.update_date) update_date,MAX(pu.state) state FROM ` + ParticipateUserTable + ` pu WHERE pu.ent_id = ? AND NOT EXISTS ( SELECT 1 FROM ` + ParticipateUserTable + ` WHERE project_id = pu.project_id AND state > pu. state ) GROUP BY pu.project_id ) pug LEFT JOIN project pt ON pug.project_id = pt.id`
|
|
|
+ adminCountSql := fmt.Sprintf(adminSql, "COUNT(pt.id)") + conditionSql
|
|
|
+ log.Println(adminCountSql)
|
|
|
count := IC.BaseMysql.CountBySql(adminCountSql, in.EntId)
|
|
|
if count > 0 {
|
|
|
data.Count = count
|
|
|
- adminListSql := fmt.Sprintf(adminSql, "pt.*, pug.ent_user_id,pug.update_date")
|
|
|
+ adminListSql := fmt.Sprintf(adminSql, "pt.*, pug.ent_user_id,pug.update_date") + conditionSql
|
|
|
list := IC.BaseMysql.SelectBySql(adminListSql, in.EntId)
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
for _, v := range *list {
|