12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package logic
- import (
- "app.yhyue.com/moapp/jybase/common"
- "context"
- IC "jyBXCore/rpc/init"
- "jyBXCore/rpc/model/es"
- "jyBXCore/rpc/service"
- "time"
- "jyBXCore/rpc/internal/svc"
- "jyBXCore/rpc/type/bxcore"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type UpdateBidStatusLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewUpdateBidStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBidStatusLogic {
- return &UpdateBidStatusLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 投标状态更新
- func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*bxcore.UpdateBidStatusRes, error) {
- result := &bxcore.UpdateBidStatusRes{
- ErrCode: -1,
- }
- // 1. 判断身份是否有权限 不是超级订阅也不是大会员 则直接返回不展示
- userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
- // 不是超级订阅 也不是大会员
- if userInfo.Vip.Status <= 0 && userInfo.Member.Status <= 0 {
- result.ErrMsg = "没有权限"
- return result, nil
- }
- participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
- participateService.EntRoleId = userInfo.Ent.EntRoleId
- // 信息id解密
- infoList, _ := service.DecodeId(in.Sid)
- if len(infoList) == 0 {
- result.ErrMsg = "信息id无效"
- return result, nil
- }
- // 根据标讯id 查询项目信息
- projectInfos := es.GetProjectByInfoId(infoList)
- if projectInfos == nil || len(*projectInfos) == 0 {
- result.ErrMsg = "未查询到项目信息"
- return result, nil
- }
- // 判断是否已经过了开标时间
- var isValid bool
- bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
- projectId := common.ObjToString((*projectInfos)[0]["_id"])
- if time.Now().Unix() >= bidopentime || bidopentime == 0 {
- isValid = true
- }
- if !isValid {
- result.ErrMsg = "已经过开标时间,无法更新"
- return result, nil
- }
- // 验证身份
- if !participateService.CheckBidPower(projectId, true) {
- result.ErrMsg = "没有更新权限"
- return result, nil
- }
- // 2. 更新
- flag := participateService.UpdateBidStatus(in, projectId)
- if !flag {
- result.ErrMsg = "更新失败"
- } else {
- result.ErrCode = 0
- }
- result.Data = flag
- return result, nil
- }
|