rai_data_summary.go 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. package statistic
  2. import (
  3. "fmt"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/controllers"
  6. "hongze/hz_crm_api/models"
  7. "hongze/hz_crm_api/models/company"
  8. "hongze/hz_crm_api/models/fms"
  9. "hongze/hz_crm_api/models/statistic_report"
  10. "hongze/hz_crm_api/models/system"
  11. "hongze/hz_crm_api/services"
  12. cygxService "hongze/hz_crm_api/services/cygx"
  13. "hongze/hz_crm_api/utils"
  14. "strconv"
  15. "strings"
  16. "time"
  17. )
  18. // 权益数据汇总
  19. // StatisticRaiDataSummaryController 权益数据汇总基类
  20. type StatisticRaiDataSummaryController struct {
  21. controllers.BaseAuthController
  22. }
  23. // MergeCompanyList
  24. // @Title 权益数据汇总
  25. // @Description 权益数据汇总统计列表接口
  26. // @Param AdminId query string true "开拓组销售id,多个用英文逗号隔开,空字符串为全部"
  27. // @Param ServiceAdminId query string true "服务组销售id,多个用英文逗号隔开,空字符串为全部"
  28. // @Param StartYear query int false "开始日期(年份)"
  29. // @Param EndYear query int false "结束日期(年份)"
  30. // @Param DataType query string false "报表类型,枚举值:`季度`,`年度`,`半年度`"
  31. // @Param DevelopButton query int false "开拓组开关,枚举值:1:开启,0:关闭 ,默认关闭"
  32. // @Param ServerButton query int false "服务组开关,枚举值:1:开启,0:关闭 ,默认关闭"
  33. // @Param ContractButtonType query string false "开关类型,:`新签`,`续约`,`收入` 多个用英文逗号隔开, "
  34. // @Param IsExport query bool false "是否导出excel,默认是false"
  35. // @Success 200 {object} statistic_report.RaiDataSummaryListResp
  36. // @router /rai_data_summary/list [get]
  37. func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
  38. br := new(models.BaseResponse).Init()
  39. defer func() {
  40. this.Data["json"] = br
  41. this.ServeJSON()
  42. }()
  43. sysUser := this.SysUser
  44. if sysUser == nil {
  45. br.Msg = "请登录"
  46. br.ErrMsg = "请登录,SysUser Is Empty"
  47. br.Ret = 408
  48. return
  49. }
  50. dataType := this.GetString("DataType")
  51. adminId := this.GetString("AdminId")
  52. serviceAdminId := this.GetString("ServiceAdminId")
  53. startYear, _ := this.GetInt("StartYear")
  54. endYear, _ := this.GetInt("EndYear")
  55. developButton, _ := this.GetBool("DevelopButton")
  56. serverButton, _ := this.GetBool("ServerButton")
  57. dataTypeArr := []string{}
  58. if dataType == "季度" {
  59. dataTypeArr = []string{"Q1", "Q2", "Q3", "Q4"}
  60. } else if dataType == "半年度" {
  61. dataTypeArr = []string{"H1", "H2"}
  62. } else {
  63. dataTypeArr = []string{""}
  64. }
  65. condition := " AND role_type_code IN ('rai_seller','rai_group') AND enabled = 1 AND rai_enabled = 1 "
  66. var pars []interface{}
  67. if adminId != "" {
  68. serviceAdminId = ""
  69. condition += " AND admin_id IN (" + adminId + ") "
  70. }
  71. if serviceAdminId != "" {
  72. condition += " AND admin_id IN (" + serviceAdminId + ") "
  73. }
  74. if developButton && !serverButton && adminId == "" && serviceAdminId == "" { //开拓组筛选条件
  75. condition += " AND real_name NOT LIKE '%6%' "
  76. }
  77. if !developButton && serverButton && adminId == "" && serviceAdminId == "" { //服务组筛选条件
  78. condition += " AND real_name LIKE '%6%' "
  79. }
  80. sellerList, err := system.GetSysUserItemsOrderByCreated(condition, pars)
  81. if err != nil {
  82. br.Msg = "获取管理账号失败"
  83. br.ErrMsg = "获取管理账号失败,Err:" + err.Error()
  84. return
  85. }
  86. var sellerDevelop []*system.AdminItem // 开拓组销售
  87. var sellerService []*system.AdminItem // 服务组销售
  88. var sellerDevelopIds = make(map[int]bool) // 开拓组销售的map
  89. for _, v := range sellerList {
  90. if strings.Contains(v.RealName, "6") {
  91. sellerService = append(sellerService, v)
  92. } else {
  93. sellerDevelop = append(sellerDevelop, v)
  94. sellerDevelopIds[v.AdminId] = true
  95. }
  96. }
  97. //拼接起始时间查询
  98. startDate := fmt.Sprintf("%d-01-01", startYear)
  99. endDate := fmt.Sprintf("%d-12-31", endYear)
  100. //新签部分的数据
  101. var conditionRai string
  102. var parsRai []interface{}
  103. conditionRai = " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
  104. parsRai = append(parsRai, startDate, endDate)
  105. listRaiData, err := statistic_report.GetRaiDataSummaryList(conditionRai, parsRai)
  106. if err != nil {
  107. br.Msg = "获取数据信息失败"
  108. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  109. return
  110. }
  111. //续约部分的数据
  112. var conditionInherit string
  113. var parsInherit []interface{}
  114. conditionInherit = " AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? "
  115. parsInherit = append(parsInherit, startDate, endDate)
  116. listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
  117. if err != nil {
  118. br.Msg = "获取数据信息失败"
  119. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  120. return
  121. }
  122. //确认不续约、到期合同部分的数据
  123. var conditionEnd string
  124. var parsEnd []interface{}
  125. conditionEnd = " AND a.product_id = 2 AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date <= ? "
  126. parsEnd = append(parsEnd, startDate, endDate, time.Now().Format(utils.FormatDate))
  127. listEndData, err := statistic_report.GetRaiDataSummaryList(conditionEnd, parsEnd)
  128. if err != nil {
  129. br.Msg = "获取数据信息失败"
  130. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  131. return
  132. }
  133. var conditionConfirm string
  134. var parsConfirm []interface{}
  135. mapNoRenewedcompanyContractIds := make(map[int]bool) //已经确定未续约的合同ID
  136. conditionConfirm = " AND company_ascribe_id != 9 "
  137. companyConfirmList, err := company.GetCompanyContractNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
  138. if err != nil && err.Error() != utils.ErrNoRow() {
  139. br.Msg = "获取失败"
  140. br.ErrMsg = "获取失败,GetCompanyNoRenewedAscribeList Err:" + err.Error()
  141. return
  142. }
  143. for _, v := range companyConfirmList {
  144. mapNoRenewedcompanyContractIds[v.CompanyContractId] = true
  145. }
  146. mapAddTrialNum := make(map[string]float64) // 新增试用-(数据)
  147. mapNewContractMoney := make(map[string]float64) // 新签合同(金额)
  148. mapNewContractNum := make(map[string]int) // 新签合同(数量)
  149. mapExpiredContractMoney := make(map[string]float64) // 到期合同(金额)
  150. mapExpiredContractNum := make(map[string]int) // 到期合同(数量)
  151. mapRenewedContractMoney := make(map[string]float64) // 续约合同(金额)
  152. mapRenewedContractNum := make(map[string]int) // 续约合同(数量)
  153. confirmedNoRenewalContractMoney := make(map[string]float64) // 确认不续约合同(金额)
  154. confirmedNoRenewalContractNum := make(map[string]int) // 确认不续约合同(数量)
  155. mapSignedClientNum := make(map[string]int) // 签约客户(数量)
  156. mapSignedClientMoney := make(map[string]float64) // 签约客户(金额)
  157. mapInvoiceAmountMoney := make(map[string]float64) // 财务系统开票金额(金额)
  158. mapPaymentAmountMoney := make(map[string]float64) // 财务系统到款金额(金额)
  159. mapNewCustomerInvoicingMoney := make(map[string]float64) // 财务系统新客开票金额(金额)
  160. mapNewCustomerPaymentsReceivedMoney := make(map[string]float64) // 财务系统新客到款金额(金额)
  161. var keyMap string
  162. var keyMapTtoal string
  163. var keyMapTtoalServer string
  164. //新签部分的数据
  165. for _, v := range listRaiData {
  166. startDateTime := utils.StrDateToDate(v.StartDate)
  167. monthNum := startDateTime.Month()
  168. yearStr := strconv.Itoa(startDateTime.Year())
  169. if dataType == "季度" {
  170. if monthNum < 4 {
  171. yearStr += "Q1"
  172. } else if monthNum > 3 && monthNum < 7 {
  173. yearStr += "Q2"
  174. } else if monthNum > 6 && monthNum < 10 {
  175. yearStr += "Q3"
  176. } else if monthNum > 9 {
  177. yearStr += "Q4"
  178. }
  179. } else if dataType == "半年度" {
  180. if monthNum < 7 {
  181. yearStr += "H1"
  182. } else {
  183. yearStr += "H2"
  184. }
  185. }
  186. keyMap = fmt.Sprint(yearStr, "_", v.SellerIdLast)
  187. if sellerDevelopIds[v.SellerIdLast] == true {
  188. keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
  189. } else {
  190. keyMapTtoal = fmt.Sprint(yearStr, "_Service")
  191. }
  192. if v.RaiContractType == "新签合同" {
  193. mapNewContractMoney[keyMap] += v.Money
  194. mapNewContractNum[keyMap]++
  195. mapNewContractMoney[keyMapTtoal] += v.Money
  196. mapNewContractNum[keyMapTtoal]++
  197. }
  198. //else if v.RaiContractType == "续约合同" {
  199. // mapRenewedContractMoney[keyMap] += v.Money
  200. // mapRenewedContractNum[keyMap]++
  201. //
  202. // mapRenewedContractMoney[keyMapTtoal] += v.Money
  203. // mapRenewedContractNum[keyMapTtoal]++
  204. //}
  205. //if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
  206. // mapExpiredContractMoney[keyMap] += v.Money
  207. // mapExpiredContractNum[keyMap]++
  208. //
  209. // mapExpiredContractMoney[keyMapTtoal] += v.Money
  210. // mapExpiredContractNum[keyMapTtoal]++
  211. //}
  212. //
  213. //if mapNoRenewedcompanyContractIds[v.CompanyContractId] { // 确认不续约合同
  214. // confirmedNoRenewalContractMoney[keyMap] += v.Money
  215. // confirmedNoRenewalContractNum[keyMap]++
  216. //
  217. // confirmedNoRenewalContractMoney[keyMapTtoal] += v.Money
  218. // confirmedNoRenewalContractNum[keyMapTtoal]++
  219. //}
  220. mapSignedClientMoney[keyMap] += v.Money
  221. mapSignedClientNum[keyMap]++
  222. mapSignedClientMoney[keyMapTtoal] += v.Money
  223. mapSignedClientNum[keyMapTtoal]++
  224. }
  225. //续约部分的数据
  226. for _, v := range listInheritData {
  227. startDateTime := utils.StrDateToDate(v.InheritEndDate)
  228. monthNum := startDateTime.Month()
  229. yearStr := strconv.Itoa(startDateTime.Year())
  230. if dataType == "季度" {
  231. if monthNum < 4 {
  232. yearStr += "Q1"
  233. } else if monthNum > 3 && monthNum < 7 {
  234. yearStr += "Q2"
  235. } else if monthNum > 6 && monthNum < 10 {
  236. yearStr += "Q3"
  237. } else if monthNum > 9 {
  238. yearStr += "Q4"
  239. }
  240. } else if dataType == "半年度" {
  241. if monthNum < 7 {
  242. yearStr += "H1"
  243. } else {
  244. yearStr += "H2"
  245. }
  246. }
  247. keyMap = fmt.Sprint(yearStr, "_", v.SellerIdLast)
  248. if sellerDevelopIds[v.SellerIdLast] == true {
  249. keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
  250. } else {
  251. keyMapTtoal = fmt.Sprint(yearStr, "_Service")
  252. }
  253. //续约合同 数据
  254. mapRenewedContractMoney[keyMap] += v.Money
  255. mapRenewedContractNum[keyMap]++
  256. mapRenewedContractMoney[keyMapTtoal] += v.Money
  257. mapRenewedContractNum[keyMapTtoal]++
  258. }
  259. //确认不续约、到期合同部分的数据
  260. for _, v := range listEndData {
  261. startDateTime := utils.StrDateToDate(v.EndDate)
  262. monthNum := startDateTime.Month()
  263. yearStr := strconv.Itoa(startDateTime.Year())
  264. if dataType == "季度" {
  265. if monthNum < 4 {
  266. yearStr += "Q1"
  267. } else if monthNum > 3 && monthNum < 7 {
  268. yearStr += "Q2"
  269. } else if monthNum > 6 && monthNum < 10 {
  270. yearStr += "Q3"
  271. } else if monthNum > 9 {
  272. yearStr += "Q4"
  273. }
  274. } else if dataType == "半年度" {
  275. if monthNum < 7 {
  276. yearStr += "H1"
  277. } else {
  278. yearStr += "H2"
  279. }
  280. }
  281. keyMap = fmt.Sprint(yearStr, "_", v.SellerIdLast)
  282. if sellerDevelopIds[v.SellerIdLast] == true {
  283. keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
  284. } else {
  285. keyMapTtoal = fmt.Sprint(yearStr, "_Service")
  286. }
  287. //到期合同数据
  288. mapExpiredContractMoney[keyMap] += v.Money
  289. mapExpiredContractNum[keyMap]++
  290. mapExpiredContractMoney[keyMapTtoal] += v.Money
  291. mapExpiredContractNum[keyMapTtoal]++
  292. if mapNoRenewedcompanyContractIds[v.CompanyContractId] { // 确认不续约合同
  293. confirmedNoRenewalContractMoney[keyMap] += v.Money
  294. confirmedNoRenewalContractNum[keyMap]++
  295. confirmedNoRenewalContractMoney[keyMapTtoal] += v.Money
  296. confirmedNoRenewalContractNum[keyMapTtoal]++
  297. }
  298. }
  299. listFmsData, err := fms.GetContractRegisterListByStartDate(startDate, endDate)
  300. if err != nil {
  301. br.Msg = "获取数据信息失败"
  302. br.ErrMsg = "获取财务系统数据信息失败,Err:" + err.Error()
  303. return
  304. }
  305. for _, v := range listFmsData {
  306. startDateTime := v.StartDate
  307. monthNum := startDateTime.Month()
  308. yearStr := strconv.Itoa(startDateTime.Year())
  309. if dataType == "季度" {
  310. if monthNum < 4 {
  311. yearStr += "Q1"
  312. } else if monthNum > 3 && monthNum < 7 {
  313. yearStr += "Q2"
  314. } else if monthNum > 6 && monthNum < 10 {
  315. yearStr += "Q3"
  316. } else if monthNum > 9 {
  317. yearStr += "Q4"
  318. }
  319. } else if dataType == "半年度" {
  320. if monthNum < 7 {
  321. yearStr += "H1"
  322. } else {
  323. yearStr += "H2"
  324. }
  325. }
  326. keyMap = fmt.Sprint(yearStr, "_", v.RaiSellerId)
  327. if sellerDevelopIds[v.RaiSellerId] == true {
  328. keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
  329. } else {
  330. keyMapTtoal = fmt.Sprint(yearStr, "_Service")
  331. }
  332. mapInvoiceAmountMoney[keyMap] += v.InvoicedAmount
  333. mapPaymentAmountMoney[keyMap] += v.PaymentAmount
  334. mapInvoiceAmountMoney[keyMapTtoal] += v.InvoicedAmount
  335. mapPaymentAmountMoney[keyMapTtoal] += v.PaymentAmount
  336. if v.ContractType == 1 {
  337. mapNewCustomerInvoicingMoney[keyMapTtoal] += v.InvoicedAmount
  338. mapNewCustomerPaymentsReceivedMoney[keyMapTtoal] += v.PaymentAmount
  339. }
  340. }
  341. conditionTry := ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ( "add","receive","apply_receive" ) AND a.sys_user_id IN ( SELECT admin_id FROM admin WHERE role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ) `
  342. var parsTry []interface{}
  343. parsTry = append(parsTry, startDate, endDate)
  344. //列表页数据
  345. tryList, err := models.GetIncrementalCompanyListByOperationRecordRai(conditionTry, parsTry, 0, 9999)
  346. if err != nil {
  347. br.Msg = "获取失败"
  348. br.ErrMsg = "获取失败,Err:" + err.Error()
  349. return
  350. }
  351. for _, v := range tryList {
  352. startDateTime := utils.StrTimeToTime(v.CreateTime)
  353. monthNum := startDateTime.Month()
  354. yearStr := strconv.Itoa(startDateTime.Year())
  355. if dataType == "季度" {
  356. if monthNum < 4 {
  357. yearStr += "Q1"
  358. } else if monthNum > 3 && monthNum < 7 {
  359. yearStr += "Q2"
  360. } else if monthNum > 6 && monthNum < 10 {
  361. yearStr += "Q3"
  362. } else if monthNum > 9 {
  363. yearStr += "Q4"
  364. }
  365. } else if dataType == "半年度" {
  366. if monthNum < 7 {
  367. yearStr += "H1"
  368. } else {
  369. yearStr += "H2"
  370. }
  371. }
  372. keyMap = fmt.Sprint(yearStr, "_", v.SysUserId)
  373. mapAddTrialNum[keyMap]++
  374. //var keyMapTtoal string
  375. sysUserId, _ := strconv.Atoi(v.SysUserId)
  376. if sellerDevelopIds[sysUserId] == true {
  377. keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
  378. } else {
  379. keyMapTtoal = fmt.Sprint(yearStr, "_Service")
  380. }
  381. mapAddTrialNum[keyMapTtoal]++
  382. }
  383. resp := new(statistic_report.RaiDataSummaryListResp)
  384. var items []*statistic_report.RaiDataSummaryResp
  385. for i := startYear; i <= endYear; i++ {
  386. //if len(dataTypeArr) > 0 {
  387. for _, Dv := range dataTypeArr {
  388. item := new(statistic_report.RaiDataSummaryResp)
  389. item.DataType = fmt.Sprint(i, Dv)
  390. keyMapTtoal = fmt.Sprint(item.DataType, "_Develop")
  391. keyMapTtoalServer = fmt.Sprint(item.DataType, "_Server")
  392. for _, vS := range sellerDevelop {
  393. keyMap = fmt.Sprint(item.DataType, "_", vS.AdminId)
  394. sellerItem := new(statistic_report.RaiDataSummaryDetail)
  395. sellerItem.SellerId = vS.AdminId
  396. sellerItem.SellerName = vS.RealName
  397. sellerItem.AddTrialCount = fmt.Sprint(mapAddTrialNum[keyMap])
  398. sellerItem.NewContractData = fmt.Sprint(utils.SubFloatToString(mapNewContractMoney[keyMap], 2), " / ", mapNewContractNum[keyMap]) // 新签合同(金额/数量)-(数据)
  399. sellerItem.ExpiredContractData = fmt.Sprint(utils.SubFloatToString(mapExpiredContractMoney[keyMap], 2), " / ", mapExpiredContractNum[keyMap]) //"到期合同(金额/数量)-(数据)"
  400. sellerItem.RenewedContractData = fmt.Sprint(utils.SubFloatToString(mapRenewedContractMoney[keyMap], 2), " / ", mapRenewedContractNum[keyMap]) // "续约合同(金额/数量)-(数据)"
  401. var renewalRateMoey string
  402. var renewalRateNum string
  403. if mapRenewedContractMoney[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
  404. renewalRateMoey = "0%"
  405. } else {
  406. renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
  407. }
  408. if mapRenewedContractNum[keyMap] == 0 || mapExpiredContractNum[keyMap] == 0 {
  409. renewalRateNum = "0%"
  410. } else {
  411. renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMap])/float64(mapExpiredContractNum[keyMap])*100, 2) + "%"
  412. }
  413. sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum) //"续约率(金额/数量)-(数据)"
  414. sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMap], 2), " / ", confirmedNoRenewalContractNum[keyMap]) //"确认不续约合同(金额/数量)-(数据)"
  415. var confirmNonRenewalRateMoey string
  416. var confirmNonRenewalRateNum string
  417. if confirmedNoRenewalContractMoney[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
  418. confirmNonRenewalRateMoey = "0%"
  419. } else {
  420. confirmNonRenewalRateMoey = utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
  421. }
  422. if confirmedNoRenewalContractNum[keyMap] == 0 || mapExpiredContractNum[keyMap] == 0 {
  423. confirmNonRenewalRateNum = "0%"
  424. } else {
  425. confirmNonRenewalRateNum = utils.SubFloatToString(float64(confirmedNoRenewalContractNum[keyMap])/float64(mapExpiredContractNum[keyMap])*100, 2) + "%"
  426. }
  427. sellerItem.ConfirmNonRenewalRateData = fmt.Sprint(confirmNonRenewalRateMoey, " / ", confirmNonRenewalRateNum) //确认不续约率(金额/数量)-(数据)"
  428. sellerItem.SignedClientCount = fmt.Sprint(mapSignedClientNum[keyMap]) // 签约客户数量
  429. if mapSignedClientNum[keyMap] == 0 || mapSignedClientMoney[keyMap] == 0 {
  430. sellerItem.AverageRevenueCount = "0"
  431. } else {
  432. sellerItem.AverageRevenueCount = utils.SubFloatToString(mapSignedClientMoney[keyMap]/float64(mapSignedClientNum[keyMap]), 2) //客单价
  433. }
  434. sellerItem.InvoiceAmountCount = utils.SubFloatToString(mapInvoiceAmountMoney[keyMap], 2) //"开票金额-(数据)"
  435. sellerItem.PaymentReceivedCount = utils.SubFloatToString(mapPaymentAmountMoney[keyMap], 2) //"开票金额-(数据)"
  436. if mapInvoiceAmountMoney[keyMap] == 0 || mapPaymentAmountMoney[keyMap] == 0 {
  437. sellerItem.UnpaidRatioCount = "0%"
  438. } else {
  439. sellerItem.UnpaidRatioCount = utils.SubFloatToString((mapInvoiceAmountMoney[keyMap]-mapPaymentAmountMoney[keyMap])/mapInvoiceAmountMoney[keyMap]*100, 2) + "%" //"未到款比例-(数据)"
  440. }
  441. sellerItem.NewCustomerInvoicingCount = utils.SubFloatToString(mapNewCustomerInvoicingMoney[keyMap], 2) // "新客开票-(数据)"
  442. sellerItem.NewCustomerPaymentsReceivedCount = utils.SubFloatToString(mapNewCustomerPaymentsReceivedMoney[keyMap], 2) // "新客到款-(数据)"
  443. item.DataList = append(item.DataList, sellerItem)
  444. }
  445. if len(sellerDevelop) > 0 {
  446. sellerItem := new(statistic_report.RaiDataSummaryDetail)
  447. sellerItem.SellerName = "开拓组合计"
  448. sellerItem.AddTrialCount = fmt.Sprint(mapAddTrialNum[keyMapTtoal])
  449. sellerItem.NewContractData = fmt.Sprint(utils.SubFloatToString(mapNewContractMoney[keyMapTtoal], 2), " / ", mapNewContractNum[keyMapTtoal]) // 新签合同(金额/数量)-(数据)
  450. sellerItem.ExpiredContractData = fmt.Sprint(utils.SubFloatToString(mapExpiredContractMoney[keyMapTtoal], 2), " / ", mapExpiredContractNum[keyMapTtoal]) //"到期合同(金额/数量)-(数据)"
  451. sellerItem.RenewedContractData = fmt.Sprint(utils.SubFloatToString(mapRenewedContractMoney[keyMapTtoal], 2), " / ", mapRenewedContractNum[keyMapTtoal]) // "续约合同(金额/数量)-(数据)"
  452. var renewalRateMoey string
  453. var renewalRateNum string
  454. if mapRenewedContractMoney[keyMapTtoal] == 0 || mapExpiredContractMoney[keyMapTtoal] == 0 {
  455. renewalRateMoey = "0%"
  456. } else {
  457. renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMapTtoal]/mapExpiredContractMoney[keyMapTtoal]*100, 2) + "%"
  458. }
  459. if mapRenewedContractNum[keyMapTtoal] == 0 || mapExpiredContractNum[keyMapTtoal] == 0 {
  460. renewalRateNum = "0%"
  461. } else {
  462. renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMapTtoal])/float64(mapExpiredContractNum[keyMapTtoal])*100, 2) + "%"
  463. }
  464. sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum) //"续约率(金额/数量)-(数据)"
  465. sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMapTtoal], 2), " / ", confirmedNoRenewalContractNum[keyMapTtoal]) //"确认不续约合同(金额/数量)-(数据)"
  466. var confirmNonRenewalRateMoey string
  467. var confirmNonRenewalRateNum string
  468. if confirmedNoRenewalContractMoney[keyMapTtoal] == 0 || mapExpiredContractMoney[keyMapTtoal] == 0 {
  469. confirmNonRenewalRateMoey = "0%"
  470. } else {
  471. confirmNonRenewalRateMoey = utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMapTtoal]/mapExpiredContractMoney[keyMapTtoal]*100, 2) + "%"
  472. }
  473. if confirmedNoRenewalContractNum[keyMapTtoal] == 0 || mapExpiredContractNum[keyMapTtoal] == 0 {
  474. confirmNonRenewalRateNum = "0%"
  475. } else {
  476. confirmNonRenewalRateNum = utils.SubFloatToString(float64(confirmedNoRenewalContractNum[keyMapTtoal])/float64(mapExpiredContractNum[keyMapTtoal])*100, 2) + "%"
  477. }
  478. sellerItem.ConfirmNonRenewalRateData = fmt.Sprint(confirmNonRenewalRateMoey, " / ", confirmNonRenewalRateNum) //确认不续约率(金额/数量)-(数据)"
  479. sellerItem.SignedClientCount = fmt.Sprint(mapSignedClientNum[keyMapTtoal]) // 签约客户数量
  480. if mapSignedClientNum[keyMapTtoal] == 0 || mapSignedClientMoney[keyMapTtoal] == 0 {
  481. sellerItem.AverageRevenueCount = "0"
  482. } else {
  483. sellerItem.AverageRevenueCount = utils.SubFloatToString(mapSignedClientMoney[keyMapTtoal]/float64(mapSignedClientNum[keyMapTtoal]), 2) //客单价
  484. }
  485. sellerItem.InvoiceAmountCount = utils.SubFloatToString(mapInvoiceAmountMoney[keyMapTtoal], 2) //"开票金额-(数据)"
  486. sellerItem.PaymentReceivedCount = utils.SubFloatToString(mapPaymentAmountMoney[keyMapTtoal], 2) //"开票金额-(数据)"
  487. if mapInvoiceAmountMoney[keyMapTtoal] == 0 || mapPaymentAmountMoney[keyMapTtoal] == 0 {
  488. sellerItem.UnpaidRatioCount = "0%"
  489. } else {
  490. sellerItem.UnpaidRatioCount = utils.SubFloatToString((mapInvoiceAmountMoney[keyMapTtoal]-mapPaymentAmountMoney[keyMapTtoal])/mapInvoiceAmountMoney[keyMapTtoal]*100, 2) + "%" //"未到款比例-(数据)"
  491. }
  492. sellerItem.NewCustomerInvoicingCount = utils.SubFloatToString(mapNewCustomerInvoicingMoney[keyMapTtoal], 2) // "新客开票-(数据)"
  493. sellerItem.NewCustomerPaymentsReceivedCount = utils.SubFloatToString(mapNewCustomerPaymentsReceivedMoney[keyMapTtoal], 2) // "新客到款-(数据)"
  494. item.DataList = append(item.DataList, sellerItem)
  495. }
  496. for _, vS := range sellerService {
  497. sellerItem := new(statistic_report.RaiDataSummaryDetail)
  498. sellerItem.SellerId = vS.AdminId
  499. sellerItem.SellerName = vS.RealName
  500. sellerItem.AddTrialCount = fmt.Sprint(mapAddTrialNum[keyMap])
  501. sellerItem.NewContractData = fmt.Sprint(utils.SubFloatToString(mapNewContractMoney[keyMap], 2), " / ", mapNewContractNum[keyMap]) // 新签合同(金额/数量)-(数据)
  502. sellerItem.ExpiredContractData = fmt.Sprint(utils.SubFloatToString(mapExpiredContractMoney[keyMap], 2), " / ", mapExpiredContractNum[keyMap]) //"到期合同(金额/数量)-(数据)"
  503. sellerItem.RenewedContractData = fmt.Sprint(utils.SubFloatToString(mapRenewedContractMoney[keyMap], 2), " / ", mapRenewedContractNum[keyMap]) // "续约合同(金额/数量)-(数据)"
  504. var renewalRateMoey string
  505. var renewalRateNum string
  506. if mapRenewedContractMoney[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
  507. renewalRateMoey = "0%"
  508. } else {
  509. renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
  510. }
  511. if mapRenewedContractNum[keyMap] == 0 || mapExpiredContractNum[keyMap] == 0 {
  512. renewalRateNum = "0%"
  513. } else {
  514. renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMap])/float64(mapExpiredContractNum[keyMap])*100, 2) + "%"
  515. }
  516. sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum) //"续约率(金额/数量)-(数据)"
  517. sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMap], 2), " / ", confirmedNoRenewalContractNum[keyMap]) //"确认不续约合同(金额/数量)-(数据)"
  518. var confirmNonRenewalRateMoey string
  519. var confirmNonRenewalRateNum string
  520. if confirmedNoRenewalContractMoney[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
  521. confirmNonRenewalRateMoey = "0%"
  522. } else {
  523. confirmNonRenewalRateMoey = utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
  524. }
  525. if confirmedNoRenewalContractNum[keyMap] == 0 || mapExpiredContractNum[keyMap] == 0 {
  526. confirmNonRenewalRateNum = "0%"
  527. } else {
  528. confirmNonRenewalRateNum = utils.SubFloatToString(float64(confirmedNoRenewalContractNum[keyMap])/float64(mapExpiredContractNum[keyMap])*100, 2) + "%"
  529. }
  530. sellerItem.ConfirmNonRenewalRateData = fmt.Sprint(confirmNonRenewalRateMoey, " / ", confirmNonRenewalRateNum) //确认不续约率(金额/数量)-(数据)"
  531. sellerItem.SignedClientCount = fmt.Sprint(mapSignedClientNum[keyMap]) // 签约客户数量
  532. if mapSignedClientNum[keyMap] == 0 || mapSignedClientMoney[keyMap] == 0 {
  533. sellerItem.AverageRevenueCount = "0"
  534. } else {
  535. sellerItem.AverageRevenueCount = utils.SubFloatToString(mapSignedClientMoney[keyMap]/float64(mapSignedClientNum[keyMap]), 2) //客单价
  536. }
  537. sellerItem.InvoiceAmountCount = utils.SubFloatToString(mapInvoiceAmountMoney[keyMap], 2) //"开票金额-(数据)"
  538. sellerItem.PaymentReceivedCount = utils.SubFloatToString(mapPaymentAmountMoney[keyMap], 2) //"开票金额-(数据)"
  539. if mapInvoiceAmountMoney[keyMap] == 0 || mapPaymentAmountMoney[keyMap] == 0 {
  540. sellerItem.UnpaidRatioCount = "0%"
  541. } else {
  542. sellerItem.UnpaidRatioCount = utils.SubFloatToString((mapInvoiceAmountMoney[keyMap]-mapPaymentAmountMoney[keyMap])/mapInvoiceAmountMoney[keyMap]*100, 2) + "%" //"未到款比例-(数据)"
  543. }
  544. sellerItem.NewCustomerInvoicingCount = utils.SubFloatToString(mapNewCustomerInvoicingMoney[keyMap], 2) // "新客开票-(数据)"
  545. sellerItem.NewCustomerPaymentsReceivedCount = utils.SubFloatToString(mapNewCustomerPaymentsReceivedMoney[keyMap], 2) // "新客到款-(数据)"
  546. item.DataList = append(item.DataList, sellerItem)
  547. }
  548. if len(sellerService) > 0 {
  549. sellerItem := new(statistic_report.RaiDataSummaryDetail)
  550. sellerItem.SellerName = "服务组合计"
  551. sellerItem.AddTrialCount = fmt.Sprint(mapAddTrialNum[keyMapTtoalServer])
  552. sellerItem.NewContractData = fmt.Sprint(utils.SubFloatToString(mapNewContractMoney[keyMapTtoalServer], 2), " / ", mapNewContractNum[keyMapTtoalServer]) // 新签合同(金额/数量)-(数据)
  553. sellerItem.ExpiredContractData = fmt.Sprint(utils.SubFloatToString(mapExpiredContractMoney[keyMapTtoalServer], 2), " / ", mapExpiredContractNum[keyMapTtoalServer]) //"到期合同(金额/数量)-(数据)"
  554. sellerItem.RenewedContractData = fmt.Sprint(utils.SubFloatToString(mapRenewedContractMoney[keyMapTtoalServer], 2), " / ", mapRenewedContractNum[keyMapTtoalServer]) // "续约合同(金额/数量)-(数据)"
  555. var renewalRateMoey string
  556. var renewalRateNum string
  557. if mapRenewedContractMoney[keyMapTtoalServer] == 0 || mapExpiredContractMoney[keyMapTtoalServer] == 0 {
  558. renewalRateMoey = "0%"
  559. } else {
  560. renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMapTtoalServer]/mapExpiredContractMoney[keyMapTtoalServer]*100, 2) + "%"
  561. }
  562. if mapRenewedContractNum[keyMapTtoalServer] == 0 || mapExpiredContractNum[keyMapTtoalServer] == 0 {
  563. renewalRateNum = "0%"
  564. } else {
  565. renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMapTtoalServer])/float64(mapExpiredContractNum[keyMapTtoalServer])*100, 2) + "%"
  566. }
  567. sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum) //"续约率(金额/数量)-(数据)"
  568. sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMapTtoalServer], 2), " / ", confirmedNoRenewalContractNum[keyMapTtoalServer]) //"确认不续约合同(金额/数量)-(数据)"
  569. var confirmNonRenewalRateMoey string
  570. var confirmNonRenewalRateNum string
  571. if confirmedNoRenewalContractMoney[keyMapTtoalServer] == 0 || mapExpiredContractMoney[keyMapTtoalServer] == 0 {
  572. confirmNonRenewalRateMoey = "0%"
  573. } else {
  574. confirmNonRenewalRateMoey = utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMapTtoalServer]/mapExpiredContractMoney[keyMapTtoalServer]*100, 2) + "%"
  575. }
  576. if confirmedNoRenewalContractNum[keyMapTtoalServer] == 0 || mapExpiredContractNum[keyMapTtoalServer] == 0 {
  577. confirmNonRenewalRateNum = "0%"
  578. } else {
  579. confirmNonRenewalRateNum = utils.SubFloatToString(float64(confirmedNoRenewalContractNum[keyMapTtoalServer])/float64(mapExpiredContractNum[keyMapTtoalServer])*100, 2) + "%"
  580. }
  581. sellerItem.ConfirmNonRenewalRateData = fmt.Sprint(confirmNonRenewalRateMoey, " / ", confirmNonRenewalRateNum) //确认不续约率(金额/数量)-(数据)"
  582. sellerItem.SignedClientCount = fmt.Sprint(mapSignedClientNum[keyMapTtoalServer]) // 签约客户数量
  583. if mapSignedClientNum[keyMapTtoalServer] == 0 || mapSignedClientMoney[keyMapTtoalServer] == 0 {
  584. sellerItem.AverageRevenueCount = "0"
  585. } else {
  586. sellerItem.AverageRevenueCount = utils.SubFloatToString(mapSignedClientMoney[keyMapTtoalServer]/float64(mapSignedClientNum[keyMapTtoalServer]), 2) //客单价
  587. }
  588. sellerItem.InvoiceAmountCount = utils.SubFloatToString(mapInvoiceAmountMoney[keyMapTtoalServer], 2) //"开票金额-(数据)"
  589. sellerItem.PaymentReceivedCount = utils.SubFloatToString(mapPaymentAmountMoney[keyMapTtoalServer], 2) //"开票金额-(数据)"
  590. if mapInvoiceAmountMoney[keyMapTtoalServer] == 0 || mapPaymentAmountMoney[keyMapTtoalServer] == 0 {
  591. sellerItem.UnpaidRatioCount = "0%"
  592. } else {
  593. sellerItem.UnpaidRatioCount = utils.SubFloatToString((mapInvoiceAmountMoney[keyMapTtoalServer]-mapPaymentAmountMoney[keyMapTtoalServer])/mapInvoiceAmountMoney[keyMapTtoalServer]*100, 2) + "%" //"未到款比例-(数据)"
  594. }
  595. sellerItem.NewCustomerInvoicingCount = utils.SubFloatToString(mapNewCustomerInvoicingMoney[keyMapTtoalServer], 2) // "新客开票-(数据)"
  596. sellerItem.NewCustomerPaymentsReceivedCount = utils.SubFloatToString(mapNewCustomerPaymentsReceivedMoney[keyMapTtoalServer], 2) // "新客到款-(数据)"
  597. item.DataList = append(item.DataList, sellerItem)
  598. }
  599. items = append(items, item)
  600. }
  601. }
  602. resp.List = items
  603. br.Ret = 200
  604. br.Success = true
  605. br.Msg = "获取成功"
  606. br.Data = resp
  607. }
  608. // MergeCompanyList
  609. // @Title 权益数据汇总弹窗详情
  610. // @Description 权益数据汇总弹窗详情接口
  611. // @Param SellerId query int true "销售ID"
  612. // @Param DataType query string false "报表类型,枚举值:`季度`,`年度`,`半年度`"
  613. // @Param PopupType query string false "弹窗数据类型,枚举值:"
  614. // @Param PageSize query int true "每页数据条数"
  615. // @Param CurrentIndex query int true "当前页页码,从1开始"
  616. // @Success 200 {object} statistic_report.RaiDataSummaryPopupTypeResp
  617. // @router /rai_data_summary/detail [get]
  618. func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
  619. br := new(models.BaseResponse).Init()
  620. defer func() {
  621. this.Data["json"] = br
  622. this.ServeJSON()
  623. }()
  624. sysUser := this.SysUser
  625. if sysUser == nil {
  626. br.Msg = "请登录"
  627. br.ErrMsg = "请登录,SysUser Is Empty"
  628. br.Ret = 408
  629. return
  630. }
  631. pageSize, _ := this.GetInt("PageSize")
  632. currentIndex, _ := this.GetInt("CurrentIndex")
  633. dataType := this.GetString("DataType")
  634. sellerId, _ := this.GetInt("SellerId")
  635. popupType := this.GetString("PopupType")
  636. var startSize int
  637. if pageSize <= 0 {
  638. pageSize = utils.PageSize20
  639. }
  640. if currentIndex <= 0 {
  641. currentIndex = 1
  642. }
  643. startSize = utils.StartIndex(currentIndex, pageSize)
  644. var startDate string
  645. var endDate string
  646. year := (dataType[:4])
  647. if strings.Contains(dataType, "Q1") {
  648. startDate = year + "-01-01"
  649. endDate = year + "-03-31"
  650. } else if strings.Contains(dataType, "Q2") {
  651. startDate = year + "-04-01"
  652. endDate = year + "-06-30"
  653. } else if strings.Contains(dataType, "Q3") {
  654. startDate = year + "-07-01"
  655. endDate = year + "-09-30"
  656. } else if strings.Contains(dataType, "Q4") {
  657. startDate = year + "-10-01"
  658. endDate = year + "-12-31"
  659. } else if strings.Contains(dataType, "H1") {
  660. startDate = year + "-01-01"
  661. endDate = year + "-06-31"
  662. } else if strings.Contains(dataType, "H2") {
  663. startDate = year + "-07-01"
  664. endDate = year + "-12-31"
  665. } else {
  666. startDate = year + "-01-01"
  667. endDate = year + "-12-31"
  668. }
  669. resp := new(statistic_report.RaiDataSummaryPopupTypeResp)
  670. var listResp []*statistic_report.RaiDataSummaryDetailResp
  671. var listGroup []*models.CompanyContractGroupList
  672. var trialTotal int
  673. var condition string
  674. var pars []interface{}
  675. switch popupType {
  676. case "新增试用":
  677. var parsTry []interface{}
  678. var conditionTry string
  679. if sellerId > 0 {
  680. conditionTry += ` AND a.sys_user_id = ? `
  681. parsTry = append(parsTry, sellerId)
  682. }
  683. conditionTry += ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ( "add","receive","apply_receive" ) AND a.sys_user_id IN ( SELECT admin_id FROM admin WHERE role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ) `
  684. parsTry = append(parsTry, startDate, endDate)
  685. total, err := models.GetIncrementalCompanyCountByOperationRecordRai(conditionTry, parsTry)
  686. if err != nil {
  687. br.Msg = "获取失败"
  688. br.ErrMsg = "获取新增试用客户数量失败,Err:" + err.Error()
  689. return
  690. }
  691. trialTotal = total
  692. //列表页数据
  693. tryList, err := models.GetIncrementalCompanyListByOperationRecordRai(conditionTry, parsTry, startSize, pageSize)
  694. if err != nil {
  695. br.Msg = "获取失败"
  696. br.ErrMsg = "获取失败,Err:" + err.Error()
  697. return
  698. }
  699. if len(tryList) > 0 {
  700. for _, v := range tryList {
  701. item := new(statistic_report.RaiDataSummaryDetailResp)
  702. v.SellerName = v.SysRealName
  703. if v.Operation == "add" {
  704. item.AddType = "新建"
  705. } else if v.Operation == "receive" || v.Operation == "apply_receive" {
  706. item.AddType = "领取"
  707. }
  708. item.CompanyName = v.CompanyName
  709. item.SellerName = v.SellerName
  710. item.CreateTime = v.CreateTime
  711. listResp = append(listResp, item)
  712. }
  713. }
  714. case "新签合同":
  715. if sellerId > 0 {
  716. condition += ` AND a.seller_id_init = ? `
  717. pars = append(pars, sellerId)
  718. }
  719. condition += ` AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? `
  720. pars = append(pars, startDate, endDate)
  721. condition += ` AND a.rai_contract_type = ? `
  722. pars = append(pars, "新签合同")
  723. total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
  724. if err != nil && err.Error() != utils.ErrNoRow() {
  725. br.Msg = "获取失败"
  726. br.ErrMsg = "获取失败,Err:" + err.Error()
  727. return
  728. }
  729. trialTotal = total
  730. //列表页数据
  731. tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
  732. if err != nil {
  733. br.Msg = "获取失败"
  734. br.ErrMsg = "获取失败,Err:" + err.Error()
  735. return
  736. }
  737. if len(tmpList) > 0 {
  738. var companyContractIds []int
  739. for _, v := range tmpList {
  740. companyContractIds = append(companyContractIds, v.CompanyContractId)
  741. }
  742. //合并合同所对应的权限
  743. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
  744. if err != nil {
  745. br.Msg = "获取失败"
  746. br.ErrMsg = "获取失败,Err:" + err.Error()
  747. return
  748. }
  749. for _, v := range tmpList {
  750. item := new(statistic_report.RaiDataSummaryDetailResp)
  751. item.CompanyName = v.CompanyName
  752. item.SellerName = v.SellerNameInit
  753. item.StartDate = v.StartDate
  754. item.EndDate = v.EndDate
  755. item.Money = v.Money
  756. item.PermissionName = mappermissionName[v.CompanyContractId]
  757. listResp = append(listResp, item)
  758. }
  759. listGroup, err = models.GetCompanyContractGroupList(condition, pars)
  760. if err != nil {
  761. br.Msg = "获取失败"
  762. br.ErrMsg = "获取失败,Err:" + err.Error()
  763. return
  764. }
  765. }
  766. case "到期合同":
  767. if sellerId > 0 {
  768. condition += ` AND a.seller_id_last = ? `
  769. pars = append(pars, sellerId)
  770. }
  771. condition += ` AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date < ? `
  772. pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
  773. total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
  774. if err != nil && err.Error() != utils.ErrNoRow() {
  775. br.Msg = "获取失败"
  776. br.ErrMsg = "获取失败,Err:" + err.Error()
  777. return
  778. }
  779. trialTotal = total
  780. //列表页数据
  781. tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
  782. if err != nil {
  783. br.Msg = "获取失败"
  784. br.ErrMsg = "获取失败,Err:" + err.Error()
  785. return
  786. }
  787. if len(tmpList) > 0 {
  788. var companyContractIds []int
  789. for _, v := range tmpList {
  790. companyContractIds = append(companyContractIds, v.CompanyContractId)
  791. }
  792. //合并合同所对应的权限
  793. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
  794. if err != nil {
  795. br.Msg = "获取失败"
  796. br.ErrMsg = "获取失败,Err:" + err.Error()
  797. return
  798. }
  799. for _, v := range tmpList {
  800. item := new(statistic_report.RaiDataSummaryDetailResp)
  801. item.CompanyName = v.CompanyName
  802. item.SellerName = v.SellerNameLast
  803. item.StartDate = v.StartDate
  804. item.EndDate = v.EndDate
  805. item.Money = v.Money
  806. item.PermissionName = mappermissionName[v.CompanyContractId]
  807. listResp = append(listResp, item)
  808. }
  809. listGroup, err = models.GetCompanyContractGroupList(condition, pars)
  810. if err != nil {
  811. br.Msg = "获取失败"
  812. br.ErrMsg = "获取失败,Err:" + err.Error()
  813. return
  814. }
  815. }
  816. case "续约合同":
  817. if sellerId > 0 {
  818. condition += ` AND a.seller_id_last = ? `
  819. pars = append(pars, sellerId)
  820. }
  821. condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND inherit_company_contract_id > 0 `
  822. pars = append(pars, startDate, endDate)
  823. total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
  824. if err != nil && err.Error() != utils.ErrNoRow() {
  825. br.Msg = "获取失败"
  826. br.ErrMsg = "获取失败,Err:" + err.Error()
  827. return
  828. }
  829. trialTotal = total
  830. //列表页数据
  831. tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
  832. if err != nil {
  833. br.Msg = "获取失败"
  834. br.ErrMsg = "获取失败,Err:" + err.Error()
  835. return
  836. }
  837. if len(tmpList) > 0 {
  838. var companyContractIds []int
  839. for _, v := range tmpList {
  840. companyContractIds = append(companyContractIds, v.CompanyContractId)
  841. }
  842. //合并合同所对应的权限
  843. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
  844. if err != nil {
  845. br.Msg = "获取失败"
  846. br.ErrMsg = "获取失败,Err:" + err.Error()
  847. return
  848. }
  849. for _, v := range tmpList {
  850. item := new(statistic_report.RaiDataSummaryDetailResp)
  851. item.CompanyName = v.CompanyName
  852. item.SellerName = v.SellerNameLast
  853. item.StartDate = v.StartDate
  854. item.EndDate = v.EndDate
  855. item.Money = v.Money
  856. item.PermissionName = mappermissionName[v.CompanyContractId]
  857. listResp = append(listResp, item)
  858. }
  859. listGroup, err = models.GetCompanyContractGroupList(condition, pars)
  860. if err != nil {
  861. br.Msg = "获取失败"
  862. br.ErrMsg = "获取失败,Err:" + err.Error()
  863. return
  864. }
  865. }
  866. case "续约率":
  867. var conditionEnd string
  868. var parsEnd []interface{}
  869. if sellerId > 0 {
  870. condition += ` AND a.seller_id_last = ? `
  871. pars = append(pars, sellerId)
  872. conditionEnd += ` AND a.seller_id_last = ? `
  873. parsEnd = append(pars, sellerId)
  874. }
  875. condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND inherit_company_contract_id > 0 `
  876. pars = append(pars, startDate, endDate)
  877. listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
  878. if err != nil {
  879. br.Msg = "获取数据信息失败"
  880. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  881. return
  882. }
  883. //到期合同数据
  884. conditionEnd += ` AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date < ? `
  885. parsEnd = append(parsEnd, startDate, endDate, time.Now().Format(utils.FormatDate))
  886. listEndData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
  887. if err != nil {
  888. br.Msg = "获取数据信息失败"
  889. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  890. return
  891. }
  892. var renewedContractMoney float64 // 续约金额
  893. var renewedContractCompany float64 // 续约客户数
  894. maprenewedContractCompany := make(map[int]bool)
  895. var expiredContractMoney float64 //到期金额
  896. var expiredContractCompany float64 // 到期客户数
  897. mapexpiredContractCompany := make(map[int]bool)
  898. for _, v := range listRaiData {
  899. renewedContractMoney += v.Money
  900. if !maprenewedContractCompany[v.CompanyId] {
  901. renewedContractCompany++
  902. maprenewedContractCompany[v.CompanyId] = true
  903. }
  904. //startDateTime := utils.StrDateToDate(v.StartDate)
  905. //if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
  906. // expiredContractMoney += v.Money
  907. // if !mapexpiredContractCompany[v.CompanyId] {
  908. // expiredContractCompany++
  909. // mapexpiredContractCompany[v.CompanyId] = true
  910. // }
  911. //}
  912. }
  913. for _, v := range listEndData {
  914. expiredContractMoney += v.Money
  915. if !mapexpiredContractCompany[v.CompanyId] {
  916. expiredContractCompany++
  917. mapexpiredContractCompany[v.CompanyId] = true
  918. }
  919. }
  920. item := new(statistic_report.RaiDataSummaryDetailResp)
  921. item.TbaleNameAText = "金额续约率"
  922. item.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(renewedContractMoney, 2))
  923. item.ExpiredContractMoney = fmt.Sprint(utils.SubFloatToString(expiredContractMoney, 2))
  924. if renewedContractMoney == 0 || expiredContractMoney == 0 {
  925. item.RenewalRate = "0%"
  926. } else {
  927. item.RenewalRate = fmt.Sprint(utils.SubFloatToString(renewedContractMoney/expiredContractMoney*100, 2), "%")
  928. }
  929. listResp = append(listResp, item)
  930. item2 := new(statistic_report.RaiDataSummaryDetailResp)
  931. item2.TbaleNameAText = "客户续约率"
  932. item2.RenewedContractMoney = fmt.Sprint(renewedContractCompany)
  933. item2.ExpiredContractMoney = fmt.Sprint(expiredContractCompany)
  934. if renewedContractCompany == 0 || expiredContractCompany == 0 {
  935. item2.RenewalRate = "0%"
  936. } else {
  937. item2.RenewalRate = fmt.Sprint(utils.SubFloatToString(renewedContractCompany/expiredContractCompany*100, 2), "%")
  938. }
  939. listResp = append(listResp, item2)
  940. case "确认不续约合同":
  941. noRenewedcompanyContractIds := services.GetCompanyContractNoRenewedAscribeListArr()
  942. condition += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `) ` // 已确认
  943. pars = append(pars, noRenewedcompanyContractIds)
  944. if sellerId > 0 {
  945. condition += ` AND a.seller_id_last = ? `
  946. pars = append(pars, sellerId)
  947. }
  948. condition += ` AND a.product_id = 2 AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date <= ? `
  949. pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
  950. total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
  951. if err != nil && err.Error() != utils.ErrNoRow() {
  952. br.Msg = "获取失败"
  953. br.ErrMsg = "获取失败,Err:" + err.Error()
  954. return
  955. }
  956. trialTotal = total
  957. //列表页数据
  958. tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
  959. if err != nil {
  960. br.Msg = "获取失败"
  961. br.ErrMsg = "获取失败,Err:" + err.Error()
  962. return
  963. }
  964. if len(tmpList) > 0 {
  965. var companyContractIds []int
  966. for _, v := range tmpList {
  967. companyContractIds = append(companyContractIds, v.CompanyContractId)
  968. }
  969. //合并合同所对应的权限
  970. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
  971. if err != nil {
  972. br.Msg = "获取失败"
  973. br.ErrMsg = "获取失败,Err:" + err.Error()
  974. return
  975. }
  976. for _, v := range tmpList {
  977. item := new(statistic_report.RaiDataSummaryDetailResp)
  978. item.CompanyName = v.CompanyName
  979. item.SellerName = v.SellerNameInit
  980. item.StartDate = v.StartDate
  981. item.EndDate = v.EndDate
  982. item.Money = v.Money
  983. item.PermissionName = mappermissionName[v.CompanyContractId]
  984. listResp = append(listResp, item)
  985. }
  986. listGroup, err = models.GetCompanyContractGroupList(condition, pars)
  987. if err != nil {
  988. br.Msg = "获取失败"
  989. br.ErrMsg = "获取失败,Err:" + err.Error()
  990. return
  991. }
  992. }
  993. case "确认不续约率":
  994. noRenewedcompanyContractIdsMap := services.GetCompanyContractNoRenewedAscribeListMap()
  995. if sellerId > 0 {
  996. condition += ` AND a.seller_id_last = ? `
  997. pars = append(pars, sellerId)
  998. }
  999. condition += ` AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? AND a.end_date <= ? `
  1000. pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
  1001. listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
  1002. if err != nil {
  1003. br.Msg = "获取数据信息失败"
  1004. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1005. return
  1006. }
  1007. var norenewedContractMoney float64 // 不续约金额
  1008. var norenewedContractCompany float64 // 不续约客户数
  1009. mapnorenewedContractCompany := make(map[int]bool)
  1010. var expiredContractMoney float64 //到期金额
  1011. var expiredContractCompany float64 // 到期客户数
  1012. mapexpiredContractCompany := make(map[int]bool)
  1013. for _, v := range listRaiData {
  1014. if noRenewedcompanyContractIdsMap[v.CompanyContractId] {
  1015. norenewedContractMoney += v.Money
  1016. if !mapnorenewedContractCompany[v.CompanyId] {
  1017. norenewedContractCompany++
  1018. mapnorenewedContractCompany[v.CompanyId] = true
  1019. }
  1020. startDateTime := utils.StrDateToDate(v.StartDate)
  1021. if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
  1022. expiredContractMoney += v.Money
  1023. if !mapexpiredContractCompany[v.CompanyId] {
  1024. expiredContractCompany++
  1025. mapexpiredContractCompany[v.CompanyId] = true
  1026. }
  1027. }
  1028. }
  1029. }
  1030. item := new(statistic_report.RaiDataSummaryDetailResp)
  1031. item.TbaleNameAText = "金额不续约率"
  1032. item.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(norenewedContractMoney, 2))
  1033. item.ExpiredContractMoney = fmt.Sprint(utils.SubFloatToString(expiredContractMoney, 2))
  1034. if norenewedContractMoney == 0 || expiredContractMoney == 0 {
  1035. item.RenewalRate = "0%"
  1036. } else {
  1037. item.RenewalRate = fmt.Sprint(utils.SubFloatToString(norenewedContractMoney/expiredContractMoney*100, 2), "%")
  1038. }
  1039. listResp = append(listResp, item)
  1040. item2 := new(statistic_report.RaiDataSummaryDetailResp)
  1041. item2.TbaleNameAText = "客户不续约率"
  1042. item2.RenewedContractMoney = fmt.Sprint(norenewedContractCompany)
  1043. item2.ExpiredContractMoney = fmt.Sprint(expiredContractCompany)
  1044. if norenewedContractCompany == 0 || expiredContractCompany == 0 {
  1045. item2.RenewalRate = "0%"
  1046. } else {
  1047. item2.RenewalRate = fmt.Sprint(utils.SubFloatToString(norenewedContractCompany/expiredContractCompany*100, 2), "%")
  1048. }
  1049. listResp = append(listResp, item2)
  1050. case "签约客户数量":
  1051. if sellerId > 0 {
  1052. condition += ` AND a.seller_id_last = ? `
  1053. pars = append(pars, sellerId)
  1054. }
  1055. condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
  1056. pars = append(pars, startDate, endDate)
  1057. listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
  1058. if err != nil {
  1059. br.Msg = "获取数据信息失败"
  1060. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1061. return
  1062. }
  1063. var renewedContractCompany int // 续约客户数
  1064. var renewedContract int // 续约合同数
  1065. maprenewedContractCompany := make(map[int]bool)
  1066. var newContractCompany int // 新签客户数
  1067. var newContract int // 新签合同数
  1068. mapenewContractCompany := make(map[int]bool)
  1069. for _, v := range listRaiData {
  1070. if v.RaiContractType == "新签合同" {
  1071. newContract++
  1072. if !mapenewContractCompany[v.CompanyId] {
  1073. newContractCompany++
  1074. mapenewContractCompany[v.CompanyId] = true
  1075. }
  1076. } else if v.RaiContractType == "续约合同" {
  1077. renewedContract++
  1078. if !maprenewedContractCompany[v.CompanyId] {
  1079. renewedContractCompany++
  1080. maprenewedContractCompany[v.CompanyId] = true
  1081. }
  1082. }
  1083. }
  1084. item := new(statistic_report.RaiDataSummaryDetailResp)
  1085. item.RenewedContractCompany = renewedContractCompany
  1086. item.RenewedContract = renewedContract
  1087. item.NewContractCompany = newContractCompany
  1088. item.NewContract = newContract
  1089. listResp = append(listResp, item)
  1090. case "客单价":
  1091. if sellerId > 0 {
  1092. condition += ` AND a.seller_id_last = ? `
  1093. pars = append(pars, sellerId)
  1094. }
  1095. condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
  1096. pars = append(pars, startDate, endDate)
  1097. listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
  1098. if err != nil {
  1099. br.Msg = "获取数据信息失败"
  1100. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1101. return
  1102. }
  1103. var ontractMoney float64 // 签约总金额
  1104. var contractNum int // 签约客户数
  1105. for _, v := range listRaiData {
  1106. ontractMoney += v.Money
  1107. contractNum++
  1108. }
  1109. item := new(statistic_report.RaiDataSummaryDetailResp)
  1110. item.ContractMoney = fmt.Sprint(utils.SubFloatToString(ontractMoney, 2))
  1111. item.ContractNum = contractNum
  1112. listResp = append(listResp, item)
  1113. case "开票金额":
  1114. if sellerId > 0 {
  1115. condition += ` AND a.rai_seller_id = ? `
  1116. pars = append(pars, sellerId)
  1117. }
  1118. condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND invoiced_amount > 0 AND product_ids LIKE '%2%' "
  1119. pars = append(pars, startDate, endDate)
  1120. listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
  1121. if err != nil {
  1122. br.Msg = "获取数据信息失败"
  1123. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1124. return
  1125. }
  1126. for _, v := range listFmsData {
  1127. item := new(statistic_report.RaiDataSummaryDetailResp)
  1128. item.CompanyName = v.CompanyName
  1129. item.SellerName = v.RaiSellerName
  1130. item.ContractCode = v.ContractCode
  1131. item.InvoicedAmount = v.InvoicedAmount
  1132. item.CreateTime = v.CreateTime.Format(utils.FormatDate)
  1133. listResp = append(listResp, item)
  1134. }
  1135. case "到款金额":
  1136. if sellerId > 0 {
  1137. condition += ` AND a.rai_seller_id = ? `
  1138. pars = append(pars, sellerId)
  1139. }
  1140. condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
  1141. pars = append(pars, startDate, endDate)
  1142. listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
  1143. if err != nil {
  1144. br.Msg = "获取数据信息失败"
  1145. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. for _, v := range listFmsData {
  1149. item := new(statistic_report.RaiDataSummaryDetailResp)
  1150. item.CompanyName = v.CompanyName
  1151. item.SellerName = v.RaiSellerName
  1152. item.ContractCode = v.ContractCode
  1153. item.PaymentAmount = v.PaymentAmount
  1154. item.CreateTime = v.CreateTime.Format(utils.FormatDate)
  1155. listResp = append(listResp, item)
  1156. }
  1157. case "未到款比例":
  1158. if sellerId > 0 {
  1159. condition += ` AND a.rai_seller_id = ? `
  1160. pars = append(pars, sellerId)
  1161. }
  1162. condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND product_ids LIKE '%2%' "
  1163. pars = append(pars, startDate, endDate)
  1164. listFmsData, err := fms.GetContractRegisterAmountList(condition, pars)
  1165. if err != nil {
  1166. br.Msg = "获取数据信息失败"
  1167. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1168. return
  1169. }
  1170. for _, v := range listFmsData {
  1171. item := new(statistic_report.RaiDataSummaryDetailResp)
  1172. item.InvoicedAmount = v.InvoicedAmount
  1173. item.PaymentAmount = v.PaymentAmount
  1174. item.NotReceivedtAmount = v.InvoicedAmount - v.PaymentAmount
  1175. item.CreateTime = v.CreateTime.Format(utils.FormatDate)
  1176. listResp = append(listResp, item)
  1177. }
  1178. case "新客开票":
  1179. if sellerId > 0 {
  1180. condition += ` AND a.rai_seller_id = ? `
  1181. pars = append(pars, sellerId)
  1182. }
  1183. condition += " AND a.is_deleted = 0 AND contract_type = 1 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
  1184. pars = append(pars, startDate, endDate)
  1185. listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
  1186. if err != nil {
  1187. br.Msg = "获取数据信息失败"
  1188. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1189. return
  1190. }
  1191. for _, v := range listFmsData {
  1192. item := new(statistic_report.RaiDataSummaryDetailResp)
  1193. item.CompanyName = v.CompanyName
  1194. item.SellerName = v.RaiSellerName
  1195. item.ContractCode = v.ContractCode
  1196. item.PaymentAmount = v.PaymentAmount
  1197. item.CreateTime = v.CreateTime.Format(utils.FormatDate)
  1198. listResp = append(listResp, item)
  1199. }
  1200. case "新客到款":
  1201. if sellerId > 0 {
  1202. condition += ` AND a.rai_seller_id = ? `
  1203. pars = append(pars, sellerId)
  1204. }
  1205. condition += " AND a.is_deleted = 0 AND contract_type = 1 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
  1206. pars = append(pars, startDate, endDate)
  1207. listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
  1208. if err != nil {
  1209. br.Msg = "获取数据信息失败"
  1210. br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
  1211. return
  1212. }
  1213. for _, v := range listFmsData {
  1214. item := new(statistic_report.RaiDataSummaryDetailResp)
  1215. item.CompanyName = v.CompanyName
  1216. item.SellerName = v.RaiSellerName
  1217. item.ContractCode = v.ContractCode
  1218. item.PaymentAmount = v.PaymentAmount
  1219. item.CreateTime = v.CreateTime.Format(utils.FormatDate)
  1220. listResp = append(listResp, item)
  1221. }
  1222. }
  1223. if len(listResp) == 0 {
  1224. listResp = make([]*statistic_report.RaiDataSummaryDetailResp, 0)
  1225. }
  1226. if len(listGroup) > 0 {
  1227. for _, v := range listGroup {
  1228. if v.CompanyCount > 1 {
  1229. resp.CompanyMultiple++
  1230. }
  1231. }
  1232. resp.CompanyNum = len(listGroup)
  1233. }
  1234. resp.List = listResp
  1235. page := paging.GetPaging(currentIndex, pageSize, trialTotal)
  1236. resp.Paging = page
  1237. br.Ret = 200
  1238. br.Success = true
  1239. br.Msg = "获取成功"
  1240. br.Data = resp
  1241. }