Browse Source

fix 模糊匹配后的客户名称,再去搜索列表改成全等搜索

Roc 3 năm trước cách đây
mục cha
commit
47780c3410

+ 7 - 0
controllers/approval.go

@@ -26,6 +26,7 @@ type ApprovalCommon struct {
 	BaseAuth
 }
 
+// List
 // @Title 获取审批列表接口
 // @Description 获取审批列表接口
 // @Param   PageSize   query   int  true       "每页数据条数"
@@ -33,6 +34,7 @@ type ApprovalCommon struct {
 // @Param   Status   query   string  true       "状态:'待审批','已审批','驳回','已撤回'"
 // @Param   KeyWord   query   string  true       "搜索关键词"
 // @Param   Keyword   query   string  true       "搜索关键词"
+// @Param   KeywordEq   query   string  true       "搜索关键词(全等)"
 // @Success 200 {object} approval.CompanyApprovalListResp
 // @router /list [get]
 func (this *ApprovalCommon) List() {
@@ -43,6 +45,7 @@ func (this *ApprovalCommon) List() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	status := this.GetString("Status")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 	keyWord := this.GetString("KeyWord")
 	if keyword == "" {
 		keyword = keyWord
@@ -82,6 +85,10 @@ func (this *ApprovalCommon) List() {
 	if keyword != "" {
 		condition += ` AND (a.company_name LIKE '%` + keyword + `%' OR a.credit_code LIKE '%` + keyword + `%') `
 	}
+	if keywordEq != "" {
+		condition += ` AND a.company_name = ? `
+		pars = append(pars, keywordEq)
+	}
 
 	total, err := company_approval.GetApprovalCount(condition, pars)
 	if err != nil {

+ 125 - 36
controllers/contract.go

@@ -9,6 +9,7 @@ import (
 	contractService "hongze/hongze_mobile_admin/services/contract"
 	"hongze/hongze_mobile_admin/utils"
 	"rdluck_tools/paging"
+	"strings"
 )
 
 //合同模块
@@ -82,6 +83,7 @@ func (this *ContractCommon) Detail() {
 // @router /company_list [get]
 func (this *ContractCommon) CompanyList() {
 	sysUser := this.AdminWx
+
 	keyword := this.GetString("Keyword")
 	//搜索关键字
 	if keyword == "" {
@@ -91,11 +93,7 @@ func (this *ContractCommon) CompanyList() {
 	status := this.GetString("Status")
 	companyNameList := make([]string, 0)
 
-	sellerId := 0
-	if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
-		sellerId = this.AdminWx.AdminId
-	}
-	list, err := contract.GetCompanyNameList(sellerId, keyword, status)
+	list, err := contract.GetCompanyNameList(this.AdminWx.AdminId, keyword, status)
 	if err != nil {
 		this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
 		return
@@ -106,40 +104,39 @@ func (this *ContractCommon) CompanyList() {
 	}
 
 	//审批列表中(跟自己有关联的)
-	//childCondition := ""
-	//condition := ""
-	//childPars := make([]interface{}, 0)
-	//pars := make([]interface{}, 0)
-	//if status != "" {
-	//	condition += `and c.status=? `
-	//	pars = append(pars, status)
-	//}
-	////归属
-	////如果不是合规,那么只能查看跟自己有关联的
-	//if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
-	//	if status == "待审批" {
-	//		condition += ` AND ((c.seller_id = ? and a.start_node_id = a.curr_node_id) OR (d.approve_user_id = ? )) and d.status="待审批" `
-	//	} else {
-	//		condition += ` AND (c.seller_id = ? or d.approve_user_id = ?)`
-	//	}
-	//	pars = append(pars, sysUser.AdminId, sysUser.AdminId)
-	//}
-	//
-	//condition += `and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%')`
-	//
-	//list2, err := contract_approval.GetCompanyNameListV2(childCondition, condition, childPars, pars)
-	//if err != nil {
-	//	this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
-	//	return
-	//}
-	//for _, v := range list2 {
-	//	if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
-	//		companyNameList = append(companyNameList, v.CompanyName)
-	//	}
-	//}
+	childCondition := ""
+	condition := ""
+	childPars := make([]interface{}, 0)
+	pars := make([]interface{}, 0)
+	if status != "" {
+		condition += `and c.status=? `
+		pars = append(pars, status)
+	}
+	//归属
+	//如果不是合规,那么只能查看跟自己有关联的
+	if status == "待审批" {
+		condition += ` AND ((c.seller_id = ? and a.start_node_id = a.curr_node_id) OR (d.approve_user_id = ? )) and d.status="待审批" `
+	} else {
+		condition += ` AND (c.seller_id = ? or (d.approve_user_id = ? and c.status != "已撤回") )`
+	}
+	pars = append(pars, sysUser.AdminId, sysUser.AdminId)
+
+	condition += `and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%')`
+
+	list2, err := contract_approval.GetCompanyNameListV2(childCondition, condition, childPars, pars)
+	if err != nil {
+		this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
+		return
+	}
+	for _, v := range list2 {
+		if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
+			companyNameList = append(companyNameList, v.CompanyName)
+		}
+	}
 	this.OkDetailed(companyNameList, "获取成功")
 }
 
+// List
 // @Title 合同列表
 // @Description 合同列表接口
 // @Param   ContractType   query   string  false       "合同类型,枚举值:'新签合同','续约合同','补充协议'"
@@ -149,6 +146,7 @@ func (this *ContractCommon) CompanyList() {
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Param   SellerId   query   string  false       "选择的销售id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全等)"
 // @Success 200 {object} contract.ContractListResp
 // @router /list [get]
 func (this *ContractCommon) List() {
@@ -161,6 +159,7 @@ func (this *ContractCommon) List() {
 	modifyEndTime := this.GetString("ModifyEndTime")
 	sellerIds := this.GetString("SellerId")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 
 	condition := ""
 	pars := make([]interface{}, 0)
@@ -201,6 +200,11 @@ func (this *ContractCommon) List() {
 	if keyword != "" {
 		condition += ` AND (contract_code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
 	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND c.company_name =? `
+		pars = append(pars, keywordEq)
+	}
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -234,6 +238,74 @@ func (this *ContractCommon) List() {
 	}, "获取成功")
 }
 
+// CompanyListBySeal
+// @Title 根据客户名称获取已存在合同系统中客户名称列表
+// @Description 获取合同详情接口
+// @Param   CompanyName   query   string  true       "客户名称"
+// @Param   Keyword   query   string  true       "关键字:客户名称、社会信用码"
+// @Param   Status   query   string  true       "合同状态"
+// @Success 200 {object} []string
+// @router /companyListBySeal [get]
+func (this *ContractCommon) CompanyListBySeal() {
+	sysUser := this.AdminWx
+	keyword := this.GetString("Keyword")
+	//搜索关键字
+	if keyword == "" {
+		this.FailWithMessage("搜索关键字必传!", "搜索关键字必传!")
+		return
+	}
+	status := this.GetString("Status")
+	companyNameList := make([]string, 0)
+
+	sellerId := 0
+	if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
+		sellerId = this.AdminWx.AdminId
+	}
+	list, err := contract.GetCompanyNameList(sellerId, keyword, status)
+	if err != nil {
+		this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
+		return
+	}
+
+	for _, v := range list {
+		companyNameList = append(companyNameList, v.CompanyName)
+	}
+
+	//审批列表中(跟自己有关联的)
+	//childCondition := ""
+	//condition := ""
+	//childPars := make([]interface{}, 0)
+	//pars := make([]interface{}, 0)
+	//if status != "" {
+	//	condition += `and c.status=? `
+	//	pars = append(pars, status)
+	//}
+	////归属
+	////如果不是合规,那么只能查看跟自己有关联的
+	//if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
+	//	if status == "待审批" {
+	//		condition += ` AND ((c.seller_id = ? and a.start_node_id = a.curr_node_id) OR (d.approve_user_id = ? )) and d.status="待审批" `
+	//	} else {
+	//		condition += ` AND (c.seller_id = ? or d.approve_user_id = ?)`
+	//	}
+	//	pars = append(pars, sysUser.AdminId, sysUser.AdminId)
+	//}
+	//
+	//condition += `and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%')`
+	//
+	//list2, err := contract_approval.GetCompanyNameListV2(childCondition, condition, childPars, pars)
+	//if err != nil {
+	//	this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
+	//	return
+	//}
+	//for _, v := range list2 {
+	//	if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
+	//		companyNameList = append(companyNameList, v.CompanyName)
+	//	}
+	//}
+	this.OkDetailed(companyNameList, "获取成功")
+}
+
 // ListBySeal
 // @Title 合同列表
 // @Description 合同列表接口
@@ -244,6 +316,7 @@ func (this *ContractCommon) List() {
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Param   SellerId   query   string  false       "选择的销售id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全等)"
 // @Success 200 {object} contract.ContractListResp
 // @router /listBySeal [get]
 func (this *ContractCommon) ListBySeal() {
@@ -257,6 +330,7 @@ func (this *ContractCommon) ListBySeal() {
 	modifyEndTime := this.GetString("ModifyEndTime")
 	sellerIds := this.GetString("SellerId")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 
 	condition := ""
 	pars := make([]interface{}, 0)
@@ -299,6 +373,11 @@ func (this *ContractCommon) ListBySeal() {
 	if keyword != "" {
 		condition += ` AND (contract_code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
 	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND c.company_name =? `
+		pars = append(pars, keywordEq)
+	}
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -332,6 +411,7 @@ func (this *ContractCommon) ListBySeal() {
 	}, "获取成功")
 }
 
+// ListV2
 // @Title 合同列表(包含待提交的)
 // @Description 合同列表接口(包含待提交的)
 // @Param   ContractType   query   string  false       "合同类型,枚举值:'新签合同','续约合同','补充协议'"
@@ -341,6 +421,7 @@ func (this *ContractCommon) ListBySeal() {
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Param   SellerId   query   string  false       "选择的销售id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全等)"
 // @Success 200 {object} contract.ContractListRespV2
 // @router /listV2 [get]
 func (this *ContractCommon) ListV2() {
@@ -355,6 +436,7 @@ func (this *ContractCommon) ListV2() {
 	modifyEndTime := this.GetString("ModifyEndTime")
 	sellerIds := this.GetString("SellerId")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 
 	childCondition := ""
 	condition := ""
@@ -438,6 +520,13 @@ func (this *ContractCommon) ListV2() {
 		condition += ` AND (c.contract_code LIKE '%` + keyword + `%' OR c.company_name LIKE '%` + keyword + `%' OR c.credit_code LIKE '%` + keyword + `%' ) `
 		unionCondition += ` AND (c.contract_code LIKE '%` + keyword + `%' OR c.company_name LIKE '%` + keyword + `%' OR c.credit_code LIKE '%` + keyword + `%' ) `
 	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND c.company_name =? `
+		pars = append(pars, keywordEq)
+		unionCondition += ` AND c.company_name =? `
+		unionPars = append(unionPars, keywordEq)
+	}
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")

+ 7 - 0
controllers/contract_approval.go

@@ -26,6 +26,7 @@ type ContractApprovalCommon struct {
 // @Param   ProductId   query   int  false       "客户类型:传0或者不传为当前账号权限,1 代表是:ficc;2 代表是:权益"
 // @Param   SellerId   query   string  false       "选择的销售id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全等)"
 // @Param   ModifyStartTime   query   string  false       "服务更新时间的选择开始时间,格式:2021-05-23 00:00:00"
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Success 200 {object} contract.ContractApprovalListResp
@@ -40,6 +41,7 @@ func (this *ContractApprovalCommon) List() {
 	productId, _ := this.GetInt("ProductId")
 	sellerIds := this.GetString("SellerId")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 	modifyStartTime := this.GetString("ModifyStartTime")
 	modifyEndTime := this.GetString("ModifyEndTime")
 
@@ -122,6 +124,11 @@ func (this *ContractApprovalCommon) List() {
 	if keyword != "" {
 		condition += ` AND (c.contract_code LIKE '%` + keyword + `%' OR c.company_name LIKE '%` + keyword + `%' OR c.credit_code LIKE '%` + keyword + `%' ) `
 	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND c.company_name =? `
+		pars = append(pars, keywordEq)
+	}
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")

+ 9 - 2
controllers/seal.go

@@ -152,7 +152,7 @@ func (c *SealCommon) CheckEdit() {
 	}, "修改合同成功")
 }
 
-//List
+// List
 // @Title 用印列表
 // @Description 用印列表接口
 // @Param   Status   query   string  false       "合同状态,枚举值:'待提交','待审批','已撤回','已审批','已驳回','已作废'"
@@ -161,6 +161,7 @@ func (c *SealCommon) CheckEdit() {
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Param   AdminId   query   string  false       "选择的用户id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全匹配搜索)"
 // @Success 200 {object} contract.ContractListResp
 // @router /list [get]
 func (c *SealCommon) List() {
@@ -172,6 +173,7 @@ func (c *SealCommon) List() {
 	modifyEndTime := c.GetString("ModifyEndTime")
 	adminIds := c.GetString("AdminId")
 	keyword := c.GetString("Keyword")
+	keywordEq := c.GetString("KeywordEq")
 
 	condition := ""
 	pars := make([]interface{}, 0)
@@ -208,7 +210,12 @@ func (c *SealCommon) List() {
 	}
 	//关键字
 	if keyword != "" {
-		condition += ` AND (contract_code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
+		condition += ` AND (code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
+	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND (c.use_company_name =? OR c.company_name =?) `
+		pars = append(pars, keywordEq, keywordEq)
 	}
 
 	pageSize, _ := c.GetInt("PageSize")

+ 8 - 0
controllers/seal_approval.go

@@ -19,6 +19,7 @@ type SealApprovalCommon struct {
 	BaseAuth
 }
 
+// List
 // @Title 审批单列表
 // @Description 审批单列表接口
 // @Param   Use   query   string  false       "用途,枚举值:销售合同, 渠道合同, 付款通知函, 招投标, 战略合作协议"
@@ -27,6 +28,7 @@ type SealApprovalCommon struct {
 // @Param   Status   query   string  false       "合同状态,枚举值:'待审批','已审批','已驳回','已撤回'"
 // @Param   UserId   query   string  false       "选择的申请人id"
 // @Param   Keyword   query   string  false       "搜索关键字"
+// @Param   KeywordEq   query   string  false       "搜索关键字(全等)"
 // @Param   ModifyStartTime   query   string  false       "服务更新时间的选择开始时间,格式:2021-05-23 00:00:00"
 // @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
 // @Success 200 {object} seal.SealApprovalListResp
@@ -43,6 +45,7 @@ func (this *SealApprovalCommon) List() {
 	productId, _ := this.GetInt("ProductId")
 	sellerIds := this.GetString("SellerId")
 	keyword := this.GetString("Keyword")
+	keywordEq := this.GetString("KeywordEq")
 	modifyStartTime := this.GetString("ModifyStartTime")
 	modifyEndTime := this.GetString("ModifyEndTime")
 
@@ -140,6 +143,11 @@ func (this *SealApprovalCommon) List() {
 	if keyword != "" {
 		condition += ` AND (c.code LIKE '%` + keyword + `%' OR c.use_company_name LIKE '%` + keyword + `%' OR c.company_name LIKE '%` + keyword + `%' OR c.credit_code LIKE '%` + keyword + `%' ) `
 	}
+	//关键字(全等)
+	if keywordEq != "" {
+		condition += ` AND (c.use_company_name =? OR c.company_name =?) `
+		pars = append(pars, keywordEq, keywordEq)
+	}
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")