Browse Source

Merge branch 'pool_369' into debug

# Conflicts:
#	models/fms/contract_register.go
ziwen 2 năm trước cách đây
mục cha
commit
8ba576ce5d

+ 28 - 1
controller/contract/register.go

@@ -2972,13 +2972,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
+}

+ 2 - 1
models/fms/contract_register.go

@@ -491,7 +491,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
@@ -549,6 +549,7 @@ 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 {

+ 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)
 }