network.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. package service
  2. import (
  3. "context"
  4. "database/sql"
  5. "fmt"
  6. "math"
  7. "strings"
  8. "sync"
  9. . "app.yhyue.com/moapp/jybase/common"
  10. . "app.yhyue.com/moapp/jybase/date"
  11. . "app.yhyue.com/moapp/jybase/es"
  12. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  13. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  14. "github.com/zeromicro/go-zero/core/logx"
  15. )
  16. var Network = &network{}
  17. type network struct {
  18. }
  19. type networkTree struct {
  20. Count int64 `json:"count"`
  21. Name string `json:"name"`
  22. Children []*networkTreeChild `json:"children"`
  23. }
  24. type networkTreeChild struct {
  25. Count int64 `json:"count"`
  26. Name string `json:"name"`
  27. Id string `json:"id"`
  28. Type int `json:"type"`
  29. }
  30. type projectInfo struct {
  31. BuyerCount int
  32. ProjectCount int
  33. ProjectAmount float64
  34. }
  35. //人脉库-添加/修改人脉
  36. func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
  37. reply := &types.Reply{}
  38. nowFormat := NowFormat(Date_Full_Layout)
  39. var saveIntroduce = func(tx *sql.Tx, cid int64, isUpdate bool) bool {
  40. if in.Type != "middleman" {
  41. return true
  42. }
  43. values := []interface{}{}
  44. if in.Introduce_owner_id != "" {
  45. for k, v := range strings.Split(in.Introduce_owner_id, ",") {
  46. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_owner_name, ",")[k], 1, nowFormat)
  47. }
  48. }
  49. if in.Introduce_project_id != "" {
  50. for k, v := range strings.Split(in.Introduce_project_id, ",") {
  51. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 2, nowFormat)
  52. }
  53. }
  54. if len(values) == 0 {
  55. return false
  56. }
  57. var r2 int64
  58. if isUpdate {
  59. r2 = CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
  60. }
  61. r3, _ := CrmMysql.InsertBatchByTx(tx, "crm.connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "relate_id", "relate_name", "itype", "create_time"}, values)
  62. return r2 >= 0 && r3 > 0
  63. }
  64. if in.Id > 0 {
  65. if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
  66. r1 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `update crm.connection set company_name=?,company_id=?,contact_person=?,contact_phone=?,update_time=? where id=? and position_id=?`, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, nowFormat, in.Id, in.PositionId)
  67. return r1 >= 0 && saveIntroduce(tx, in.Id, true)
  68. }) {
  69. reply.Data = map[string]interface{}{
  70. "status": 1,
  71. }
  72. } else {
  73. reply.Data = map[string]interface{}{
  74. "status": 0,
  75. }
  76. }
  77. } else {
  78. itype := n.TypeConvert(in.Type)
  79. var r1 int64
  80. if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
  81. _, r1 = CrmMysql.InsertBatchByTx(tx, "crm.connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "contact_person", "contact_phone", "status", "create_time", "update_time"}, []interface{}{in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, itype, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
  82. return r1 > 0 && saveIntroduce(tx, r1, false)
  83. }) {
  84. reply.Data = map[string]interface{}{
  85. "status": 1,
  86. "id": r1,
  87. }
  88. } else {
  89. reply.Data = map[string]interface{}{
  90. "status": 0,
  91. }
  92. }
  93. }
  94. return reply
  95. }
  96. //人脉库-业主名称联想
  97. func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
  98. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  99. res := []map[string]interface{}{}
  100. reply = &types.Reply{Data: res}
  101. in.Name = strings.TrimSpace(in.Name)
  102. if in.Name == "" {
  103. return
  104. }
  105. pageSize := 10
  106. if in.Type == "adiffb" {
  107. probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
  108. if len(probusfors) > 0 {
  109. args := []interface{}{in.EntName}
  110. wh, newArgs := NetworkCom.WhArgs(probusfors)
  111. args = append(args, newArgs...)
  112. q := `select DISTINCT b.winner_id,b.winner from information.transaction_info a
  113. inner join information.transaction_info b on (has(a.winner, ?) and a.buyer_id<>'' and a.buyer_id=b.buyer_id and hasAny(b.property_form,[` + wh + `])) ORDER BY b.project_id`
  114. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  115. if err != nil {
  116. logx.Error(err)
  117. } else {
  118. repeat := map[string]bool{}
  119. for rows.Next() {
  120. var (
  121. winner_id []string
  122. winner []string
  123. )
  124. if err := rows.Scan(&winner_id, &winner); err != nil {
  125. logx.Error(err)
  126. continue
  127. }
  128. for k, v := range winner {
  129. if repeat[v] || !strings.Contains(v, in.Name) {
  130. continue
  131. }
  132. repeat[v] = true
  133. if k >= len(winner_id) {
  134. continue
  135. }
  136. res = append(res, map[string]interface{}{
  137. "company_name": v,
  138. "company_id": winner_id[k],
  139. })
  140. }
  141. }
  142. rows.Close()
  143. if err := rows.Err(); err != nil {
  144. logx.Error(err)
  145. }
  146. if len(res) > pageSize {
  147. res = res[:pageSize]
  148. }
  149. }
  150. }
  151. } else {
  152. must := []string{fmt.Sprintf(`{"multi_match":{"query":"%s","type":"phrase","fields":["company_name"]}}`, in.Name)}
  153. switch in.Type {
  154. case "firstparty":
  155. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  156. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  157. case "supplier":
  158. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  159. must = append(must, `{"term":{"company_unit_type":3}}`)
  160. case "middleman_owner":
  161. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  162. case "agency":
  163. must = append(must, `{"term":{"company_unit_type":4}}`)
  164. }
  165. q := fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":%d,"_source":["id","company_name"]}`, strings.Join(must, ","), pageSize)
  166. logx.Info("人脉库-业主名称联想", q)
  167. datas := VarEs.Get("ent_info", "ent_info", q)
  168. if datas != nil {
  169. for _, v := range *datas {
  170. res = append(res, map[string]interface{}{
  171. "company_name": ObjToString(v["company_name"]),
  172. "company_id": ObjToString(v["id"]),
  173. })
  174. }
  175. }
  176. }
  177. reply.Data = res
  178. return
  179. }
  180. //人脉库-全部人脉项目
  181. func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
  182. pool := make(chan bool, 5)
  183. wait := &sync.WaitGroup{}
  184. lock := &sync.Mutex{}
  185. reply = &types.Reply{}
  186. wh, newArgs := NetworkCom.WhArgs(NetworkCom.GetMyProbusfor(in.EntAccountId))
  187. var count int64
  188. var list []*networkTree
  189. if in.Id != "" {
  190. if in.Type == 1 {
  191. q := `select a.b_id as company_id,a.b_name as company_name,b.name from information.ent_map_code a
  192. inner join information.ent_code b on (a.a_id=? and b.pcode in ('0100','0200') and a.code=b.code)`
  193. args := []interface{}{in.Id}
  194. if in.Name != "" {
  195. q += ` where c.company_name like ?`
  196. args = append(args, "%"+in.Name+"%")
  197. }
  198. q += ` order by b.name,a.b_name`
  199. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  200. if err != nil {
  201. logx.Error(err)
  202. return
  203. }
  204. nameIndex := map[string]int{}
  205. for rows.Next() {
  206. var (
  207. company_id string
  208. company_name string
  209. name string
  210. )
  211. if err := rows.Scan(&company_id, &company_name, &name); err != nil {
  212. logx.Error(err)
  213. continue
  214. }
  215. if _, ok := nameIndex[name]; !ok {
  216. nameIndex[name] = len(list)
  217. list = append(list, &networkTree{
  218. Name: name,
  219. })
  220. }
  221. pool <- true
  222. wait.Add(1)
  223. go func(cIndex int, cId, cName string) {
  224. defer func() {
  225. <-pool
  226. wait.Done()
  227. }()
  228. ntc := &networkTreeChild{
  229. Name: cName,
  230. Id: cId,
  231. Type: 1,
  232. }
  233. if wh != "" {
  234. thisArgs := []interface{}{ntc.Id}
  235. thisArgs = append(thisArgs, newArgs...)
  236. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
  237. }
  238. lock.Lock()
  239. count++
  240. list[cIndex].Count += ntc.Count
  241. list[cIndex].Children = append(list[cIndex].Children, ntc)
  242. lock.Unlock()
  243. }(nameIndex[name], company_id, company_name)
  244. }
  245. wait.Wait()
  246. rows.Close()
  247. if err := rows.Err(); err != nil {
  248. logx.Error(err)
  249. }
  250. }
  251. } else {
  252. q := `SELECT a.company_id,a.company_name,a.itype,COUNT(b.id) AS ipc FROM crm.connection a
  253. LEFT JOIN crm.connection_introduce b ON (b.position_id=? AND b.itype=2 AND a.id=b.connection_id) WHERE a.position_id=?`
  254. args := []interface{}{in.PositionId, in.PositionId}
  255. if in.Name != "" {
  256. q += ` and company_name like ?`
  257. args = append(args, "%"+in.Name+"%")
  258. }
  259. q += ` GROUP BY a.id ORDER BY a.create_time DESC`
  260. datas := CrmMysql.SelectBySql(q, args...)
  261. list = []*networkTree{
  262. &networkTree{
  263. Name: "甲方",
  264. Children: []*networkTreeChild{},
  265. },
  266. &networkTree{
  267. Name: "供应商",
  268. Children: []*networkTreeChild{},
  269. },
  270. &networkTree{
  271. Name: "同甲异业渠道",
  272. Children: []*networkTreeChild{},
  273. },
  274. &networkTree{
  275. Name: "中间人",
  276. Children: []*networkTreeChild{},
  277. },
  278. &networkTree{
  279. Name: "招标代理",
  280. Children: []*networkTreeChild{},
  281. },
  282. }
  283. //
  284. for _, vt := range *datas {
  285. pool <- true
  286. wait.Add(1)
  287. go func(v map[string]interface{}) {
  288. defer func() {
  289. <-pool
  290. wait.Done()
  291. }()
  292. itype := IntAll(v["itype"])
  293. if itype <= 0 || itype > len(list) {
  294. return
  295. }
  296. ntc := &networkTreeChild{
  297. Name: ObjToString(v["company_name"]),
  298. Id: ObjToString(v["company_id"]),
  299. Type: IntAll(v["itype"]),
  300. }
  301. if wh != "" {
  302. thisArgs := []interface{}{ntc.Id}
  303. thisArgs = append(thisArgs, newArgs...)
  304. if itype == 1 {
  305. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
  306. } else if itype == 2 || itype == 3 {
  307. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where has(winner_id,?) and hasAny(property_form,[`+wh+`])`, thisArgs...)
  308. } else if itype == 4 {
  309. ntc.Count = Int64All(v["ipc"])
  310. } else if itype == 5 {
  311. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where agency_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
  312. }
  313. }
  314. lock.Lock()
  315. count += ntc.Count
  316. list[itype-1].Count += ntc.Count
  317. list[itype-1].Children = append(list[itype-1].Children, ntc)
  318. lock.Unlock()
  319. }(vt)
  320. }
  321. wait.Wait()
  322. }
  323. reply = &types.Reply{
  324. Data: map[string]interface{}{
  325. "count": count,
  326. "list": list,
  327. },
  328. }
  329. return reply
  330. }
  331. //人脉库-列表
  332. func (n *network) List(in *types.NetWorkListReq) *types.Reply {
  333. q := `select a.company_id,a.company_name,a.itype,a.contact_person as person,a.contact_phone as phone,count(if(b.itype=1,1,null)) as buyer_count,count(if(b.itype=2,1,null)) as project_count,GROUP_CONCAT(b.relate_id) as relate_id,a.create_time from crm.connection a
  334. left join crm.connection_introduce b on (a.id=b.connection_id) where a.position_id=?`
  335. args := []interface{}{in.PositionId}
  336. if in.Type != "" {
  337. q += ` and a.itype=?`
  338. args = append(args, n.TypeConvert(in.Type))
  339. }
  340. if in.Starttime != "" {
  341. q += ` and a.create_time>=?`
  342. args = append(args, in.Starttime)
  343. }
  344. if in.Endtime != "" {
  345. q += ` and a.create_time<=?`
  346. args = append(args, in.Endtime)
  347. }
  348. if in.Name != "" {
  349. q += ` and a.company_name like ?`
  350. args = append(args, "%"+in.Name+"%")
  351. }
  352. q += ` GROUP BY a.id order by a.create_time desc`
  353. listTemp := CrmMysql.SelectBySql(q, args...)
  354. supplier_array, adiffb_array, agency_array, middleman_array := []string{}, []string{}, []string{}, []string{}
  355. for _, v := range *listTemp {
  356. switch Int64All(v["itype"]) {
  357. case 2:
  358. supplier_array = append(supplier_array, ObjToString(v["company_id"]))
  359. case 3:
  360. adiffb_array = append(adiffb_array, ObjToString(v["company_id"]))
  361. case 4:
  362. if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
  363. middleman_array = append(middleman_array, strings.Split(relate_id, ",")...)
  364. }
  365. case 5:
  366. agency_array = append(agency_array, ObjToString(v["company_id"]))
  367. }
  368. }
  369. //
  370. firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
  371. list := []map[string]interface{}{}
  372. supplier_project := n.Introduce_Agency(supplier_array)
  373. adiffb_project := n.Introduce_Supplier(adiffb_array)
  374. agency_project := n.Introduce_Agency(agency_array)
  375. middleman_project := n.Introduce_Middleman(middleman_array)
  376. for _, v := range *listTemp {
  377. itype := ""
  378. buyer_count, project_count, expect_amount := 0, 0, float64(0)
  379. company_id := ObjToString(v["company_id"])
  380. switch Int64All(v["itype"]) {
  381. case 1:
  382. itype = "甲方"
  383. firstparty_count++
  384. case 2:
  385. itype = "供应商"
  386. supplier_count++
  387. if supplier_project[company_id] != nil {
  388. buyer_count = supplier_project[company_id].BuyerCount
  389. project_count = supplier_project[company_id].ProjectCount
  390. expect_amount = supplier_project[company_id].ProjectAmount
  391. }
  392. case 3:
  393. itype = "同甲异业渠道"
  394. adiffb_count++
  395. if adiffb_project[company_id] != nil {
  396. buyer_count = adiffb_project[company_id].BuyerCount
  397. project_count = adiffb_project[company_id].ProjectCount
  398. expect_amount = adiffb_project[company_id].ProjectAmount
  399. }
  400. case 4:
  401. itype = "中间人"
  402. middleman_count++
  403. buyer_count = IntAll(v["buyer_count"])
  404. project_count = IntAll(v["project_count"])
  405. if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
  406. for _, v := range strings.Split(relate_id, ",") {
  407. if middleman_project[v] != nil {
  408. expect_amount += middleman_project[v].ProjectAmount
  409. }
  410. }
  411. }
  412. if middleman_project[company_id] != nil {
  413. expect_amount = middleman_project[company_id].ProjectAmount
  414. }
  415. case 5:
  416. itype = "招标代理机构"
  417. agency_count++
  418. if agency_project[company_id] != nil {
  419. buyer_count = agency_project[company_id].BuyerCount
  420. project_count = agency_project[company_id].ProjectCount
  421. expect_amount = agency_project[company_id].ProjectAmount
  422. }
  423. }
  424. list = append(list, map[string]interface{}{
  425. "company_id": company_id,
  426. "company_name": v["company_name"],
  427. "type": itype,
  428. "person": v["person"],
  429. "phone": v["phone"],
  430. "buyer_count": buyer_count,
  431. "monitor_count": 0,
  432. "expect_amount": expect_amount,
  433. "project_count": project_count,
  434. "create_time": v["create_time"],
  435. })
  436. }
  437. length := int64(len(list))
  438. var pageSize int64 = 10
  439. total_page := int64(math.Ceil(float64(length) / float64(pageSize)))
  440. finalList := []map[string]interface{}{}
  441. if length > 0 {
  442. if in.Current_page <= 0 {
  443. in.Current_page = 1
  444. }
  445. if in.Current_page > total_page {
  446. in.Current_page = total_page
  447. }
  448. start := (in.Current_page - 1) * pageSize
  449. end := start + pageSize
  450. if end > length {
  451. end = length
  452. }
  453. finalList = list[start:end]
  454. }
  455. return &types.Reply{
  456. Data: map[string]interface{}{
  457. "total_page": total_page,
  458. "firstparty_count": firstparty_count,
  459. "supplier_count": supplier_count,
  460. "adiffb_count": adiffb_count,
  461. "middleman_count": middleman_count,
  462. "agency_count": agency_count,
  463. "list": finalList,
  464. },
  465. }
  466. }
  467. //
  468. func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
  469. vm := map[string]*projectInfo{}
  470. for _, v := range values {
  471. vm[v] = &projectInfo{}
  472. }
  473. wh, newArgs := NetworkCom.WhArgs(values)
  474. rows, err := ClickhouseConn.Query(context.Background(), `select a.winner_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
  475. inner join information.transaction_info b on (hasAny(a.winner_id,[`+wh+`]) and a.buyer_id=b.buyer_id)
  476. group by a.winner_id`, newArgs...)
  477. if err != nil {
  478. logx.Error(err)
  479. return nil
  480. }
  481. for rows.Next() {
  482. var (
  483. winner_id []string
  484. buyer_count uint64
  485. project_count uint64
  486. project_amount float64
  487. )
  488. if err := rows.Scan(&winner_id, &buyer_count, &project_count, &project_amount); err != nil {
  489. logx.Error(err)
  490. continue
  491. }
  492. for _, v := range winner_id {
  493. if vm[v] == nil {
  494. continue
  495. }
  496. vm[v].BuyerCount += int(buyer_count)
  497. vm[v].ProjectCount += int(project_count)
  498. vm[v].ProjectAmount += project_amount
  499. }
  500. }
  501. rows.Close()
  502. if err := rows.Err(); err != nil {
  503. logx.Error(err)
  504. }
  505. return vm
  506. }
  507. //
  508. func (n *network) Introduce_Agency(values []string) map[string]*projectInfo {
  509. vm := map[string]*projectInfo{}
  510. for _, v := range values {
  511. vm[v] = &projectInfo{}
  512. }
  513. wh, newArgs := NetworkCom.WhArgs(values)
  514. rows, err := ClickhouseConn.Query(context.Background(), `select a.agency_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
  515. inner join information.transaction_info b on (agency_id in (`+wh+`) and a.buyer_id=b.buyer_id)
  516. group by a.agency_id`, newArgs...)
  517. if err != nil {
  518. logx.Error(err)
  519. return nil
  520. }
  521. for rows.Next() {
  522. var (
  523. agency_id string
  524. buyer_count uint64
  525. project_count uint64
  526. project_amount float64
  527. )
  528. if err := rows.Scan(&agency_id, &buyer_count, &project_count, &project_amount); err != nil {
  529. logx.Error(err)
  530. continue
  531. }
  532. if vm[agency_id] == nil {
  533. continue
  534. }
  535. vm[agency_id].BuyerCount += int(buyer_count)
  536. vm[agency_id].ProjectCount += int(project_count)
  537. vm[agency_id].ProjectAmount += project_amount
  538. }
  539. rows.Close()
  540. if err := rows.Err(); err != nil {
  541. logx.Error(err)
  542. }
  543. return vm
  544. }
  545. //
  546. func (n *network) Introduce_Middleman(values []string) map[string]*projectInfo {
  547. vm := map[string]*projectInfo{}
  548. wh, newArgs := NetworkCom.WhArgs(values)
  549. rows, err := ClickhouseConn.Query(context.Background(), `select project_id,project_money from information.transaction_info where project_id in (`+wh+`)`, newArgs...)
  550. if err != nil {
  551. logx.Error(err)
  552. return nil
  553. }
  554. for rows.Next() {
  555. var (
  556. project_id string
  557. project_money float64
  558. )
  559. if err := rows.Scan(&project_id, &project_money); err != nil {
  560. logx.Error(err)
  561. continue
  562. }
  563. vm[project_id] = &projectInfo{
  564. ProjectAmount: project_money,
  565. }
  566. }
  567. rows.Close()
  568. if err := rows.Err(); err != nil {
  569. logx.Error(err)
  570. }
  571. return vm
  572. }
  573. //
  574. func (n *network) TypeConvert(itype string) int {
  575. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  576. switch itype {
  577. case "firstparty":
  578. return 1
  579. case "supplier":
  580. return 2
  581. case "adiffb":
  582. return 3
  583. case "middleman":
  584. return 4
  585. case "agency":
  586. return 5
  587. }
  588. return 0
  589. }