Browse Source

路演-英文客户

hsun 2 years ago
parent
commit
eaa257b99c

+ 78 - 24
controllers/roadshow/calendar.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_mobile_admin/models"
 	"hongze/hongze_mobile_admin/models/roadshow"
 	"hongze/hongze_mobile_admin/models/tables/admin"
+	"hongze/hongze_mobile_admin/models/tables/english_company"
 	"hongze/hongze_mobile_admin/services"
 	"hongze/hongze_mobile_admin/services/rs"
 	"hongze/hongze_mobile_admin/utils"
@@ -16,7 +17,7 @@ import (
 	"time"
 )
 
-//日历
+// 日历
 type CalendarController struct {
 	controllers.BaseAuth
 }
@@ -179,6 +180,7 @@ func (this *CalendarController) Add() {
 	rsCalendar.ModifyTime = time.Now()
 	rsCalendar.ActivityCategory = req.ActivityCategory
 	rsCalendar.Source = 0
+	rsCalendar.EnglishCompany = req.EnglishCompany
 	rsCalendar.Title = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
 	rsCalendarId, err := roadshow.AddRsCalendar(rsCalendar)
 	if err != nil {
@@ -335,6 +337,38 @@ func (this *CalendarController) CalendarList() {
 		this.FailWithMessage("获取信息失败!", "获取数据失败,GetCalendarList,Err:"+err.Error())
 		return
 	}
+
+	// 英文客户的国家以及点击量
+	englishIds := make([]int, 0)
+	for i := range dataList {
+		if dataList[i].EnglishCompany == 1 {
+			englishIds = append(englishIds, dataList[i].CompanyId)
+		}
+	}
+	englishMap := make(map[int]*english_company.EnglishCompany)
+	if len(englishIds) > 0 {
+		englishCond := ` AND company_id IN (` + utils.GetOrmInReplace(len(englishIds)) + `)`
+		englishPars := make([]interface{}, 0)
+		englishPars = append(englishPars, englishIds)
+		englishList, e := english_company.GetEnglishCompanyList(englishCond, englishPars, "")
+		if e != nil {
+			this.FailWithMessage("获取英文客户失败!", "获取英文客户失败, Err:"+err.Error())
+			return
+		}
+		for i := range englishList {
+			englishMap[englishList[i].CompanyId] = englishList[i]
+		}
+	}
+	for i := range dataList {
+		if dataList[i].EnglishCompany == 1 {
+			en := englishMap[dataList[i].CompanyId]
+			if en != nil {
+				dataList[i].EnglishCountry = en.Country
+				dataList[i].EnglishViewTotal = en.ViewTotal
+			}
+		}
+	}
+
 	resp.Paging = page
 	resp.List = dataList
 	this.OkDetailed(resp, "获取成功")
@@ -595,31 +629,49 @@ func (this *CalendarController) CalendarDetail() {
 	}
 
 	companyDetailView := new(roadshow.CompanyDetailView)
+
 	if calendarItem != nil && calendarItem.CompanyId > 0 {
-		companyId := calendarItem.CompanyId
-		companyProductItem, err := models.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
-		if err != nil {
-			this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
-			return
-		}
-		permissionList, err := models.GetCompanyProductReportPermissionList(companyId, 1)
-		if err != nil {
-			this.FailWithMessage("搜索客户权限失败", "搜索客户权限失败!GetRsCalendarResearcherById:"+err.Error())
-			return
-		}
-		var permissionArr []string
-		for _, v := range permissionList {
-			permissionArr = append(permissionArr, v.PermissionName)
-		}
+		// 中文客户
+		if calendarItem.EnglishCompany == 0 {
+			companyId := calendarItem.CompanyId
+			companyProductItem, err := models.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
+			if err != nil {
+				this.FailWithMessage("获取数据失败", "获取数据失败!GetRsCalendarResearcherById:"+err.Error())
+				return
+			}
+			permissionList, err := models.GetCompanyProductReportPermissionList(companyId, 1)
+			if err != nil {
+				this.FailWithMessage("搜索客户权限失败", "搜索客户权限失败!GetRsCalendarResearcherById:"+err.Error())
+				return
+			}
+			var permissionArr []string
+			for _, v := range permissionList {
+				permissionArr = append(permissionArr, v.PermissionName)
+			}
 
-		readNum := companyProductItem.ViewTotal
-		companyDetailView.CompanyId = companyProductItem.CompanyId
-		companyDetailView.CompanyName = companyProductItem.CompanyName
-		companyDetailView.Status = companyProductItem.Status
-		companyDetailView.IndustryId = companyProductItem.IndustryId
-		companyDetailView.IndustryName = companyProductItem.IndustryName
-		companyDetailView.PermissionName = strings.Join(permissionArr, "/")
-		companyDetailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
+			readNum := companyProductItem.ViewTotal
+			companyDetailView.CompanyId = companyProductItem.CompanyId
+			companyDetailView.CompanyName = companyProductItem.CompanyName
+			companyDetailView.Status = companyProductItem.Status
+			companyDetailView.IndustryId = companyProductItem.IndustryId
+			companyDetailView.IndustryName = companyProductItem.IndustryName
+			companyDetailView.PermissionName = strings.Join(permissionArr, "/")
+			companyDetailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
+		}
+		// 英文客户
+		if calendarItem.EnglishCompany == 1 {
+			enItem, e := english_company.GetEnglishCompanyById(calendarItem.CompanyId)
+			if e != nil {
+				this.FailWithMessage("搜索客户失败!", "获取英文客户详情失败, Err: "+e.Error())
+				return
+			}
+			companyDetailView.CompanyId = enItem.CompanyId
+			companyDetailView.CompanyName = enItem.CompanyName
+			companyDetailView.Status = "正常"
+			companyDetailView.EnglishCompany = 1
+			companyDetailView.EnglishCountry = enItem.Country
+			companyDetailView.EnglishViewTotal = enItem.ViewTotal
+		}
 	}
 
 	resp := new(roadshow.CalendarDetailResp)
@@ -1270,6 +1322,8 @@ func (this *CalendarController) Edit() {
 		calendarUpdateParams["city"] = req.City
 	}
 
+	calendarUpdateParams["english_company"] = req.EnglishCompany
+
 	calendarUpdateParams["modify_time"] = time.Now()
 	calendarUpdateParams["title"] = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
 	err = roadshow.UpdateRsCalendar(calendarWhereParams, calendarUpdateParams)

+ 52 - 31
controllers/roadshow/company.go

@@ -2,6 +2,7 @@ package roadshow
 
 import (
 	"hongze/hongze_mobile_admin/models/roadshow"
+	"hongze/hongze_mobile_admin/models/tables/english_company"
 	"hongze/hongze_mobile_admin/services"
 	"hongze/hongze_mobile_admin/utils"
 	"strconv"
@@ -25,7 +26,8 @@ func (this *CalendarController) CompanySearch() {
 		this.FailWithMessage("请输入搜索词!", "请输入搜索词!")
 		return
 	}
-	list, err := roadshow.CompanySearch(sysUser.AdminId, KeyWord)
+	KeyWord = "%" + KeyWord + "%"
+	list, err := roadshow.CompanySearchV2(sysUser.AdminId, KeyWord)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error())
 		return
@@ -36,9 +38,11 @@ func (this *CalendarController) CompanySearch() {
 	this.OkDetailed(list, "获取成功")
 }
 
+// CompanyDetail
 // @Title 我的日历列表
 // @Description 我的日历列表接口
 // @Param   CompanyId   query   int  true       "公司id"
+// @Param   EnglishCompany   query   int  true       "是否为英文客户"
 // @Success 200 {object} rs.CompanyDetailView
 // @router /company/detail [get]
 func (this *CalendarController) CompanyDetail() {
@@ -52,38 +56,55 @@ func (this *CalendarController) CompanyDetail() {
 		this.FailWithMessage("参数错误!", "参数错误!")
 		return
 	}
-	companyProductItem, err := roadshow.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
-	if err != nil {
-		this.FailWithMessage("搜索客户失败!",  "搜索客户失败!Err:" + err.Error())
-		return
-	}
-	permissionList, err := roadshow.GetCompanyProductReportPermissionList(companyId, 1)
-	if err != nil {
-		this.FailWithMessage("搜索客户权限失败!",  "搜索客户权限失败!Err:" + err.Error())
-		return
-	}
-	var permissionArr []string
-	for _, v := range permissionList {
-		permissionArr = append(permissionArr, v.PermissionName)
-	}
-	readMap, err := services.GetFiccCountUserViewHistoryByCompanyIds(strconv.Itoa(companyId))
-	if err != nil {
-		this.FailWithMessage("获取阅读次数失败!",  "获取阅读次数失败!Err:" + err.Error())
+	englishCompany, _ := this.GetInt("EnglishCompany")
+
+	detailView := new(roadshow.CompanyDetailView)
+	if englishCompany == 0 {
+		companyProductItem, err := roadshow.GetCompanyProductByCompanyIdAndProductId(companyId, 1)
+		if err != nil {
+			this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error())
+			return
+		}
+		permissionList, err := roadshow.GetCompanyProductReportPermissionList(companyId, 1)
+		if err != nil {
+			this.FailWithMessage("搜索客户权限失败!", "搜索客户权限失败!Err:"+err.Error())
+			return
+		}
+		var permissionArr []string
+		for _, v := range permissionList {
+			permissionArr = append(permissionArr, v.PermissionName)
+		}
+		readMap, err := services.GetFiccCountUserViewHistoryByCompanyIds(strconv.Itoa(companyId))
+		if err != nil {
+			this.FailWithMessage("获取阅读次数失败!", "获取阅读次数失败!Err:"+err.Error())
+			return
+		}
+		readNum, ok := readMap[companyId]
+		if !ok {
+			readNum = 0
+		}
+		detailView.CompanyId = companyProductItem.CompanyId
+		detailView.CompanyName = companyProductItem.CompanyName
+		detailView.Status = companyProductItem.Status
+		detailView.IndustryId = companyProductItem.IndustryId
+		detailView.IndustryName = companyProductItem.IndustryName
+		detailView.PermissionName = strings.Join(permissionArr, "/")
+		detailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
+		this.OkDetailed(detailView, "获取成功")
 		return
 	}
 
-	readNum, ok := readMap[companyId]
-	if !ok {
-		readNum = 0
+	// 英文客户
+	enItem, e := english_company.GetEnglishCompanyById(companyId)
+	if e != nil {
+		this.FailWithMessage("搜索客户失败!", "获取英文客户详情失败, Err: "+e.Error())
+		return
 	}
-
-	detailView := new(roadshow.CompanyDetailView)
-	detailView.CompanyId = companyProductItem.CompanyId
-	detailView.CompanyName = companyProductItem.CompanyName
-	detailView.Status = companyProductItem.Status
-	detailView.IndustryId = companyProductItem.IndustryId
-	detailView.IndustryName = companyProductItem.IndustryName
-	detailView.PermissionName = strings.Join(permissionArr, "/")
-	detailView.ReportReadTotal = readNum //ficc报告-累计阅读次数
+	detailView.CompanyId = enItem.CompanyId
+	detailView.CompanyName = enItem.CompanyName
+	detailView.Status = "正常"
+	detailView.EnglishCompany = 1
+	detailView.EnglishCountry = enItem.Country
+	detailView.EnglishViewTotal = enItem.ViewTotal
 	this.OkDetailed(detailView, "获取成功")
-}
+}

+ 2 - 0
models/db_init.go

@@ -30,6 +30,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/contract_service_detail"
 	"hongze/hongze_mobile_admin/models/tables/contract_service_template"
 	"hongze/hongze_mobile_admin/models/tables/contract_template"
+	"hongze/hongze_mobile_admin/models/tables/english_company"
 	"hongze/hongze_mobile_admin/models/tables/h5_admin_session"
 	"hongze/hongze_mobile_admin/models/tables/report"
 	"hongze/hongze_mobile_admin/models/tables/research_variety_tag_relation"
@@ -111,6 +112,7 @@ func init() {
 		new(chart_permission.ChartPermission),                                 // 品种权限表
 		new(company_product_try_out_update_log.CompanyProductTryOutUpdateLog), //客户产品试用变更状态表
 		new(company_product_try_out_update_permission_log.CompanyProductTryOutUpdatePermissionLog), //客户产品试用变更品种详情表
+		new(english_company.EnglishCompany), // 英文客户表
 	)
 
 	// 社区问答相关

+ 10 - 3
models/roadshow/calendar.go

@@ -21,6 +21,7 @@ type AddActivityReq struct {
 	CooperationName  string `description:"合作方名称"`
 	ActivityCategory string `description:"活动类别"`
 	ResearcherList   []*CalendarResearcher
+	EnglishCompany   int `description:"是否为英文客户"`
 }
 
 type CalendarResearcher struct {
@@ -55,6 +56,8 @@ type RsCalendar struct {
 	ModifyTime       time.Time
 	ActivityCategory string `description:"活动类别"`
 	IsSynced         int    `description:"是否与上海同步 0:未同步 1:已同步"`
+	UnionCode        string `description:"公开会议联合编码"`
+	EnglishCompany   int    `description:"是否为英文客户: 0-否; 1-是"`
 }
 
 type RsCalendarResearcher struct {
@@ -156,6 +159,9 @@ type CalendarListView struct {
 	ActivityCategory       string    `description:"活动类别"`
 	Source                 int       `description:"来源,0:自系统,1:上海方的"`
 	Title                  string    `description:"活动标题"`
+	EnglishCompany         int       `description:"是否为英文客户: 0-否; 1-是"`
+	EnglishCountry         string    `description:"英文客户-国家"`
+	EnglishViewTotal       int       `description:"英文客户-累计点击量"`
 }
 
 type CalendarListResp struct {
@@ -391,6 +397,7 @@ type EditActivityReq struct {
 	CooperationName        string `description:"合作方名称"`
 	ActivityCategory       string `description:"活动类别"`
 	ResearcherList         []*CalendarResearcher
+	EnglishCompany         int `description:"是否为英文客户"`
 }
 
 // GetRsCalendarResearcherListByRsCalendarId 根据路演id获取路演研究员列表
@@ -420,21 +427,21 @@ func GetMattersById(rsMatters int) (item *RsMatters, err error) {
 	return
 }
 
-//添加RsCalendarResearcher
+// 添加RsCalendarResearcher
 func AddRsMatters(item *RsMatters) (id int64, err error) {
 	o := orm.NewOrm()
 	id, err = o.Insert(item)
 	return
 }
 
-//添加RsCalendar
+// 添加RsCalendar
 func AddRsCalendar(item *RsCalendar) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//添加RsCalendarResearcher
+// 添加RsCalendarResearcher
 func AddRsCalendarResearcher(item *RsCalendarResearcher) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)

+ 50 - 13
models/roadshow/company.go

@@ -1,15 +1,18 @@
 package roadshow
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mobile_admin/utils"
 	"time"
 )
 
 type CompanySearchView struct {
-	CompanyId   int    `orm:"column(company_id);pk"`
-	CompanyName string `description:"客户名称"`
-	CreditCode  string `description:"社会统一信用码"`
-	CompanyCode string `description:"客户编码"`
+	CompanyId      int    `orm:"column(company_id);pk"`
+	CompanyName    string `description:"客户名称"`
+	CreditCode     string `description:"社会统一信用码"`
+	CompanyCode    string `description:"客户编码"`
+	EnglishCompany int    `description:"是否为英文客户"`
 }
 
 func CompanySearch(sellerId int, keyWord string) (list []*CompanySearchView, err error) {
@@ -26,13 +29,16 @@ func CompanySearch(sellerId int, keyWord string) (list []*CompanySearchView, err
 }
 
 type CompanyDetailView struct {
-	CompanyId       int    `orm:"column(company_id);pk"`
-	CompanyName     string `description:"客户名称"`
-	Status          string `description:"客户状态"`
-	IndustryId      int    `description:"行业id"`
-	IndustryName    string `description:"行业名称"`
-	PermissionName  string `description:"开通品种"`
-	ReportReadTotal int    `description:"累计阅读次数"`
+	CompanyId        int    `orm:"column(company_id);pk"`
+	CompanyName      string `description:"客户名称"`
+	Status           string `description:"客户状态"`
+	IndustryId       int    `description:"行业id"`
+	IndustryName     string `description:"行业名称"`
+	PermissionName   string `description:"开通品种"`
+	ReportReadTotal  int    `description:"累计阅读次数"`
+	EnglishCompany   int    `description:"是否为英文客户: 0-否; 1-是"`
+	EnglishCountry   string `description:"英文客户-国家"`
+	EnglishViewTotal int    `description:"英文客户-累计点击量"`
 }
 
 type CompanyProduct struct {
@@ -84,7 +90,7 @@ func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *C
 	return
 }
 
-//客户授权产品结构体(包含产品名称)
+// 客户授权产品结构体(包含产品名称)
 type CompanyReportPermissionAndName struct {
 	CompanyReportPermissionId int `description:"客户授权产品id"`
 	CompanyId                 int
@@ -103,10 +109,41 @@ type CompanyReportPermissionAndName struct {
 	ModifyTime                time.Time `description:"修改时间"`
 }
 
-//根据企业用户id和产品id获取所有正式的权限
+// 根据企业用户id和产品id获取所有正式的权限
 func GetCompanyProductReportPermissionList(companyId, productId int) (items []*CompanyReportPermissionAndName, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT a.*,b.permission_name,b.classify_name FROM company_report_permission a left join chart_permission b on a.chart_permission_id=b.chart_permission_id WHERE a.company_id = ? and a.product_id=? `
 	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
 	return
 }
+
+func CompanySearchV2(sellerId int, keyWord string) (list []*CompanySearchView, err error) {
+	o := orm.NewOrm()
+	rddp := `hongze_rddp`
+	if utils.RunMode == "debug" {
+		rddp = `test_v2_hongze_rddp`
+	}
+	sql := `SELECT
+				b.company_id,
+				b.company_name,
+				0 AS english_company
+			FROM
+				company AS a
+			INNER JOIN company_product AS b ON a.company_id = b.company_id
+			WHERE
+				b.status IN ('正式', '试用') AND b.seller_id = ? AND b.company_name LIKE ?
+			GROUP BY
+				b.company_id
+			UNION
+				SELECT
+					company_id,
+					company_name,
+					1
+				FROM
+					%s.english_company
+				WHERE
+					is_deleted = 0 AND company_name LIKE ?`
+	sql = fmt.Sprintf(sql, rddp)
+	_, err = o.Raw(sql, sellerId, keyWord, keyWord).QueryRows(&list)
+	return
+}

+ 214 - 0
models/tables/english_company/english_company.go

@@ -0,0 +1,214 @@
+package english_company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+// EnglishCompany 英文客户
+type EnglishCompany struct {
+	CompanyId   int       `orm:"column(company_id);pk" description:"英文客户ID"`
+	CompanyName string    `description:"客户名称"`
+	CountryCode string    `description:"国家Code"`
+	Country     string    `description:"国家"`
+	SellerId    int       `description:"销售ID"`
+	SellerName  string    `description:"销售姓名"`
+	ViewTotal   int       `description:"累计点击量/阅读量"`
+	IsDeleted   int       `description:"删除状态:0-正常;1-已删除"`
+	CreateTime  time.Time `description:"创建时间"`
+	ModifyTime  time.Time `description:"更新时间"`
+}
+
+type EnglishCompanyListItem struct {
+	EnglishCompany
+	TodoStatusStr string
+	TodoEndTime   time.Time
+	TodoSellerId  int
+}
+
+func (item *EnglishCompany) TableName() string {
+	return "english_company"
+}
+
+func (item *EnglishCompany) Create() (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	id, err := o.Insert(item)
+	if err != nil {
+		return
+	}
+	item.CompanyId = int(id)
+	return
+}
+
+// EnglishCompanySaveReq 英文客户-保存请求体
+type EnglishCompanySaveReq struct {
+	CompanyId   int    `description:"客户ID"`
+	CompanyName string `description:"客户名称"`
+	CountryCode string `description:"国家代码"`
+	Country     string `description:"国家"`
+	SellerId    int    `description:"销售ID"`
+}
+
+func (item *EnglishCompany) Update(cols []string) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	_, err = o.Update(item, cols...)
+	return
+}
+
+// GetEnglishCompanyById 主键获取客户
+func GetEnglishCompanyById(id int) (item *EnglishCompany, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_id = ? LIMIT 1`
+	err = o.Raw(sql, id).QueryRow(&item)
+	return
+}
+
+// GetEnglishCompanyByName 名称获取客户
+func GetEnglishCompanyByName(companyName string) (item *EnglishCompany, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_name = ? LIMIT 1`
+	err = o.Raw(sql, companyName).QueryRow(&item)
+	return
+}
+
+// EnglishCompanyDelReq 英文客户-删除请求体
+type EnglishCompanyDelReq struct {
+	CompanyId int `description:"客户ID"`
+}
+
+// DeleteEnglishCompanyAndEmails 删除英文客户及联系人
+func DeleteEnglishCompanyAndEmails(companyId int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	tx, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = tx.Rollback()
+		} else {
+			_ = tx.Commit()
+		}
+	}()
+
+	// 删除客户
+	sql := `UPDATE english_company SET is_deleted = 1,modify_time = NOW() WHERE company_id = ? LIMIT 1`
+	_, err = tx.Raw(sql, companyId).Exec()
+	if err != nil {
+		return
+	}
+
+	// 删除联系人
+	sql = `UPDATE english_report_email SET is_deleted = 1,modify_time = NOW() WHERE company_id = ?`
+	_, err = tx.Raw(sql, companyId).Exec()
+	return
+}
+
+// EnglishCompanyPageListResp 英文客户-分页列表响应体
+type EnglishCompanyPageListResp struct {
+	List   []*EnglishCompanyResp
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+// EnglishCompanyResp 英文客户-列表响应体
+type EnglishCompanyResp struct {
+	CompanyId   int                     `description:"客户ID"`
+	CompanyName string                  `description:"客户名称"`
+	CountryCode string                  `description:"国家代码"`
+	Country     string                  `description:"国家"`
+	SellerId    int                     `description:"销售ID"`
+	SellerName  string                  `description:"销售姓名"`
+	ViewTotal   int                     `description:"累计点击量"`
+	CreateTime  string                  `description:"创建时间"`
+	TodoInfo    *EnglishCompanyListTodo `description:"TODO任务信息"`
+}
+
+// EnglishCompanyListTodo 英文客户列表-TODO任务信息
+type EnglishCompanyListTodo struct {
+	Deadline       string `description:"未完成的todo任务的截止日期,截止目前还剩余的天数"`
+	TodoEndTimeStr string `description:"未完成的todo任务的截止日期拼接格式"`
+	//TodoEndTime     time.Time `description:"未完成的todo任务的截止日期"`
+	TodoStatus      bool   `description:"是否存在进行中任务"`
+	CanConfirm      bool   `description:"是否允许完成任务"`
+	HiddenConfirm   bool   `description:"是否隐藏完成任务按钮"`
+	HiddenCreate    bool   `description:"是否隐藏新增/编辑按钮"`
+	TodoButtonColor string `description:"任务按钮颜色: red; green; gray"`
+}
+
+// GetEnglishCompanyPageList 获取客户列表-分页
+func GetEnglishCompanyPageList(condition string, pars []interface{}, order string, startSize, pageSize int) (total int, list []*EnglishCompanyListItem, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT
+	c.*,
+IF
+	( ct.status IS NULL, "无任务", ct.status ) AS todo_status_str,
+	ct.seller_id as todo_seller_id,
+IF
+	( ct.end_time IS NULL or ct.status !="进行中", "9999-01-01", ct.end_time) AS todo_end_time
+FROM
+	english_company AS c
+	LEFT JOIN (
+SELECT
+	b.* 
+FROM
+	(
+SELECT
+	company_id,
+	MAX( create_time ) AS ct 
+FROM
+	english_company_todo 
+WHERE
+	is_delete = 0 
+	AND STATUS != "已作废"
+GROUP BY
+	company_id 
+	) AS a
+	LEFT JOIN english_company_todo AS b ON b.company_id = a.company_id 
+	AND b.create_time = a.ct 
+	) AS ct ON c.company_id = ct.company_id 
+WHERE
+	c.is_deleted = 0`
+	sql += condition
+	if order != "" {
+		sql += order
+	} else {
+		sql += ` ORDER BY c.create_time DESC`
+	}
+	totalSQl := `SELECT COUNT(1) total FROM (` + sql + `) z`
+	if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
+		return
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// GetEnglishCompanyViewPageListResp 英文客户-点击量分页列表响应体
+type GetEnglishCompanyViewPageListResp struct {
+	List   []*EnglishCompanyViewResp
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+// EnglishCompanyViewResp 英文客户-点击量响应体
+type EnglishCompanyViewResp struct {
+	EmailId      int    `description:"联系人ID"`
+	UserName     string `description:"联系人姓名"`
+	Email        string `description:"邮箱地址"`
+	ViewTotal    int    `description:"累计点击量"`
+	LastViewTime string `description:"创建时间"`
+}
+
+// GetEnglishCompanyList 获取英文客户列表
+func GetEnglishCompanyList(condition string, pars []interface{}, order string) (list []*EnglishCompany, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM english_company WHERE is_deleted = 0 `
+	sql += condition
+	if order != "" {
+		sql += order
+	} else {
+		sql += ` ORDER BY create_time DESC`
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+	return
+}