participateshowlogic.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package logic
  2. import (
  3. "context"
  4. IC "jyBXCore/rpc/init"
  5. "jyBXCore/rpc/internal/svc"
  6. "jyBXCore/rpc/model/es"
  7. "jyBXCore/rpc/service"
  8. "jyBXCore/rpc/type/bxcore"
  9. "jyBXCore/rpc/util"
  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: -1,
  29. Data: []*bxcore.ShowInfo{},
  30. }
  31. // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
  32. userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
  33. //不是超级订阅 也不是大会员
  34. if userInfo.Vip.Status < 0 && userInfo.Member.Status < 0 {
  35. result.ErrMsg = "没有权限"
  36. return &result, nil
  37. }
  38. participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  39. participateService.EntRoleId = userInfo.Ent.EntRoleId
  40. // 2. 根据标讯id 查询项目信息 拿到有效的项目id (无项目信息或者已经过开标时间 则不展示按钮 在开标时间内或者没有开标时间字段需要展示)
  41. // 信息id解密
  42. infoList, infoSet := service.DecodeId(in.Ids)
  43. if len(infoList) == 0 {
  44. result.ErrMsg = "信息id无效"
  45. return &result, nil
  46. }
  47. // 查有效项目id信息
  48. projectInfos := es.GetValidProjectByInfoId(infoList)
  49. if projectInfos == nil || len(*projectInfos) == 0 {
  50. result.ErrCode = 0
  51. return &result, nil
  52. }
  53. // 记录信息id和项目id的映射 用于最后处理返回数据
  54. infoM, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
  55. // 3. 查询参标信息 处理按钮 区分个人和企业
  56. var formatList []*bxcore.ShowInfo
  57. switch int(in.PositionType) {
  58. case service.PositionTypePersonal:
  59. existList := participateService.PersonalExistProject(projectIds)
  60. formatList = participateService.ListPersonalFormat(existList, infoM)
  61. case service.PositionTypeEnt:
  62. isAllow := util.IsALLow(in.EntId)
  63. existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
  64. formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
  65. }
  66. result.ErrCode = 0
  67. result.Data = formatList
  68. return &result, nil
  69. }