123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- package company
- //合同未续约说明
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyContractNoRenewedAscribe struct {
- NoRenewedAscribeId int `orm:"column(no_renewed_ascribe_id);pk" description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- CompanyContractId int `description:"合同id"`
- ProductId int `description:"产品id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- type CompanyContractNoRenewedAscribeLog struct {
- NoRenewedAscribeId int `orm:"column(no_renewed_ascribe_id);pk" description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- CompanyContractId int `description:"合同id"`
- ProductId int `description:"产品id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- type CompanyContractNoRenewedAscribeResp struct {
- NoRenewedAscribeId int `description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- ProductId int `description:"产品id"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- CompanyContractId int `description:"合同id"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"更新时间"`
- }
- type CompanyContractNoRenewedAscribeListResp struct {
- List []*CompanyContractNoRenewedAscribeResp
- }
- type CompanyContractNoRenewedAscribeDetailResp struct {
- Detail *CompanyContractNoRenewedAscribeResp
- }
- type CompanyContractNoRenewedAscribeReq struct {
- CompanyAscribeId int `description:"归因ID"`
- ProductId int `description:"产品id"`
- Content string `description:"内容说明"`
- CompanyId int `description:"公司ID"`
- CompanyContractId int `description:"合同id"`
- }
- // 添加
- func AddCompanyContractNoRenewedAscribe(item *CompanyContractNoRenewedAscribe, itemLog *CompanyContractNoRenewedAscribeLog) (err error) {
- o := orm.NewOrm()
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- _, err = to.Insert(item)
- if err != nil {
- return
- }
- _, err = to.Insert(itemLog)
- //修改未续约归因
- sql := `UPDATE company_contract SET company_ascribe_id = ? WHERE company_contract_id=? `
- _, err = to.Raw(sql, item.CompanyAscribeId, item.CompanyContractId).Exec()
- return
- }
- // 修改
- func UpdateCompanyContractNoRenewedAscribe(item *CompanyContractNoRenewedAscribe, itemLog *CompanyContractNoRenewedAscribeLog) (err error) {
- o := orm.NewOrm()
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- updateParams := make(map[string]interface{})
- updateParams["CompanyAscribeId"] = item.CompanyAscribeId
- updateParams["ModifyTime"] = item.ModifyTime
- updateParams["Content"] = item.Content
- updateParams["AscribeContent"] = item.AscribeContent
- ptrStructOrTableName := "company_contract_no_renewed_ascribe"
- whereParam := map[string]interface{}{"company_id": item.CompanyId, "company_contract_id": item.CompanyContractId}
- qs := to.QueryTable(ptrStructOrTableName)
- for expr, exprV := range whereParam {
- qs = qs.Filter(expr, exprV)
- }
- _, err = qs.Update(updateParams)
- if err != nil {
- return
- }
- _, err = to.Insert(itemLog)
- //修改未续约归因
- sql := `UPDATE company_contract SET company_ascribe_id = ? WHERE company_contract_id=? `
- _, err = to.Raw(sql, item.CompanyAscribeId, item.CompanyContractId).Exec()
- return
- }
- // 获取数量
- func GetCompanyContractNoRenewedAscribeCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM company_contract_no_renewed_ascribe as a WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 通过ID获取详情
- func GetCompanyContractNoRenewedAscribeDetail(companyContractId int) (item *CompanyContractNoRenewedAscribeResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM company_contract_no_renewed_ascribe WHERE company_contract_id=? `
- err = o.Raw(sql, companyContractId).QueryRow(&item)
- return
- }
- // 列表
- func GetCompanyContractNoRenewedAscribeList(condition string, pars []interface{}, startSize, pageSize int) (items []*CompanyContractNoRenewedAscribeResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM company_contract_no_renewed_ascribe as a WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- if startSize+pageSize > 0 {
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
|