|
@@ -8,6 +8,7 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
IC "jyBXCore/rpc/init"
|
|
|
+ "jyBXCore/rpc/model/es"
|
|
|
"jyBXCore/rpc/type/bxcore"
|
|
|
"strconv"
|
|
|
"strings"
|
|
@@ -19,7 +20,7 @@ var (
|
|
|
)
|
|
|
|
|
|
//划转参标信息
|
|
|
-func TransferParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
+func TransferParticipateInfo(projectId string, in *bxcore.ParticipateActionReq) error {
|
|
|
defer MC.Catch()
|
|
|
//保存或更新新跟踪人
|
|
|
if !IC.BaseMysql.ExecTx("划转参标信息", func(tx *sql.Tx) bool {
|
|
@@ -34,7 +35,7 @@ func TransferParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
//是否保留原参标人
|
|
|
if !in.IsRetain {
|
|
|
//不保留 原参标人,获取把原参标人信息
|
|
|
- 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)
|
|
|
+ partInfo := IC.BaseMysql.SelectBySqlByTx(tx, "SELECT id,position_id FROM `participate_user` WHERE project_id = ? AND ent_id = ? AND state > -1", projectId, in.EntId)
|
|
|
if partInfo != nil && len(*partInfo) > 0 {
|
|
|
for _, v := range *partInfo {
|
|
|
ids = append(ids, MC.IntAll(v["id"]))
|
|
@@ -43,7 +44,7 @@ func TransferParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
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
|
|
|
+ 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, projectId) > 0
|
|
|
}
|
|
|
//查询划转人信息
|
|
|
entUserId, _ := strconv.ParseInt(in.ToEntUserId, 10, 64)
|
|
@@ -56,20 +57,20 @@ func TransferParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
"ent_id": in.EntId,
|
|
|
"ent_user_id": entUserId,
|
|
|
"position_id": positionId,
|
|
|
- "project_id": in.BidId,
|
|
|
+ "project_id": projectId,
|
|
|
"record_content": content,
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
return b1 && b2 && b3
|
|
|
}) {
|
|
|
- logx.Info(in.PositionId, "---终止---", in.BidId)
|
|
|
+ logx.Info(in.PositionId, "---终止---", projectId)
|
|
|
return fmt.Errorf("终止参标更新信息出错")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//终止参标
|
|
|
-func CancelParticipateInfo(in *bxcore.ParticipateActionReq, roleId int64) error {
|
|
|
+func CancelParticipateInfo(projectId string, in *bxcore.ParticipateActionReq, roleId int64) error {
|
|
|
defer MC.Catch()
|
|
|
if !IC.BaseMysql.ExecTx("终止参标", func(tx *sql.Tx) bool {
|
|
|
var (
|
|
@@ -79,7 +80,7 @@ func CancelParticipateInfo(in *bxcore.ParticipateActionReq, roleId int64) error
|
|
|
)
|
|
|
//管理员终止:当前项目 其他参标人也被终止
|
|
|
query := map[string]interface{}{
|
|
|
- "project_id": in.BidId,
|
|
|
+ "project_id": projectId,
|
|
|
"ent_id": in.EntId,
|
|
|
}
|
|
|
//个人终止:仅仅终止本人参标项目
|
|
@@ -98,31 +99,31 @@ func CancelParticipateInfo(in *bxcore.ParticipateActionReq, roleId int64) error
|
|
|
"ent_id": in.EntId,
|
|
|
"ent_user_id": in.EntUserId,
|
|
|
"position_id": in.PositionId,
|
|
|
- "project_id": in.BidId,
|
|
|
+ "project_id": projectId,
|
|
|
"record_content": tip,
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
return b1 && b2
|
|
|
}) {
|
|
|
- logx.Info(in.PositionId, "---终止---", in.BidId)
|
|
|
+ logx.Info(in.PositionId, "---终止---", projectId)
|
|
|
return fmt.Errorf("终止参标更新信息出错")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//保存参标信息
|
|
|
-func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
+func SaveParticipateInfo(projectId string, in *bxcore.ParticipateActionReq) error {
|
|
|
defer MC.Catch()
|
|
|
if !IC.BaseMysql.ExecTx("保存|更新参标信息及保存参标记录", func(tx *sql.Tx) bool {
|
|
|
var (
|
|
|
- b1, b2 bool
|
|
|
- now = time.Now()
|
|
|
+ b1, b2, b3 bool
|
|
|
+ now = time.Now()
|
|
|
)
|
|
|
//保存参标--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 {
|
|
|
+ if c := IC.BaseMysql.CountBySql("SELECT count(id) FROM `participate_user` WHERE position_id = ? AND project_id = ? AND ent_id = ?", in.PositionId, projectId, in.EntId); c > 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
|
|
|
+ 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, projectId) > 0
|
|
|
} else {
|
|
|
//保存
|
|
|
b1 = IC.BaseMysql.InsertByTx(tx, "participate_user", map[string]interface{}{
|
|
@@ -140,11 +141,14 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
|
|
|
"ent_id": in.EntId,
|
|
|
"ent_user_id": in.EntUserId,
|
|
|
"position_id": in.PositionId,
|
|
|
- "project_id": in.BidId,
|
|
|
+ "project_id": projectId,
|
|
|
"record_content": "参标",
|
|
|
"create_date": date.FormatDate(&now, date.Date_Full_Layout),
|
|
|
}) > 0
|
|
|
- return b1 && b2
|
|
|
+ //保存或更新项目信息
|
|
|
+ //有问题 其他回滚,项目信息不用回滚
|
|
|
+ b3 = UpdateProjectInfo(projectId, es.GetProjectInfo(projectId), es.GetBiddingInfo(in.BidId)) == nil
|
|
|
+ return b1 && b2 && b3
|
|
|
}) {
|
|
|
logx.Info(in.PositionId, "---保存---", in.BidId)
|
|
|
return fmt.Errorf("保存参标信息出错")
|
|
@@ -157,9 +161,9 @@ func IsParticipatedByBidId(in *bxcore.ParticipateActionReq) bool {
|
|
|
defer MC.Catch()
|
|
|
//如果不允许多人参标 当前项目是否已经有企业其他人员参标
|
|
|
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 {
|
|
|
+ if in.PositionType > 0 { //企业版
|
|
|
query = fmt.Sprintf(query, fmt.Sprintf("ent_id = %d", in.EntId))
|
|
|
- } else {
|
|
|
+ } else { //个人版
|
|
|
query = fmt.Sprintf(query, fmt.Sprintf("position_id = %d", in.PositionId))
|
|
|
}
|
|
|
return IC.BaseMysql.CountBySql(query) > 0
|
|
@@ -281,7 +285,7 @@ func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.Particip
|
|
|
}
|
|
|
|
|
|
//保存或更新tidb 项目信息
|
|
|
-func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string]interface{}) {
|
|
|
+func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string]interface{}) error {
|
|
|
//id 项目id
|
|
|
//name 项目名称
|
|
|
//area 省份
|
|
@@ -313,11 +317,12 @@ func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string
|
|
|
if ok := IC.BaseMysql.Update("project", map[string]interface{}{
|
|
|
"id": id,
|
|
|
}, projectInfo); ok {
|
|
|
- fmt.Errorf("项目信息更新异常", id)
|
|
|
+ return fmt.Errorf("项目信息更新异常", id)
|
|
|
}
|
|
|
} else {
|
|
|
if i := IC.BaseMysql.Insert("project", projectInfo); i <= 0 {
|
|
|
- fmt.Errorf("项目信息插入异常", id)
|
|
|
+ return fmt.Errorf("项目信息插入异常", id)
|
|
|
}
|
|
|
}
|
|
|
+ return nil
|
|
|
}
|