tableConfig.tsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. import React from "react"
  2. import { Statistic } from "antd"
  3. import { gameClassifyEnum } from "@/components/QueryForm/const"
  4. import WidthEllipsis from "@/components/widthEllipsis"
  5. import moment from "moment"
  6. function columnsUser12(): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  7. let defaultStart = 13
  8. // 用户LTV
  9. const userLtvDay = Array(90).fill('').map((_item: string, index: number) => {
  10. let field = `userLtv${index + 1}`
  11. let data = {
  12. title: `注册LTV_D${index + 1}`,
  13. dataIndex: field,
  14. label: "注册LTV",
  15. align: "center",
  16. width: 70,
  17. render: (a: string, b: any) => {
  18. let date1 = moment()
  19. if (b?.costDate === '总计') {
  20. if (b?.beginDay) {
  21. date1 = moment(b?.beginDay)
  22. } else {
  23. date1 = moment()
  24. }
  25. } else {
  26. date1 = moment(b.costDate)
  27. }
  28. let dt = moment()
  29. let day = dt.diff(date1, 'day');
  30. if (index <= day) {
  31. return <Statistic value={a || 0} />
  32. }
  33. return '--'
  34. }
  35. }
  36. data['default'] = defaultStart + index
  37. return data
  38. })
  39. // 用户LTV月
  40. let defaultStartM = 103
  41. let userLtvMonth = [4, 5, 6, 7, 8, 9, 10, 11].map((item, index) => {
  42. let field = `userLtvM${item}`
  43. let data = {
  44. title: `注册LTV_M${item}`,
  45. dataIndex: field,
  46. label: "注册LTV",
  47. align: "center",
  48. width: 70,
  49. render: (a: string, b: any) => {
  50. let date1 = moment()
  51. if (b?.costDate === '总计') {
  52. if (b?.beginDay) {
  53. date1 = moment(b?.beginDay)
  54. } else {
  55. date1 = moment()
  56. }
  57. } else {
  58. date1 = moment(b.costDate)
  59. }
  60. let dt = moment()
  61. let day = dt.diff(date1, 'day');
  62. if (item * 30 <= day) {
  63. return <Statistic value={a || 0} />
  64. }
  65. return '--'
  66. }
  67. }
  68. data['default'] = defaultStartM + index
  69. return data
  70. })
  71. userLtvMonth.push({
  72. title: `注册LTV_Y1`,
  73. dataIndex: 'userLtvY1',
  74. label: "注册LTV",
  75. align: "center",
  76. width: 70,
  77. default: 111,
  78. render: (a: string, b: any) => {
  79. let date1 = moment()
  80. if (b?.costDate === '总计') {
  81. if (b?.beginDay) {
  82. date1 = moment(b?.beginDay)
  83. } else {
  84. date1 = moment()
  85. }
  86. } else {
  87. date1 = moment(b.costDate)
  88. }
  89. let dt = moment()
  90. let day = dt.diff(date1, 'day');
  91. if (365 <= day) {
  92. return <Statistic value={a || 0} />
  93. }
  94. return '--'
  95. }
  96. } as any)
  97. userLtvMonth.push({
  98. title: `注册LTV_总`,
  99. dataIndex: 'userLtvTotal',
  100. label: "注册LTV",
  101. align: "center",
  102. width: 70,
  103. default: 112,
  104. render: (a: string) => <Statistic value={a || 0} />
  105. } as any)
  106. // 创角LTV
  107. const roleLtvDay = Array(90).fill('').map((_item: string, index: number) => {
  108. let field = `roleLtv${index + 1}`
  109. let data = {
  110. title: `创角LTV_D${index + 1}`,
  111. dataIndex: field,
  112. label: "创角LTV",
  113. align: "center",
  114. width: 70,
  115. render: (a: string, b: any) => {
  116. let date1 = moment()
  117. if (b?.costDate === '总计') {
  118. if (b?.beginDay) {
  119. date1 = moment(b?.beginDay)
  120. } else {
  121. date1 = moment()
  122. }
  123. } else {
  124. date1 = moment(b.costDate)
  125. }
  126. let dt = moment()
  127. let day = dt.diff(date1, 'day');
  128. if (index <= day) {
  129. return <Statistic value={a || 0} />
  130. }
  131. return '--'
  132. }
  133. }
  134. return data
  135. })
  136. let roleLtvMonth = [4, 5, 6, 7, 8, 9, 10, 11].map((item, index) => {
  137. let field = `roleLtvM${item}`
  138. let data = {
  139. title: `创角LTV_M${item}`,
  140. dataIndex: field,
  141. label: "创角LTV",
  142. align: "center",
  143. width: 70,
  144. render: (a: string, b: any) => {
  145. let date1 = moment()
  146. if (b?.costDate === '总计') {
  147. if (b?.beginDay) {
  148. date1 = moment(b?.beginDay)
  149. } else {
  150. date1 = moment()
  151. }
  152. } else {
  153. date1 = moment(b.costDate)
  154. }
  155. let dt = moment()
  156. let day = dt.diff(date1, 'day');
  157. if (item * 30 <= day) {
  158. return <Statistic value={a || 0} />
  159. }
  160. return '--'
  161. }
  162. }
  163. return data
  164. })
  165. roleLtvMonth.push({
  166. title: `创角LTV_Y1`,
  167. dataIndex: 'roleLtvY1',
  168. label: "创角LTV",
  169. align: "center",
  170. width: 70,
  171. render: (a: string, b: any) => {
  172. let date1 = moment()
  173. if (b?.costDate === '总计') {
  174. if (b?.beginDay) {
  175. date1 = moment(b?.beginDay)
  176. } else {
  177. date1 = moment()
  178. }
  179. } else {
  180. date1 = moment(b.costDate)
  181. }
  182. let dt = moment()
  183. let day = dt.diff(date1, 'day');
  184. if (365 <= day) {
  185. return <Statistic value={a || 0} />
  186. }
  187. return '--'
  188. }
  189. } as any)
  190. roleLtvMonth.push({
  191. title: `创角LTV_总`,
  192. dataIndex: 'roleLtvTotal',
  193. label: "创角LTV",
  194. align: "center",
  195. width: 70,
  196. render: (a: string) => <Statistic value={a || 0} />
  197. } as any)
  198. return [
  199. {
  200. label: '游戏信息',
  201. data: [
  202. {
  203. title: '推广游戏名称', dataIndex: 'gameName', label: '游戏信息', align: 'center', width: 70, default: 2,
  204. render: (a: string, b: any) => (<WidthEllipsis isCopy={b?.costDate !== '总计'} value={a} />)
  205. },
  206. {
  207. title: '推广游戏应用类型', dataIndex: 'gameClassify', label: '游戏信息', align: 'center', width: 80,
  208. render: (a: string) => (<WidthEllipsis value={gameClassifyEnum[a]} />)
  209. }
  210. ]
  211. },
  212. {
  213. label: '时间',
  214. data: [
  215. {
  216. title: '日期', dataIndex: 'costDate', label: '时间', align: 'center', width: 90, default: 1,
  217. render: (a: string) => (<WidthEllipsis value={a} />)
  218. },
  219. ]
  220. },
  221. {
  222. label: '消耗',
  223. data: [
  224. {
  225. title: '消耗', dataIndex: 'cost', label: '消耗', align: 'center', width: 90, sorter: true, default: 3,
  226. render: (a: string) => <Statistic value={a || 0} />
  227. }
  228. ]
  229. },
  230. {
  231. label: '用户数据',
  232. data: [
  233. {
  234. title: '注册人数', dataIndex: 'regNum', label: '用户数据', align: 'center', width: 70, sorter: true, default: 4,
  235. render: (a: string) => <Statistic value={a || 0} />
  236. },
  237. {
  238. title: '注册成本', dataIndex: 'regCost', label: '用户数据', align: 'center', width: 70, sorter: true,
  239. render: (a: string) => <Statistic value={a || 0} />
  240. }
  241. ]
  242. },
  243. {
  244. label: '付费数据',
  245. data: [
  246. {
  247. title: '首日新用户充值次数', dataIndex: 'firstNewUserAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  248. render: (a: string) => <Statistic value={a || 0} />
  249. },
  250. {
  251. title: '首日新用户充值人数', dataIndex: 'firstNewUserAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 5,
  252. render: (a: string) => <Statistic value={a || 0} />
  253. },
  254. {
  255. title: '首日新用户充值金额', dataIndex: 'firstNewUserAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 6,
  256. render: (a: string) => <Statistic value={a || 0} />
  257. },
  258. {
  259. title: '老用户充值次数', dataIndex: 'oldUserCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  260. render: (a: string) => <Statistic value={a || 0} />
  261. },
  262. {
  263. title: '老用户充值人数', dataIndex: 'oldUserNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  264. render: (a: string) => <Statistic value={a || 0} />
  265. },
  266. {
  267. title: '老用户充值金额', dataIndex: 'oldUserAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  268. render: (a: string) => <Statistic value={a || 0} />
  269. },
  270. {
  271. title: '账面充值次数', dataIndex: 'amountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  272. render: (a: string) => <Statistic value={a || 0} />
  273. },
  274. {
  275. title: '账面充值人数', dataIndex: 'amountNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  276. render: (a: string) => <Statistic value={a || 0} />
  277. },
  278. {
  279. title: '账面充值金额', dataIndex: 'amount', label: '付费数据', align: 'center', width: 70, sorter: true,
  280. render: (a: string) => <Statistic value={a || 0} />
  281. },
  282. {
  283. title: '新用户累计充值次数', dataIndex: 'newUserTotalAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  284. render: (a: string) => <Statistic value={a || 0} />
  285. },
  286. {
  287. title: '新用户累计充值人数', dataIndex: 'newUserTotalAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 7,
  288. render: (a: string) => <Statistic value={a || 0} />
  289. },
  290. {
  291. title: '新用户累计充值金额', dataIndex: 'newUserTotalAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 8,
  292. render: (a: string) => <Statistic value={a || 0} />
  293. },
  294. {
  295. title: '首日ROI', dataIndex: 'firstRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 9,
  296. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  297. },
  298. {
  299. title: '总ROI', dataIndex: 'totalRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 12,
  300. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  301. },
  302. {
  303. title: '首日付费率', dataIndex: 'firstAmountRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  304. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  305. },
  306. {
  307. title: '至今付费率', tips: '至今付费率(总)=新用户累计充值人数/注册人数', dataIndex: 'todayAmountRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  308. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  309. },
  310. {
  311. title: '新用户付费比', dataIndex: 'newUserRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  312. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  313. },
  314. {
  315. title: '首日客单价', dataIndex: 'firstAvgAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  316. render: (a: string) => <Statistic value={a || 0} />
  317. },
  318. {
  319. title: '首日充值成本', dataIndex: 'firstNewUserRechargeCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 10,
  320. render: (a: string) => <Statistic value={a || 0} />
  321. },
  322. {
  323. title: '总充值成本', dataIndex: 'totalRechargeCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 11,
  324. render: (a: string) => <Statistic value={a || 0} />
  325. },
  326. {
  327. title: '至今客单价', tips: '至今客单价(总)=新用户累计充值金额/新用户累计充值次数', dataIndex: 'todayAvgAmount', label: '付费数据', align: 'center', width: 80, sorter: true,
  328. render: (a: string) => <Statistic value={a || 0} />
  329. },
  330. {
  331. title: '账面客单价', dataIndex: 'avgAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  332. render: (a: string) => <Statistic value={a || 0} />
  333. },
  334. {
  335. title: '复充率', tips: '复充率(总)=新用户复充人数/新用户累计充值人数(新用户复充人数为累计充值次数n≥2)', dataIndex: 'userAgainRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  336. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  337. },
  338. {
  339. title: '单日付费100+人数', dataIndex: 'hundredUserNum', label: '付费数据', align: 'center', width: 90, sorter: true,
  340. render: (a: string) => <Statistic value={a || 0} />
  341. },
  342. {
  343. title: '单日付费100+成本', dataIndex: 'hundredUserNumCost', label: '付费数据', align: 'center', width: 90, sorter: true,
  344. render: (a: string) => <Statistic value={a || 0} precision={2} />
  345. },
  346. {
  347. title: '首日创角人数', dataIndex: 'firstRoleNum', label: '付费数据', align: 'center', width: 80, sorter: true,
  348. render: (a: string) => <Statistic value={a || 0} />
  349. },
  350. {
  351. title: '创角人数', dataIndex: 'roleNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  352. render: (a: string) => <Statistic value={a || 0} />
  353. },
  354. {
  355. title: '新用户累计创角人数', dataIndex: 'newUserTotalRoleNum', label: '付费数据', align: 'center', width: 85, sorter: true,
  356. render: (a: string) => <Statistic value={a || 0} />
  357. },
  358. {
  359. title: '首日创角人数成本', dataIndex: 'firstRoleNumCost', label: '付费数据', align: 'center', width: 80, sorter: true,
  360. render: (a: string) => <Statistic value={a || 0} precision={2} />
  361. },
  362. {
  363. title: '创角人数成本', dataIndex: 'roleNumCost', label: '付费数据', align: 'center', width: 75, sorter: true,
  364. render: (a: string) => <Statistic value={a || 0} precision={2} />
  365. },
  366. {
  367. title: '新用户累计创角人数成本', dataIndex: 'newUserTotalRoleNumCost', label: '付费数据', align: 'center', width: 90, sorter: true,
  368. render: (a: string) => <Statistic value={a || 0} precision={2} />
  369. },
  370. {
  371. title: '首日创角率', dataIndex: 'firstRoleNumRate', label: '付费数据', align: 'center', width: 75, sorter: true,
  372. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  373. },
  374. {
  375. title: '创角率', dataIndex: 'roleNumRate', label: '付费数据', align: 'center', width: 75, sorter: true,
  376. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  377. },
  378. {
  379. title: '新用户累计创角率', dataIndex: 'newUserTotalRoleNumRate', label: '付费数据', align: 'center', width: 90, sorter: true,
  380. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  381. },
  382. {
  383. title: '新增注册ARPPU', dataIndex: 'regUserArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  384. render: (a: string) => <Statistic value={a || 0} />
  385. },
  386. {
  387. title: '首日付费ARPPU', dataIndex: 'firstAmountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  388. render: (a: string) => <Statistic value={a || 0} />
  389. },
  390. {
  391. title: '至今付费ARPPU', dataIndex: 'todayAmountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  392. render: (a: string) => <Statistic value={a || 0} />
  393. },
  394. {
  395. title: '账面ARPPU', dataIndex: 'amountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  396. render: (a: string) => <Statistic value={a || 0} />
  397. }
  398. ]
  399. },
  400. {
  401. label: '注册LTV',
  402. data: [
  403. ...userLtvDay,
  404. ...userLtvMonth
  405. ]
  406. },
  407. {
  408. label: '创角LTV',
  409. data: [
  410. ...roleLtvDay,
  411. ...roleLtvMonth
  412. ]
  413. }
  414. ]
  415. }
  416. export default columnsUser12