participateshowlogic.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. IC "jyBXCore/rpc/init"
  6. "jyBXCore/rpc/internal/svc"
  7. "jyBXCore/rpc/model/es"
  8. "jyBXCore/rpc/service"
  9. "jyBXCore/rpc/type/bxcore"
  10. "jyBXCore/rpc/util"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type ParticipateShowLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewParticipateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipateShowLogic {
  19. return &ParticipateShowLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 列表数据参标信息接口
  26. func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*bxcore.ParticipateShowRes, error) {
  27. result := bxcore.ParticipateShowRes{
  28. ErrMsg: "",
  29. ErrCode: 0,
  30. Data: []*bxcore.ShowInfo{},
  31. }
  32. // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
  33. userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
  34. //不是超级订阅 也不是大会员
  35. if userInfo.Vip.Status < 0 && userInfo.Member.Status < 0 {
  36. return &result, fmt.Errorf("没权限")
  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. return &result, fmt.Errorf("信息id无效")
  45. }
  46. // 查有效项目id信息
  47. projectInfos := es.GetValidProjectByInfoId(infoList)
  48. if projectInfos == nil || len(*projectInfos) == 0 {
  49. return &result, nil
  50. }
  51. // 记录信息id和项目id的映射 用于最后处理返回数据
  52. infoM, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
  53. // 3. 查询参标信息 处理按钮 区分个人和企业
  54. var formatList []*bxcore.ShowInfo
  55. switch int(in.PositionType) {
  56. case service.PositionTypePersonal:
  57. existList := participateService.PersonalExistProject(projectIds)
  58. formatList = participateService.ListPersonalFormat(existList, infoM)
  59. case service.PositionTypeEnt:
  60. isAllow := util.IsALLow(in.EntId)
  61. existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
  62. formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
  63. }
  64. result.Data = formatList
  65. return &result, nil
  66. }