Browse Source

代付合同需求调整

hsun 2 years ago
parent
commit
d315e3ffc2

+ 28 - 29
controller/contract/register.go

@@ -52,10 +52,10 @@ func (rg *RegisterController) List(c *gin.Context) {
 
 
 	cond := `1 = 1`
 	cond := `1 = 1`
 	pars := make([]interface{}, 0)
 	pars := make([]interface{}, 0)
-	// 合同编号/客户姓名/销售/代付
+	// 合同编号/客户姓名/销售/实际使用
 	if req.Keyword != "" {
 	if req.Keyword != "" {
 		kw := "%" + req.Keyword + "%"
 		kw := "%" + req.Keyword + "%"
-		cond += ` AND (company_name LIKE ? OR contract_code LIKE ? OR seller_name LIKE ? OR pay_company_name LIKE ?)`
+		cond += ` AND (company_name LIKE ? OR contract_code LIKE ? OR seller_name LIKE ? OR actual_company_name LIKE ?)`
 		pars = append(pars, kw, kw, kw, kw)
 		pars = append(pars, kw, kw, kw, kw)
 	}
 	}
 	if req.StartDate != "" && req.EndDate != "" {
 	if req.StartDate != "" && req.EndDate != "" {
@@ -217,11 +217,11 @@ func (rg *RegisterController) Add(c *gin.Context) {
 
 
 	nowTime := time.Now().Local()
 	nowTime := time.Now().Local()
 	ob.ContractCode = req.ContractCode
 	ob.ContractCode = req.ContractCode
-	ob.PayContractCode = req.PayContractCode
+	ob.RelateContractCode = req.RelateContractCode
 	ob.CrmContractId = req.CrmContractId
 	ob.CrmContractId = req.CrmContractId
 	ob.ContractSource = req.ContractSource
 	ob.ContractSource = req.ContractSource
 	ob.CompanyName = req.CompanyName
 	ob.CompanyName = req.CompanyName
-	ob.PayCompanyName = req.PayCompanyName
+	ob.ActualCompanyName = req.ActualCompanyName
 	ob.ProductId = req.ProductId
 	ob.ProductId = req.ProductId
 	ob.SellerId = req.SellerId
 	ob.SellerId = req.SellerId
 	ob.SellerName = req.SellerName
 	ob.SellerName = req.SellerName
@@ -235,9 +235,10 @@ func (rg *RegisterController) Add(c *gin.Context) {
 	ob.RegisterStatus = fms.ContractRegisterStatusIng
 	ob.RegisterStatus = fms.ContractRegisterStatusIng
 	ob.Remark = req.Remark
 	ob.Remark = req.Remark
 	ob.ServiceRemark = req.ServiceRemark
 	ob.ServiceRemark = req.ServiceRemark
+	ob.HasPayment = req.HasPayment
 	ob.Set()
 	ob.Set()
-	// 补充协议直接完成
-	if req.ContractType == fms.ContractTypePlus {
+	// 存在代付的直接完成登记, 且不允许进行开票/到款登记
+	if req.HasPayment == 1 {
 		ob.RegisterStatus = fms.ContractRegisterStatusComplete
 		ob.RegisterStatus = fms.ContractRegisterStatusComplete
 	}
 	}
 
 
@@ -344,13 +345,18 @@ func (rg *RegisterController) Edit(c *gin.Context) {
 		return
 		return
 	}
 	}
 
 
+	updateCols := []string{
+		"ContractCode", "RelateContractCode", "CrmContractId", "ContractSource", "CompanyName", "ActualCompanyName",
+		"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime",
+		"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "ModifyTime",
+	}
 	nowTime := time.Now().Local()
 	nowTime := time.Now().Local()
 	item.ContractCode = req.ContractCode
 	item.ContractCode = req.ContractCode
-	item.PayContractCode = req.PayContractCode
+	item.RelateContractCode = req.RelateContractCode
 	item.CrmContractId = req.CrmContractId
 	item.CrmContractId = req.CrmContractId
 	item.ContractSource = req.ContractSource
 	item.ContractSource = req.ContractSource
 	item.CompanyName = req.CompanyName
 	item.CompanyName = req.CompanyName
-	item.PayCompanyName = req.PayCompanyName
+	item.ActualCompanyName = req.ActualCompanyName
 	item.SellerId = req.SellerId
 	item.SellerId = req.SellerId
 	item.SellerName = req.SellerName
 	item.SellerName = req.SellerName
 	item.ContractType = req.ContractType
 	item.ContractType = req.ContractType
@@ -361,17 +367,14 @@ func (rg *RegisterController) Edit(c *gin.Context) {
 	item.AgreedPayTime = req.AgreedPayTime
 	item.AgreedPayTime = req.AgreedPayTime
 	item.ContractStatus = req.ContractStatus
 	item.ContractStatus = req.ContractStatus
 	item.RegisterStatus = fms.ContractRegisterStatusIng
 	item.RegisterStatus = fms.ContractRegisterStatusIng
-	// 补充协议直接完成
-	if req.ContractType == fms.ContractTypePlus {
-		item.RegisterStatus = fms.ContractRegisterStatusComplete
-	}
 	item.Remark = req.Remark
 	item.Remark = req.Remark
 	item.ServiceRemark = req.ServiceRemark
 	item.ServiceRemark = req.ServiceRemark
+	item.HasPayment = req.HasPayment
 	item.ModifyTime = nowTime
 	item.ModifyTime = nowTime
-	updateCols := []string{
-		"ContractCode", "CrmContractId", "ContractSource", "CompanyName", "SellerId", "SellerName",
-		"ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime", "ContractStatus",
-		"RegisterStatus", "Remark", "ModifyTime", "ServiceRemark",
+	// 存在代付的直接完成登记, 且不允许进行开票/到款登记
+	if req.HasPayment == 1 {
+		item.RegisterStatus = fms.ContractRegisterStatusComplete
+		updateCols = append(updateCols, "RegisterStatus")
 	}
 	}
 
 
 	// 套餐信息
 	// 套餐信息
@@ -387,10 +390,8 @@ func (rg *RegisterController) Edit(c *gin.Context) {
 		return
 		return
 	}
 	}
 
 
-	// 非补充协议校验金额-是否修改状态
-	if item.ContractType != fms.ContractTypePlus {
-		go fmsService.CheckContractRegisterAmount(item.ContractRegisterId)
-	}
+	// 校验金额-是否修改状态
+	go fmsService.CheckContractRegisterAmount(item.ContractRegisterId)
 
 
 	// 操作日志
 	// 操作日志
 	go func() {
 	go func() {
@@ -591,10 +592,8 @@ func (rg *RegisterController) UpdateStatus(c *gin.Context) {
 		return
 		return
 	}
 	}
 
 
-	// 非补充协议校验金额-是否修改状态
-	if item.ContractType != fms.ContractTypePlus {
-		go fmsService.CheckContractRegisterAmount(req.ContractRegisterId)
-	}
+	// 校验金额-是否修改状态
+	go fmsService.CheckContractRegisterAmount(req.ContractRegisterId)
 
 
 	// 操作日志
 	// 操作日志
 	go func() {
 	go func() {
@@ -651,8 +650,9 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
 		resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
 		resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
 		return
 		return
 	}
 	}
-	if item.ContractType == fms.ContractTypePlus {
-		resp.Fail("补充协议不允许添加开票/到款登记", c)
+	// 合同存在代付不允许开票/到款登记
+	if item.HasPayment == 1 {
+		resp.Fail("合同存在代付不允许添加开票/到款登记", c)
 		return
 		return
 	}
 	}
 
 
@@ -794,10 +794,10 @@ func (rg *RegisterController) Export(c *gin.Context) {
 
 
 	cond := `1 = 1`
 	cond := `1 = 1`
 	pars := make([]interface{}, 0)
 	pars := make([]interface{}, 0)
-	// 合同编号/客户姓名/销售/代付
+	// 合同编号/客户姓名/销售/实际使用
 	if req.Keyword != "" {
 	if req.Keyword != "" {
 		kw := "%" + req.Keyword + "%"
 		kw := "%" + req.Keyword + "%"
-		cond += ` AND (company_name LIKE ? OR contract_code LIKE ? OR seller_name LIKE ? OR pay_company_name LIKE ?)`
+		cond += ` AND (company_name LIKE ? OR contract_code LIKE ? OR seller_name LIKE ? OR actual_company_name LIKE ?)`
 		pars = append(pars, kw, kw, kw, kw)
 		pars = append(pars, kw, kw, kw, kw)
 	}
 	}
 	if req.StartDate != "" && req.EndDate != "" {
 	if req.StartDate != "" && req.EndDate != "" {
@@ -1529,7 +1529,6 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						}
 						}
 						if v == "3" {
 						if v == "3" {
 							rowRegister.ContractType = fms.ContractTypePlus
 							rowRegister.ContractType = fms.ContractTypePlus
-							rowRegister.RegisterStatus = fms.ContractRegisterStatusComplete // 补充协议标记已完成
 						}
 						}
 					}
 					}
 					// 销售
 					// 销售

+ 21 - 23
controller/crm/contract.go

@@ -1,7 +1,6 @@
 package crm
 package crm
 
 
 import (
 import (
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/gin-gonic/gin"
 	"github.com/go-playground/validator/v10"
 	"github.com/go-playground/validator/v10"
 	"hongze/fms_api/controller/resp"
 	"hongze/fms_api/controller/resp"
@@ -63,7 +62,7 @@ func (rg *ContractController) SearchList(c *gin.Context) {
 	// 获取代付合同实际使用方
 	// 获取代付合同实际使用方
 	peyContractIds := make([]int, 0)
 	peyContractIds := make([]int, 0)
 	for i := range list {
 	for i := range list {
-		if list[i].ContractBusinessType == "代付合同" {
+		if list[i].ContractBusinessType == crm.ContractTypePayment {
 			peyContractIds = append(peyContractIds, list[i].ContractId)
 			peyContractIds = append(peyContractIds, list[i].ContractId)
 		}
 		}
 	}
 	}
@@ -88,25 +87,25 @@ func (rg *ContractController) SearchList(c *gin.Context) {
 	for i := range list {
 	for i := range list {
 		contractType := list[i].ContractType
 		contractType := list[i].ContractType
 		contractTypeKey := crm.ContractTypeFmsMap[list[i].ContractType]
 		contractTypeKey := crm.ContractTypeFmsMap[list[i].ContractType]
-		if list[i].ContractBusinessType == "代付合同" {
-			contractType = "代付合同"
+		if list[i].ContractBusinessType == crm.ContractTypePayment {
+			contractType = crm.ContractTypePayment
 			contractTypeKey = fms.ContractTypeAgentPay
 			contractTypeKey = fms.ContractTypeAgentPay
 		}
 		}
 
 
 		respList = append(respList, &crm.ContractSearchListResp{
 		respList = append(respList, &crm.ContractSearchListResp{
-			ContractId:      list[i].ContractId,
-			ContractCode:    list[i].ContractCode,
-			ProductId:       list[i].ProductId,
-			CompanyName:     list[i].CompanyName,
-			PayContractCode: payContractCodeMap[list[i].ContractId],
-			PayCompanyName:  payCompanyMap[list[i].ContractId],
-			SellerId:        list[i].SellerId,
-			SellerName:      list[i].SellerName,
-			ContractTypeKey: contractTypeKey,
-			ContractType:    contractType,
-			Price:           list[i].Price,
-			StartDate:       utils.TimeTransferString(utils.FormatDate, list[i].StartDate),
-			EndDate:         utils.TimeTransferString(utils.FormatDate, list[i].EndDate),
+			ContractId:         list[i].ContractId,
+			ContractCode:       list[i].ContractCode,
+			ProductId:          list[i].ProductId,
+			CompanyName:        list[i].CompanyName,
+			RelateContractCode: payContractCodeMap[list[i].ContractId],
+			ActualCompanyName:  payCompanyMap[list[i].ContractId],
+			SellerId:           list[i].SellerId,
+			SellerName:         list[i].SellerName,
+			ContractTypeKey:    contractTypeKey,
+			ContractType:       contractType,
+			Price:              list[i].Price,
+			StartDate:          utils.TimeTransferString(utils.FormatDate, list[i].StartDate),
+			EndDate:            utils.TimeTransferString(utils.FormatDate, list[i].EndDate),
 		})
 		})
 	}
 	}
 
 
@@ -240,12 +239,11 @@ func (rg *ContractController) ServiceDetail(c *gin.Context) {
 		return
 		return
 	}
 	}
 
 
-	chartPermissionMap, e := crmService.GetServicePermissionMap(contractDetail.Service)
-	if e != nil {
-		resp.FailMsg("获取失败", "获取合同服务中的权限ID失败, Err: "+e.Error(), c)
-		return
-	}
-	fmt.Println(chartPermissionMap)
+	//chartPermissionMap, e := crmService.GetServicePermissionMap(contractDetail.Service)
+	//if e != nil {
+	//	resp.FailMsg("获取失败", "获取合同服务中的权限ID失败, Err: "+e.Error(), c)
+	//	return
+	//}
 
 
 	resp.OkData("获取成功", contractDetail, c)
 	resp.OkData("获取成功", contractDetail, c)
 }
 }

+ 1 - 1
models/crm/chart_permission.go

@@ -93,7 +93,7 @@ type CompanyPermissionLookItem struct {
 
 
 func GetPermissionLookItems(productId int, classifyName string) (items []*CompanyPermissionLookItem, err error) {
 func GetPermissionLookItems(productId int, classifyName string) (items []*CompanyPermissionLookItem, err error) {
 	items = make([]*CompanyPermissionLookItem, 0)
 	items = make([]*CompanyPermissionLookItem, 0)
-	err = global.MYSQL["report"].Model(ChartPermission{}).
+	err = global.MYSQL["report"].Table("chart_permission").
 		Where("enabled = 1 AND product_id = ? AND classify_name = ?", productId, classifyName).
 		Where("enabled = 1 AND product_id = ? AND classify_name = ?", productId, classifyName).
 		Order("sort ASC").
 		Order("sort ASC").
 		Find(&items).Error
 		Find(&items).Error

+ 4 - 0
models/crm/constants.go

@@ -41,6 +41,10 @@ const (
 	ContractTypeNew   = "新签合同" // 新签
 	ContractTypeNew   = "新签合同" // 新签
 	ContractTypeRenew = "续约合同" // 续约
 	ContractTypeRenew = "续约合同" // 续约
 	ContractTypePlus  = "补充协议" // 补充
 	ContractTypePlus  = "补充协议" // 补充
+
+	// 合同业务类型
+	ContractTypeBusiness = "业务合同"
+	ContractTypePayment  = "代付合同"
 )
 )
 
 
 // ContractTypeFmsMap CRM系统合同类型/FMS系统合同类型
 // ContractTypeFmsMap CRM系统合同类型/FMS系统合同类型

+ 4 - 2
models/crm/contract.go

@@ -80,8 +80,10 @@ type ContractSearchListResp struct {
 	ContractCode    string  `json:"contract_code" description:"合同编号"`
 	ContractCode    string  `json:"contract_code" description:"合同编号"`
 	ProductId       int     `json:"product_id" description:"产品ID"`
 	ProductId       int     `json:"product_id" description:"产品ID"`
 	CompanyName     string  `json:"company_name" description:"客户名称"`
 	CompanyName     string  `json:"company_name" description:"客户名称"`
-	PayContractCode string  `json:"pay_contract_code" description:"代付合同编号"`
-	PayCompanyName  string  `json:"pay_company_name" description:"代付客户名称"`
+	//PayContractCode string  `json:"pay_contract_code" description:"代付合同编号"`
+	RelateContractCode string `json:"relate_contract_code" description:"代付合同关联的实际使用方合同编号"`
+	//PayCompanyName  string  `json:"pay_company_name" description:"代付客户名称"`
+	ActualCompanyName string `json:"actual_company_name" description:"实际使用方"`
 	SellerId        int     `json:"seller_id" description:"销售ID"`
 	SellerId        int     `json:"seller_id" description:"销售ID"`
 	SellerName      string  `json:"seller_name" description:"销售名称"`
 	SellerName      string  `json:"seller_name" description:"销售名称"`
 	ContractTypeKey int     `json:"contract_type_key" description:"FMS合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议;"`
 	ContractTypeKey int     `json:"contract_type_key" description:"FMS合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议;"`

+ 29 - 25
models/fms/contract_register.go

@@ -11,11 +11,11 @@ import (
 type ContractRegister struct {
 type ContractRegister struct {
 	ContractRegisterId int       `gorm:"primaryKey;column:contract_register_id" json:"contract_register_id" description:"登记ID"`
 	ContractRegisterId int       `gorm:"primaryKey;column:contract_register_id" json:"contract_register_id" description:"登记ID"`
 	ContractCode       string    `gorm:"column:contract_code" json:"contract_code" description:"合同编号"`
 	ContractCode       string    `gorm:"column:contract_code" json:"contract_code" description:"合同编号"`
-	PayContractCode    string    `gorm:"column:pay_contract_code" json:"pay_contract_code" description:"代付合同编号"`
+	RelateContractCode string    `gorm:"column:relate_contract_code" json:"relate_contract_code" description:"关联合同编号"`
 	CrmContractId      int       `gorm:"column:crm_contract_id" json:"crm_contract_id" description:"CRM系统-合同ID"`
 	CrmContractId      int       `gorm:"column:crm_contract_id" json:"crm_contract_id" description:"CRM系统-合同ID"`
 	ContractSource     int       `gorm:"column:contract_source" json:"contract_source" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
 	ContractSource     int       `gorm:"column:contract_source" json:"contract_source" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
 	CompanyName        string    `gorm:"column:company_name" json:"company_name" description:"客户名称"`
 	CompanyName        string    `gorm:"column:company_name" json:"company_name" description:"客户名称"`
-	PayCompanyName     string    `gorm:"column:pay_company_name" json:"pay_company_name" description:"代付方-客户名称"`
+	ActualCompanyName  string    `gorm:"column:actual_company_name" json:"actual_company_name" description:"实际使用方"`
 	ProductId          int       `gorm:"column:product_id" json:"product_id" description:"产品ID: 1-FICC; 2-权益"`
 	ProductId          int       `gorm:"column:product_id" json:"product_id" description:"产品ID: 1-FICC; 2-权益"`
 	SellerId           int       `gorm:"column:seller_id" json:"seller_id" description:"CRM系统-销售ID"`
 	SellerId           int       `gorm:"column:seller_id" json:"seller_id" description:"CRM系统-销售ID"`
 	SellerName         string    `gorm:"column:seller_name" json:"seller_name" description:"CRM系统-销售名称"`
 	SellerName         string    `gorm:"column:seller_name" json:"seller_name" description:"CRM系统-销售名称"`
@@ -31,6 +31,7 @@ type ContractRegister struct {
 	RegisterStatus     int       `gorm:"column:register_status" json:"register_status" description:"登记状态: 1-进行中; 2-已完成;"`
 	RegisterStatus     int       `gorm:"column:register_status" json:"register_status" description:"登记状态: 1-进行中; 2-已完成;"`
 	Remark             string    `gorm:"column:remark" json:"remark" description:"备注信息"`
 	Remark             string    `gorm:"column:remark" json:"remark" description:"备注信息"`
 	ServiceRemark      string    `gorm:"column:service_remark" json:"service_remark" description:"套餐备注信息"`
 	ServiceRemark      string    `gorm:"column:service_remark" json:"service_remark" description:"套餐备注信息"`
+	HasPayment         int       `gorm:"column:has_payment" json:"has_payment" description:"是否有代付: 0-无; 1-有"`
 	IsDeleted          int       `gorm:"column:is_deleted" json:"is_deleted" description:"是否已删除: 0-正常; 1-已删除"`
 	IsDeleted          int       `gorm:"column:is_deleted" json:"is_deleted" description:"是否已删除: 0-正常; 1-已删除"`
 	base.TimeBase
 	base.TimeBase
 }
 }
@@ -104,11 +105,11 @@ type ContractRegisterListReq struct {
 type ContractRegisterItem struct {
 type ContractRegisterItem struct {
 	ContractRegisterId int     `json:"contract_register_id" description:"登记ID"`
 	ContractRegisterId int     `json:"contract_register_id" description:"登记ID"`
 	ContractCode       string  `json:"contract_code" description:"合同编号"`
 	ContractCode       string  `json:"contract_code" description:"合同编号"`
-	PayContractCode    string  `json:"pay_contract_code" description:"代付合同编号"`
+	RelateContractCode string  `json:"relate_contract_code" description:"关联合同编号"`
 	CrmContractId      int     `json:"crm_contract_id" description:"CRM系统-合同ID"`
 	CrmContractId      int     `json:"crm_contract_id" description:"CRM系统-合同ID"`
 	ContractSource     int     `json:"contract_source" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
 	ContractSource     int     `json:"contract_source" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
 	CompanyName        string  `json:"company_name" description:"客户名称"`
 	CompanyName        string  `json:"company_name" description:"客户名称"`
-	PayCompanyName     string  `json:"pay_company_name" description:"代付方-客户名称"`
+	ActualCompanyName  string  `json:"actual_company_name" description:"实际使用方"`
 	SellerId           int     `json:"seller_id" description:"CRM系统-销售ID"`
 	SellerId           int     `json:"seller_id" description:"CRM系统-销售ID"`
 	SellerName         string  `json:"seller_name" description:"CRM系统-销售名称"`
 	SellerName         string  `json:"seller_name" description:"CRM系统-销售名称"`
 	ContractType       int     `json:"contract_type" description:"合同类型: 1-新签; 2-续约"`
 	ContractType       int     `json:"contract_type" description:"合同类型: 1-新签; 2-续约"`
@@ -123,6 +124,7 @@ type ContractRegisterItem struct {
 	RegisterStatus     int     `json:"register_status" description:"登记状态: 1-进行中; 2-已完成;"`
 	RegisterStatus     int     `json:"register_status" description:"登记状态: 1-进行中; 2-已完成;"`
 	Remark             string  `json:"remark" description:"备注信息"`
 	Remark             string  `json:"remark" description:"备注信息"`
 	ServiceRemark      string  `json:"service_remark" description:"套餐备注信息"`
 	ServiceRemark      string  `json:"service_remark" description:"套餐备注信息"`
+	HasPayment         int     `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
 	CreateTime         string  `json:"create_time" description:"登记时间"`
 	CreateTime         string  `json:"create_time" description:"登记时间"`
 }
 }
 
 
@@ -147,25 +149,26 @@ type ContractRegisterUpdateStatusReq struct {
 
 
 // ContractRegisterAddReq 新增合同登记请求体
 // ContractRegisterAddReq 新增合同登记请求体
 type ContractRegisterAddReq struct {
 type ContractRegisterAddReq struct {
-	ContractCode    string                  `json:"contract_code" binding:"required" description:"合同编号"`
-	PayContractCode string                  `json:"pay_contract_code" description:"代付合同编号"`
-	CrmContractId   int                     `json:"crm_contract_id" description:"CRM系统-合同ID"`
-	ContractSource  int                     `json:"contract_source" binding:"oneof=0 1" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
-	CompanyName     string                  `json:"company_name" binding:"required" description:"客户名称"`
-	PayCompanyName  string                  `json:"pay_company_name" description:"代付方客户名称"`
-	SellerId        int                     `json:"seller_id" binding:"required" description:"CRM系统-销售ID"`
-	SellerName      string                  `json:"seller_name" binding:"required" description:"CRM系统-销售名称"`
-	ContractType    int                     `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"`
-	ContractAmount  float64                 `json:"contract_amount" binding:"required" description:"合同金额"`
-	StartDate       string                  `json:"start_date" binding:"required" description:"合同开始日期"`
-	EndDate         string                  `json:"end_date" binding:"required" description:"合同结束日期"`
-	SignDate        string                  `json:"sign_date" description:"合同签订日期"`
-	AgreedPayTime   string                  `json:"agreed_pay_time" description:"约定付款时间(如:生效日起10日内)"`
-	ContractStatus  int                     `json:"contract_status" binding:"oneof=1 2 3" description:"合同状态: 1-已审批; 2-单章寄出; 3-已签回"`
-	Remark          string                  `json:"remark" description:"备注信息"`
-	ProductId       int                     `json:"product_id" binding:"oneof=1 2" description:"产品ID"`
-	ServiceRemark   string                  `json:"service_remark" description:"套餐备注"`
-	Services        []ContractServiceAddReq `json:"services" description:"服务套餐内容"`
+	ContractCode       string                  `json:"contract_code" binding:"required" description:"合同编号"`
+	RelateContractCode string                  `json:"relate_contract_code" description:"关联合同编号"`
+	CrmContractId      int                     `json:"crm_contract_id" description:"CRM系统-合同ID"`
+	ContractSource     int                     `json:"contract_source" binding:"oneof=0 1" description:"合同来源: 0-非系统合同导入; 1-CRM合同导入"`
+	CompanyName        string                  `json:"company_name" binding:"required" description:"客户名称"`
+	ActualCompanyName  string                  `json:"actual_company_name" description:"实际使用方"`
+	SellerId           int                     `json:"seller_id" binding:"required" description:"CRM系统-销售ID"`
+	SellerName         string                  `json:"seller_name" binding:"required" description:"CRM系统-销售名称"`
+	ContractType       int                     `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"`
+	ContractAmount     float64                 `json:"contract_amount" binding:"required" description:"合同金额"`
+	StartDate          string                  `json:"start_date" binding:"required" description:"合同开始日期"`
+	EndDate            string                  `json:"end_date" binding:"required" description:"合同结束日期"`
+	SignDate           string                  `json:"sign_date" description:"合同签订日期"`
+	AgreedPayTime      string                  `json:"agreed_pay_time" description:"约定付款时间(如:生效日起10日内)"`
+	ContractStatus     int                     `json:"contract_status" binding:"oneof=1 2 3" description:"合同状态: 1-已审批; 2-单章寄出; 3-已签回"`
+	Remark             string                  `json:"remark" description:"备注信息"`
+	ProductId          int                     `json:"product_id" binding:"oneof=1 2" description:"产品ID"`
+	ServiceRemark      string                  `json:"service_remark" description:"套餐备注"`
+	HasPayment         int                     `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
+	Services           []ContractServiceAddReq `json:"services" description:"服务套餐内容"`
 }
 }
 
 
 // ContractRegisterEditReq 编辑合同登记请求体
 // ContractRegisterEditReq 编辑合同登记请求体
@@ -328,11 +331,11 @@ func formatContractRegister2Item(item *ContractRegister) (formatItem *ContractRe
 	formatItem = new(ContractRegisterItem)
 	formatItem = new(ContractRegisterItem)
 	formatItem.ContractRegisterId = item.ContractRegisterId
 	formatItem.ContractRegisterId = item.ContractRegisterId
 	formatItem.ContractCode = item.ContractCode
 	formatItem.ContractCode = item.ContractCode
-	formatItem.PayContractCode = item.PayContractCode
+	formatItem.RelateContractCode = item.RelateContractCode
 	formatItem.CrmContractId = item.CrmContractId
 	formatItem.CrmContractId = item.CrmContractId
 	formatItem.ContractSource = item.ContractSource
 	formatItem.ContractSource = item.ContractSource
 	formatItem.CompanyName = item.CompanyName
 	formatItem.CompanyName = item.CompanyName
-	formatItem.PayCompanyName = item.PayCompanyName
+	formatItem.ActualCompanyName = item.ActualCompanyName
 	formatItem.SellerId = item.SellerId
 	formatItem.SellerId = item.SellerId
 	formatItem.SellerName = item.SellerName
 	formatItem.SellerName = item.SellerName
 	formatItem.ContractType = item.ContractType
 	formatItem.ContractType = item.ContractType
@@ -347,6 +350,7 @@ func formatContractRegister2Item(item *ContractRegister) (formatItem *ContractRe
 	formatItem.RegisterStatus = item.RegisterStatus
 	formatItem.RegisterStatus = item.RegisterStatus
 	formatItem.Remark = item.Remark
 	formatItem.Remark = item.Remark
 	formatItem.ServiceRemark = item.ServiceRemark
 	formatItem.ServiceRemark = item.ServiceRemark
+	formatItem.HasPayment = item.HasPayment
 	formatItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, item.CreateTime)
 	formatItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, item.CreateTime)
 	return
 	return
 }
 }

+ 3 - 2
services/fms/contract_register.go

@@ -54,9 +54,10 @@ func CheckContractRegisterAmount(registerId int) {
 		}
 		}
 	}
 	}
 
 
-	// 核对金额是否相等, 并更新状态
 	status := fms.ContractRegisterStatusIng
 	status := fms.ContractRegisterStatusIng
-	if amount.Equal(invoiceAmount) && invoiceAmount.Equal(paymentAmount) && item.ContractStatus == fms.ContractStatusCheckedBack {
+	// 以下情况更新合同登记状态为已完成
+	// 1.合同存在代付; 2.合同状态为已签回且合同金额=开票金额=到款金额
+	if item.HasPayment == 1 || (amount.Equal(invoiceAmount) && invoiceAmount.Equal(paymentAmount) && item.ContractStatus == fms.ContractStatusCheckedBack) {
 		status = fms.ContractRegisterStatusComplete
 		status = fms.ContractRegisterStatusComplete
 	}
 	}
 	updateCols := []string{"InvoicedAmount", "PaymentAmount", "RegisterStatus", "ModifyTime"}
 	updateCols := []string{"InvoicedAmount", "PaymentAmount", "RegisterStatus", "ModifyTime"}