123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_mobile_admin/models"
- contractReq "hongze/hongze_mobile_admin/models/request/contract"
- contractResp "hongze/hongze_mobile_admin/models/response/contract"
- "hongze/hongze_mobile_admin/models/tables/contract"
- "hongze/hongze_mobile_admin/models/tables/contract_approval"
- "hongze/hongze_mobile_admin/models/tables/contract_relation"
- contractService "hongze/hongze_mobile_admin/services/contract"
- "hongze/hongze_mobile_admin/services/seal"
- "hongze/hongze_mobile_admin/utils"
- "path"
- "strconv"
- "strings"
- )
- // 合同模块
- type ContractCommon struct {
- BaseAuth
- }
- // @Title 上传签回附件
- // @Description 上传签回附件接口
- // @Param request body contract.UploadCheckBackFileReq true "type json string"
- // @Success Ret=200 上传成功
- // @router /upload_check_back_file [post]
- func (c *ContractCommon) UploadCheckBackFile() {
- //var req contractReq.UploadCheckBackFileReq
- //err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
- //if err != nil {
- // c.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
- // return
- //}
- ////合同编号
- //if req.ContractId <= 0 {
- // c.FailWithMessage("请传入合同编号!", "请传入合同编号")
- // return
- //}
- //
- //if req.FileUrl == "" {
- // c.FailWithMessage("请先上传附件!", "请先上传附件")
- // return
- //}
- contractIdStr := c.Ctx.Request.Form.Get("ContractId")
- if contractIdStr == "" {
- c.FailWithMessage("合同ID必传!", "合同ID必传")
- return
- }
- contractId, err := strconv.Atoi(contractIdStr)
- if err != nil {
- c.FailWithMessage("合同ID异常!", "合同ID必传")
- return
- }
- //合同编号
- if contractId <= 0 {
- c.FailWithMessage("请传入合同编号", "请传入合同编号")
- return
- }
- fileMulti, h, err := c.GetFile("file")
- if err != nil {
- c.FailWithMessage("获取资源信息失败", "获取资源信息失败,Err:"+err.Error())
- return
- }
- ext := path.Ext(h.Filename)
- //err = contractService.UploadCheckBackFile(contractId, req.FileUrl, c.AdminWx)
- resourceUrl, err := contractService.UploadCheckBackFileByFile(contractId, ext, fileMulti, c.AdminWx)
- //更新用印中的签回合同
- _, _ = seal.UploadCheckBackFile(contractId, resourceUrl, c.AdminWx)
- c.OkWithMessage("上传成功")
- }
- // Detail
- // @Title 获取合同详情
- // @Description 获取合同详情接口
- // @Param ContractId query int true "合同id"
- // @Success 200 {object} contract.ContractDetailResp
- // @router /detail [get]
- func (c *ContractCommon) Detail() {
- //合同类型、产品类型、合同状态、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- contractId, _ := c.GetInt("ContractId")
- //合同id
- if contractId <= 0 {
- c.FailWithMessage("合同id必传!", "合同id必传!")
- return
- }
- //获取合同详情
- contractInfo, flowNodeListResp, contractOpButton, err := contractService.GetContractDetailByContractId(contractId, c.AdminWx)
- if err != nil {
- c.FailWithMessage("获取合同详情失败!", "获取合同详情失败,ERR:"+err.Error())
- return
- }
- resp := contractResp.ContractDetailResp{
- ContractDetail: contractInfo,
- FlowNodeList: flowNodeListResp,
- OpButton: contractOpButton,
- }
- c.OkDetailed(resp, "获取成功")
- }
- // CompanyList
- // @Title 根据客户名称获取已存在合同系统中客户名称列表
- // @Description 获取合同详情接口
- // @Param CompanyName query string true "客户名称"
- // @Param Keyword query string true "关键字:客户名称、社会信用码"
- // @Param Status query string true "合同状态"
- // @Success 200 {object} []string
- // @router /company_list [get]
- func (c *ContractCommon) CompanyList() {
- sysUser := c.AdminWx
- keyword := c.GetString("Keyword")
- //搜索关键字
- if keyword == "" {
- c.FailWithMessage("搜索关键字必传!", "搜索关键字必传!")
- return
- }
- status := c.GetString("Status")
- companyNameList := make([]string, 0)
- list, err := contract.GetCompanyNameList(c.AdminWx.AdminId, keyword, status)
- if err != nil {
- c.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 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 d.node_id <= a.curr_node_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 {
- c.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
- return
- }
- for _, v := range list2 {
- if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
- companyNameList = append(companyNameList, v.CompanyName)
- }
- }
- c.OkDetailed(companyNameList, "获取成功")
- }
- // List
- // @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 "搜索关键字"
- // @Param KeywordEq query string false "搜索关键字(全等)"
- // @Success 200 {object} contract.ContractListResp
- // @router /list [get]
- func (c *ContractCommon) List() {
- //合同类型、产品类型、合同状态、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- contractType := c.GetString("ContractType")
- status := c.GetString("Status")
- productId, _ := c.GetInt("ProductId")
- modifyStartTime := c.GetString("ModifyStartTime")
- modifyEndTime := c.GetString("ModifyEndTime")
- sellerIds := c.GetString("SellerId")
- keyword := c.GetString("Keyword")
- keywordEq := c.GetString("KeywordEq")
- condition := ""
- pars := make([]interface{}, 0)
- //如果不是超管或者合规,那么只能查看自己的合同
- condition += ` AND seller_id = ? `
- pars = append(pars, c.AdminWx.AdminId)
- //合同类型、、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- if contractType != "" {
- condition += ` AND contract_type = ? `
- pars = append(pars, contractType)
- }
- //合同状态
- if status != "" {
- condition += ` AND status = ? `
- pars = append(pars, status)
- }
- //产品类型
- 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 + `%' ) `
- }
- //关键字(全等)
- if keywordEq != "" {
- condition += ` AND c.company_name =? `
- pars = append(pars, keywordEq)
- }
- pageSize, _ := c.GetInt("PageSize")
- currentIndex, _ := c.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 {
- c.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
- return
- }
- list, err := contract.GetContractList(condition, pars, startSize, pageSize)
- if err != nil {
- c.FailWithMessage("获取合同列表失败", "获取合同列表失败,Err:"+err.Error())
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- c.OkDetailed(contractResp.ContractListResp{
- List: list,
- Paging: page,
- }, "获取成功")
- }
- // 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 (c *ContractCommon) CompanyListBySeal() {
- sysUser := c.AdminWx
- keyword := c.GetString("Keyword")
- //搜索关键字
- if keyword == "" {
- c.FailWithMessage("搜索关键字必传!", "搜索关键字必传!")
- return
- }
- status := c.GetString("Status")
- companyNameList := make([]string, 0)
- sellerId := 0
- if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
- sellerId = c.AdminWx.AdminId
- }
- list, err := contract.GetCompanyNameList(sellerId, keyword, status)
- if err != nil {
- c.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
- return
- }
- for _, v := range list {
- companyNameList = append(companyNameList, v.CompanyName)
- }
- // 13.6正式共享客户的处理
- {
- // 通过关键词获取分配给当前销售的正式共享客户
- kw := fmt.Sprint("%", keyword, "%")
- cond := ` AND share_seller_id = ? AND is_share = 1 AND company_name LIKE ?`
- pars := make([]interface{}, 0)
- pars = append(pars, sysUser.AdminId, kw)
- shares, e := models.GetCompanyListByCondition(cond, pars, []string{"company_id", "company_name"}, "")
- if e != nil {
- c.FailWithMessage("获取失败", "获取共享客户信息失败, Err: "+e.Error())
- return
- }
- for _, v := range shares {
- if !utils.InArrayByStr(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 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 {
- // c.FailWithMessage("获取客户名称列表失败!", "获取客户名称列表失败,ERR:"+err.Error())
- // return
- //}
- //for _, v := range list2 {
- // if !strings.Contains(strings.Join(companyNameList, ","), v.CompanyName) {
- // companyNameList = append(companyNameList, v.CompanyName)
- // }
- //}
- c.OkDetailed(companyNameList, "获取成功")
- }
- // ListBySeal
- // @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 "搜索关键字"
- // @Param KeywordEq query string false "搜索关键字(全等)"
- // @Success 200 {object} contract.ContractListResp
- // @router /listBySeal [get]
- func (c *ContractCommon) ListBySeal() {
- sysUser := c.AdminWx
- //合同类型、产品类型、合同状态、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- contractType := c.GetString("ContractType")
- status := c.GetString("Status")
- productId, _ := c.GetInt("ProductId")
- modifyStartTime := c.GetString("ModifyStartTime")
- modifyEndTime := c.GetString("ModifyEndTime")
- sellerIds := c.GetString("SellerId")
- keyword := c.GetString("Keyword")
- keywordEq := c.GetString("KeywordEq")
- condition := ""
- pars := make([]interface{}, 0)
- //如果不是合规,那么只能查看自己的合同
- if c.AdminWx.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
- condition += ` AND a.seller_id = ? `
- pars = append(pars, c.AdminWx.AdminId)
- }
- //合同类型、、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- if contractType != "" {
- condition += ` AND a.contract_type = ? `
- pars = append(pars, contractType)
- }
- //合同状态
- if status != "" {
- condition += ` AND a.status = ? `
- pars = append(pars, status)
- }
- //产品类型
- if productId > 0 {
- condition += ` AND a.product_id = ? `
- pars = append(pars, productId)
- }
- //所选销售
- if sellerIds != "" {
- condition += ` AND a.seller_id IN (` + sellerIds + `) `
- }
- //更新开始时间
- if modifyStartTime != "" {
- condition += ` AND a.modify_time >= ? `
- pars = append(pars, modifyStartTime)
- }
- //更新结束时间
- if modifyEndTime != "" {
- condition += ` AND a.modify_time <= ? `
- pars = append(pars, modifyEndTime)
- }
- //关键字
- if keyword != "" {
- condition += ` AND (a.contract_code LIKE '%` + keyword + `%' OR a.company_name LIKE '%` + keyword + `%' OR a.credit_code LIKE '%` + keyword + `%' ) `
- }
- //关键字(全等)
- if keywordEq != "" {
- condition += ` AND c.company_name =? `
- pars = append(pars, keywordEq)
- }
- pageSize, _ := c.GetInt("PageSize")
- currentIndex, _ := c.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 {
- // c.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
- // return
- //}
- //
- //list, err := contract.GetContractList(condition, pars, startSize, pageSize)
- //if err != nil {
- // c.FailWithMessage("获取合同列表失败", "获取合同列表失败,Err:"+err.Error())
- // return
- //}
- // 13.6正式共享客户
- joinStr := ` LEFT JOIN company AS b ON a.company_name = b.company_name `
- // 非合规角色可查看自己的合同或是自己的共享客户下的非自己创建的合同
- if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
- condition += ` AND (a.seller_id = ? OR (b.is_share = 1 AND b.share_seller_id = ?))`
- pars = append(pars, sysUser.AdminId, sysUser.AdminId)
- }
- total, err := contract.GetJoinContractListCount(condition, joinStr, pars)
- if err != nil {
- c.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
- return
- }
- list, e := contract.GetJoinContractList(condition, joinStr, pars, startSize, pageSize)
- if e != nil {
- c.FailWithMessage("获取失败", "获取合同列表失败,Err:"+err.Error())
- return
- }
- if len(list) > 0 {
- // 代付合同查询代付用户名称
- contractIdSlice := make([]string, 0)
- for i := 0; i < len(list); i++ {
- if list[i].ContractBusinessType == "代付合同" {
- contractIdSlice = append(contractIdSlice, strconv.Itoa(list[i].ContractId))
- }
- }
- if len(contractIdSlice) > 0 {
- contractIdStr := strings.Join(contractIdSlice, ",")
- contractList, err := contract_relation.GetContractRelationListByPaymentOnBehalfContractIds(contractIdStr)
- if err != nil {
- c.FailWithMessage("获取失败", "获取代付合同对应的合同数据失败,Err:"+err.Error())
- return
- }
- userCompanyNameMap := make(map[int]string, 0)
- for i := 0; i < len(contractList); i++ {
- userCompanyNameMap[contractList[i].PaymentOnBehalfContractId] = contractList[i].CompanyName
- }
- for _, item := range list {
- if item.ContractBusinessType == "代付合同" {
- item.UseCompanyName = userCompanyNameMap[item.ContractId]
- }
- }
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- c.OkDetailed(contractResp.ContractListResp{
- List: list,
- Paging: page,
- }, "获取成功")
- }
- // ListV2
- // @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 "搜索关键字"
- // @Param KeywordEq query string false "搜索关键字(全等)"
- // @Success 200 {object} contract.ContractListRespV2
- // @router /listV2 [get]
- func (c *ContractCommon) ListV2() {
- sysUser := c.AdminWx
- //合同类型、产品类型、合同状态、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- contractType := c.GetString("ContractType")
- status := c.GetString("Status")
- productId, _ := c.GetInt("ProductId")
- modifyStartTime := c.GetString("ModifyStartTime")
- modifyEndTime := c.GetString("ModifyEndTime")
- sellerIds := c.GetString("SellerId")
- keyword := c.GetString("Keyword")
- keywordEq := c.GetString("KeywordEq")
- childCondition := ""
- condition := ""
- unionCondition := ""
- childPars := make([]interface{}, 0)
- pars := make([]interface{}, 0)
- unionPars := make([]interface{}, 0)
- //归属
- 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)
- unionCondition += ` AND c.seller_id = ? `
- unionPars = append(unionPars, sysUser.AdminId)
- //合同类型、、更新时间、所选销售
- //关键字:合同编号、客户名称,社会信用码
- if contractType != "" {
- condition += ` AND c.contract_type = ? `
- pars = append(pars, contractType)
- unionCondition += ` AND c.contract_type = ? `
- unionPars = append(unionPars, contractType)
- }
- //审批状态
- if status != "" {
- if status == "已审批" {
- condition += ` AND c.status in ("已审批","已驳回") `
- unionCondition += ` AND c.status in ("已审批","已驳回") `
- } else {
- condition += ` AND c.status = ? `
- unionCondition += ` AND c.status = ? `
- if status == "处理中" {
- pars = append(pars, "待审批")
- unionPars = append(unionPars, "待审批")
- } else {
- pars = append(pars, status)
- unionPars = append(unionPars, status)
- }
- }
- } else {
- condition += ` AND c.status not in ("已撤回","待提交") `
- unionCondition += ` AND c.status = "待提交" `
- }
- //产品类型
- if productId > 0 {
- condition += ` AND c.product_id = ? `
- pars = append(pars, productId)
- unionCondition += ` AND c.product_id = ? `
- unionPars = append(unionPars, productId)
- }
- //所选销售
- if sellerIds != "" {
- condition += ` AND c.seller_id IN (` + sellerIds + `) `
- unionCondition += ` AND c.seller_id IN (` + sellerIds + `) `
- }
- //更新开始时间
- if modifyStartTime != "" {
- condition += ` AND a.modify_time >= ? `
- pars = append(pars, modifyStartTime)
- unionCondition += ` AND a.modify_time >= ? `
- unionPars = append(unionPars, modifyStartTime)
- }
- //更新结束时间
- if modifyEndTime != "" {
- condition += ` AND a.modify_time <= ? `
- pars = append(pars, modifyEndTime)
- unionCondition += ` AND a.modify_time <= ? `
- unionPars = append(unionPars, modifyEndTime)
- }
- //关键字
- if keyword != "" {
- 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, _ := c.GetInt("PageSize")
- currentIndex, _ := c.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- //joinCondition := " and a.curr_node_id=d.node_id"
- joinCondition := ""
- total, err := contract_approval.GetContractListCountV2(childCondition, condition, joinCondition, unionCondition, childPars, pars, unionPars)
- if err != nil {
- c.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
- return
- }
- list, err := contract_approval.GetContractListV2(childCondition, condition, joinCondition, unionCondition, childPars, pars, unionPars, startSize, pageSize)
- if err != nil {
- c.FailWithMessage("获取合同列表失败", "获取合同列表失败,Err:"+err.Error())
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- c.OkDetailed(contractResp.ContractListRespV2{
- List: list,
- Paging: page,
- }, "获取成功")
- }
- // @Title 作废合同
- // @Description 作废合同接口
- // @Param request body contract.InvalidReq true "type json string"
- // @Success Ret=200 作废成功
- // @router /invalid [post]
- func (c *ContractCommon) Invalid() {
- var req contractReq.InvalidReq
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
- if err != nil {
- c.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
- return
- }
- //合同id
- if req.ContractId <= 0 {
- c.FailWithMessage("合同id必传!", "合同id必传!")
- return
- }
- err = contractService.InvalidContract(req.ContractId, c.AdminWx)
- if err != nil {
- c.FailWithMessage("作废合同失败!", "作废合同失败,Err:"+err.Error())
- return
- }
- c.OkWithMessage("作废成功")
- return
- }
|