ziwen il y a 2 ans
Parent
commit
e348697255

+ 28 - 1
controller/contract/register.go

@@ -2934,13 +2934,40 @@ func (rg *RegisterController) CheckContractName(c *gin.Context) {
 			return
 		}
 		if existCond != "" {
-			existCond += ` or (start_date =? and end_date=?)`
+			existCond += ` AND (start_date =? and end_date=?)`
 		} else {
 			existCond = ` start_date = ? and end_date=?`
 		}
 
 		existPars = append(existPars, startDate, endDate)
 	}
+	if req.SellerIds != "" {
+		admin := new(crm.Admin)
+		sellerIds := strings.Split(req.SellerIds, ",")
+		if len(sellerIds) > 2 {
+			resp.Fail("最多只能选择两个销售", c)
+			return
+		}
+		var pars []interface{}
+		cond := ` admin_id in (?) `
+		pars = append(pars, sellerIds)
+		sellers, e := admin.List(cond, pars)
+		if e != nil {
+			resp.FailMsg("获取销售信息失败", "获取销售信息失败, Err: "+e.Error(), c)
+			return
+		}
+		var sellerId, raiSellerId int
+		for _, v := range sellers {
+			if v.DepartmentId == crm.SellerDepartmentId {
+				sellerId = v.AdminId
+			} else if v.DepartmentId == crm.RaiSellerDepartmentId {
+				raiSellerId = v.AdminId
+			}
+		}
+		existCond += ` AND (seller_id =? and rai_seller_id=?)`
+		existPars = append(existPars, sellerId, raiSellerId)
+	}
+
 	if existCond == "" {
 		resp.Fail("请输入合同名称或者合同有效期", c)
 		return

+ 18 - 0
controller/crm/company_seller.go

@@ -66,3 +66,21 @@ func (rg *CompanySellerController) GroupList(c *gin.Context) {
 	}
 	resp.OkData("获取成功", list, c)
 }
+
+// List
+// @Title 销售列表
+// @Description 销售列表
+// @Success 200 {object} crm.SellerAdminWithGroupList
+// @router /crm/company_seller/all_list [get]
+func (rg *CompanySellerController) AllList(c *gin.Context) {
+	sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
+	if e != nil {
+		resp.FailData("获取销售失败", "Err:"+e.Error(), c)
+		return
+	}
+	respItem := crm.AllSellerResp{
+		FiccSeller: sellerList,
+		RaiSeller:  sellerList,
+	}
+	resp.OkData("获取成功", respItem, c)
+}

+ 5 - 0
models/crm/sys_group.go

@@ -36,3 +36,8 @@ func (m *SysGroup) Count(condition string, pars []interface{}) (total int64, err
 		Count(&total).Error
 	return
 }
+
+type AllSellerResp struct {
+	FiccSeller []*SellerAdminWithGroupTeam
+	RaiSeller []*SellerAdminWithGroupTeam
+}

+ 11 - 13
models/fms/contract_register.go

@@ -277,7 +277,6 @@ func UpdateContractRegister(item *ContractRegister, updateCols []string, service
 	sql = `DELETE FROM contract_service_amount WHERE contract_register_id = ?`
 	tx.Exec(sql, item.ContractRegisterId)
 
-
 	// 新增合同服务
 	//nowTime := time.Now().Local()
 	for i := 0; i < len(serviceDetail); i++ {
@@ -348,11 +347,11 @@ type ContractRegisterDetailReq struct {
 // ContractRegisterDetail-合同登记详情
 type ContractRegisterDetail struct {
 	*ContractRegisterItem
-	ServiceList       []*ContractServiceAndDetail `json:"service_list" description:"合同服务及详情"`
-	InvoiceList       []*ContractInvoiceItem      `json:"invoice_list" description:"开票信息"`
-	PaymentList       []*ContractInvoiceItem      `json:"payment_list" description:"到款信息"`
-	Logs              []*ContractRegisterLogItem  `json:"logs" description:"登记日志"`
-	ServiceAmountList []*ContractServiceAmountItem    `json:"service_amount_list" description:"合同套餐金额"`
+	ServiceList       []*ContractServiceAndDetail  `json:"service_list" description:"合同服务及详情"`
+	InvoiceList       []*ContractInvoiceItem       `json:"invoice_list" description:"开票信息"`
+	PaymentList       []*ContractInvoiceItem       `json:"payment_list" description:"到款信息"`
+	Logs              []*ContractRegisterLogItem   `json:"logs" description:"登记日志"`
+	ServiceAmountList []*ContractServiceAmountItem `json:"service_amount_list" description:"合同套餐金额"`
 }
 
 // GetContractRegisterItemById 获取合同登记信息
@@ -484,8 +483,7 @@ func CreateImportContractRegister(item *ContractRegister, serviceList []*Contrac
 	return
 }
 
-
-func GetContractInfoByRegisterIds(registerIds []int) (list []ContractRegister,err error) {
+func GetContractInfoByRegisterIds(registerIds []int) (list []ContractRegister, err error) {
 	err = global.DEFAULT_MYSQL.Model(ContractRegister{}).
 		Where("is_deleted = 0 AND contract_register_id in ?", registerIds).
 		Find(&list).Error
@@ -539,13 +537,13 @@ func CreateContractRegisterAndServicesAndPayMent(item *ContractRegister, service
 	return
 }
 
-type  CheckContractNameReq struct {
+type CheckContractNameReq struct {
 	CompanyName string `json:"company_name" form:"company_name" description:"客户名称"`
 	StartDate   string `json:"start_date" form:"start_date" description:"合同开始日期"`
 	EndDate     string `json:"end_date" form:"end_date" description:"合同结束日期"`
+	SellerIds   string `json:"seller_ids" form:"seller_ids" binding:"required" description:"CRM系统-销售ID"`
 }
 
-
-type  CheckContractNameResp struct {
-	Exist int 	`json:"exist" description:"是否存在相似的合同:0不存在,1存在"`
-}
+type CheckContractNameResp struct {
+	Exist int `json:"exist" description:"是否存在相似的合同:0不存在,1存在"`
+}

+ 1 - 0
routers/crm.go

@@ -19,4 +19,5 @@ func InitCrm(rg *gin.RouterGroup) {
 	slGroup := rg.Group("company_seller/").Use(middleware.Token())
 	slGroup.GET("list", sl.List)
 	slGroup.GET("group_list", sl.GroupList)
+	slGroup.GET("all_list", sl.AllList)
 }