1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package logic
- import (
- "context"
- "jyBXCore/entity"
- "jyBXCore/rpc/service"
- "jyBXCore/rpc/util"
- "strconv"
- "jyBXCore/rpc/internal/svc"
- "jyBXCore/rpc/type/bxcore"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type ParticipateShowLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewParticipateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipateShowLogic {
- return &ParticipateShowLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 列表数据参标信息接口
- func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*bxcore.ParticipateShowRes, error) {
- result := bxcore.ParticipateShowRes{
- ErrMsg: "",
- ErrCode: 0,
- Data: []*bxcore.ShowInfo{},
- }
- // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
- baseUserId, _ := strconv.ParseInt(in.NewUserId, 10, 64)
- accountId, _ := strconv.ParseInt(in.AccountId, 10, 64)
- userInfoRpc := entity.UserInfoRpc{
- AppId: in.AppId,
- UserId: in.UserId,
- BaseUserId: baseUserId,
- EntId: in.EntId,
- EntUserId: in.EntUserId,
- AccountId: accountId,
- PositionType: in.PositionType,
- PositionId: in.PositionId,
- MgoUserId: in.MgoUserId,
- }
- participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
- if participateService.ParticipatePowerCheck(userInfoRpc) {
- return &result, nil
- }
- // 2. 根据标讯id 查询项目信息 拿到有效的项目id (无项目信息或者已经过开标时间 则不展示按钮 在开标时间内或者没有开标时间字段需要展示)
- // 信息id解密
- infoList, infoSet := service.DecodeId(in.Ids)
- if len(infoList) == 0 {
- return &result, nil
- }
- // 查有效项目id信息
- projectInfos := participateService.GetProjectByInfoId(infoList)
- if projectInfos == nil || len(*projectInfos) == 0 {
- return &result, nil
- }
- // 记录信息id和项目id的映射 用于最后处理返回数据
- infoM, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
- // 3. 查询参标信息 处理按钮 区分个人和企业
- var formatList []*bxcore.ShowInfo
- switch int(in.PositionType) {
- case service.PositionTypePersonal:
- existList := participateService.PersonalExistProject(projectIds)
- formatList = participateService.ListPersonalFormat(existList, infoM)
- case service.PositionTypeEnt:
- partUser := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType)
- isAllow := partUser.IsALLow()
- existList := participateService.EntExistProject(projectIds) // 查询出已经存在的
- formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
- }
- result.Data = formatList
- return &result, nil
- }
|