participateshowlogic.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package logic
  2. import (
  3. "context"
  4. "jyBXCore/entity"
  5. "jyBXCore/rpc/service"
  6. "jyBXCore/rpc/util"
  7. "strconv"
  8. "jyBXCore/rpc/internal/svc"
  9. "jyBXCore/rpc/type/bxcore"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type ParticipateShowLogic struct {
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. logx.Logger
  16. }
  17. func NewParticipateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipateShowLogic {
  18. return &ParticipateShowLogic{
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. Logger: logx.WithContext(ctx),
  22. }
  23. }
  24. // 列表数据参标信息接口
  25. func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*bxcore.ParticipateShowRes, error) {
  26. result := bxcore.ParticipateShowRes{
  27. ErrMsg: "",
  28. ErrCode: 0,
  29. Data: []*bxcore.ShowInfo{},
  30. }
  31. // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
  32. baseUserId, _ := strconv.ParseInt(in.NewUserId, 10, 64)
  33. accountId, _ := strconv.ParseInt(in.AccountId, 10, 64)
  34. userInfoRpc := entity.UserInfoRpc{
  35. AppId: in.AppId,
  36. UserId: in.UserId,
  37. BaseUserId: baseUserId,
  38. EntId: in.EntId,
  39. EntUserId: in.EntUserId,
  40. AccountId: accountId,
  41. PositionType: in.PositionType,
  42. PositionId: in.PositionId,
  43. MgoUserId: in.MgoUserId,
  44. }
  45. participateService := service.NewParticipateBid(int(in.EntId), int(in.EntUserId), int(in.PositionType), int(in.PositionId))
  46. if participateService.ParticipatePowerCheck(userInfoRpc) {
  47. return &result, nil
  48. }
  49. // 2. 根据标讯id 查询项目信息 拿到有效的项目id (无项目信息或者已经过开标时间 则不展示按钮 在开标时间内或者没有开标时间字段需要展示)
  50. // 信息id解密
  51. infoList, infoSet := service.DecodeId(in.Ids)
  52. if len(infoList) == 0 {
  53. return &result, nil
  54. }
  55. // 查有效项目id信息
  56. projectInfos := participateService.GetProjectByInfoId(infoList)
  57. if projectInfos == nil || len(*projectInfos) == 0 {
  58. return &result, nil
  59. }
  60. // 记录信息id和项目id的映射 用于最后处理返回数据
  61. infoM, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
  62. // 3. 查询参标信息 处理按钮 区分个人和企业
  63. var formatList []*bxcore.ShowInfo
  64. switch int(in.PositionType) {
  65. case service.PositionTypePersonal:
  66. existList := participateService.PersonalExistProject(projectIds)
  67. formatList = participateService.ListPersonalFormat(existList, infoM)
  68. case service.PositionTypeEnt:
  69. partUser := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType)
  70. isAllow := partUser.IsALLow()
  71. existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
  72. formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
  73. }
  74. result.Data = formatList
  75. return &result, nil
  76. }