Эх сурвалжийг харах

feature(项目):
1、项目管理模块联系人信息优化

ZZH-wl 2 жил өмнө
parent
commit
d88bd634d1

+ 3 - 0
opms_parent/app/dao/proj/internal/proj_business_contact.go

@@ -32,6 +32,7 @@ type projBusinessContactColumns struct {
 	Id          string // 主键
 	BusId       string // 关联项目
 	ContactId   string // 联系人主键
+	ContactType string // 联系人类型(10客户联系人 20 渠道联系人)
 	Remark      string // 备注
 	CreatedBy   string // 创建者
 	CreatedName string // 创建人
@@ -52,6 +53,7 @@ var (
 			Id:          "id",
 			BusId:       "bus_id",
 			ContactId:   "contact_id",
+			ContactType: "contact_type",
 			Remark:      "remark",
 			CreatedBy:   "created_by",
 			CreatedName: "created_name",
@@ -74,6 +76,7 @@ func NewProjBusinessContactDao(tenant string) ProjBusinessContactDao {
 			Id:          "id",
 			BusId:       "bus_id",
 			ContactId:   "contact_id",
+			ContactType: "contact_type",
 			Remark:      "remark",
 			CreatedBy:   "created_by",
 			CreatedName: "created_name",

+ 1 - 1
opms_parent/app/handler/proj/business.go

@@ -39,7 +39,7 @@ func (p *BusinessHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq
 	if err != nil {
 		return err
 	}
-	rsp.Data, err = businessService.GetEntityById(req.Id)
+	rsp.Data, err = businessService.GetBusinessInfoById(req.Id)
 	if err != nil {
 		return myerrors.QueryError(err, "项目")
 	}

+ 4 - 4
opms_parent/app/handler/proj/business_contact.go

@@ -48,15 +48,15 @@ func (p *BusinessContactHandler) Create(ctx context.Context, req *projModel.Busi
 }
 
 // Swagger:BusinessContact 项目联系人 删除
-func (p *BusinessContactHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq, rsp *comm_def.CommonMsg) error {
+func (p *BusinessContactHandler) DeleteByIds(ctx context.Context, req *projModel.DeleteBusinessContactReq, rsp *comm_def.CommonMsg) error {
 	// 参数校验
-	if len(req.Ids) == 0 {
-		return myerrors.ValidError("id参数有误!")
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
 	}
 	contactService, err := projSrv.NewBusinessContactService(ctx)
 	if err != nil {
 		return err
 	}
-	err = contactService.DeleteByIds(req.Ids)
+	err = contactService.DeleteByIds(req)
 	return err
 }

+ 1 - 0
opms_parent/app/model/proj/internal/proj_business_contact.go

@@ -13,6 +13,7 @@ type ProjBusinessContact struct {
 	Id          int         `orm:"id,primary"   json:"id"`          // 主键
 	BusId       int         `orm:"bus_id"       json:"busId"`       // 关联项目
 	ContactId   int         `orm:"contact_id"   json:"contactId"`   // 联系人主键
+	ContactType string      `orm:"contact_type" json:"contactType"` // 联系人类型(10客户联系人 20 渠道联系人)
 	Remark      string      `orm:"remark"       json:"remark"`      // 备注
 	CreatedBy   int         `orm:"created_by"   json:"createdBy"`   // 创建者
 	CreatedName string      `orm:"created_name" json:"createdName"` // 创建人

+ 6 - 0
opms_parent/app/model/proj/proj_business.go

@@ -244,3 +244,9 @@ type BusinessDynamicsReq struct {
 	OpnType string `json:"opnType"`                                   // 操作类型
 	request.PageReq
 }
+
+type SetBusinessContactReq struct {
+	BusId       int    `json:"busId"             ` // 关联项目
+	ContactId   int    `json:"contactIds"        ` // 联系人主键
+	ContactType string `json:"contactType"       ` // 联系人类型
+}

+ 12 - 5
opms_parent/app/model/proj/proj_business_contact.go

@@ -18,6 +18,7 @@ type BusinessContact struct {
 	Id             int    `json:"id"`             // 主键
 	BusId          int    `json:"busId"`          // 关联项目
 	ContactId      int    `json:"contactId"`      // 联系人主键
+	ContactType    string `json:"contactType"`    // 联系人类型(10客户联系人 20 渠道联系人)
 	CustId         int    `json:"custId" `        // 关联客户
 	CuctName       string `json:"cuctName"  `     // 姓名
 	CuctGender     string `json:"cuctGender"`     // 性别(10男20女)
@@ -33,13 +34,19 @@ type BusinessContact struct {
 // BusinessContactSearchReq 获取项目关联联系人信息
 type BusinessContactSearchReq struct {
 	BusId    int64  `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 主键
-	CuctId   int    `json:"cuctId"`                                    // 客户联系人
-	CuctName string `json:"cuctName"`                                  // 客户联系人姓名
+	CuctId   int    `json:"cuctId"`                                            // 客户联系人
+	CuctName string `json:"cuctName"`                                          // 客户联系人姓名
 	request.PageReq
 }
 
 type BusinessContactReq struct {
-	BusId      int    `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 关联项目
-	ContactIds []int  `json:"contactIds"        v:"required#联系人不能为空"`    // 联系人主键
-	Remark     string `json:"remark"`                                    // 备注
+	BusId       int    `json:"busId"             v:"required|min:1#|关联项目不能为空"` // 关联项目
+	ContactIds  []int  `json:"contactIds"        v:"required#联系人不能为空"`          // 联系人主键
+	ContactType string `json:"contactType"       v:"required#联系人类型不能为空"`      // 联系人类型
+	Remark      string `json:"remark"`                                                 // 备注
+}
+
+type DeleteBusinessContactReq struct {
+	BusId      int64 `json:"busId"             v:"required|min:1#|关联项目不能为空"` // 关联项目
+	ContactIds []int `json:"contactIds"        v:"required#联系人不能为空"`          // 联系人主键
 }

+ 12 - 0
opms_parent/app/service/base/base_distributor_contact.go

@@ -79,6 +79,18 @@ func (s BaseDistributorContactService) List(ctx context.Context, req *model.Base
 	return total, ents, nil
 }
 
+// GetEntityById 详情
+func (s BaseDistributorContactService) GetEntityById(id int64) (entityInfo *model.BaseDistributorContact, err error) {
+	entityInfo, err = s.Dao.WherePri(id).One()
+	if err != nil {
+		return
+	}
+	if entityInfo == nil {
+		return nil, myerrors.TipsError("联系人不存在")
+	}
+	return
+}
+
 func (s BaseDistributorContactService) Add(ctx context.Context, req *model.BaseDistributorContactAddReq) (int, error) {
 	validErr := gvalid.CheckStruct(ctx, req, nil)
 	if validErr != nil {

+ 12 - 0
opms_parent/app/service/cust/cust_customer_contact.go

@@ -96,6 +96,18 @@ func (s *CustomercontactService) GetList(req *model.ContactSeq) (total int, list
 	return
 }
 
+// GetEntityById 详情
+func (s *CustomercontactService) GetEntityById(id int64) (entityInfo *model.CustCustomerContact, err error) {
+	entityInfo, err = s.Dao.WherePri(id).One()
+	if err != nil {
+		return
+	}
+	if entityInfo == nil {
+		return nil, myerrors.TipsError("联系人不存在")
+	}
+	return
+}
+
 // 删除联系人
 func (s *CustomercontactService) DeleteById(Ids []int64) (err error) {
 	result, err := s.Dao.Where(" id  in (?) ", Ids).Count()

+ 82 - 17
opms_parent/app/service/proj/business.go

@@ -33,9 +33,10 @@ import (
 
 type businessService struct {
 	*service.ContextService
-	Dao       *projDao.ProjBusinessDao
-	FollowDao *platDao.PlatFollowupDao
-	fileDao   *projDao.ProjBusinessFileDao
+	Dao        *projDao.ProjBusinessDao
+	ContactDao *projDao.ProjBusinessContactDao
+	FollowDao  *platDao.PlatFollowupDao
+	fileDao    *projDao.ProjBusinessFileDao
 }
 
 func NewBusinessService(ctx context.Context) (svc *businessService, err error) {
@@ -44,6 +45,7 @@ func NewBusinessService(ctx context.Context) (svc *businessService, err error) {
 		return nil, err
 	}
 	svc.Dao = projDao.NewProjBusinessDao(svc.Tenant)
+	svc.ContactDao = projDao.NewProjBusinessContactDao(svc.Tenant)
 	svc.FollowDao = platDao.NewPlatFollowupDao(svc.Tenant)
 	svc.fileDao = projDao.NewProjBusinessFileDao(svc.Tenant)
 	return svc, nil
@@ -97,6 +99,17 @@ func (p *businessService) GetList(req *model.ProjBusinessSearchReq) (total int,
 }
 
 func (p *businessService) GetEntityById(id int64) (business *model.ProjBusinessRes, err error) {
+	err = p.Dao.Where(projDao.ProjBusiness.C.Id, id).Scan(&business)
+	if err != nil {
+		return nil, err
+	}
+	if business == nil {
+		return nil, myerrors.TipsError("项目不存在")
+	}
+	return
+}
+
+func (p *businessService) GetBusinessInfoById(id int64) (business *model.ProjBusinessRes, err error) {
 	err = p.Dao.Where(projDao.ProjBusiness.C.Id, id).Scan(&business)
 	if err != nil {
 		return nil, err
@@ -377,6 +390,27 @@ func (p *businessService) setProductInfo(busId int, productInfo []model.Business
 	return totalPrice.InexactFloat64(), products, nil
 }
 
+// setBusinessContact 设置项目联系人
+func (p *businessService) setBusinessContact(tx *gdb.TX, contactList []model.SetBusinessContactReq) (err error) {
+	for _, item := range contactList {
+		count, err := p.ContactDao.Where(p.ContactDao.C.BusId, item.BusId).Where(p.ContactDao.C.ContactType, item.ContactType).Count()
+		if err != nil {
+			return err
+		}
+		if count == 0 {
+			data := new(model.ProjBusinessContact)
+			data.BusId = item.BusId
+			data.ContactId = item.ContactId
+			data.ContactType = item.ContactType
+			service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
+			_, err = p.ContactDao.TX(tx).Data(data).Insert()
+			if err != nil {
+				return err
+			}
+		}
+	}
+	return
+}
 func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 	record, err := p.Dao.WherePri(req.Id).Count()
 	if err != nil {
@@ -391,16 +425,21 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 		return err
 	}
 	// 设置默认联系人
-	contact := g.Map{
-		projDao.ProjBusinessContact.C.BusId:     req.Id,
-		projDao.ProjBusinessContact.C.ContactId: req.ContactId,
-	}
-	contactFlag, err := projDao.NewProjBusinessContactDao(p.Tenant).Where(contact).Count()
-	if err != nil {
-		return err
+
+	contactList := make([]model.SetBusinessContactReq, 0)
+	if req.ContactId != 0 {
+		contactList = append(contactList, model.SetBusinessContactReq{
+			BusId:       req.Id,
+			ContactId:   req.ContactId,
+			ContactType: "10",
+		})
 	}
-	if contactFlag == 0 {
-		service.SetCreatedInfo(contact, p.GetCxtUserId(), p.GetCxtUserName())
+	if req.DealerSalesId != 0 {
+		contactList = append(contactList, model.SetBusinessContactReq{
+			BusId:       req.Id,
+			ContactId:   req.DealerSalesId,
+			ContactType: "20",
+		})
 	}
 
 	// 设置项目信息
@@ -427,11 +466,9 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 		}
 
 		// 关联联系人
-		if contactFlag == 0 {
-			_, err = projDao.NewProjBusinessContactDao(p.Tenant).TX(tx).Insert(contact)
-			if err != nil {
-				return err
-			}
+		err = p.setBusinessContact(tx, contactList)
+		if err != nil {
+			return err
 		}
 
 		// 添加项目动态
@@ -446,6 +483,13 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 	return err
 }
 
+// UpdateBusinessContactInfo 清理项目表联系人信息
+func (p *businessService) UpdateBusinessContactInfo(tx *gdb.TX, busId int, data g.Map) (err error) {
+	fields := []interface{}{p.Dao.C.ContactId, p.Dao.C.ContactName, p.Dao.C.ContactPostion, p.Dao.C.ContactTelephone, p.Dao.C.DealerSalesId, p.Dao.C.DealerSalesName, p.Dao.C.DealerSalesContact}
+	_, err = p.Dao.TX(tx).Fields(fields...).WherePri(busId).Data(data).Update()
+	return
+}
+
 func (p *businessService) DeleteByIds(ids []int64) (err error) {
 	_, err = p.Dao.WhereIn(projDao.ProjBusiness.C.Id, ids).Delete()
 	return
@@ -665,12 +709,33 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq, fileMap
 		defer os.Remove(fileMap["dashooParamFile"].File.Name())
 	}
 
+	contactList := make([]model.SetBusinessContactReq, 0)
+	if req.ContactId != 0 {
+		contactList = append(contactList, model.SetBusinessContactReq{
+			BusId:       req.Id,
+			ContactId:   req.ContactId,
+			ContactType: "10",
+		})
+	}
+	if req.DealerSalesId != 0 {
+		contactList = append(contactList, model.SetBusinessContactReq{
+			BusId:       req.Id,
+			ContactId:   req.DealerSalesId,
+			ContactType: "20",
+		})
+	}
+
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
 		// 更新项目调级
 		_, err = p.Dao.TX(tx).WherePri(req.Id).Data(businessMap).Update()
 		if err != nil {
 			return err
 		}
+		// 关联联系人
+		err = p.setBusinessContact(tx, contactList)
+		if err != nil {
+			return err
+		}
 		// 添加项目动态
 		dynamics := model.ProjBusinessDynamics{
 			BusId:   business.Id,

+ 129 - 14
opms_parent/app/service/proj/business_contact.go

@@ -2,10 +2,13 @@ package proj
 
 import (
 	"context"
+	baseDao "dashoo.cn/micro/app/dao/base"
 	custDao "dashoo.cn/micro/app/dao/cust"
 	projDao "dashoo.cn/micro/app/dao/proj"
 	projModel "dashoo.cn/micro/app/model/proj"
 	"dashoo.cn/micro/app/service"
+	"dashoo.cn/micro/app/service/base"
+	"dashoo.cn/micro/app/service/cust"
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/container/gset"
 	"github.com/gogf/gf/database/gdb"
@@ -28,26 +31,34 @@ func NewBusinessContactService(ctx context.Context) (svc *businessContactService
 }
 
 func (p *businessContactService) GetList(req *projModel.BusinessContactSearchReq) (total int, contactList []*projModel.BusinessContact, err error) {
-	db := p.Dao.As("bus").LeftJoin(custDao.CustCustomerContact.Table, "contact", "bus.contact_id=contact.id").
+	db := p.Dao.As("bus").Unscoped().WhereNull("bus."+p.Dao.C.DeletedTime).
+		LeftJoin(custDao.CustCustomerContact.Table, "cust", "bus.contact_id=cust.id AND bus.contact_type='10' AND `cust`.`deleted_time` IS NULL ").
+		LeftJoin(baseDao.BaseDistributorContact.Table, "dist", "bus.contact_id=dist.id AND bus.contact_type='20' AND `dist`.`deleted_time` IS NULL ").
 		Where("bus."+p.Dao.C.BusId, req.BusId)
 	if req.CuctId != 0 {
 		db = db.Where("contact.cuct_id", req.CuctId)
 	}
 	if req.CuctName != "" {
-		db = db.Where("contact.cuct_name", req.BusId)
+		db = db.Where("contact.cuct_name = ? or dist.name = ?", req.CuctName, req.CuctName)
 	}
 	total, err = db.Count()
 	if err != nil {
 		g.Log().Error(err)
 		return
 	}
-
-	err = db.Fields("bus.*, contact.*,bus.id AS id").Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
+	fields := "bus.*, case when bus.contact_type ='10' then cust.cuct_name when bus.contact_type ='20' then dist.name end  as name," +
+		"case when bus.contact_type ='10' then cust.cuct_name when bus.contact_type ='20' then dist.name end  as cuct_name," +
+		"case when bus.contact_type ='10' then cust.postion when bus.contact_type ='20' then dist.post end  as postion," +
+		"case when bus.contact_type ='10' then cust.telephone when bus.contact_type ='20' then dist.phone end  as telephone," +
+		"case when bus.contact_type ='10' then cust.wechat when bus.contact_type ='20' then dist.name end  as wechat," +
+		"case when bus.contact_type ='10' then cust.email when bus.contact_type ='20' then dist.mail end  as email," +
+		"case when bus.contact_type ='10' then cust.office_location when bus.contact_type ='20' then dist.territory end  as office_location"
+	err = db.Fields(fields).Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
 	return
 }
 
 func (p *businessContactService) Create(req *projModel.BusinessContactReq) (err error) {
-	dbContactIds, err := p.Dao.Where(p.Dao.C.BusId, req.BusId).Fields(p.Dao.C.ContactId).Array()
+	dbContactIds, err := p.Dao.Fields(p.Dao.C.ContactId).Where(p.Dao.C.BusId, req.BusId).Where(p.Dao.C.ContactType, req.ContactType).Array()
 	if err != nil {
 		g.Log().Error(err)
 		return myerrors.DbError("查询项目联系人失败")
@@ -63,47 +74,151 @@ func (p *businessContactService) Create(req *projModel.BusinessContactReq) (err
 		data := new(projModel.ProjBusinessContact)
 		data.BusId = req.BusId
 		data.ContactId = v
+		data.ContactType = req.ContactType
 		data.Remark = req.Remark
 		service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
 		contactList = append(contactList, data)
 	}
-	b, _ := NewBusinessService(p.Ctx)
+	busSrv, _ := NewBusinessService(p.Ctx)
+	busInfo, err := busSrv.GetEntityById(int64(req.BusId))
+	if err != nil {
+		return err
+	}
+	updateBusData := g.Map{}
+	if busInfo.ContactId == 0 && req.ContactType == "10" {
+		custSrv, _ := cust.NewCustomerContactService(p.Ctx)
+		info, err := custSrv.GetEntityById(int64(req.ContactIds[0]))
+		if err != nil {
+			return err
+		}
+		updateBusData[projDao.ProjBusiness.C.ContactId] = info.Id
+		updateBusData[projDao.ProjBusiness.C.ContactName] = info.CuctName
+		updateBusData[projDao.ProjBusiness.C.ContactPostion] = info.Postion
+		updateBusData[projDao.ProjBusiness.C.ContactTelephone] = info.Telephone + "/" + info.Wechat
+	}
+	if busInfo.DealerSalesId == 0 && req.ContactType == "20" {
+		distSrv, _ := base.NewBaseDistributorContactService(p.Ctx)
+		info, err := distSrv.GetEntityById(int64(req.ContactIds[0]))
+		if err != nil {
+			return err
+		}
+		updateBusData[projDao.ProjBusiness.C.DealerSalesId] = info.Id
+		updateBusData[projDao.ProjBusiness.C.DealerSalesName] = info.Name
+		updateBusData[projDao.ProjBusiness.C.DealerSalesContact] = info.Phone + "/" + info.Wechat
+	}
+
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
 		_, err = p.Dao.Insert(&contactList)
 		if err != nil {
 			return err
 		}
+
+		if len(updateBusData) > 0 {
+			// 	清理项目联系人信息
+			err = busSrv.UpdateBusinessContactInfo(tx, busInfo.Id, updateBusData)
+			if err != nil {
+				return err
+			}
+		}
 		// 添加项目动态
 		dynamics := projModel.ProjBusinessDynamics{
 			BusId:   req.BusId,
 			OpnType: OpnAssociation,
 		}
-		_, err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		_, err = busSrv.CreateProjBusinessDynamics(tx, dynamics, nil)
 		return err
 	})
 	return
 }
 
-func (p *businessContactService) DeleteByIds(ids []int64) (err error) {
-	result, err := p.Dao.Where(projDao.ProjBusinessContact.C.Id+" IN(?)", ids).One()
+func (p *businessContactService) DeleteByIds(req *projModel.DeleteBusinessContactReq) (err error) {
+	busSrv, _ := NewBusinessService(p.Ctx)
+	busInfo, err := busSrv.GetEntityById(req.BusId)
 	if err != nil {
 		return err
 	}
-	if result == nil {
+	list, err := p.Dao.Where(p.Dao.C.BusId, req.BusId).All()
+	if err != nil {
+		return err
+	}
+	if list == nil || len(list) == 0 {
 		return myerrors.TipsError("联系人不存在")
 	}
-	b, _ := NewBusinessService(p.Ctx)
+	delIds := gset.NewIntSetFrom(req.ContactIds, true)
+	allIds := gset.NewIntSet(true)
+	for _, item := range list {
+		allIds.Add(item.Id)
+	}
+	if delIds.Diff(allIds).Size() > 0 {
+		return myerrors.TipsError("联系人不存在")
+	}
+
+	updateBusData := g.Map{}
+	var custContactId int
+	var dealerSalesId int
+	for _, item := range list {
+		if item.ContactType == "10" {
+			if item.ContactId == busInfo.ContactId && delIds.Contains(item.Id) {
+				updateBusData[projDao.ProjBusiness.C.ContactId] = ""
+				updateBusData[projDao.ProjBusiness.C.ContactName] = ""
+				updateBusData[projDao.ProjBusiness.C.ContactPostion] = ""
+				updateBusData[projDao.ProjBusiness.C.ContactTelephone] = ""
+			} else {
+				custContactId = item.ContactId
+			}
+		}
+		if item.ContactType == "20" {
+			if item.ContactId == busInfo.DealerSalesId && delIds.Contains(item.Id) {
+				updateBusData[projDao.ProjBusiness.C.DealerSalesId] = ""
+				updateBusData[projDao.ProjBusiness.C.DealerSalesName] = ""
+				updateBusData[projDao.ProjBusiness.C.DealerSalesContact] = ""
+			} else {
+				dealerSalesId = item.ContactId
+			}
+		}
+	}
+	if _, ok := updateBusData[projDao.ProjBusiness.C.ContactId]; ok && custContactId != 0 {
+		custSrv, _ := cust.NewCustomerContactService(p.Ctx)
+		info, err := custSrv.GetEntityById(int64(custContactId))
+		if err != nil {
+			return err
+		}
+		updateBusData[projDao.ProjBusiness.C.ContactId] = info.Id
+		updateBusData[projDao.ProjBusiness.C.ContactName] = info.CuctName
+		updateBusData[projDao.ProjBusiness.C.ContactPostion] = info.Postion
+		updateBusData[projDao.ProjBusiness.C.ContactTelephone] = info.Telephone + "/" + info.Wechat
+	}
+	if _, ok := updateBusData[projDao.ProjBusiness.C.DealerSalesId]; ok && dealerSalesId != 0 {
+		distSrv, _ := base.NewBaseDistributorContactService(p.Ctx)
+		info, err := distSrv.GetEntityById(int64(dealerSalesId))
+		if err != nil {
+			return err
+		}
+		updateBusData[projDao.ProjBusiness.C.DealerSalesId] = info.Id
+		updateBusData[projDao.ProjBusiness.C.DealerSalesName] = info.Name
+		updateBusData[projDao.ProjBusiness.C.DealerSalesContact] = info.Phone + "/" + info.Wechat
+	}
+
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
-		_, err = p.Dao.WhereIn(projDao.ProjBusinessContact.C.Id, ids).Delete()
+		_, err = p.Dao.Where(p.Dao.C.BusId, req.BusId).WhereIn(p.Dao.C.Id, req.ContactIds).Delete()
 		if err != nil {
 			return err
 		}
+
+		if len(updateBusData) > 0 {
+			// 	清理项目联系人信息
+			err = busSrv.UpdateBusinessContactInfo(tx, busInfo.Id, updateBusData)
+			if err != nil {
+				return err
+			}
+		}
+
 		// 添加项目动态
 		dynamics := projModel.ProjBusinessDynamics{
-			BusId:   result.BusId,
+			BusId:   busInfo.Id,
 			OpnType: OpnDisassociation,
 		}
-		_, err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		_, err = busSrv.CreateProjBusinessDynamics(tx, dynamics, nil)
 		return err
 	})
 	return