|
@@ -146,72 +146,73 @@ func GetCompanySearchCount(condition string, pars []interface{}) (count int, err
|
|
|
}
|
|
|
|
|
|
type CompanyItem struct {
|
|
|
- CompanyId int `orm:"column(company_id);pk"`
|
|
|
- CompanyName string `description:"客户名称"`
|
|
|
- CreditCode string `description:"社会统一信用码"`
|
|
|
- CompanyCode string `description:"客户编码"`
|
|
|
- StartDate string `description:"合同开始日期"`
|
|
|
- EndDate string `description:"合同结束日期"`
|
|
|
- LoseReason string `description:"流失原因"`
|
|
|
- RenewalReason string `description:"续约说明"`
|
|
|
- FreezeReason string `description:"冻结理由"`
|
|
|
- LossTime string `description:"流失时间"`
|
|
|
- Status string `description:"客户状态:'试用','永续','冻结','流失','正式' "`
|
|
|
- CompanyType string `description:"客户类型:ficc/权益"`
|
|
|
- ApproveStatus string `description:"审批状态:'待审批','已审批','驳回' 审批状态为空时,表示没有审批申请"`
|
|
|
- SellerName string `description:"销售:吉根龙/颖丹"`
|
|
|
- SellerId int `description:"销售ID"`
|
|
|
- SellerIds string `description:"销售ID集合,包含ficc和权益的销售id"`
|
|
|
- ShareSeller string `description:"共享销售员"`
|
|
|
- ShareSellerId int `description:"共享销售员id"`
|
|
|
- PackageTypes string `description:"套餐类型集合,包含ficc和权益的套餐类型" json:"-"`
|
|
|
- FiccPackageType int `description:"ficc的套餐类型"`
|
|
|
- ExpireDay string `description:"到期天数"`
|
|
|
- FreezeTime string `description:"冻结时间"`
|
|
|
- GroupId int `description:"分组id"`
|
|
|
- GroupIds string `description:"分组id集合,包含ficc和权益的小组id" json:"-"`
|
|
|
- DepartmentId int `description:"部门id"`
|
|
|
- IndustryName string `description:"所属行业"`
|
|
|
- IsSuspend int `description:"是否暂停:1:暂停,0:启用 "`
|
|
|
- CreatedTime string `description:"创建时间"`
|
|
|
- Source string `description:"客户来源"`
|
|
|
- Province string `description:"省"`
|
|
|
- City string `description:"市"`
|
|
|
- Address string `description:"详细地址"`
|
|
|
- Reasons string `description:"新增理由"`
|
|
|
- FreezeStartDate string `description:"冻结开始日期"`
|
|
|
- FreezeEndDate string `description:"冻结结束日期"`
|
|
|
- FreezeExpireDays int `description:"冻结到期天数"`
|
|
|
- BtnItem *ButtonPermission
|
|
|
- ProductId int `json:"-"`
|
|
|
- ProductIds string `description:"产品id集合,包含ficc和权益的产品id" json:"-"`
|
|
|
- FormalTime string `description:"转正时间"`
|
|
|
- IsShared bool `description:"是否共享客户"`
|
|
|
- RegionType string `description:"区域:国内,海外"`
|
|
|
- FiccLastViewTime string `description:"ficc最近一次阅读时间"`
|
|
|
- RaiLastViewTime string `description:"权益最近一次阅读时间"`
|
|
|
- ViewTotals string `description:"阅读次数集合,包含ficc和权益的阅读次数" json:"-"`
|
|
|
- LastViewTimes string `description:"最近一次阅读时间集合,包含ficc和权益的最近一次阅读时间" json:"-"`
|
|
|
- FiccView int `description:"Ficc报告阅读次数" json:"-"`
|
|
|
- RaiView int `description:"权益报告阅读次数" json:"-"`
|
|
|
- RoadShowTotal int `description:"累计路演次数"`
|
|
|
- TodoStatuss string `description:"任务状态"`
|
|
|
- TryStageStr string `description:"试用客户子标签"`
|
|
|
- TryStageSlice []*TryStageSliceItem `description:"试用状态相关"`
|
|
|
- AllViewTotal int `description:"总阅读数"`
|
|
|
- Deadline string `description:"未完成的todo任务的截止日期,截止目前还剩余的天数"`
|
|
|
- TodoEndTimeStr string `description:"未完成的todo任务的截止日期拼接格式"`
|
|
|
- TodoEndTime time.Time `description:"未完成的todo任务的截止日期"`
|
|
|
- TryOutDayTotals string `description:"试用天数集合,包含ficc和权益的试用天数" json:"-"`
|
|
|
- FiccTryOutDay int `description:"Ficc试用天数" json:"-"`
|
|
|
- RaiTryOutDay int `description:"权益试用天数" json:"-"`
|
|
|
- WeekViewActive int `description:"周阅读活跃: 0-七日内无阅读; 1-活跃"`
|
|
|
- IsShare int `description:"0:非共享用户,1:共享客户"`
|
|
|
- LastServiceTime string `description:"最后服务时间"`
|
|
|
- ServiceTimes int `description:"服务次数"`
|
|
|
- CloseReason string `description:"关闭原因"`
|
|
|
- CloseTime string `description:"关闭时间"`
|
|
|
- Nation string `description:"所属国家"`
|
|
|
+ CompanyId int `orm:"column(company_id);pk"`
|
|
|
+ CompanyName string `description:"客户名称"`
|
|
|
+ CreditCode string `description:"社会统一信用码"`
|
|
|
+ CompanyCode string `description:"客户编码"`
|
|
|
+ StartDate string `description:"合同开始日期"`
|
|
|
+ EndDate string `description:"合同结束日期"`
|
|
|
+ LoseReason string `description:"流失原因"`
|
|
|
+ RenewalReason string `description:"续约说明"`
|
|
|
+ FreezeReason string `description:"冻结理由"`
|
|
|
+ LossTime string `description:"流失时间"`
|
|
|
+ Status string `description:"客户状态:'试用','永续','冻结','流失','正式' "`
|
|
|
+ CompanyType string `description:"客户类型:ficc/权益"`
|
|
|
+ ApproveStatus string `description:"审批状态:'待审批','已审批','驳回' 审批状态为空时,表示没有审批申请"`
|
|
|
+ SellerName string `description:"销售:吉根龙/颖丹"`
|
|
|
+ SellerId int `description:"销售ID"`
|
|
|
+ SellerIds string `description:"销售ID集合,包含ficc和权益的销售id"`
|
|
|
+ ShareSeller string `description:"共享销售员"`
|
|
|
+ ShareSellerId int `description:"共享销售员id"`
|
|
|
+ PackageTypes string `description:"套餐类型集合,包含ficc和权益的套餐类型" json:"-"`
|
|
|
+ FiccPackageType int `description:"ficc的套餐类型"`
|
|
|
+ ExpireDay string `description:"到期天数"`
|
|
|
+ FreezeTime string `description:"冻结时间"`
|
|
|
+ GroupId int `description:"分组id"`
|
|
|
+ GroupIds string `description:"分组id集合,包含ficc和权益的小组id" json:"-"`
|
|
|
+ DepartmentId int `description:"部门id"`
|
|
|
+ IndustryName string `description:"所属行业"`
|
|
|
+ IsSuspend int `description:"是否暂停:1:暂停,0:启用 "`
|
|
|
+ CreatedTime string `description:"创建时间"`
|
|
|
+ Source string `description:"客户来源"`
|
|
|
+ Province string `description:"省"`
|
|
|
+ City string `description:"市"`
|
|
|
+ Address string `description:"详细地址"`
|
|
|
+ Reasons string `description:"新增理由"`
|
|
|
+ FreezeStartDate string `description:"冻结开始日期"`
|
|
|
+ FreezeEndDate string `description:"冻结结束日期"`
|
|
|
+ FreezeExpireDays int `description:"冻结到期天数"`
|
|
|
+ BtnItem *ButtonPermission
|
|
|
+ ProductId int `json:"-"`
|
|
|
+ ProductIds string `description:"产品id集合,包含ficc和权益的产品id" json:"-"`
|
|
|
+ FormalTime string `description:"转正时间"`
|
|
|
+ IsShared bool `description:"是否共享客户"`
|
|
|
+ RegionType string `description:"区域:国内,海外"`
|
|
|
+ FiccLastViewTime string `description:"ficc最近一次阅读时间"`
|
|
|
+ RaiLastViewTime string `description:"权益最近一次阅读时间"`
|
|
|
+ ViewTotals string `description:"阅读次数集合,包含ficc和权益的阅读次数" json:"-"`
|
|
|
+ LastViewTimes string `description:"最近一次阅读时间集合,包含ficc和权益的最近一次阅读时间" json:"-"`
|
|
|
+ FiccView int `description:"Ficc报告阅读次数" json:"-"`
|
|
|
+ RaiView int `description:"权益报告阅读次数" json:"-"`
|
|
|
+ RoadShowTotal int `description:"累计路演次数"`
|
|
|
+ TodoStatuss string `description:"任务状态"`
|
|
|
+ TryStageStr string `description:"试用客户子标签"`
|
|
|
+ TryStageSlice []*TryStageSliceItem `description:"试用状态相关"`
|
|
|
+ AllViewTotal int `description:"总阅读数"`
|
|
|
+ Deadline string `description:"未完成的todo任务的截止日期,截止目前还剩余的天数"`
|
|
|
+ TodoEndTimeStr string `description:"未完成的todo任务的截止日期拼接格式"`
|
|
|
+ TodoEndTime time.Time `description:"未完成的todo任务的截止日期"`
|
|
|
+ TryOutDayTotals string `description:"试用天数集合,包含ficc和权益的试用天数" json:"-"`
|
|
|
+ FiccTryOutDay int `description:"Ficc试用天数" json:"-"`
|
|
|
+ RaiTryOutDay int `description:"权益试用天数" json:"-"`
|
|
|
+ WeekViewActive int `description:"周阅读活跃: 0-七日内无阅读; 1-活跃"`
|
|
|
+ IsShare int `description:"0:非共享用户,1:共享客户"`
|
|
|
+ LastServiceTime string `description:"最后服务时间"`
|
|
|
+ ServiceTimes int `description:"服务次数"`
|
|
|
+ CloseReason string `description:"关闭原因"`
|
|
|
+ CloseTime string `description:"关闭时间"`
|
|
|
+ Nation string `description:"所属国家"`
|
|
|
+ LatestServiceRecord time.Time `description:"最近沟通时间"`
|
|
|
}
|
|
|
|
|
|
type CompanyListItem struct {
|
|
@@ -316,7 +317,7 @@ func GetCompanyList(condition, status, sortStr string, pars []interface{}, start
|
|
|
// 权益客户: 以权益最后一次阅读时间作为参考
|
|
|
t := time.Now().Local().AddDate(0, 0, -7).Format(utils.FormatDate)
|
|
|
|
|
|
- sql := `SELECT a.company_id,a.company_name,a.credit_code,a.company_code,a.created_time,a.province,a.city,a.address,a.region_type,b.group_id,b.road_show_total,a.is_share,
|
|
|
+ sql := `SELECT a.company_id,a.company_name,a.credit_code,a.company_code,a.created_time,a.province,a.city,a.address,a.region_type,b.group_id,b.road_show_total,b.is_share,
|
|
|
CASE
|
|
|
WHEN GROUP_CONCAT(b.status) LIKE "%永续%" THEN 1
|
|
|
WHEN GROUP_CONCAT(b.status) LIKE "%正式%" THEN 2
|
|
@@ -368,8 +369,8 @@ as sort_todo_end_time,
|
|
|
b.freeze_time,b.freeze_reason,b.renewal_reason,
|
|
|
b.view_total,
|
|
|
b.last_view_time,
|
|
|
- a.share_seller,
|
|
|
- a.share_seller_id,
|
|
|
+ b.share_seller,
|
|
|
+ b.share_seller_id,
|
|
|
MAX(b.last_view_time) as max_last_view_time,
|
|
|
MIN(b.last_view_time) as min_last_view_time,
|
|
|
MAX(b.end_date) as max_end_date,
|
|
@@ -377,9 +378,15 @@ as sort_todo_end_time,
|
|
|
SUM(b.view_total) as all_view_total,
|
|
|
SUM(b.try_out_day_total) as all_try_out_day_total,
|
|
|
IF(LEFT(GROUP_CONCAT(DISTINCT b.last_view_time ORDER BY b.product_id), 19) >= "` + t + `", 1, 0) AS week_view_active,
|
|
|
- a.nation
|
|
|
+ a.nation,
|
|
|
+ c.latest_service_record
|
|
|
FROM company AS a
|
|
|
INNER JOIN company_product AS b ON a.company_id=b.company_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT company_id, MAX(create_time) AS latest_service_record
|
|
|
+ FROM company_service_record
|
|
|
+ GROUP BY company_id
|
|
|
+) AS c ON a.company_id = c.company_id
|
|
|
WHERE a.enabled=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -1726,7 +1733,7 @@ func GetShareCompanyList(condition, sortStr string, pars []interface{}, startSiz
|
|
|
t := time.Now().Local().AddDate(0, 0, -7).Format(utils.FormatDate)
|
|
|
|
|
|
sql := `SELECT a.company_id,a.company_name,a.credit_code,a.company_code,a.created_time,a.province,a.city,
|
|
|
-a.address,a.region_type,b.group_id,b.road_show_total,a.is_share,a.share_seller_id,a.share_seller,
|
|
|
+a.address,a.region_type,b.group_id,b.road_show_total,b.is_share,b.share_seller_id,b.share_seller,
|
|
|
CASE
|
|
|
WHEN GROUP_CONCAT(b.status) LIKE "%永续%" THEN 1
|
|
|
WHEN GROUP_CONCAT(b.status) LIKE "%正式%" THEN 2
|
|
@@ -1935,4 +1942,4 @@ func GetOverseasCompanys() (items []*Company, err error) {
|
|
|
sql := ` SELECT * FROM company where region_type= '海外' `
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
-}
|
|
|
+}
|