updatebidstatuslogic.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "jyBXCore/rpc/model/es"
  6. "jyBXCore/rpc/service"
  7. "jyBXCore/rpc/util"
  8. "time"
  9. "jyBXCore/rpc/internal/svc"
  10. "jyBXCore/rpc/type/bxcore"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type UpdateBidStatusLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewUpdateBidStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBidStatusLogic {
  19. return &UpdateBidStatusLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 投标状态更新
  26. func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*bxcore.UpdateBidStatusRes, error) {
  27. result := &bxcore.UpdateBidStatusRes{
  28. ErrCode: -1,
  29. }
  30. if msg := util.IsAllowedAccess("updatebidstatus"); msg != "" {
  31. result.ErrMsg = msg
  32. return result, nil
  33. }
  34. b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
  35. // 不是超级订阅 也不是大会员
  36. if !b {
  37. result.ErrMsg = "没有权限"
  38. return result, nil
  39. }
  40. participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  41. participateService.EntRoleId = entRoleId
  42. // 信息id解密
  43. infoList, _ := service.DecodeId(in.Sid)
  44. if len(infoList) == 0 {
  45. result.ErrMsg = "信息id无效"
  46. return result, nil
  47. }
  48. // 根据标讯id 查询项目信息
  49. projectInfos := es.GetProjectByInfoId(infoList)
  50. if projectInfos == nil || len(*projectInfos) == 0 {
  51. result.ErrMsg = "未查询到项目信息"
  52. return result, nil
  53. }
  54. // 判断是否已经过了投标截止时间
  55. bidendtime := common.Int64All((*projectInfos)[0]["bidendtime"])
  56. bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
  57. projectId := common.ObjToString((*projectInfos)[0]["_id"])
  58. now := time.Now().Unix()
  59. if (now > bidopentime && bidopentime != 0) || (now > bidendtime && bidendtime != 0) {
  60. result.ErrMsg = "已经过投标截止时间,无法更新"
  61. return result, nil
  62. }
  63. // 验证身份
  64. if !participateService.CheckUpdateBidPower(projectId, true) {
  65. result.ErrMsg = "没有更新权限"
  66. return result, nil
  67. }
  68. // 2. 更新
  69. if err := participateService.UpdateBidStatus(in, projectId); err != nil {
  70. result.ErrMsg = err.Error()
  71. } else {
  72. result.Data = true
  73. result.ErrCode = 0
  74. }
  75. return result, nil
  76. }