participateshowlogic.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. Data: []*bxcore.ShowInfo{},
  28. }
  29. b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
  30. if !b {
  31. result.ErrMsg = "没有权限"
  32. return &result, nil
  33. }
  34. participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
  35. participateService.EntRoleId = entRoleId
  36. // 2. 根据标讯id 查询项目信息 拿到有效的项目id (无项目信息或者已经过开标时间 则不展示按钮 在开标时间内或者没有开标时间字段需要展示)
  37. // 信息id解密
  38. infoList, infoSet := service.DecodeId(in.Ids)
  39. if len(infoList) == 0 {
  40. result.ErrCode = -1
  41. result.ErrMsg = "信息id无效"
  42. return &result, nil
  43. }
  44. // 查有效项目id信息
  45. projectInfos := es.GetValidProjectByInfoId(infoList)
  46. if projectInfos == nil || len(*projectInfos) == 0 {
  47. return &result, nil
  48. }
  49. // 记录信息id和项目id的映射 用于最后处理返回数据
  50. infoM, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
  51. // 3. 查询参标信息 处理按钮 区分个人和企业
  52. var formatList []*bxcore.ShowInfo
  53. switch int(in.PositionType) {
  54. case service.PositionTypePersonal:
  55. existList := participateService.PersonalExistProject(projectIds)
  56. formatList = participateService.ListPersonalFormat(existList, infoM)
  57. case service.PositionTypeEnt:
  58. isAllow := mysql.IsALLow(in.EntId)
  59. existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
  60. formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
  61. }
  62. result.Data = formatList
  63. return &result, nil
  64. }