|
@@ -1,11 +1,28 @@
|
|
|
package overseas_custom
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
+ "hongze/hongze_task/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type Custom struct {
|
|
|
+ CompanyId int `description:"客户id"`
|
|
|
+ CompanyName string `description:"客户名称"`
|
|
|
+ Nation string `description:"国家"`
|
|
|
+ SellerId int `description:"销售id"`
|
|
|
+ SellerName string `description:"销售名称"`
|
|
|
+ CompanyStatus string `description:"状态"`
|
|
|
+ ViewTotal int `description:"累计点击量"`
|
|
|
+ RoadShowTotal int `description:"路演数量"`
|
|
|
+ LastViewTime string `description:"最近阅读时间"`
|
|
|
+ CreateTime string `description:"创建时间"`
|
|
|
+ IsHide int `description:"是否隐藏:0:不隐藏,1:隐藏"`
|
|
|
+ OverseasStatus string `description:"海外客户状态:'正式','试用','关闭'"`
|
|
|
+ Source int `description:"来源:1,英文客户,2:客户列表"`
|
|
|
+ OverseasLabel int `description:"海外客户试用子标签:1未分类、2 推进、3 跟踪、4 预备、"`
|
|
|
+ ResetBtn int `description:"转正式和重置按钮:同步过来默认为0:显示转正式为1:显示重置为2"`
|
|
|
}
|
|
|
|
|
|
type RsCompany struct {
|
|
@@ -82,3 +99,63 @@ func (obj *Custom) UpdateEnglishCompanyLastViewTime(companyId int, lastViewTime
|
|
|
_, err = o.Raw(sql, lastViewTime, companyId).Exec()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+type OverseasCompany struct {
|
|
|
+}
|
|
|
+
|
|
|
+// 获取客户路演数据
|
|
|
+func (obj *Custom) GetOverseasCompany() (list []*Custom, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := ``
|
|
|
+ var databaseName string
|
|
|
+ if utils.RunMode == "debug" {
|
|
|
+ databaseName = "test_v2_hongze_rddp"
|
|
|
+ } else {
|
|
|
+ databaseName = "hongze_rddp"
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = ` SELECT * FROM (
|
|
|
+ SELECT a.company_id,a.company_name,a.nation,b.seller_id,b.seller_name,
|
|
|
+ b.view_total,b.road_show_total,a.created_time AS create_time,b.last_view_time,a.is_hide,a.overseas_status,
|
|
|
+ 2 AS source,b.overseas_label,a.reset_btn,
|
|
|
+ CASE b.status
|
|
|
+ WHEN '正式' THEN '正式'
|
|
|
+ WHEN '永续' THEN '正式'
|
|
|
+ WHEN '试用' THEN '试用'
|
|
|
+ ELSE '关闭' END AS company_status
|
|
|
+ FROM company AS a
|
|
|
+ INNER JOIN company_product AS b ON a.company_id=b.company_id
|
|
|
+ INNER JOIN overseas_custom_seller AS c ON b.seller_id=c.seller_id
|
|
|
+ WHERE b.product_id=1 AND b.is_overseas = 0
|
|
|
+ UNION ALL
|
|
|
+ SELECT t.company_id+10000000,t.company_name,t.nation,t.seller_id,t.seller_name,
|
|
|
+ t.view_total,t.road_show_total,t.create_time,t.last_view_time,t.is_hide,t.overseas_status,
|
|
|
+ 1 AS source,t.overseas_label,t.reset_btn,
|
|
|
+ CASE t.enabled
|
|
|
+ WHEN 0 THEN '关闭'
|
|
|
+ ELSE '试用' END AS company_status
|
|
|
+ FROM %s.english_company AS t
|
|
|
+ INNER JOIN overseas_custom_seller AS n ON t.seller_id=n.seller_id
|
|
|
+ WHERE 1=1 AND t.is_deleted=0
|
|
|
+ )AS m WHERE 1=1
|
|
|
+ AND m.reset_btn=0
|
|
|
+ AND m.company_status<>m.overseas_status `
|
|
|
+
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (obj *Custom) UpdateEnglishCompanyOverseasStatus(companyId int, companyStatus string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ sql := ` UPDATE english_company SET overseas_status=? WHERE company_id=? `
|
|
|
+ _, err = o.Raw(sql, companyStatus, companyId).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (obj *Custom) UpdateCompanyOverseasStatus(companyId int, companyStatus string) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := ` UPDATE company SET overseas_status=? WHERE company_id=? `
|
|
|
+ _, err = o.Raw(sql, companyStatus, companyId).Exec()
|
|
|
+ return
|
|
|
+}
|