wangchuanjin 1 жил өмнө
parent
commit
4d5068b96c

+ 14 - 0
api/internal/service/CoopHistoryService.go

@@ -46,6 +46,20 @@ type ResultData struct {
 	IsMonitor        bool    `json:"isMonitor"`
 	IsMonitor        bool    `json:"isMonitor"`
 }
 }
 
 
+type ResultDatas []*ResultData
+
+func (n *ResultDatas) Len() int {
+	return len(*n)
+}
+
+func (n *ResultDatas) Less(i, j int) bool {
+	return (*n)[i].RecentTime > (*n)[j].RecentTime
+}
+
+func (n *ResultDatas) Swap(i, j int) {
+	(*n)[i], (*n)[j] = (*n)[j], (*n)[i]
+}
+
 type ProjectTmp struct {
 type ProjectTmp struct {
 	Buyer        string   `ch:"buyer"`
 	Buyer        string   `ch:"buyer"`
 	BuyerId      string   `ch:"buyer_id"`
 	BuyerId      string   `ch:"buyer_id"`

+ 26 - 5
api/internal/service/network_test.go

@@ -112,11 +112,11 @@ func TestAllProject(t *testing.T) {
 	InitConf()
 	InitConf()
 	res := Network.AllProject(&types.AllprojectReq{
 	res := Network.AllProject(&types.AllprojectReq{
 		EntAccountId: 64,
 		EntAccountId: 64,
-		//PositionId:   935,
-		PositionId: 1205591997, //刘苗
+		PositionId:   935,
+		//PositionId: 1205591997, //刘苗
 		//PositionId: 1205592003,//刘亚丽
 		//PositionId: 1205592003,//刘亚丽
-		Id:   "009c313ef8e740e59d57432aea777102",
-		Type: "firstparty",
+		//Id:   "009c313ef8e740e59d57432aea777102",
+		//Type: "firstparty",
 	})
 	})
 	b, _ := json.Marshal(res.Data)
 	b, _ := json.Marshal(res.Data)
 	log.Println(string(b))
 	log.Println(string(b))
@@ -169,7 +169,7 @@ func TestCandidateChannel(t *testing.T) {
 		PositionId:   1205591999,
 		PositionId:   1205591999,
 	}
 	}
 	data, a1, a2, a3, a4 := ownerService.CandidateChannel()
 	data, a1, a2, a3, a4 := ownerService.CandidateChannel()
-	for _, v := range data {
+	for _, v := range *data {
 		log.Println(fmt.Sprintf("%+v", v))
 		log.Println(fmt.Sprintf("%+v", v))
 	}
 	}
 	log.Println(a1)
 	log.Println(a1)
@@ -185,3 +185,24 @@ func TestProjectHistory(t *testing.T) {
 		log.Println(fmt.Sprintf("%+v", v))
 		log.Println(fmt.Sprintf("%+v", v))
 	}
 	}
 }
 }
+func TestChanceAdd(t *testing.T) {
+	chance := &service.SaleChanceService{
+		PositionId:        935,
+		AppId:             "10000",
+		ChanceName:        "王传进的销售机会5",  //机会名称
+		Summary:           "王传进的销售机会5",  //概要信息
+		ChanceClassify:    30,           //机会分类
+		ExpectedOrderTime: 0,            //最初预计落单段时间 时间戳
+		CustomName:        "王传进测试",      //客户全称
+		BusinessType:      3,            //业务类型
+		NextfollowUpTime:  1715097600,   //下次跟进时间戳
+		Types:             1,            //处理方式 1自办;2转办
+		User:              []int64{935}, //企业用户id
+		CustomId:          300069,       //客户id
+		CreateName:        "企业管理员",
+		ChanceSource:      54,
+		BusinessId:        "",
+	}
+	status, _ := chance.Add(context.Background())
+	log.Println(status)
+}

+ 4 - 3
api/internal/service/owner.go

@@ -1080,7 +1080,7 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 }
 }
 
 
 // 候选渠道
 // 候选渠道
-func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
+func (t *OwnerService) CandidateChannel() (*ResultDatas, int, int, int, int) {
 	returnData := []*ResultData{}
 	returnData := []*ResultData{}
 	dataMap := &map[string]map[string]interface{}{}
 	dataMap := &map[string]map[string]interface{}{}
 	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
 	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
@@ -1181,7 +1181,7 @@ func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
 		}
 		}
 	}
 	}
 	//状态处理
 	//状态处理
-	result := []*ResultData{}
+	result := &ResultDatas{}
 	if len(returnData) > 0 {
 	if len(returnData) > 0 {
 		monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
 		monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
 		_, ignoredMap, createdMap := FindStatus(t.PositionId)
 		_, ignoredMap, createdMap := FindStatus(t.PositionId)
@@ -1199,8 +1199,9 @@ func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
 			if t.Type != "" && t.Type != value.SourceType {
 			if t.Type != "" && t.Type != value.SourceType {
 				continue
 				continue
 			}
 			}
-			result = append(result, value)
+			*result = append(*result, value)
 		}
 		}
 	}
 	}
+	sort.Sort(result)
 	return result, a1, a2, a3, a4
 	return result, a1, a2, a3, a4
 }
 }