updatebidstatuslogic.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. IC "jyBXCore/rpc/init"
  6. "jyBXCore/rpc/model/es"
  7. "jyBXCore/rpc/service"
  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. // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
  31. userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
  32. // 不是超级订阅 也不是大会员
  33. if userInfo.Vip.Status <= 0 && userInfo.Member.Status <= 0 {
  34. result.ErrMsg = "没有权限"
  35. return result, nil
  36. }
  37. participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  38. participateService.EntRoleId = userInfo.Ent.EntRoleId
  39. // 信息id解密
  40. infoList, _ := service.DecodeId(in.Sid)
  41. if len(infoList) == 0 {
  42. result.ErrMsg = "信息id无效"
  43. return result, nil
  44. }
  45. // 根据标讯id 查询项目信息
  46. projectInfos := es.GetProjectByInfoId(infoList)
  47. if projectInfos == nil || len(*projectInfos) == 0 {
  48. result.ErrMsg = "未查询到项目信息"
  49. return result, nil
  50. }
  51. // 判断是否已经过了投标截止时间
  52. bidendtime := common.Int64All((*projectInfos)[0]["bidendtime"])
  53. projectId := common.ObjToString((*projectInfos)[0]["_id"])
  54. if !(time.Now().Unix() < bidendtime || bidendtime == 0) {
  55. result.ErrMsg = "已经过投标截止时间,无法更新"
  56. return result, nil
  57. }
  58. // 验证身份
  59. if !participateService.CheckBidPower(projectId, true) {
  60. result.ErrMsg = "没有更新权限"
  61. return result, nil
  62. }
  63. // 2. 更新
  64. if err := participateService.UpdateBidStatus(in, projectId); err != nil {
  65. result.ErrMsg = err.Error()
  66. } else {
  67. result.Data = true
  68. result.ErrCode = 0
  69. }
  70. return result, nil
  71. }