123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package company_product
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyProduct struct {
- CompanyProductId int `orm:"column(company_product_id);pk" description:"客户产品id"`
- CompanyId int `description:"客户id"`
- ProductId int `description:"产品id"`
- ProductName string `description:"产品名称"`
- CompanyName string `description:"客户名称"`
- Source string `description:"来源"`
- Reasons string `description:"新增理由"`
- Status string `description:"客户状态"`
- InitStatus string `description:"客户初始化状态(目前用来处理权益的永续客户使用)"`
- IndustryId int `description:"行业id"`
- IndustryName string `description:"行业名称"`
- SellerId int `description:"销售id"`
- SellerName string `description:"销售名称"`
- GroupId int `description:"销售分组id"`
- DepartmentId int `description:"销售部门id"`
- IsSuspend int `description:"1:暂停,0:启用"`
- SuspendTime time.Time `description:"暂停启用时间"`
- ApproveStatus string `description:"审批状态:'审批中','通过','驳回'"`
- FreezeTime time.Time `description:"冻结时间"`
- Remark string `description:"备注信息"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- ContractEndDate time.Time `description:"合同结束日期"`
- LoseReason string `description:"流失原因"`
- LossTime time.Time `description:"流失时间"`
- CompanyType string `description:"客户类型"`
- PackageType int `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
- IsFormal int `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
- ShareSeller string `description:"共享销售员"`
- ShareSellerId int `description:"共享销售员id"`
- }
- func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *CompanyProduct, err error) {
- o := orm.NewOrm()
- sql := `SELECT b.* 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=? LIMIT 1 `
- err = o.Raw(sql, companyId, productId).QueryRow(&item)
- return
- }
- // 更新客户产品信息
- func (companyProduct *CompanyProduct) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(companyProduct, cols...)
- return
- }
- // CompanyProductItem
- // @Description: 客户品种
- type CompanyProductItem struct {
- CompanyProductId int `orm:"column(company_product_id);pk" description:"客户产品id"`
- CompanyId int `description:"客户id"`
- ProductId int `description:"产品id"`
- ProductName string `description:"产品名称"`
- CompanyName string `description:"客户名称"`
- Source string `description:"来源"`
- Reasons string `description:"新增理由"`
- Status string `description:"客户状态"`
- IndustryId int `description:"行业id"`
- IndustryName string `description:"行业名称"`
- SellerId int `description:"销售id"`
- SellerName string `description:"销售名称"`
- GroupId int `description:"销售分组id"`
- DepartmentId int `description:"销售部门id"`
- IsSuspend int `description:"1:暂停,0:启用"`
- SuspendTime time.Time `description:"暂停启用时间"`
- ApproveStatus string `description:"审批状态:'审批中','通过','驳回'"`
- FreezeTime time.Time `description:"冻结时间"`
- Remark string `description:"备注信息"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- ContractEndDate string `description:"合同结束日期"`
- LoseReason string `description:"流失原因"`
- LossTime time.Time `description:"流失时间"`
- CompanyType string `description:"客户类型"`
- OpenCode string `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
- Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。"`
- ViewTotal int `description:"总阅读次数"`
- RoadShowTotal int `description:"累计路演次数"`
- LastViewTime time.Time `description:"最后一次阅读时间"`
- PackageType int `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
- IsFormal int `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
- TodoStatus string `description:"任务处理状态;枚举值:'无任务','未完成','已完成'"`
- TodoCreateTime time.Time `description:"任务创建时间"`
- TodoApproveTime time.Time `description:"任务审批时间"`
- TryStage int `description:"试用客户子标签:1未分类、2 推进、3 跟踪、4 预备"`
- IsShare int `description:"0:非共享用户,1:共享客户"`
- ShareSeller string `description:"共享销售员"`
- ShareSellerId int `description:"共享销售员id"`
- }
- // GetCompanyProductItemByCompanyId
- // @Description: 根据客户ID获取客户产品列表
- // @author: Roc
- // @datetime 2023-12-07 11:06:58
- // @param companyIdList []int
- // @param productId int
- // @return items []*CompanyProductItem
- // @return err error
- func GetCompanyProductItemByCompanyId(companyId int, productId int) (items *CompanyProductItem, err error) {
- o := orm.NewOrm()
- sql := `SELECT a.* FROM company_product as a
- WHERE a.company_id = ? AND a.product_id = ? `
- _, err = o.Raw(sql, companyId, productId).QueryRows(&items)
- return
- }
- // 获取权益用户客户数量
- func GetCompanyProductRaiForeverCount(companyId int) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM company_product WHERE 1= 1 AND product_id = 2 AND status = '永续' AND company_id = ? `
- o := orm.NewOrm()
- err = o.Raw(sqlCount, companyId).QueryRow(&count)
- return
- }
- // 获取列表
- func GetCompanyProductList(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM company_product WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // 合同未到期更新对应销售的信息
- func UpdateCompanyProductSellerUnexpired(sellerId, shareSellerInit int, sellerName, shareSeller string, companyId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE company_product SET
- seller_id_last = ? ,
- seller_name_last = ? ,
- share_seller_id_last = ? ,
- share_seller_last = ? WHERE company_id = ? AND product_id= 2 `
- _, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, companyId).Exec()
- return
- }
|