123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package service
- import (
- MC "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/encrypt"
- "fmt"
- IC "jyBXCore/rpc/init"
- "jyBXCore/rpc/model/tidb"
- "jyBXCore/rpc/type/bxcore"
- "jyBXCore/rpc/util"
- )
- //参标动作:参标、终止参标、划转:in:参标;out:终止参标;transfer:划转
- func ParticipateDo(in *bxcore.ParticipateActionReq) (*bxcore.ParticipateActionRes, error) {
- //招标信息解密
- in.BidId = encrypt.DecodeArticleId2ByCheck(in.BidId)[0]
- if in.BidId == "" {
- return nil, fmt.Errorf("当前招标信息有误")
- }
- //当前项目是否符合参标条件
- participateBid := NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
- projectInfos := participateBid.GetProjectByInfoId([]string{in.BidId})
- if projectInfos == nil || len(*projectInfos) == 0 {
- return nil, fmt.Errorf("当前项目信息不满足参标条件")
- }
- //符合参标项目id
- projectInfo := (*projectInfos)[0]
- if projectInfo["_id"] != nil && MC.ObjToString(projectInfo["_id"]) != "" {
- in.BidId = MC.ObjToString(projectInfo["_id"])
- } else {
- return nil, fmt.Errorf("当前项目信息有误")
- }
- switch in.ActionType {
- case "in":
- //是否允许多人参标
- if isAllow := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType).IsALLow(); !isAllow {
- //如果不允许多人参标 当前项目是否已经有企业其他人员参标
- query := fmt.Sprintf(`SELECT count(id) FROM participate_user WHERE %s AND project_id = %s AND state >-1`, "%s", in.BidId)
- if in.PositionType > 0 {
- query = fmt.Sprintf(query, fmt.Sprintf("ent_id = %d", in.EntId))
- } else {
- query = fmt.Sprintf(query, fmt.Sprintf("position_id = %d", in.PositionId))
- }
- if ok := tidb.IsParticipatedByBidId(query); ok {
- return nil, fmt.Errorf("当前项目不允许多人参标")
- }
- }
- //保存参标信息 更新当前企业参标项目记录
- if err := tidb.SaveParticipateInfo(in); err != nil {
- return nil, err
- }
- case "out": //终止参标
- if err := tidb.UpdateParticipateInfo(in); err != nil {
- return nil, err
- }
- case "transfer":
- if in.PositionType == 0 {
- return nil, fmt.Errorf("当前企业身份有误")
- }
- //企业版 判断是否是管理员
- //判断用户身份
- userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
- if userInfo.Ent.EntRoleId == 0 { //1:企业管理员;2:部门管理员
- return nil, fmt.Errorf("当前企业身份无权限")
- }
- //是否保留原跟踪人?
- partUser := util.NewPartUserInfo(in.EntId, in.EntUserId, in.PositionId, in.PositionType)
- isAllow := partUser.IsALLow()
- if !isAllow && in.IsRetain {
- //不允许多人参标,但是前端参数又是保留原参标人 互相矛盾
- return nil, fmt.Errorf("当前项目只允许一人参标")
- }
- if err := tidb.TransferParticipate(in); err != nil {
- return nil, err
- }
- }
- return &bxcore.ParticipateActionRes{
- Data: true,
- }, nil
- }
- //参标设置更新及设置内容
- func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.ParticipateSetUpInfoRes, error) {
- res := &bxcore.ParticipateSetUpInfoRes{Data: &bxcore.ParticipateSetUpInfo{
- IsAllow: "0",
- BidType: nil,
- RemindRule: nil,
- }}
- switch in.SetAction {
- case "U": //update 更新设置信息
- res.Data = nil
- if err := tidb.UpdateParticipateSetInfo(in); err != nil {
- res.ErrCode = -1
- res.ErrMsg = err.Error()
- }
- default: //默认查询对应设置信息
- //查询对应用户设置信息
- //未设置过 返回默认配置
- if info, err := tidb.GetParticipateSetInfo(in); err == nil {
- res.Data = info
- } else {
- res.ErrCode = -1
- res.ErrMsg = err.Error()
- }
- }
- return res, nil
- }
|