|
@@ -10,6 +10,7 @@ import (
|
|
|
IC "jyBXCore/rpc/init"
|
|
|
"jyBXCore/rpc/type/bxcore"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -18,33 +19,36 @@ var (
|
|
|
)
|
|
|
|
|
|
//划转参标信息
|
|
|
-func TransferParticipate(in *bxcore.ParticipateActionReq) error {
|
|
|
+func TransferParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
//保存或更新新跟踪人
|
|
|
if !IC.BaseMysql.ExecTx("划转参标信息", func(tx *sql.Tx) bool {
|
|
|
var (
|
|
|
- b = true
|
|
|
- b2, b3 bool
|
|
|
- now = time.Now()
|
|
|
- content = "%s划转给%s"
|
|
|
+ b1 = true
|
|
|
+ b2, b3 bool
|
|
|
+ now = time.Now()
|
|
|
+ content = "%s划转给%s"
|
|
|
+ fromUserNames []string
|
|
|
+ ids []int
|
|
|
)
|
|
|
//是否保留原参标人
|
|
|
if !in.IsRetain {
|
|
|
- content = fmt.Sprintf(content, "", "%s")
|
|
|
- b = IC.BaseMysql.UpdateOrDeleteBySqlByTx(tx, fmt.Sprintf(`UPDATE participate_user SET state = -2 ,update_date = %s WHERE ent_id = ? AND project_id = ?`, date.FormatDate(&now, date.Date_Full_Layout)), in.EntId, in.BidId) > 0
|
|
|
//不保留 原参标人,获取把原参标人信息
|
|
|
- } else {
|
|
|
- entUserId, _ := strconv.ParseInt(in.ToEntUserId, 10, 64)
|
|
|
- IC.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
- }
|
|
|
- //查询原跟踪人信息
|
|
|
- if entUserInfos := IC.MainMysql.SelectBySql(`SELECT name FROM entniche_user WHERE id = ? LIMIT 1`, in.ToEntUserId); entUserInfos != nil && len(*entUserInfos) > 0 {
|
|
|
- entUserInfo := (*entUserInfos)[0]
|
|
|
- //用户名称
|
|
|
- if name := MC.ObjToString(entUserInfo["name"]); name != "" {
|
|
|
- b2 = true
|
|
|
- content = fmt.Sprintf(content, name)
|
|
|
+ partInfo := IC.BaseMysql.SelectBySqlByTx(tx, "SELECT id,position_id FROM `participate_user` WHERE project_id = ? AND ent_id = ? AND state > -1", in.BidId, in.EntId)
|
|
|
+ if partInfo != nil && len(*partInfo) > 0 {
|
|
|
+ for _, v := range *partInfo {
|
|
|
+ ids = append(ids, MC.IntAll(v["id"]))
|
|
|
+ positionId := MC.Int64All(v["position_id"])
|
|
|
+ userInfo := IC.Middleground.UserCenter.IdentityByPositionId(positionId)
|
|
|
+ fromUserNames = append(fromUserNames, userInfo.EntUserName)
|
|
|
+ }
|
|
|
}
|
|
|
+ b1 = IC.BaseMysql.UpdateOrDeleteBySqlByTx(tx, fmt.Sprintf(`UPDATE participate_user SET state = -2 ,update_date = %s WHERE ent_id = ? AND project_id = ?`, date.FormatDate(&now, date.Date_Full_Layout)), in.EntId, in.BidId) > 0
|
|
|
}
|
|
|
+ //查询划转人信息
|
|
|
+ entUserId, _ := strconv.ParseInt(in.ToEntUserId, 10, 64)
|
|
|
+ userInfo := IC.Middleground.UserCenter.IdentityByEntUserId(entUserId)
|
|
|
+ in.PositionId = userInfo.PositionId
|
|
|
+ content = fmt.Sprintf(content, strings.Join(fromUserNames, ","), userInfo.EntUserName)
|
|
|
//
|
|
|
//保存参标--participate_user
|
|
|
b3 = IC.BaseMysql.InsertByTx(tx, "participate_bid_records", map[string]interface{}{
|
|
@@ -55,7 +59,7 @@ func TransferParticipate(in *bxcore.ParticipateActionReq) error {
|
|
|
"record_content": content,
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
- return b && b2 && b3
|
|
|
+ return b1 && b2 && b3
|
|
|
}) {
|
|
|
logx.Info(in.PositionId, "---终止---", in.BidId)
|
|
|
return fmt.Errorf("终止参标更新信息出错")
|
|
@@ -63,25 +67,40 @@ func TransferParticipate(in *bxcore.ParticipateActionReq) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//更新参标信息
|
|
|
-func UpdateParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
+//终止参标
|
|
|
+func CancelParticipateInfo(in *bxcore.ParticipateActionReq, roleId int64) error {
|
|
|
if !IC.BaseMysql.ExecTx("终止参标", func(tx *sql.Tx) bool {
|
|
|
var (
|
|
|
- ppu, pph bool
|
|
|
- now = time.Now()
|
|
|
+ b1, b2 bool
|
|
|
+ now = time.Now()
|
|
|
+ tip = "终止参标(被)"
|
|
|
)
|
|
|
+ //管理员终止:当前项目 其他参标人也被终止
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "project_id": in.BidId,
|
|
|
+ "ent_id": in.EntId,
|
|
|
+ }
|
|
|
+ //个人终止:仅仅终止本人参标项目
|
|
|
+ if roleId == 0 {
|
|
|
+ query["position_id"] = in.PositionId
|
|
|
+ tip = "终止参标"
|
|
|
+ }
|
|
|
+ insert := map[string]interface{}{
|
|
|
+ "state": -1,
|
|
|
+ "update_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
+ }
|
|
|
//更新参标participate_user
|
|
|
- ppu = IC.BaseMysql.UpdateOrDeleteBySqlByTx(tx, fmt.Sprintf(`UPDATE participate_user SET state = -1 ,update_date = %s WHERE position_id = ? AND ent_id = ? AND project_id = ?`, date.FormatDate(&now, date.Date_Full_Layout)), in.PositionId, in.EntId, in.BidId) > 0
|
|
|
+ b1 = IC.BaseMysql.UpdateByTx(tx, "participate_user", query, insert)
|
|
|
//保存参标记录--participate_bid_records
|
|
|
- pph = IC.BaseMysql.InsertByTx(tx, "participate_bid_records", map[string]interface{}{
|
|
|
+ b2 = IC.BaseMysql.InsertByTx(tx, "participate_bid_records", map[string]interface{}{
|
|
|
"ent_id": in.EntId,
|
|
|
"ent_user_id": in.EntUserId,
|
|
|
"position_id": in.PositionId,
|
|
|
"project_id": in.BidId,
|
|
|
- "record_content": "终止参标",
|
|
|
+ "record_content": tip,
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
- return ppu && pph
|
|
|
+ return b1 && b2
|
|
|
}) {
|
|
|
logx.Info(in.PositionId, "---终止---", in.BidId)
|
|
|
return fmt.Errorf("终止参标更新信息出错")
|
|
@@ -93,15 +112,28 @@ func UpdateParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
if !IC.BaseMysql.ExecTx("保存|更新参标信息及保存参标记录", func(tx *sql.Tx) bool {
|
|
|
var (
|
|
|
- ppu, pph bool
|
|
|
- now = time.Now()
|
|
|
+ b1, b2 bool
|
|
|
+ now = time.Now()
|
|
|
)
|
|
|
- //保存参标记录participate_bid_records
|
|
|
+ //保存参标--participate_user
|
|
|
+ //查看是否参标过当前项目
|
|
|
if c := IC.BaseMysql.CountBySql("SELECT count(id) FROM `participate_user` WHERE position_id = ? AND project_id = ? AND ent_id = ?", in.PositionId, in.BidId, in.EntId); c > 0 {
|
|
|
- ppu = IC.BaseMysql.UpdateOrDeleteBySqlByTx(tx, fmt.Sprintf(`UPDATE participate_user SET state = 0 ,update_date = %s WHERE position_id = ? AND ent_id = ? AND project_id = ?`, date.FormatDate(&now, date.Date_Full_Layout)), in.PositionId, in.EntId, in.BidId) > 0
|
|
|
+ //更新
|
|
|
+ b1 = IC.BaseMysql.UpdateOrDeleteBySqlByTx(tx, fmt.Sprintf(`UPDATE participate_user SET state = 0 ,update_date = %s WHERE position_id = ? AND ent_id = ? AND project_id = ?`, date.FormatDate(&now, date.Date_Full_Layout)), in.PositionId, in.EntId, in.BidId) > 0
|
|
|
+ } else {
|
|
|
+ //保存
|
|
|
+ b1 = IC.BaseMysql.InsertByTx(tx, "participate_user", map[string]interface{}{
|
|
|
+ "ent_id": in.EntId,
|
|
|
+ "ent_user_id": in.EntUserId,
|
|
|
+ "position_id": in.PositionId,
|
|
|
+ "project_id": in.PositionId,
|
|
|
+ "state": 0,
|
|
|
+ "create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
+ "update_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
+ }) > 0
|
|
|
}
|
|
|
- //保存参标--participate_user
|
|
|
- pph = IC.BaseMysql.InsertByTx(tx, "participate_bid_records", map[string]interface{}{
|
|
|
+ //保存参标记录participate_bid_records
|
|
|
+ b2 = IC.BaseMysql.InsertByTx(tx, "participate_bid_records", map[string]interface{}{
|
|
|
"ent_id": in.EntId,
|
|
|
"ent_user_id": in.EntUserId,
|
|
|
"position_id": in.PositionId,
|
|
@@ -109,7 +141,7 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
"record_content": "参标",
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
- return ppu && pph
|
|
|
+ return b1 && b2
|
|
|
}) {
|
|
|
logx.Info(in.PositionId, "---保存---", in.BidId)
|
|
|
return fmt.Errorf("保存参标信息出错")
|
|
@@ -118,7 +150,14 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
}
|
|
|
|
|
|
//查询当前招标信息是否已被参标
|
|
|
-func IsParticipatedByBidId(query string) bool {
|
|
|
+func IsParticipatedByBidId(in *bxcore.ParticipateActionReq) bool {
|
|
|
+ //如果不允许多人参标 当前项目是否已经有企业其他人员参标
|
|
|
+ query := fmt.Sprintf(`SELECT count(id) FROM participate_user WHERE %s AND project_id = %s AND state >-1`, "%s", in.BidId)
|
|
|
+ if in.PositionType > 0 {
|
|
|
+ query = fmt.Sprintf(query, fmt.Sprintf("ent_id = %d", in.EntId))
|
|
|
+ } else {
|
|
|
+ query = fmt.Sprintf(query, fmt.Sprintf("position_id = %d", in.PositionId))
|
|
|
+ }
|
|
|
return IC.BaseMysql.CountBySql(query) > 0
|
|
|
}
|
|
|
|