participateshowlogic.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "jyBXCore/rpc/internal/svc"
  6. "jyBXCore/rpc/model/es"
  7. "jyBXCore/rpc/model/mysql"
  8. "jyBXCore/rpc/service"
  9. "jyBXCore/rpc/type/bxcore"
  10. "jyBXCore/rpc/util"
  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. b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
  32. if !b {
  33. result.ErrMsg = "没有权限"
  34. return &result, nil
  35. }
  36. participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  37. participateService.EntRoleId = entRoleId
  38. // 2. 根据标讯id 查询项目信息 拿到有效的项目id (无项目信息或者已经过开标时间 则不展示按钮 在开标时间内或者没有开标时间字段需要展示)
  39. // 信息id解密
  40. infoList, infoSet := service.DecodeId(in.Ids)
  41. if len(infoList) == 0 {
  42. result.ErrMsg = "信息id无效"
  43. return &result, nil
  44. }
  45. // 查有效项目id信息
  46. projectInfos := es.GetValidProjectByInfoId(infoList)
  47. if projectInfos == nil || len(*projectInfos) == 0 {
  48. result.ErrCode = 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 := mysql.IsALLow(in.EntId)
  61. existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
  62. formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
  63. }
  64. result.ErrCode = 0
  65. result.Data = formatList
  66. return &result, nil
  67. }