Browse Source

Merge branch 'small_291'

xiziwen 2 days ago
parent
commit
d531c42f41

+ 3 - 3
controllers/contract.go

@@ -307,9 +307,9 @@ func (c *ContractCommon) CompanyListBySeal() {
 	{
 		// 通过关键词获取分配给当前销售的正式共享客户
 		kw := fmt.Sprint("%", keyword, "%")
-		cond := ` AND share_seller_id = ? AND is_share = 1 AND company_name LIKE ?`
+		cond := ` AND company_name LIKE ?`
 		pars := make([]interface{}, 0)
-		pars = append(pars, sysUser.AdminId, kw)
+		pars = append(pars, kw)
 		shares, e := models.GetCompanyListByCondition(cond, pars, []string{"company_id", "company_name"}, "")
 		if e != nil {
 			c.FailWithMessage("获取失败", "获取共享客户信息失败, Err: "+e.Error())
@@ -459,7 +459,7 @@ func (c *ContractCommon) ListBySeal() {
 	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 = ?))`
+		condition += ` AND a.seller_id = ? `
 		pars = append(pars, sysUser.AdminId, sysUser.AdminId)
 	}
 

+ 16 - 1
controllers/message.go

@@ -10,6 +10,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval_record"
+	"hongze/hongze_mobile_admin/models/tables/seal"
 	"hongze/hongze_mobile_admin/models/tables/yb_community_question"
 	"hongze/hongze_mobile_admin/models/tables/yb_community_question_comment"
 	"hongze/hongze_mobile_admin/services"
@@ -275,7 +276,7 @@ func (c *MessageCommon) MessageList() {
 		}
 	}
 
-	for _, messageInfo := range list {
+	for i, messageInfo := range list {
 		approvalInfo := company_approval_message.ApprovalInfo{}
 		if messageInfo.SourceType == 1 {
 			if companyApproval, ok := companyApprovalMap[messageInfo.CompanyApprovalId]; ok {
@@ -308,6 +309,20 @@ func (c *MessageCommon) MessageList() {
 				}
 				messageInfo.BusinessTripInfo = bt
 			}
+		} else if messageInfo.SourceType == 3 {
+			if newApproval, ok := newApprovalMap[messageInfo.CompanyApprovalId]; ok {
+				approvalInfo.Type = newApproval.ApplyContent
+				approvalInfo.ApplyName = newApproval.ApplyUserName
+				approvalInfo.ApplyTime = newApproval.CreateTime
+				approvalInfo.ApprovalTime = newApproval.ModifyTime
+
+				var sealItem *seal.Seal
+				err = json.Unmarshal([]byte(newApproval.ContractDetail), &sealItem)
+				if err != nil {
+					return
+				}
+				list[i].AffiliatedCompany = sealItem.AffiliatedCompany
+			}
 		} else {
 			if newApproval, ok := newApprovalMap[messageInfo.CompanyApprovalId]; ok {
 				approvalInfo.Type = newApproval.ApplyContent

+ 32 - 2
controllers/seal.go

@@ -12,6 +12,7 @@ import (
 	"hongze/hongze_mobile_admin/utils"
 	"path"
 	"strconv"
+	"strings"
 )
 
 //SealCommon
@@ -59,8 +60,11 @@ func (c *SealCommon) Add() {
 		c.FailWithMessage("合同附件不能为空", "合同附件不能为空")
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		c.FailWithMessage("归属公司不能为空", "归属公司不能为空")
+	}
 
-	sealInfo, err := sealService.AddSeal(c.AdminWx.AdminId, req.ContractId, req.FileNum, c.AdminWx.RealName, req.Use, req.UseCompanyName, req.CompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls)
+	sealInfo, err := sealService.AddSeal(c.AdminWx.AdminId, req.ContractId, req.FileNum, c.AdminWx.RealName, req.Use, req.UseCompanyName, req.CompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, req.AffiliatedCompany)
 	if err != nil {
 		c.FailWithMessage("用印添加失败", err.Error())
 		return
@@ -119,8 +123,11 @@ func (c *SealCommon) Edit() {
 		c.FailWithMessage("合同附件不能为空", "合同附件不能为空")
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		c.FailWithMessage("归属公司不能为空", "归属公司不能为空")
+	}
 
-	sealInfo, err := sealService.Edit(req.SealId, c.AdminWx.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, c.AdminWx.RealName)
+	sealInfo, err := sealService.Edit(req.SealId, c.AdminWx.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, c.AdminWx.RealName, req.AffiliatedCompany)
 	if err != nil {
 		c.FailWithMessage("修改合同失败!", "修改合同失败,Err:"+err.Error())
 		return
@@ -204,6 +211,7 @@ func (c *SealCommon) List() {
 	adminIds := c.GetString("AdminId")
 	keyword := c.GetString("Keyword")
 	keywordEq := c.GetString("KeywordEq")
+	affiliatedCompany := c.GetString("AffiliatedCompany")
 
 	condition := ""
 	pars := make([]interface{}, 0)
@@ -247,6 +255,11 @@ func (c *SealCommon) List() {
 		condition += ` AND (c.use_company_name =? OR c.company_name =?) `
 		pars = append(pars, keywordEq, keywordEq)
 	}
+	// 归属公司
+	if affiliatedCompany != "" {
+		condition += ` AND affiliated_company =? `
+		pars = append(pars, affiliatedCompany)
+	}
 
 	pageSize, _ := c.GetInt("PageSize")
 	currentIndex, _ := c.GetInt("CurrentIndex")
@@ -473,5 +486,22 @@ func (c *SealCommon) CompanyNameList() {
 		return
 	}
 
+	c.OkDetailed(list, "获取成功")
+}
+
+// 关联公司列表
+// @Title 关联公司列表
+// @Description 关联公司列表
+// @Success 200 {object} response.SealApprovalListResp
+// @router /getAffiliatedCompany [get]
+func (c *SealCommon) AffiliatedCompanyList() {
+
+	crmConfig, err := company.GetConfigDetailByCode("affiliated_company")
+	if err != nil {
+		c.FailWithMessage( "获取配置失败!", "获取配置失败,Err:"+err.Error())
+		return
+	}
+	list := strings.Split(crmConfig.ConfigValue, ",")
+
 	c.OkDetailed(list, "获取成功")
 }

+ 6 - 0
controllers/seal_approval.go

@@ -48,6 +48,7 @@ func (c *SealApprovalCommon) List() {
 	keywordEq := c.GetString("KeywordEq")
 	modifyStartTime := c.GetString("ModifyStartTime")
 	modifyEndTime := c.GetString("ModifyEndTime")
+	affiliatedCompany := c.GetString("AffiliatedCompany")
 
 	childCondition := ""
 	condition := ""
@@ -153,6 +154,11 @@ func (c *SealApprovalCommon) List() {
 		condition += ` AND (c.use_company_name =? OR c.company_name =?) `
 		pars = append(pars, keywordEq, keywordEq)
 	}
+	// 归属公司
+	if affiliatedCompany != "" {
+		condition += ` AND c.affiliated_company =? `
+		pars = append(pars, affiliatedCompany)
+	}
 
 	pageSize, _ := c.GetInt("PageSize")
 	currentIndex, _ := c.GetInt("CurrentIndex")

+ 26 - 24
models/request/seal/sale.go

@@ -1,35 +1,37 @@
 package seal
 
-//新增用印请求
+// 新增用印请求
 type AddReq struct {
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"多个文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"多个文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
-//编辑用印请求
+// 编辑用印请求
 type EditReq struct {
-	SealId         int      `description:"用印id"`
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	SealId            int      `description:"用印id"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
-//审批者编辑用印请求
+// 审批者编辑用印请求
 type CheckEditReq struct {
 	SealId   int      `description:"用印单id"`
 	Use      string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`

+ 82 - 0
models/tables/company/company_config.go

@@ -0,0 +1,82 @@
+package company
+
+import (
+	"encoding/json"
+	"errors"
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mobile_admin/utils"
+)
+
+const (
+	ConfAreaCodeListKey = "area_code_list" // 手机号区号列表
+)
+
+type CrmConfig struct {
+	ConfigCode  string `description:"详情Code"`
+	ConfigValue string `description:"详情"`
+}
+
+func GetConfigValueByCode(configCode string) (total int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT config_value FROM crm_config WHERE config_code=? `
+	err = o.Raw(sql, configCode).QueryRow(&total)
+	return
+}
+
+// 修改
+func CrmConfigUpdate(newValue, configCode string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE crm_config SET  config_value=?   WHERE config_code=  ?`
+	_, err = o.Raw(sql, newValue, configCode).Exec()
+	return
+}
+
+// ConfigClassifyId
+// @Description: 后台配置的报告id
+type ConfigClassifyId struct {
+	Debug   int `json:"debug"`
+	Release int `json:"release"`
+}
+
+func GetConfigDetailByCode(configCode string) (item CrmConfig, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM crm_config WHERE config_code=? `
+	err = o.Raw(sql, configCode).QueryRow(&item)
+	return
+}
+
+// GetReportClassifyIdByConfigKey
+// @Description: 获取关联的报告id
+// @author: Roc
+// @datetime 2024-06-18 14:10:27
+// @param configKey string
+// @return classifyId int
+// @return err error
+func GetReportClassifyIdByConfigKey(configKey string) (classifyId int, err error) {
+	// 别问为啥要从配置里拿=_=!
+	conf, e := GetConfigDetailByCode(configKey)
+	if e != nil {
+		err = errors.New("获取配置的id失败, Err: " + e.Error())
+		return
+	}
+	if conf.ConfigValue == "" {
+		err = errors.New("ID配置有误")
+		return
+	}
+	type TwoWeekIdConf struct {
+		Debug   []int
+		Release []int
+	}
+	classifyIdConf := new(ConfigClassifyId)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &classifyIdConf); e != nil {
+		err = errors.New("解析ID配置失败, Err: " + e.Error())
+		return
+	}
+	if utils.RunMode == "debug" {
+		classifyId = classifyIdConf.Debug
+	} else {
+		classifyId = classifyIdConf.Release
+	}
+
+	return
+}

+ 1 - 0
models/tables/company_approval_message/company_approval_message.go

@@ -59,6 +59,7 @@ type CompanyApprovalMessageList struct {
 	MessageInfo       string                           `description:"消息主要内容,json数据" json:"-"`
 	ApprovalInfo      ApprovalInfo                     `description:"审批单信息"`
 	BusinessTripInfo  *business_trip.BusinessApplyView `description:"出差申请信息"`
+	AffiliatedCompany string                           `description:"归属公司-用印审批用"`
 }
 
 // 消息审批单信息

+ 1 - 2
models/tables/company_product/company_product.go

@@ -111,8 +111,7 @@ type CompanyProductItem struct {
 // @return err error
 func GetCompanyProductItemByCompanyId(companyId int, productId int) (items *CompanyProductItem, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT a.*,b.is_share,b.share_seller,b.share_seller_id FROM company_product as a 
-         JOIN company b on a.company_id=b.company_id
+	sql := `SELECT a.* FROM company_product as a
          WHERE a.company_id = ? AND a.product_id = ? `
 	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
 

+ 39 - 23
models/tables/contract_approval/contract_approval.go

@@ -8,7 +8,7 @@ import (
 	"time"
 )
 
-//合同审批单
+// 合同审批单
 type ContractApproval struct {
 	ContractApprovalId int       `orm:"column(contract_approval_id);pk"`
 	ApprovalType       string    `description:"审批单类型,枚举值,合同:contract;用印:seal;默认:contract"`
@@ -27,7 +27,7 @@ type ContractApproval struct {
 	CreateTime         time.Time `description:"最近一次审批单修改时间"`
 }
 
-//根据合同审批单id获取合同审批单信息
+// 根据合同审批单id获取合同审批单信息
 func GetContractApprovalById(contractApprovalId int) (contractApprovalInfo *ContractApproval, err error) {
 	o := orm.NewOrm()
 	sql := `select * from contract_approval where contract_approval_id = ? `
@@ -35,7 +35,7 @@ func GetContractApprovalById(contractApprovalId int) (contractApprovalInfo *Cont
 	return
 }
 
-//根据合同id获取最近一次待审批的合同审批单信息
+// 根据合同id获取最近一次待审批的合同审批单信息
 func GetLastPendingContractApprovalByContractId(contractId int) (contractApprovalInfo *ContractApproval, err error) {
 	o := orm.NewOrm()
 	sql := `select * from contract_approval where status = "待审批" AND contract_id=? order by contract_approval_id desc`
@@ -43,7 +43,7 @@ func GetLastPendingContractApprovalByContractId(contractId int) (contractApprova
 	return
 }
 
-//根据合同id获取最近一次提交的合同审批单信息
+// 根据合同id获取最近一次提交的合同审批单信息
 func GetLastContractApprovalByContractId(contractId int, approvalType string) (contractApprovalInfo *ContractApproval, err error) {
 	o := orm.NewOrm()
 	sql := `select * from contract_approval where contract_id=? and approval_type =? order by contract_approval_id desc`
@@ -51,7 +51,7 @@ func GetLastContractApprovalByContractId(contractId int, approvalType string) (c
 	return
 }
 
-//根据合同id获取总共被驳回的次数
+// 根据合同id获取总共被驳回的次数
 func GetRejectContractCountByContractId(contractId int) (total int64, err error) {
 	o := orm.NewOrm()
 	sql := `select count(1) total from contract_approval where status = "已驳回" AND contract_id=? `
@@ -59,7 +59,7 @@ func GetRejectContractCountByContractId(contractId int) (total int64, err error)
 	return
 }
 
-//获取合同审批列表数据数量
+// 获取合同审批列表数据数量
 func GetContractApprovalListCount(childCondition, condition, joinCondition string, childPars, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `
@@ -81,7 +81,7 @@ WHERE c.is_delete = 0  AND a.approval_type="contract" `
 	return
 }
 
-//合同审批列表
+// 合同审批列表
 type ContractApprovalList struct {
 	ContractApprovalId       int                     `description:"审批单id"`
 	ContractId               int                     `description:"合同id"`
@@ -182,7 +182,7 @@ WHERE c.is_delete = 0  AND a.approval_type="contract" `
 	return
 }
 
-//获取客户名称
+// 获取客户名称
 func GetCompanyNameListV2(childCondition, condition string, childPars, pars []interface{}) (list []*contract.CompanyNameList, err error) {
 	o := orm.NewOrm()
 	sql := `
@@ -261,7 +261,7 @@ type CompanyNameList struct {
 	CompanyName string `description:"客户名称,甲方名称,长度32位"`
 }
 
-//根据合同id获取合同审批单信息
+// 根据合同id获取合同审批单信息
 func (ContractApproval) CheckPendingByContractId(contractId int, approvalType string) (has bool, err error) {
 	o := orm.NewOrm()
 	var contractApprovalInfo ContractApproval
@@ -281,7 +281,7 @@ func (ContractApproval) CheckPendingByContractId(contractId int, approvalType st
 	return
 }
 
-//发起审批(工作流)
+// 发起审批(工作流)
 func (ContractApproval) Apply(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord) (err error) {
 	o := orm.NewOrm()
 	tx, err := o.Begin()
@@ -328,7 +328,7 @@ func (ContractApproval) Apply(contractApprovalInfo *ContractApproval, contractAp
 	return
 }
 
-//撤回审核单
+// 撤回审核单
 func (ContractApproval) Cancel(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord) (err error) {
 	o := orm.NewOrm()
 	tx, err := o.Begin()
@@ -374,7 +374,7 @@ func (ContractApproval) Cancel(contractApprovalInfo *ContractApproval, contractA
 	return
 }
 
-//审核驳回
+// 审核驳回
 func (ContractApproval) Reject(contractApprovalInfo *ContractApproval, contractApprovalRecord *contract_approval_record.ContractApprovalRecord, approveUserId int, approveUserName, remark string) (err error) {
 	o := orm.NewOrm()
 	tx, err := o.Begin()
@@ -423,14 +423,14 @@ func (ContractApproval) Reject(contractApprovalInfo *ContractApproval, contractA
 	return
 }
 
-//下级审批人信息
+// 下级审批人信息
 type NextApproval struct {
 	ApproveRoleTypeCode string
 	ApproveUserId       int
 	ApproveUserName     string
 }
 
-//审核通过
+// 审核通过
 func (ContractApproval) Approved(contractApprovalInfo *ContractApproval, contractApprovalRecord *contract_approval_record.ContractApprovalRecord, remark string) (err error) {
 	o := orm.NewOrm()
 	tx, err := o.Begin()
@@ -501,7 +501,7 @@ func (ContractApproval) Approved(contractApprovalInfo *ContractApproval, contrac
 	return
 }
 
-//抄送
+// 抄送
 func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, contractApprovalRecordList []*contract_approval_record.ContractApprovalRecord, remark string, nextNodeId int) (err error) {
 	o := orm.NewOrm()
 	tx, err := o.Begin()
@@ -575,7 +575,7 @@ func (ContractApproval) ApprovedByCc(contractApprovalInfo *ContractApproval, con
 	return
 }
 
-//根据合同审批单id集合获取合同审批单信息列表
+// 根据合同审批单id集合获取合同审批单信息列表
 func GetContractApprovalByIds(contractApprovalIds string) (contractApprovalList []*ContractApproval, err error) {
 	o := orm.NewOrm()
 	sql := `select * from contract_approval where contract_approval_id in (` + contractApprovalIds + `) `
@@ -583,7 +583,7 @@ func GetContractApprovalByIds(contractApprovalIds string) (contractApprovalList
 	return
 }
 
-//获取用印审批列表数据数量
+// 获取用印审批列表数据数量
 func GetSealApprovalListCount(childCondition, condition, joinCondition string, childPars, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.create_time,a.modify_time,a.status,c.status seal_status,
@@ -603,7 +603,7 @@ WHERE c.is_delete = 0  AND a.approval_type="seal" `
 	return
 }
 
-//用印审批列表
+// 用印审批列表
 type SealApprovalList struct {
 	ContractApprovalId       int                     `description:"审批单id"`
 	ContractId               int                     `description:"合同id"`
@@ -635,12 +635,13 @@ type SealApprovalList struct {
 	ModifyTimeStr            string                  `description:"最后一次修改的时间(字符串类型)"`
 	ApproveTimeStr           string                  `description:"审批时间(字符串类型)"`
 	InvalidTimeStr           string                  `description:"作废时间(字符串类型)"`
+	AffiliatedCompany        string                  `description:"归属公司"`
 }
 
-//获取合同审批列表数据
+// 获取合同审批列表数据
 func GetSealApprovalList(childCondition, condition, joinCondition string, childPars, pars []interface{}, startSize, pageSize int) (list []*SealApprovalList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time from contract_approval a
+	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time,c.affiliated_company from contract_approval a
 	join 
 	( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type="seal" `
 	sql += childCondition
@@ -654,7 +655,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
 	return
 }
 
-//处理后的
+// 处理后的
 func GetSealApprovalListCountV2(childCondition, condition string, childPars, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.create_time,a.modify_time,a.status,c.status seal_status,
@@ -675,7 +676,7 @@ WHERE c.is_delete = 0  AND a.approval_type="seal" `
 }
 func GetSealApprovalListV2(childCondition, condition, orderBy string, childPars, pars []interface{}, startSize, pageSize int) (list []*SealApprovalList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time from contract_approval a
+	sql := `SELECT a.contract_approval_id,a.contract_id,a.apply_content,a.approve_remark,a.apply_user_id,a.apply_user_name,a.curr_node_id,a.start_node_id,a.create_time,a.modify_time,a.status approval_status,c.status,c.seal_type,c.company_name,c.user_id,c.user_name,c.file_url,c.approve_time,c.invalid_time,c.code,c.check_back_file_time, c.affiliated_company from contract_approval a
 	join 
 	( SELECT max( contract_approval_id ) max_id,contract_id FROM contract_approval where 1=1 and approval_type="seal" `
 	sql += childCondition
@@ -689,7 +690,7 @@ WHERE c.is_delete = 0 AND a.approval_type="seal" `
 	return
 }
 
-//审批列表
+// 审批列表
 type CompanyApprovalList struct {
 	ContractApprovalId       int                     `description:"审批单id"`
 	ContractId               int                     `description:"客户单id"`
@@ -780,3 +781,18 @@ from contract_approval a
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
+
+func GetContractApprovalByRecordId(companyApprovalRecordIds []int) (list *ContractApproval, err error) {
+	o := orm.NewOrm()
+	sql := `
+SELECT
+	b.* 
+FROM
+	contract_approval_record AS a
+	INNER JOIN contract_approval AS b ON a.contract_approval_id = b.contract_approval_id 
+WHERE
+	contract_approval_record_id IN (` + utils.GetOrmInReplace(len(companyApprovalRecordIds)) + `) `
+
+	_, err = o.Raw(sql, companyApprovalRecordIds).QueryRows(&list)
+	return
+}

+ 1 - 0
models/tables/seal/seal.go

@@ -32,6 +32,7 @@ type Seal struct {
 	ModifyTime        time.Time `description:"最近一次修改时间"`
 	CreateTime        time.Time `description:"添加时间"`
 	CheckBackFileTime time.Time `description:"签回用印附件时间"`
+	AffiliatedCompany string    `description:"归属公司"`
 }
 
 var EnumUse = []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议", "代付合同", "总对总协议"}

+ 9 - 0
routers/commentsRouter.go

@@ -763,6 +763,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"],
+        beego.ControllerComments{
+            Method: "AffiliatedCompanyList",
+            Router: `/getAffiliatedCompany`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"],
         beego.ControllerComments{
             Method: "Invalid",

+ 5 - 3
services/seal/seal.go

@@ -21,7 +21,7 @@ import (
 )
 
 // AddSeal 添加用印
-func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, companyName, creditCode, serviceType, sealType, remark string, fileUrls []string) (sealInfo *seal.Seal, err error) {
+func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, companyName, creditCode, serviceType, sealType, remark string, fileUrls []string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	o := orm.NewOrm()
 	to, err := o.Begin()
 	if err != nil {
@@ -70,6 +70,7 @@ func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, com
 		ContractId:     contractId,
 		ModifyTime:     now,
 		CreateTime:     now,
+		AffiliatedCompany: affiliatedCompany,
 	}
 	err = seal.AddSeal(sealInfo)
 	if err != nil {
@@ -104,7 +105,7 @@ func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, com
 }
 
 // Edit 修改用印
-func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, userName string) (sealInfo *seal.Seal, err error) {
+func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, userName string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	o := orm.NewOrm()
 	to, err := o.Begin()
 	if err != nil {
@@ -163,8 +164,9 @@ func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompany
 	sealInfo.CreateTime = now	// 重提更新提交时间
 	sealInfo.ModifyTime = now
 	sealInfo.Status = "待提交" //用印状态
+	sealInfo.AffiliatedCompany = affiliatedCompany
 
-	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "CreateTime", "ModifyTime", "Status"})
+	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "CreateTime", "ModifyTime", "Status", "AffiliatedCompany"})
 	if err != nil {
 		err = errors.New("新增用印日志失败")
 		return