|
@@ -3,6 +3,7 @@ package company
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -406,3 +407,92 @@ func UpdateCompanyContractSellerUnexpired(sellerId, shareSellerInit int, sellerN
|
|
|
_, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, companyContractId).Exec()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+type CompanyContractRespInit struct {
|
|
|
+ MaxCompanyContractId int
|
|
|
+ CompanyContractId int `orm:"column(company_contract_id);pk" description:"客户合同id"`
|
|
|
+ ContractType string `description:"合同类型:枚举值:'新签合同','续约合同','补充协议'"`
|
|
|
+ ProductId int `description:"产品id"`
|
|
|
+ ProductName string `description:"产品名称"`
|
|
|
+ CompanyId int `description:"客户id"`
|
|
|
+ CompanyProductId int `description:"客户产品id"`
|
|
|
+ ContractCode string `description:"合同编码"`
|
|
|
+ StartDate string `description:"合同开始时间"`
|
|
|
+ EndDate string `description:"合同结束时间"`
|
|
|
+ Money float64 `description:"合同金额"`
|
|
|
+ PayMethod string `description:"支付方式"`
|
|
|
+ PayChannel string `description:"支付渠道"`
|
|
|
+ ImgUrl string `description:"合同图片,多个用#隔开"`
|
|
|
+ CreateTime time.Time `description:"合同创建时间"`
|
|
|
+ ModifyTime time.Time `description:"合同修改时间"`
|
|
|
+ Status int `description:"状态"`
|
|
|
+ Source string `description:"合同来源,枚举值:上传附件、系统合同,默认上传附件"`
|
|
|
+ PackageType int `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
|
|
|
+ RaiPackageType int `description:"权益套餐类型: 0-无; 1-70w大套餐; 2-45w大套餐"`
|
|
|
+ PermissionName string `description:"权限名"`
|
|
|
+}
|
|
|
+
|
|
|
+// 通过ID获取详情
|
|
|
+func GetCompanyContracListInit(condition string, pars []interface{}) (items []*CompanyContractRespInit, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ MAX( company_contract_id ) AS max_company_contract_id,
|
|
|
+ COUNT(a.company_id) AS cc ,
|
|
|
+ a.*
|
|
|
+FROM
|
|
|
+ company_contract a
|
|
|
+ JOIN company b ON a.company_id = b.company_id
|
|
|
+ JOIN company_product c ON a.company_id = c.company_id
|
|
|
+ AND a.product_id = c.product_id
|
|
|
+WHERE
|
|
|
+ 1 = 1 -- AND b.company_name LIKE "%上海亘%"
|
|
|
+
|
|
|
+ AND c.product_id = 2 -- AND b.company_name LIKE "%上海亘%"
|
|
|
+
|
|
|
+ AND c.product_id = 2
|
|
|
+ AND a.not_renewal_hide = 0
|
|
|
+ AND a.STATUS = 1
|
|
|
+ AND c.STATUS NOT IN ( "永续", "正式", "关闭" )
|
|
|
+
|
|
|
+ AND a.company_contract_id NOT IN (SELECT company_contract_id FROM company_contract_no_renewed_ascribe )
|
|
|
+GROUP BY
|
|
|
+ a.company_id
|
|
|
+ ` + condition
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 通过ID获取详情
|
|
|
+func GetCompanyContracListInit_CRM_16_1(condition string, pars []interface{}) (items []*CompanyContractRespInit, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ a.*
|
|
|
+FROM
|
|
|
+ company_contract a
|
|
|
+ JOIN company b ON a.company_id = b.company_id
|
|
|
+ JOIN company_product c ON a.company_id = c.company_id
|
|
|
+ AND a.product_id = c.product_id
|
|
|
+WHERE
|
|
|
+ 1 = 1 -- AND b.company_name LIKE "%上海亘%"
|
|
|
+
|
|
|
+ AND c.product_id = 2 -- AND b.company_name LIKE "%上海亘%"
|
|
|
+
|
|
|
+ AND c.product_id = 2
|
|
|
+ AND a.not_renewal_hide = 0
|
|
|
+ AND a.STATUS = 1
|
|
|
+ AND c.STATUS NOT IN ( "永续", "正式", "关闭" )
|
|
|
+
|
|
|
+ AND a.company_contract_id NOT IN (SELECT company_contract_id FROM company_contract_no_renewed_ascribe )
|
|
|
+ ` + condition
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 合同未生效更新对应销售的信息
|
|
|
+func UpdateCompanyContracthide(companyContractId []string) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `UPDATE company_contract SET not_renewal_hide = 1
|
|
|
+ WHERE company_contract_id IN (` + strings.Join(companyContractId, ",") + `) `
|
|
|
+ _, err = o.Raw(sql).Exec()
|
|
|
+ return
|
|
|
+}
|