tableConfig.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. import WidthEllipsis from "@/components/widthEllipsis"
  2. import { Statistic } from "antd"
  3. import React from "react"
  4. import { version } from "../../components/TableData"
  5. import moment from "moment"
  6. import style from '../../extensionData/everyday/index.less'
  7. import { gameClassifyEnum } from "@/components/QueryForm/const"
  8. function columns12(): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  9. const roiC = Array(29).fill('').map((_item: string, index: number) => {
  10. let data = {
  11. title: `${index + 2}日ROI`,
  12. dataIndex: `roi${index + 2}`,
  13. label: '付费数据',
  14. align: 'center',
  15. width: 80,
  16. sorter: true,
  17. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  18. }
  19. index++;
  20. return data
  21. })
  22. let defaultValue = [ // 默认展示字段
  23. { label: '充值人数', key: 'rechargeUserCount', type: '付费趋势' },
  24. { label: '充值金额', key: 'rechargeMoney', type: '付费趋势' },
  25. { label: '增', key: 'increase', type: '付费趋势' },
  26. { label: '回', key: 'back', type: '付费趋势' },
  27. { label: '倍', key: 'multiples', type: '付费趋势' },
  28. ]
  29. const getFieldDta = () => {
  30. let mySelectFieldData = localStorage.getItem(`myAdFieldConfig${version}_投手每日数据`)
  31. let newSelectFieldData: any = {}
  32. if (mySelectFieldData) {
  33. newSelectFieldData = JSON.parse(mySelectFieldData).date_field
  34. } else {
  35. newSelectFieldData = defaultValue
  36. }
  37. return newSelectFieldData
  38. }
  39. // 总付费趋势
  40. let defaultStart = 18
  41. const zC = Array(90).fill('').map((_item: string, index: number) => {
  42. let field = `amountD${index + 1}Trend`
  43. if (index === 29) [
  44. field = 'amountM1Trend'
  45. ]
  46. let data = {
  47. title: `D${index + 1}`,
  48. dataIndex: `D${index + 1}`,
  49. label: "时间区间跨度",
  50. width: 110,
  51. render: (a: any, b: any) => {
  52. let date1 = moment()
  53. if (b?.pitcher === '总计') {
  54. if (b?.beginDay) {
  55. date1 = moment(b.beginDay)
  56. } else {
  57. date1 = moment()
  58. }
  59. } else {
  60. date1 = moment(b.dt)
  61. }
  62. let dt = moment()
  63. let day = dt.diff(date1, 'day');
  64. let fieldData = getFieldDta()
  65. if (fieldData?.length > 0 && index <= day) {
  66. let data: any = {}
  67. let keyS: string[] = fieldData?.map((item: any) => item.key)
  68. switch (fieldData[0].type) {
  69. case '付费趋势':
  70. if (b?.[field]) {
  71. data = b?.[field]
  72. return <div className={style.dbox}>
  73. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  74. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  75. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  76. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  77. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  78. </div>
  79. }
  80. return '--'
  81. }
  82. }
  83. return '--'
  84. },
  85. }
  86. data['default'] = defaultStart + index
  87. return data
  88. })
  89. let mDefaultStart = 108, count = 0
  90. const Mc = [4, 5, 6, 7, 8, 9, 10, 11, 12].map(index => {
  91. let field = `amountM${index}Trend`
  92. let data = {
  93. title: `M${index}`,
  94. dataIndex: `M${index}`,
  95. label: "时间区间跨度",
  96. width: 110,
  97. render: (a: any, b: any) => {
  98. let date1 = moment()
  99. if (b?.pitcher === '总计') {
  100. if (b?.beginDay) {
  101. date1 = moment(b.beginDay)
  102. } else {
  103. date1 = moment()
  104. }
  105. } else {
  106. date1 = moment(b.dt)
  107. }
  108. let dt = moment()
  109. let day = dt.diff(date1, 'day');
  110. let fieldData = getFieldDta()
  111. if (fieldData?.length > 0 && index * 30 <= day) {
  112. let data: any = {}
  113. let keyS: string[] = fieldData?.map((item: any) => item.key)
  114. switch (fieldData[0].type) {
  115. case '付费趋势':
  116. if (b?.[field]) {
  117. data = b?.[field]
  118. return <div className={style.dbox}>
  119. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  120. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  121. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  122. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  123. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  124. </div>
  125. }
  126. return '--'
  127. }
  128. }
  129. return '--'
  130. },
  131. }
  132. data['default'] = mDefaultStart + count
  133. count++;
  134. return data
  135. })
  136. Mc.push({
  137. title: "总",
  138. default: 117,
  139. dataIndex: "amountSumTrend",
  140. label: "时间区间跨度",
  141. align: "center",
  142. width: 110,
  143. render: (a: any, b: any) => {
  144. let fieldData = getFieldDta()
  145. if (fieldData?.length > 0) {
  146. let data: any = {}
  147. let keyS: string[] = fieldData?.map((item: any) => item.key)
  148. switch (fieldData[0].type) {
  149. case '付费趋势':
  150. if (a) {
  151. data = a
  152. return <div className={style.dbox}>
  153. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  154. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  155. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  156. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  157. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  158. </div>
  159. }
  160. return '--'
  161. }
  162. }
  163. return '--'
  164. },
  165. } as any)
  166. return [
  167. {
  168. label: '基本信息',
  169. data: [
  170. {
  171. title: '投手', dataIndex: 'pitcher', label: '基本信息', align: 'center', width: 95, default: 1,
  172. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  173. },
  174. {
  175. title: '推广游戏名称', dataIndex: 'gameName', label: '基本信息', align: 'center', width: 95, default: 2,
  176. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  177. },
  178. {
  179. title: '推广游戏CP名称', dataIndex: 'gameCp', label: '基本信息', align: 'center', width: 95, default: 3,
  180. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  181. },
  182. {
  183. title: '推广游戏应用类型', dataIndex: 'gameType', label: '基本信息', align: 'center', width: 95, default: 4,
  184. render: (a: string, b: any) => (<WidthEllipsis value={gameClassifyEnum[a]} />)
  185. },
  186. {
  187. title: '时间', dataIndex: 'dt', label: '基本信息', align: 'center', width: 110, default: 5, sorter: true,
  188. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  189. },
  190. {
  191. title: '消耗', dataIndex: 'cost', label: '基本信息', align: 'center', width: 70, default: 6, sorter: true,
  192. render: (a: string) => <Statistic value={a || 0} />
  193. },
  194. {
  195. title: '推广账号数量', dataIndex: 'accountCount', label: '基本信息', align: 'center', width: 80, sorter: true,
  196. render: (a: string) => <Statistic value={a || 0} />
  197. },
  198. {
  199. title: '推广渠道数量', dataIndex: 'agentCount', label: '基本信息', align: 'center', width: 70, sorter: true,
  200. render: (a: string) => <Statistic value={a || 0} />
  201. },
  202. {
  203. title: '推广计划数量', dataIndex: 'planCount', label: '基本信息', align: 'center', width: 70, sorter: true,
  204. render: (a: string) => <Statistic value={a || 0} />
  205. }
  206. ]
  207. },
  208. {
  209. label: '用户数据',
  210. data: [
  211. {
  212. title: '注册人数', dataIndex: 'registerNum', label: '用户数据', align: 'center', width: 70, sorter: true, default: 7,
  213. render: (a: string) => <Statistic value={a || 0} />
  214. },
  215. {
  216. title: '注册成本', dataIndex: 'registerCost', label: '用户数据', align: 'center', width: 70, sorter: true, default: 8,
  217. render: (a: string) => <Statistic value={a || 0} />
  218. },
  219. {
  220. title: '创角人数', dataIndex: 'roleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  221. render: (a: string) => <Statistic value={a || 0} />
  222. },
  223. {
  224. title: '首日创角人数', dataIndex: 'firstRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  225. render: (a: string) => <Statistic value={a || 0} />
  226. },
  227. {
  228. title: '新用户累计创角人数', dataIndex: 'newUserTotalRoleNum', label: '用户数据', align: 'center', width: 100, sorter: true,
  229. render: (a: string) => <Statistic value={a || 0} />
  230. },
  231. {
  232. title: '首日创角成本', dataIndex: 'firstRoleCost', label: '用户数据', align: 'center', width: 70, sorter: true,
  233. render: (a: string) => <Statistic value={a || 0} />
  234. },
  235. {
  236. title: '新用户累计创角成本', dataIndex: 'newUserTotalRoleCost', label: '用户数据', align: 'center', width: 70, sorter: true,
  237. render: (a: string) => <Statistic value={a || 0} />
  238. },
  239. // {
  240. // title: '创角量', dataIndex: 'roleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  241. // render: (a: string) => <Statistic value={a || 0} />
  242. // },
  243. // {
  244. // title: '首日创角量', dataIndex: 'firstRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  245. // render: (a: string) => <Statistic value={a || 0} />
  246. // },
  247. // {
  248. // title: '新用户累计创角量', dataIndex: 'newUserTotalRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  249. // render: (a: string) => <Statistic value={a || 0} />
  250. // },
  251. {
  252. title: '首日创角率', dataIndex: 'firstRoleRate', label: '用户数据', align: 'center', width: 70, sorter: true,
  253. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 50 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  254. },
  255. {
  256. title: '新用户创角率', dataIndex: 'newUserTotalRoleRate', label: '用户数据', align: 'center', width: 70, sorter: true,
  257. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 50 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  258. }
  259. ]
  260. },
  261. {
  262. label: '付费数据',
  263. data: [
  264. {
  265. title: '首日新用户充值次数', dataIndex: 'firstNewUserAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  266. render: (a: string) => <Statistic value={a || 0} />
  267. },
  268. {
  269. title: '首日新用户充值人数', dataIndex: 'firstNewUserAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 9,
  270. render: (a: string) => <Statistic value={a || 0} />
  271. },
  272. {
  273. title: '首日新用户充值金额', dataIndex: 'firstNewUserAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 10,
  274. render: (a: string) => <Statistic value={a || 0} />
  275. },
  276. {
  277. title: '老用户充值次数', dataIndex: 'oldAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  278. render: (a: string) => <Statistic value={a || 0} />
  279. },
  280. {
  281. title: '老用户充值人数', dataIndex: 'oldAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  282. render: (a: string) => <Statistic value={a || 0} />
  283. },
  284. {
  285. title: '老用户充值金额', dataIndex: 'oldAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  286. render: (a: string) => <Statistic value={a || 0} />
  287. },
  288. {
  289. title: '账面充值次数', dataIndex: 'amountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  290. render: (a: string) => <Statistic value={a || 0} />
  291. },
  292. {
  293. title: '账面充值人数', dataIndex: 'amountNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  294. render: (a: string) => <Statistic value={a || 0} />
  295. },
  296. {
  297. title: '账面充值金额', dataIndex: 'amount', label: '付费数据', align: 'center', width: 70, sorter: true,
  298. render: (a: string) => <Statistic value={a || 0} />
  299. },
  300. {
  301. title: '新用户累计充值次数', dataIndex: 'buyNewUserTotalAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  302. render: (a: string) => <Statistic value={a || 0} />
  303. },
  304. {
  305. title: '新用户累计充值人数', dataIndex: 'buyNewUserTotalAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 11,
  306. render: (a: string) => <Statistic value={a || 0} />
  307. },
  308. {
  309. title: '新用户累计充值金额', dataIndex: 'buyNewUserTotalAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 12,
  310. render: (a: string) => <Statistic value={a || 0} />
  311. },
  312. {
  313. title: '首日ROI', dataIndex: 'firstRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 13,
  314. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  315. },
  316. {
  317. title: '毛利额', dataIndex: 'grossProfit', label: '付费数据', align: 'center', width: 70, sorter: true,
  318. render: (a: number) => <Statistic value={a} precision={2} valueStyle={a < 0 ? { color: 'red' } : {}} />
  319. },
  320. {
  321. title: '至今回收率', dataIndex: 'todayRoi', label: '付费数据', align: 'center', width: 70, sorter: true,
  322. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  323. },
  324. ...roiC,
  325. {
  326. title: '60日ROI', dataIndex: 'roi60', label: '付费数据', align: 'center', width: 80, sorter: true,
  327. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 0.9 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  328. },
  329. {
  330. title: '90日ROI', dataIndex: 'roi90', label: '付费数据', align: 'center', width: 80, sorter: true,
  331. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  332. },
  333. {
  334. title: '180日ROI', dataIndex: 'roi180', label: '付费数据', align: 'center', width: 80, sorter: true,
  335. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  336. },
  337. {
  338. title: '1年ROI', dataIndex: 'roi1yaer', label: '付费数据', align: 'center', width: 80, sorter: true,
  339. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  340. },
  341. {
  342. title: '总ROI', dataIndex: 'todayRoi', label: '付费数据', align: 'center', width: 80, default: 14, sorter: true,
  343. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  344. },
  345. {
  346. title: '首日付费率', dataIndex: 'firstRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  347. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  348. },
  349. {
  350. title: '至今付费率', tips: '至今付费率(总)=新用户累计充值人数/注册人数', dataIndex: 'todayRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  351. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  352. },
  353. {
  354. title: '新用户付费比', dataIndex: 'newUserAmountRatio', label: '付费数据', align: 'center', width: 70, sorter: true,
  355. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  356. },
  357. {
  358. title: '首日客单价', dataIndex: 'firstAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  359. render: (a: string) => <Statistic value={a || 0} />
  360. },
  361. {
  362. title: '至今客单价', dataIndex: 'buyAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  363. render: (a: string) => <Statistic value={a || 0} />
  364. },
  365. {
  366. title: '账面客单价', dataIndex: 'paperAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  367. render: (a: string) => <Statistic value={a || 0} />
  368. },
  369. {
  370. title: '首日充值成本', dataIndex: 'firstAmountCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 15,
  371. render: (a: string) => <Statistic value={a || 0} />
  372. },
  373. {
  374. title: '至今充值成本', dataIndex: 'todayAmountCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 16,
  375. render: (a: string) => <Statistic value={a || 0} />
  376. },
  377. {
  378. title: '至今复充率', dataIndex: 'todayAgainRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  379. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  380. },
  381. {
  382. title: '新增注册ARPPU', dataIndex: 'newRegArpu', label: '付费数据', align: 'center', width: 70, sorter: true, default: 17,
  383. render: (a: string) => <Statistic value={a || 0} />
  384. },
  385. {
  386. title: '首日付费ARPPU', dataIndex: 'firstArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  387. render: (a: string) => <Statistic value={a || 0} />
  388. },
  389. {
  390. title: '至今付费ARPPU', dataIndex: 'todayArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  391. render: (a: string) => <Statistic value={a || 0} />
  392. },
  393. {
  394. title: '账面ARPPU', dataIndex: 'paperArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  395. render: (a: string) => <Statistic value={a || 0} />
  396. }
  397. ]
  398. },
  399. {
  400. fieldSHow: {
  401. label: '日期区间字段展示',
  402. saveField: 'date_field',
  403. defaultValue,
  404. data: [
  405. {
  406. label: '付费趋势',
  407. data: defaultValue
  408. },
  409. ]
  410. },
  411. label: '时间区间跨度',
  412. data: [
  413. ...zC,
  414. ...Mc
  415. ]
  416. }
  417. ]
  418. }
  419. export default columns12