123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- package service
- import (
- MC "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/encrypt"
- "fmt"
- "github.com/zeromicro/go-zero/core/logx"
- IC "jyBXCore/rpc/init"
- "jyBXCore/rpc/model/es"
- "jyBXCore/rpc/model/mysql"
- "jyBXCore/rpc/type/bxcore"
- "jyBXCore/rpc/util"
- "strings"
- )
- //我的参标项目|企业参标项目 列表
- func ParticipateList(in *bxcore.ParticipateListReq) (*bxcore.ParticipateListRes, error) {
- defer MC.Catch()
- res := &bxcore.ParticipateListRes{Data: &bxcore.ParticipateData{}}
- if in.PositionType > 0 {
- userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
- if userInfo.Ent.EntRoleId == 0 {
- in.EntUserIds = ""
- }
- }
- switch in.Identity {
- case "mine": //员工|个人列表
- r, e := mysql.SingleParticipateList(in, mysql.ParticipateListSql(in))
- if e != nil {
- res.ErrCode = -1
- res.ErrMsg = e.Error()
- return res, nil
- }
- res.Data = r
- case "ent": //企业管理员
- r, e := mysql.AdminParticipateList(in, mysql.ParticipateListSql(in))
- if e != nil {
- res.ErrCode = -1
- res.ErrMsg = e.Error()
- return res, nil
- }
- res.Data = r
- }
- return res, nil
- }
- /*
- 已过投标截止日期项目
- (1) 不显示终止投标倒计时
- (2) 显示参标人信息
- (3) 无终止参标操作入口
- (4) 不能划转
- (5) 不能参标
- */
- //参标动作:参标、终止参标、划转:in:参标;out:终止参标;transfer:划转
- func ParticipateDo(in *bxcore.ParticipateActionReq) error {
- defer MC.Catch()
- var (
- tip = "参标"
- )
- switch in.ActionType {
- case "out":
- tip = "终止参标"
- case "transfer":
- tip = "划转"
- }
- //企业版 判断是否是管理员
- //判断用户身份
- userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
- switch in.ActionType {
- case "in": //参标针对单个招标信息 或者 项目
- if in.BidIds == "" && in.ProjectIds == "" {
- return fmt.Errorf("缺少参数")
- }
- if in.ProjectIds != "" {
- in.ProjectIds = strings.Split(in.ProjectIds, ",")[0]
- in.ProjectIds = encrypt.DecodeArticleId2ByCheck(in.ProjectIds)[0]
- if in.ProjectIds == "" {
- return fmt.Errorf("当前招标信息有误")
- }
- //当前项目是否符合参标条件
- projectInfos := es.GetBidInfoByPId(in.ProjectIds)
- if projectInfos == nil || len(*projectInfos) == 0 {
- return fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
- }
- //符合参标项目id
- projectInfo := (*projectInfos)[0]
- if projectInfo["sourceinfoid"] != nil && MC.ObjToString(projectInfo["sourceinfoid"]) != "" {
- //招标信息id
- in.BidIds = MC.ObjToString(projectInfo["sourceinfoid"])
- } else {
- return fmt.Errorf("当前项目信息有误")
- }
- } else {
- in.BidIds = strings.Split(in.BidIds, ",")[0]
- //招标信息解密
- in.BidIds = encrypt.DecodeArticleId2ByCheck(in.BidIds)[0]
- if in.BidIds == "" {
- return fmt.Errorf("当前招标信息有误")
- }
- //当前项目是否符合参标条件
- projectInfos := es.GetProjectByInfoId(strings.Split(in.BidIds, ","))
- if projectInfos == nil || len(*projectInfos) == 0 {
- return fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
- }
- //符合参标项目id
- projectInfo := (*projectInfos)[0]
- if projectInfo["_id"] != nil && MC.ObjToString(projectInfo["_id"]) != "" {
- //项目信息id
- in.ProjectIds = MC.ObjToString(projectInfo["_id"])
- } else {
- return fmt.Errorf("当前项目信息有误")
- }
- }
- //是否允许多人参标
- if isAllow := util.IsALLow(in.EntId); !isAllow {
- if ok := mysql.IsParticipatedByBidId(in); ok {
- return fmt.Errorf("当前项目不允许多人参标")
- }
- }
- //保存参标信息 更新当前企业参标项目记录
- if err := mysql.SaveParticipateInfo(in); err != nil {
- return err
- }
- case "out": //终止参标
- if in.ProjectIds == "" {
- return fmt.Errorf("项目信息有误")
- }
- in.ProjectIds = strings.Split(in.ProjectIds, ",")[0]
- //招标信息解密
- in.ProjectIds = encrypt.DecodeArticleId2ByCheck(in.ProjectIds)[0]
- if in.ProjectIds == "" {
- return fmt.Errorf("当前项目信息有误")
- }
- if err := mysql.CancelParticipateInfo(in, userInfo.Ent.EntRoleId); err != nil {
- return err
- }
- case "transfer":
- if in.ProjectIds == "" {
- return fmt.Errorf("项目信息有误")
- }
- //个人版
- if in.PositionType == 0 {
- return fmt.Errorf("当前企业身份有误")
- }
- //非管理员
- if userInfo.Ent.EntRoleId == 0 { //1:企业管理员;2:部门管理员
- return fmt.Errorf("当前企业身份无权限")
- }
- //判断划转人
- if in.ToEntUserId == "" {
- return fmt.Errorf("划转对象不能为空")
- }
- //是否保留原跟踪人?
- isAllow := util.IsALLow(in.EntId)
- if in.IsRetain && !isAllow {
- //不允许多人参标,但是前端参数又是保留原参标人 互相矛盾
- return fmt.Errorf("当前项目只允许一人参标")
- }
- //in.ProjectIds //项目id
- projectIds := strings.Split(in.ProjectIds, ",")
- projectNum := 0
- for _, v := range projectIds {
- projectId := encrypt.DecodeArticleId2ByCheck(v)[0]
- if projectId == "" {
- continue
- }
- if err := mysql.TransferParticipateInfo(projectId, in); err != nil {
- logx.Info(fmt.Sprintf("是否允许多人参标:%v, 项目id:%s,企业id:%d,划转对象entuserid:%s,划转异常:", isAllow, projectId, in.EntId, in.ToEntUserId))
- continue
- }
- projectNum += 1
- }
- if projectNum != len(projectIds) {
- return fmt.Errorf("划转失败")
- }
- }
- return nil
- }
- //参标设置更新及设置内容
- func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.ParticipateSetUpInfoRes, error) {
- defer MC.Catch()
- res := &bxcore.ParticipateSetUpInfoRes{Data: &bxcore.ParticipateSetUpInfo{
- IsAllow: "0",
- BidType: nil,
- RemindRule: nil,
- }}
- switch in.SetAction {
- case "U": //update 更新设置信息
- res.Data = nil
- if err := mysql.UpdateParticipateSetInfo(in); err != nil {
- res.ErrCode = -1
- res.ErrMsg = err.Error()
- }
- default: //默认查询对应设置信息
- //查询对应用户设置信息
- //未设置过 返回默认配置
- if info, err := mysql.GetParticipateSetInfo(in); err == nil {
- res.Data = info
- } else {
- res.ErrCode = -1
- res.ErrMsg = err.Error()
- }
- }
- return res, nil
- }
|