participate.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package service
  2. import (
  3. MC "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "fmt"
  6. IC "jyBXCore/rpc/init"
  7. "jyBXCore/rpc/model/tidb"
  8. "jyBXCore/rpc/type/bxcore"
  9. "jyBXCore/rpc/util"
  10. )
  11. //更新数据 加锁。。。。。
  12. /*
  13. 已过投标截止日期项目
  14. (1) 不显示终止投标倒计时
  15. (2) 显示参标人信息
  16. (3) 无终止参标操作入口
  17. (4) 不能划转
  18. (5) 不能参标
  19. */
  20. //参标动作:参标、终止参标、划转:in:参标;out:终止参标;transfer:划转
  21. func ParticipateDo(in *bxcore.ParticipateActionReq) (*bxcore.ParticipateActionRes, error) {
  22. //招标信息解密
  23. in.BidId = encrypt.DecodeArticleId2ByCheck(in.BidId)[0]
  24. if in.BidId == "" {
  25. return nil, fmt.Errorf("当前招标信息有误")
  26. }
  27. //当前项目是否符合参标条件
  28. participateBid := NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  29. projectInfos := participateBid.GetProjectByInfoId([]string{in.BidId})
  30. if projectInfos == nil || len(*projectInfos) == 0 {
  31. tip := "参标"
  32. switch in.ActionType {
  33. case "out":
  34. tip = "终止参标"
  35. case "transfer":
  36. tip = "划转"
  37. }
  38. return nil, fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
  39. }
  40. //符合参标项目id
  41. projectInfo := (*projectInfos)[0]
  42. if projectInfo["_id"] != nil && MC.ObjToString(projectInfo["_id"]) != "" {
  43. in.BidId = MC.ObjToString(projectInfo["_id"])
  44. } else {
  45. return nil, fmt.Errorf("当前项目信息有误")
  46. }
  47. //企业版 判断是否是管理员
  48. //判断用户身份
  49. userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
  50. switch in.ActionType {
  51. case "in":
  52. //是否允许多人参标
  53. if isAllow := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType).IsALLow(); !isAllow {
  54. if ok := tidb.IsParticipatedByBidId(in); ok {
  55. return nil, fmt.Errorf("当前项目不允许多人参标")
  56. }
  57. }
  58. //保存参标信息 更新当前企业参标项目记录
  59. if err := tidb.SaveParticipateInfo(in); err != nil {
  60. return nil, err
  61. }
  62. case "out": //终止参标
  63. if err := tidb.CancelParticipateInfo(in, userInfo.Ent.EntRoleId); err != nil {
  64. return nil, err
  65. }
  66. case "transfer":
  67. //个人版
  68. if in.PositionType == 0 {
  69. return nil, fmt.Errorf("当前企业身份有误")
  70. }
  71. //非管理员
  72. if userInfo.Ent.EntRoleId == 0 { //1:企业管理员;2:部门管理员
  73. return nil, fmt.Errorf("当前企业身份无权限")
  74. }
  75. //是否保留原跟踪人?
  76. partUser := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType)
  77. isAllow := partUser.IsALLow()
  78. if in.IsRetain && !isAllow {
  79. //不允许多人参标,但是前端参数又是保留原参标人 互相矛盾
  80. return nil, fmt.Errorf("当前项目只允许一人参标")
  81. }
  82. if err := tidb.TransferParticipateInfo(in); err != nil {
  83. return nil, err
  84. }
  85. }
  86. return &bxcore.ParticipateActionRes{
  87. Data: true,
  88. }, nil
  89. }
  90. //参标设置更新及设置内容
  91. func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.ParticipateSetUpInfoRes, error) {
  92. res := &bxcore.ParticipateSetUpInfoRes{Data: &bxcore.ParticipateSetUpInfo{
  93. IsAllow: "0",
  94. BidType: nil,
  95. RemindRule: nil,
  96. }}
  97. switch in.SetAction {
  98. case "U": //update 更新设置信息
  99. res.Data = nil
  100. if err := tidb.UpdateParticipateSetInfo(in); err != nil {
  101. res.ErrCode = -1
  102. res.ErrMsg = err.Error()
  103. }
  104. default: //默认查询对应设置信息
  105. //查询对应用户设置信息
  106. //未设置过 返回默认配置
  107. if info, err := tidb.GetParticipateSetInfo(in); err == nil {
  108. res.Data = info
  109. } else {
  110. res.ErrCode = -1
  111. res.ErrMsg = err.Error()
  112. }
  113. }
  114. return res, nil
  115. }