package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type Company struct { CompanyId int64 `orm:"column(company_id);pk"` CompanyName string `description:"客户名称"` CreditCode string `description:"社会统一信用码"` CompanyCode string `description:"客户编码"` Sort int `description:"优先级"` IsFeeCustomer int `description:"是否付费用户"` Country string `description:"国家编码"` ProvinceId int `description:"省id"` CityId int `description:"市id"` Address string `description:"详细地址"` CompanyType int `orm:"column(type)" description:"客户标签,1:付费客户,2:试用客户,3:流失客户,4:潜在客户"` Enabled int `description:"用户状态"` CreatedTime time.Time `description:"创建时间"` LastUpdatedTime time.Time `description:"最后一次阅读时间"` Seller string `description:"销售员"` SellsId int `description:"销售员id"` CompanyBelong string `description:"客户所属,ficc:ficc客户,public_offering:公募客户,partner:合作伙伴"` StartDate string `description:"合同开始日期"` EndDate string `description:"合同结束日期"` LoseReason string `description:"流失原因"` LastType int `description:"原客户标签"` IsVip int `description:"0:普通用户,1:大客户"` LossTime time.Time `description:"流失时间"` FirstStartDate string `description:"首次设置为试用客户开始时间"` FirstEndDate string `description:"首次设置为试用客户结束时间"` DateType int `description:"设置流失类型,1:1个月,2:2个月,3:3个月"` Status string `description:"'试用','永续','冻结','流失','正式','潜在'"` } //获取企业信息详情 func GetCompanyInfoById(companyId int) (item *Company, err error) { o := orm.NewOrm() sql := ` SELECT * FROM company WHERE company_id = ? ` err = o.Raw(sql, companyId).QueryRow(&item) return } func GetCompanyById(companyId int) (item []*CompanyProduct, err error) { o := orm.NewOrm() sql := ` SELECT a.*,b.status,b.is_suspend,b.product_id, b.seller_name FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.company_id=? ` _, err = o.Raw(sql, companyId).QueryRows(&item) return } func GetCompanyProductById(companyId, productId int) (item *CompanyProduct, err error) { o := orm.NewOrm() sql := ` SELECT a.*,b.status,b.is_suspend,b.seller_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.company_id=? AND b.product_id=? ` err = o.Raw(sql, companyId, productId).QueryRow(&item) return }