|
@@ -9,7 +9,7 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-//合同
|
|
|
|
|
|
+// 合同
|
|
type Contract struct {
|
|
type Contract struct {
|
|
ContractId int `orm:"column(contract_id);pk"`
|
|
ContractId int `orm:"column(contract_id);pk"`
|
|
ContractCode string `description:"合同编号,长度32位"`
|
|
ContractCode string `description:"合同编号,长度32位"`
|
|
@@ -52,14 +52,14 @@ type Contract struct {
|
|
CreateTime time.Time `description:"合同添加时间"`
|
|
CreateTime time.Time `description:"合同添加时间"`
|
|
}
|
|
}
|
|
|
|
|
|
-//更新合同基础信息
|
|
|
|
|
|
+// 更新合同基础信息
|
|
func (contract *Contract) Update(cols []string) (err error) {
|
|
func (contract *Contract) Update(cols []string) (err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
_, err = o.Update(contract, cols...)
|
|
_, err = o.Update(contract, cols...)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//根据合同id获取合同信息
|
|
|
|
|
|
+// 根据合同id获取合同信息
|
|
func GetContractById(contractId int) (contractInfo *Contract, err error) {
|
|
func GetContractById(contractId int) (contractInfo *Contract, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
sql := `select * from contract where contract_id = ? `
|
|
sql := `select * from contract where contract_id = ? `
|
|
@@ -67,7 +67,7 @@ func GetContractById(contractId int) (contractInfo *Contract, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//合同详情信息(包含服务信息等)
|
|
|
|
|
|
+// 合同详情信息(包含服务信息等)
|
|
type ContractDetail struct {
|
|
type ContractDetail struct {
|
|
ContractId int `description:"合同唯一id"`
|
|
ContractId int `description:"合同唯一id"`
|
|
ContractCode string `description:"合同编号,长度32位"`
|
|
ContractCode string `description:"合同编号,长度32位"`
|
|
@@ -132,7 +132,7 @@ func GetContractDetailById(contractId int) (contractInfo *ContractDetail, err er
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//合同添加
|
|
|
|
|
|
+// 合同添加
|
|
func AddContract(contractInfo *Contract, contractServiceAndDetailList []*contract.ContractServiceAndDetail) (newContract *Contract, err error) {
|
|
func AddContract(contractInfo *Contract, contractServiceAndDetailList []*contract.ContractServiceAndDetail) (newContract *Contract, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
tx, err := o.Begin()
|
|
tx, err := o.Begin()
|
|
@@ -246,7 +246,7 @@ type ContractList struct {
|
|
Service []*contract.ContractServiceAndDetail
|
|
Service []*contract.ContractServiceAndDetail
|
|
}
|
|
}
|
|
|
|
|
|
-//获取合同列表数据数量
|
|
|
|
|
|
+// 获取合同列表数据数量
|
|
func GetContractListCount(condition string, pars []interface{}) (count int, err error) {
|
|
func GetContractListCount(condition string, pars []interface{}) (count int, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
sql := "select count(*) AS COUNT from contract where 1=1 AND is_delete = 0 "
|
|
sql := "select count(*) AS COUNT from contract where 1=1 AND is_delete = 0 "
|
|
@@ -255,7 +255,7 @@ func GetContractListCount(condition string, pars []interface{}) (count int, err
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//获取合同列表数据
|
|
|
|
|
|
+// 获取合同列表数据
|
|
func GetContractList(condition string, pars []interface{}, startSize, pageSize int) (list []*ContractList, err error) {
|
|
func GetContractList(condition string, pars []interface{}, startSize, pageSize int) (list []*ContractList, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
sql := "select * from contract where 1=1 AND is_delete = 0 "
|
|
sql := "select * from contract where 1=1 AND is_delete = 0 "
|
|
@@ -265,7 +265,28 @@ func GetContractList(condition string, pars []interface{}, startSize, pageSize i
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//修改合同
|
|
|
|
|
|
+// GetJoinContractListCount 获取合同列表数据数量
|
|
|
|
+func GetJoinContractListCount(condition, joinStr string, pars []interface{}) (count int, err error) {
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
+ sql := `select count(a.contract_id) AS COUNT from contract a ` + joinStr
|
|
|
|
+ sql += ` where a.is_delete = 0 `
|
|
|
|
+ sql += condition
|
|
|
|
+ err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetJoinContractList 获取合同列表数据
|
|
|
|
+func GetJoinContractList(condition, joinStr string, pars []interface{}, startSize, pageSize int) (list []*ContractList, err error) {
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
+ sql := "select a.* from contract a " + joinStr
|
|
|
|
+ sql += ` where a.is_delete = 0 `
|
|
|
|
+ sql += condition
|
|
|
|
+ sql += ` order by modify_time desc LIMIT ?,? `
|
|
|
|
+ _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 修改合同
|
|
func EditContract(contractInfo *Contract, contractServiceAndDetailList []*contract.ContractServiceAndDetail) (err error) {
|
|
func EditContract(contractInfo *Contract, contractServiceAndDetailList []*contract.ContractServiceAndDetail) (err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
tx, err := o.Begin()
|
|
tx, err := o.Begin()
|
|
@@ -334,7 +355,7 @@ func EditContract(contractInfo *Contract, contractServiceAndDetailList []*contra
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//添加生成后的合同地址
|
|
|
|
|
|
+// 添加生成后的合同地址
|
|
func AddContractPdf(contractId int, pdfUrl string) (err error) {
|
|
func AddContractPdf(contractId int, pdfUrl string) (err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
|
|
|
|
@@ -344,7 +365,7 @@ func AddContractPdf(contractId int, pdfUrl string) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//删除合同
|
|
|
|
|
|
+// 删除合同
|
|
func DeleteContract(contractInfo *Contract) (err error) {
|
|
func DeleteContract(contractInfo *Contract) (err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
tx, err := o.Begin()
|
|
tx, err := o.Begin()
|
|
@@ -369,7 +390,7 @@ func DeleteContract(contractInfo *Contract) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//作废合同
|
|
|
|
|
|
+// 作废合同
|
|
func InvalidContract(contractInfo *Contract) (err error) {
|
|
func InvalidContract(contractInfo *Contract) (err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
tx, err := o.Begin()
|
|
tx, err := o.Begin()
|
|
@@ -395,7 +416,7 @@ func InvalidContract(contractInfo *Contract) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//生成合同编号
|
|
|
|
|
|
+// 生成合同编号
|
|
func GetCompanyContractCode(productId int) (companyCode string, err error) {
|
|
func GetCompanyContractCode(productId int) (companyCode string, err error) {
|
|
var num int
|
|
var num int
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
@@ -421,7 +442,7 @@ type CompanyNameList struct {
|
|
CompanyName string `description:"客户名称,甲方名称,长度32位"`
|
|
CompanyName string `description:"客户名称,甲方名称,长度32位"`
|
|
}
|
|
}
|
|
|
|
|
|
-//获取客户名称列表数据
|
|
|
|
|
|
+// 获取客户名称列表数据
|
|
func GetCompanyNameList(sellerId int, keyword, status string) (list []*CompanyNameList, err error) {
|
|
func GetCompanyNameList(sellerId int, keyword, status string) (list []*CompanyNameList, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
sql := `select * from contract where is_delete=0 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 + `%') `
|