|
@@ -2,8 +2,8 @@ package service
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
P "app.yhyue.com/moapp/jybase/mapping"
|
|
|
+ "app.yhyue.com/moapp/jypkg/ent/util"
|
|
|
T "bp.jydev.jianyu360.cn/CRM/application/api/common"
|
|
|
"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
|
|
|
"context"
|
|
@@ -16,6 +16,7 @@ const (
|
|
|
sql_1 = `SELECT buyer_id, count(1) as count FROM information.transaction_info WHERE buyer_id in (%s) GROUP BY buyer_id`
|
|
|
sql_2 = `SELECT relate_id, is_handle, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND itype = 2`
|
|
|
sql_3 = `SELECT * FROM crm.connection WHERE company_id in (%s) AND status = 1`
|
|
|
+ sql_4 = `SELECT id, s_id FROM base_service.follow_project_monitor WHERE s_uerid = ?`
|
|
|
)
|
|
|
|
|
|
type ProjectData struct {
|
|
@@ -36,6 +37,7 @@ type ProjectEntry struct {
|
|
|
ZbTime int64 `ch:"zbtime"`
|
|
|
EndTime int64 `ch:"endtime"`
|
|
|
ProjectMoney decimal.Decimal `ch:"project_money"`
|
|
|
+ InfoId string `ch:"info_id"`
|
|
|
IsHandle int `json:"IsHandle"`
|
|
|
IsIgnore int `json:"IsIgnore"`
|
|
|
IsCreate int `json:"IsCreate"`
|
|
@@ -48,12 +50,13 @@ type ProjectEntry struct {
|
|
|
SourceType string `json:"SourceType"` // firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
|
|
|
Person string `json:"Person"`
|
|
|
Num string `json:"Num"`
|
|
|
+ FocusId string `json:"FocusId"`
|
|
|
}
|
|
|
|
|
|
func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasNextPage bool, total int) {
|
|
|
|
|
|
buyerM := BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency, req.PositionId)
|
|
|
- MonitorStatusInit(req.PositionId, buyerM, "0")
|
|
|
+ mmp := MonitorStatus(req.UserId) // 项目监控
|
|
|
buyerArr := make([]string, len(*buyerM))
|
|
|
for b := range *buyerM {
|
|
|
buyerArr = append(buyerArr, b)
|
|
@@ -73,11 +76,12 @@ func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasN
|
|
|
for rows.Next() {
|
|
|
project := ProjectEntry{}
|
|
|
_ = rows.ScanStruct(&project)
|
|
|
- project.ProjectId = encrypt.CommonEncodeArticle("content", project.ProjectId)
|
|
|
+ //project.ProjectId = encrypt.CommonEncodeArticle("content", project.ProjectId)
|
|
|
+ project.ProjectId = util.EncodeId(project.ProjectId)
|
|
|
resultList = append(resultList, &project)
|
|
|
}
|
|
|
|
|
|
- resultList = filterData(req, resultList, preSales, isSqlPage)
|
|
|
+ resultList = filterData(req, resultList, preSales, mmp, isSqlPage)
|
|
|
if !isSqlPage {
|
|
|
total = len(resultList)
|
|
|
if total > req.PageSize {
|
|
@@ -208,7 +212,7 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (cou
|
|
|
}
|
|
|
querys = append(querys, fmt.Sprintf(" a.property_form in (%s) ", strings.Join(arr, ",")))
|
|
|
}
|
|
|
- findSql = "select a.project_id, a.project_name, a.business_type, a.buyer, a.buyer_id, a.area, a.city, a.district, a.zbtime, a.endtime, a.project_money "
|
|
|
+ findSql = "select a.project_id, a.project_name, a.business_type, a.buyer, a.buyer_id, a.area, a.city, a.district, a.zbtime, a.endtime, a.project_money, a.info_id "
|
|
|
if len(querys) > 0 {
|
|
|
countSql = fmt.Sprintf("select count(1) from %s a where %s ", "information.transaction_info", strings.Join(querys, " and "))
|
|
|
findSql = fmt.Sprintf("%s from %s a where %s order by zbtime", findSql, "information.transaction_info", strings.Join(querys, " and "))
|
|
@@ -225,7 +229,7 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (cou
|
|
|
// @Author jianghan
|
|
|
// @Description 过滤数据/补充销售机会状态信息,返回分页结果数据
|
|
|
// @Date 2024/4/18
|
|
|
-func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales map[string]interface{}, isSqlPage bool) []*ProjectEntry {
|
|
|
+func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales, mmp map[string]interface{}, isSqlPage bool) []*ProjectEntry {
|
|
|
var newList []*ProjectEntry
|
|
|
f := make(map[string]int, 3)
|
|
|
if strings.Contains(req.SaleStatus, "1") {
|
|
@@ -237,10 +241,16 @@ func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales
|
|
|
}
|
|
|
for _, m := range resultList {
|
|
|
if m1, ok := preSales[m.ProjectId].(map[string]interface{}); ok {
|
|
|
- m.IsHandle = common.IntAll(m1["is_handle"])
|
|
|
m.IsIgnore = common.IntAll(m1["is_ignore"])
|
|
|
m.IsCreate = common.IntAll(m1["is_create"])
|
|
|
}
|
|
|
+ for _, s := range strings.Split(m.InfoId, ",") {
|
|
|
+ if mmp[s] != nil {
|
|
|
+ m.IsHandle = 1
|
|
|
+ m.FocusId = common.ObjToString(mmp[s])
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
if !isSqlPage {
|
|
|
for k, v := range f {
|
|
|
if k == "is_handle" && m.IsHandle == v {
|
|
@@ -367,3 +377,12 @@ func moreInfo(req *types.ProjectListReq, list []*ProjectEntry) (result []*Projec
|
|
|
}
|
|
|
return list
|
|
|
}
|
|
|
+
|
|
|
+func MonitorStatus(uid string) map[string]interface{} {
|
|
|
+ m1 := make(map[string]interface{})
|
|
|
+ info := T.BaseMysql.SelectBySql(sql_4, uid)
|
|
|
+ for _, m := range *info {
|
|
|
+ m1[common.ObjToString(m["s_id"])] = util.EncodeId(common.ObjToString(m["id"]))
|
|
|
+ }
|
|
|
+ return m1
|
|
|
+}
|