participateshowlogic.go 2.7 KB

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