소스 검색

fix 用印审批过后的审批时间问题,用印筛选合同问题

Roc 3 년 전
부모
커밋
bc2c114a59
4개의 변경된 파일139개의 추가작업 그리고 29개의 파일을 삭제
  1. 131 25
      controllers/contract.go
  2. 1 0
      controllers/contract_approval.go
  3. 5 2
      models/tables/contract/contract.go
  4. 2 2
      models/tables/contract_approval/contract_approval.go

+ 131 - 25
controllers/contract.go

@@ -9,7 +9,6 @@ import (
 	contractService "hongze/hongze_mobile_admin/services/contract"
 	"hongze/hongze_mobile_admin/utils"
 	"rdluck_tools/paging"
-	"strings"
 )
 
 //合同模块
@@ -91,7 +90,12 @@ func (this *ContractCommon) CompanyList() {
 	}
 	status := this.GetString("Status")
 	companyNameList := make([]string, 0)
-	list, err := contract.GetCompanyNameList(this.AdminWx.AdminId, keyword, status)
+
+	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
@@ -101,37 +105,136 @@ func (this *ContractCommon) CompanyList() {
 		companyNameList = append(companyNameList, v.CompanyName)
 	}
 
-	//审批列表中
-	childCondition := ""
+	//审批列表中(跟自己有关联的)
+	//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, "获取成功")
+}
+
+// @Title 合同列表
+// @Description 合同列表接口
+// @Param   ContractType   query   string  false       "合同类型,枚举值:'新签合同','续约合同','补充协议'"
+// @Param   Status   query   string  false       "合同状态,枚举值:'待提交','待审批','已撤回','已审批','已驳回','已作废'"
+// @Param   ProductId   query   int  false       "客户类型:传0或者不传为当前账号权限,1 代表是:ficc;2 代表是:权益"
+// @Param   ModifyStartTime   query   string  false       "服务更新时间的选择开始时间,格式:2021-05-23 00:00:00"
+// @Param   ModifyEndTime   query   string  false       "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
+// @Param   SellerId   query   string  false       "选择的销售id"
+// @Param   Keyword   query   string  false       "搜索关键字"
+// @Success 200 {object} contract.ContractListResp
+// @router /list [get]
+func (this *ContractCommon) List() {
+	//合同类型、产品类型、合同状态、更新时间、所选销售
+	//关键字:合同编号、客户名称,社会信用码
+	contractType := this.GetString("ContractType")
+	status := this.GetString("Status")
+	productId, _ := this.GetInt("ProductId")
+	modifyStartTime := this.GetString("ModifyStartTime")
+	modifyEndTime := this.GetString("ModifyEndTime")
+	sellerIds := this.GetString("SellerId")
+	keyword := this.GetString("Keyword")
+
 	condition := ""
-	childPars := make([]interface{}, 0)
 	pars := make([]interface{}, 0)
+	//如果不是超管或者合规,那么只能查看自己的合同
+	condition += ` AND seller_id = ? `
+	pars = append(pars, this.AdminWx.AdminId)
+	//合同类型、、更新时间、所选销售
+	//关键字:合同编号、客户名称,社会信用码
+	if contractType != "" {
+		condition += ` AND contract_type = ? `
+		pars = append(pars, contractType)
+	}
+	//合同状态
 	if status != "" {
-		condition += `and c.status=? `
+		condition += ` AND 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 = ?)`
+	//产品类型
+	if productId > 0 {
+		condition += ` AND product_id = ? `
+		pars = append(pars, productId)
+	}
+	//所选销售
+	if sellerIds != "" {
+		condition += ` AND seller_id IN (` + sellerIds + `) `
+	}
+	//更新开始时间
+	if modifyStartTime != "" {
+		condition += ` AND modify_time >= ? `
+		pars = append(pars, modifyStartTime)
+	}
+	//更新结束时间
+	if modifyEndTime != "" {
+		condition += ` AND modify_time <= ? `
+		pars = append(pars, modifyEndTime)
+	}
+	//关键字
+	if keyword != "" {
+		condition += ` AND (contract_code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
 	}
-	condition += `and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%')`
 
-	pars = append(pars, sysUser.AdminId, sysUser.AdminId)
-	list2, err := contract_approval.GetCompanyNameListV2(childCondition, condition, childPars, pars)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	total, err := contract.GetContractListCount(condition, pars)
 	if err != nil {
-		this.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
+		this.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
 		return
 	}
-	for _, v := range list2 {
-		if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
-			companyNameList = append(companyNameList, v.CompanyName)
-		}
+
+	list, err := contract.GetContractList(condition, pars, startSize, pageSize)
+	if err != nil {
+		this.FailWithMessage("获取合同列表失败", "获取合同列表失败,Err:"+err.Error())
+		return
 	}
-	this.OkDetailed(companyNameList, "获取成功")
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+
+	this.OkDetailed(contractResp.ContractListResp{
+		List:   list,
+		Paging: page,
+	}, "获取成功")
 }
 
+// ListBySeal
 // @Title 合同列表
 // @Description 合同列表接口
 // @Param   ContractType   query   string  false       "合同类型,枚举值:'新签合同','续约合同','补充协议'"
@@ -142,10 +245,11 @@ func (this *ContractCommon) CompanyList() {
 // @Param   SellerId   query   string  false       "选择的销售id"
 // @Param   Keyword   query   string  false       "搜索关键字"
 // @Success 200 {object} contract.ContractListResp
-// @router /list [get]
-func (this *ContractCommon) List() {
+// @router /listBySeal [get]
+func (this *ContractCommon) ListBySeal() {
 	//合同类型、产品类型、合同状态、更新时间、所选销售
 	//关键字:合同编号、客户名称,社会信用码
+
 	contractType := this.GetString("ContractType")
 	status := this.GetString("Status")
 	productId, _ := this.GetInt("ProductId")
@@ -156,9 +260,11 @@ func (this *ContractCommon) List() {
 
 	condition := ""
 	pars := make([]interface{}, 0)
-	//如果不是超管或者合规,那么只能查看自己的合同
-	condition += ` AND seller_id = ? `
-	pars = append(pars, this.AdminWx.AdminId)
+	//如果不是合规,那么只能查看自己的合同
+	if this.AdminWx.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
+		condition += ` AND seller_id = ? `
+		pars = append(pars, this.AdminWx.AdminId)
+	}
 	//合同类型、、更新时间、所选销售
 	//关键字:合同编号、客户名称,社会信用码
 	if contractType != "" {

+ 1 - 0
controllers/contract_approval.go

@@ -18,6 +18,7 @@ type ContractApprovalCommon struct {
 	BaseAuth
 }
 
+// List
 // @Title 审批单列表
 // @Description 审批单列表接口
 // @Param   ContractType   query   string  false       "合同类型,枚举值:'新签合同','续约合同','补充协议'"

+ 5 - 2
models/tables/contract/contract.go

@@ -405,11 +405,14 @@ type CompanyNameList struct {
 //获取客户名称列表数据
 func GetCompanyNameList(sellerId int, keyword, status string) (list []*CompanyNameList, err error) {
 	o := orm.NewOrm()
-	sql := `select * from contract where is_delete=0 and seller_id=? and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%') `
+	sql := `select * from contract where is_delete=0 and (company_name like '%` + keyword + `%' or credit_code like '%` + keyword + `%') `
 	if status != "" {
 		sql += ` AND status='` + status + `' `
 	}
+	if sellerId > 0 {
+		sql += ` and seller_id=? `
+	}
 	sql += ` group by company_name order by modify_time desc `
-	_, err = o.Raw(sql, sellerId).QueryRows(&list)
+	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }

+ 2 - 2
models/tables/contract_approval/contract_approval.go

@@ -529,7 +529,7 @@ func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, con
 		switch contractApprovalInfo.ApprovalType {
 		case "contract":
 			//修改合同状态为已审批
-			sql := `UPDATE contract SET status="已审批",approval_remark=?,modify_time=NOW() WHERE contract_id = ?`
+			sql := `UPDATE contract SET status="已审批",approval_remark=?,approve_time=NOW(),modify_time=NOW() WHERE contract_id = ?`
 			_, tmpErr = o.Raw(sql, remark, contractApprovalInfo.ContractId).Exec()
 			if tmpErr != nil {
 				err = tmpErr
@@ -537,7 +537,7 @@ func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, con
 			}
 		case "seal":
 			//修改用印状态为已审批
-			sql := `UPDATE seal SET status="已审批",approval_remark=?,modify_time=NOW() WHERE seal_id = ?`
+			sql := `UPDATE seal SET status="已审批",approval_remark=?,approve_time=NOW(),modify_time=NOW() WHERE seal_id = ?`
 			_, tmpErr = o.Raw(sql, remark, contractApprovalInfo.ContractId).Exec()
 			if tmpErr != nil {
 				err = tmpErr