tableConfig.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. import React from "react"
  2. import style from './index.less'
  3. import { Statistic } from "antd"
  4. import { gameClassifyEnum } from "@/components/QueryForm/const"
  5. import { version } from "../../components/TableData"
  6. import moment from "moment"
  7. function columnsNature12(rechargeTrendHandle: (data: any) => void): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  8. const getFieldDta = () => {
  9. let defaultValue = [ // 默认展示字段
  10. { label: '充值人数', key: 'rechargeUserCount', type: '付费趋势' },
  11. { label: '充值金额', key: 'rechargeMoney', type: '付费趋势' },
  12. { label: '增', key: 'increase', type: '付费趋势' },
  13. { label: '回', key: 'back', type: '付费趋势' },
  14. { label: '倍', key: 'multiples', type: '付费趋势' },
  15. ]
  16. let mySelectFieldData = localStorage.getItem(`myAdFieldConfig${version}_游戏每日数据`)
  17. let newSelectFieldData: any = {}
  18. if (mySelectFieldData) {
  19. newSelectFieldData = JSON.parse(mySelectFieldData).date_field
  20. } else {
  21. newSelectFieldData = defaultValue
  22. }
  23. return newSelectFieldData
  24. }
  25. let defaultStart = 14
  26. // 总付费趋势
  27. const zC = Array(90).fill('').map((_item: string, index: number) => {
  28. let field = `amountD${index + 1}Trend`
  29. let data = {
  30. title: `D${index + 1}`,
  31. dataIndex: `D${index + 1}`,
  32. label: "付费趋势",
  33. align: "center",
  34. width: 110,
  35. render: (a: any, b: any) => {
  36. let date1 = moment()
  37. if (b?.costDate === '总计') {
  38. if (b?.beginDay) {
  39. date1 = moment(b?.beginDay)
  40. } else {
  41. date1 = moment()
  42. }
  43. } else {
  44. date1 = moment(b.costDate)
  45. }
  46. let dt = moment()
  47. let day = dt.diff(date1, 'day');
  48. let fieldData = getFieldDta()
  49. if (fieldData?.length > 0 && index <= day) {
  50. let data: any = {}
  51. let keyS: string[] = fieldData?.map((item: any) => item.key)
  52. switch (fieldData[0].type) {
  53. case '付费趋势':
  54. if (b?.[field]) {
  55. data = b?.[field]
  56. return <div className={style.dbox}>
  57. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  58. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  59. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  60. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  61. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  62. </div>
  63. }
  64. return '--'
  65. }
  66. }
  67. return '--'
  68. },
  69. }
  70. if (index < 30) {
  71. data['default'] = defaultStart + index
  72. }
  73. return data
  74. })
  75. const zM = [4, 5, 6, 7, 8, 9, 10, 11, 12].map((index, num) => {
  76. let field = `amountM${index}Trend`
  77. let data = {
  78. title: `M${index}`,
  79. dataIndex: `M${index}`,
  80. label: "付费趋势",
  81. align: "center",
  82. width: 110,
  83. render: (a: any, b: any) => {
  84. let date1 = moment()
  85. if (b?.costDate === '总计') {
  86. if (b?.beginDay) {
  87. date1 = moment(b?.beginDay)
  88. } else {
  89. date1 = moment()
  90. }
  91. } else {
  92. date1 = moment(b.costDate)
  93. }
  94. let dt = moment()
  95. let day = dt.diff(date1, 'day');
  96. let fieldData = getFieldDta()
  97. if (fieldData?.length > 0 && index * 30 <= day) {
  98. let data: any = {}
  99. let keyS: string[] = fieldData?.map((item: any) => item.key)
  100. switch (fieldData[0].type) {
  101. case '付费趋势':
  102. if (b?.[field]) {
  103. data = b?.[field]
  104. return <div className={style.dbox}>
  105. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  106. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  107. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  108. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  109. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  110. </div>
  111. }
  112. return '--'
  113. }
  114. }
  115. return '--'
  116. },
  117. }
  118. // data['default'] = defaultStart + 90 + num
  119. return data
  120. })
  121. return [
  122. {
  123. label: '游戏信息',
  124. data: [
  125. {
  126. title: '推广游戏名称', dataIndex: 'gameName', label: '游戏信息', align: 'center', width: 70, default: 2,
  127. render: (a: string) => a || '--'
  128. },
  129. {
  130. title: '推广游戏应用类型', dataIndex: 'gameClassify', label: '游戏信息', align: 'center', width: 80,
  131. render: (a: string, b?: any) => (<span>{gameClassifyEnum[a]}</span>)
  132. }
  133. ]
  134. },
  135. {
  136. label: '时间',
  137. data: [
  138. { title: '日期', dataIndex: 'costDate', label: '时间', align: 'center', width: 90, default: 1 },
  139. ]
  140. },
  141. {
  142. label: '消耗',
  143. data: [
  144. {
  145. title: '消耗', dataIndex: 'cost', label: '消耗', align: 'center', width: 90, sorter: true, default: 3,
  146. render: (a: string) => <Statistic value={a || 0} />
  147. }
  148. ]
  149. },
  150. {
  151. label: '用户数据',
  152. data: [
  153. { title: '注册人数', dataIndex: 'regNum', label: '用户数据', align: 'center', width: 70, default: 4, sorter: true },
  154. { title: '注册成本', dataIndex: 'regCost', label: '用户数据', align: 'center', width: 70, default: 5, sorter: true }
  155. ]
  156. },
  157. {
  158. label: '付费数据',
  159. data: [
  160. { title: '首日新用户充值次数', dataIndex: 'firstNewUserAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true },
  161. { title: '首日新用户充值人数', dataIndex: 'firstNewUserAmountNum', label: '付费数据', align: 'center', width: 70, default: 6, sorter: true },
  162. {
  163. title: '首日新用户充值金额', dataIndex: 'firstNewUserAmount', label: '付费数据', align: 'center', width: 70, default: 7, sorter: true,
  164. render: (a: string) => <Statistic value={a || 0} />
  165. },
  166. { title: '老用户充值次数', dataIndex: 'oldUserCount', label: '付费数据', align: 'center', width: 70, sorter: true },
  167. { title: '老用户充值人数', dataIndex: 'oldUserNum', label: '付费数据', align: 'center', width: 70, sorter: true },
  168. {
  169. title: '老用户充值金额', dataIndex: 'oldUserAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  170. render: (a: string) => <Statistic value={a || 0} />
  171. },
  172. { title: '账面充值次数', dataIndex: 'amountCount', label: '付费数据', align: 'center', width: 70, sorter: true },
  173. { title: '账面充值人数', dataIndex: 'amountNum', label: '付费数据', align: 'center', width: 70, sorter: true },
  174. {
  175. title: '账面充值金额', dataIndex: 'amount', label: '付费数据', align: 'center', width: 70, sorter: true,
  176. render: (a: string) => <Statistic value={a || 0} />
  177. },
  178. { title: '新用户累计充值次数', dataIndex: 'newUserTotalAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true },
  179. { title: '新用户累计充值人数', dataIndex: 'newUserTotalAmountNum', label: '付费数据', align: 'center', width: 70, default: 8, sorter: true },
  180. {
  181. title: '新用户累计充值金额', dataIndex: 'newUserTotalAmount', label: '付费数据', align: 'center', width: 70, default: 9, sorter: true,
  182. render: (a: string) => <Statistic value={a || 0} />
  183. },
  184. {
  185. title: '首日ROI', dataIndex: 'firstRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 10,
  186. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  187. },
  188. {
  189. title: '总ROI', dataIndex: 'totalRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 11,
  190. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  191. },
  192. {
  193. title: '首日付费率', dataIndex: 'firstAmountRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  194. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  195. },
  196. {
  197. title: '至今付费率', tips: '至今付费率(总)=新用户累计充值人数/注册人数', dataIndex: 'todayAmountRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  198. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  199. },
  200. {
  201. title: '新用户付费比', dataIndex: 'newUserRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  202. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  203. },
  204. {
  205. title: '首日客单价', dataIndex: 'firstAvgAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  206. render: (a: string) => <Statistic value={a || 0} />
  207. },
  208. {
  209. title: '首日充值成本', dataIndex: 'firstNewUserRechargeCost', label: '付费数据', align: 'center', width: 70, default: 12, sorter: true,
  210. render: (a: string) => <Statistic value={a || 0} />
  211. },
  212. {
  213. title: '总充值成本', dataIndex: 'totalRechargeCost', label: '付费数据', align: 'center', width: 70, default: 13, sorter: true,
  214. render: (a: string) => <Statistic value={a || 0} />
  215. },
  216. {
  217. title: '至今客单价', tips: '至今客单价(总)=新用户累计充值金额/新用户累计充值次数', dataIndex: 'todayAvgAmount', label: '付费数据', align: 'center', width: 80, sorter: true,
  218. render: (a: string) => <Statistic value={a || 0} />
  219. },
  220. {
  221. title: '账面客单价', dataIndex: 'avgAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  222. render: (a: string) => <Statistic value={a || 0} />
  223. },
  224. {
  225. title: '复充率', tips: '复充率(总)=新用户复充人数/新用户累计充值人数(新用户复充人数为累计充值次数n≥2)', dataIndex: 'userAgainRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  226. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  227. },
  228. {
  229. title: '单日付费100+人数', dataIndex: 'hundredUserNum', label: '付费数据', align: 'center', width: 90, sorter: true,
  230. render: (a: string) => <Statistic value={a || 0} />
  231. },
  232. {
  233. title: '单日付费100+成本', dataIndex: 'hundredUserNumCost', label: '付费数据', align: 'center', width: 90, sorter: true,
  234. render: (a: string) => <Statistic value={a || 0} precision={2} />
  235. },
  236. {
  237. title: '首日创角人数', dataIndex: 'firstRoleNum', label: '付费数据', align: 'center', width: 80, sorter: true,
  238. render: (a: string) => <Statistic value={a || 0} />
  239. },
  240. {
  241. title: '创角人数', dataIndex: 'roleNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  242. render: (a: string) => <Statistic value={a || 0} />
  243. },
  244. {
  245. title: '新用户累计创角人数', dataIndex: 'newUserTotalRoleNum', label: '付费数据', align: 'center', width: 85, sorter: true,
  246. render: (a: string) => <Statistic value={a || 0} />
  247. },
  248. {
  249. title: '首日创角人数成本', dataIndex: 'firstRoleNumCost', label: '付费数据', align: 'center', width: 80, sorter: true,
  250. render: (a: string) => <Statistic value={a || 0} precision={2} />
  251. },
  252. {
  253. title: '创角人数成本', dataIndex: 'roleNumCost', label: '付费数据', align: 'center', width: 75, sorter: true,
  254. render: (a: string) => <Statistic value={a || 0} precision={2} />
  255. },
  256. {
  257. title: '新用户累计创角人数成本', dataIndex: 'newUserTotalRoleNumCost', label: '付费数据', align: 'center', width: 90, sorter: true,
  258. render: (a: string) => <Statistic value={a || 0} precision={2} />
  259. },
  260. {
  261. title: '首日创角率', dataIndex: 'firstRoleNumRate', label: '付费数据', align: 'center', width: 75, sorter: true,
  262. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  263. },
  264. {
  265. title: '创角率', dataIndex: 'roleNumRate', label: '付费数据', align: 'center', width: 75, sorter: true,
  266. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  267. },
  268. {
  269. title: '新用户累计创角率', dataIndex: 'newUserTotalRoleNumRate', label: '付费数据', align: 'center', width: 90, sorter: true,
  270. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  271. },
  272. {
  273. title: '新增注册ARPPU', dataIndex: 'regUserArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  274. render: (a: string) => <Statistic value={a || 0} />
  275. },
  276. {
  277. title: '首日付费ARPPU', dataIndex: 'firstAmountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  278. render: (a: string) => <Statistic value={a || 0} />
  279. },
  280. {
  281. title: '至今付费ARPPU', dataIndex: 'todayAmountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  282. render: (a: string) => <Statistic value={a || 0} />
  283. },
  284. {
  285. title: '账面ARPPU', dataIndex: 'amountArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  286. render: (a: string) => <Statistic value={a || 0} />
  287. }
  288. ]
  289. },
  290. {
  291. fieldSHow: {
  292. label: '付费趋势区间字段展示',
  293. saveField: 'date_field',
  294. defaultValue: [ // 默认展示字段
  295. { label: '充值人数', key: 'rechargeUserCount', type: '付费趋势' },
  296. { label: '充值金额', key: 'rechargeMoney', type: '付费趋势' },
  297. { label: '增', key: 'increase', type: '付费趋势' },
  298. { label: '回', key: 'back', type: '付费趋势' },
  299. { label: '倍', key: 'multiples', type: '付费趋势' },
  300. ],
  301. data: [
  302. {
  303. label: '付费趋势',
  304. data: [
  305. { label: '充值人数', key: 'rechargeUserCount', type: '付费趋势' },
  306. { label: '充值金额', key: 'rechargeMoney', type: '付费趋势' },
  307. { label: '增', key: 'increase', type: '付费趋势' },
  308. { label: '回', key: 'back', type: '付费趋势' },
  309. { label: '倍', key: 'multiples', type: '付费趋势' },
  310. ]
  311. }
  312. ]
  313. },
  314. label: '总付费趋势',
  315. data: [
  316. ...zC,
  317. ...zM,
  318. {
  319. title: "总",
  320. dataIndex: "total",
  321. label: "付费趋势",
  322. align: "center",
  323. width: 110,
  324. default: 44,
  325. render: (a: any, b: any) => {
  326. let fieldData = getFieldDta()
  327. if (fieldData?.length > 0) {
  328. let data: any = {}
  329. let keyS: string[] = fieldData?.map((item: any) => item.key)
  330. switch (fieldData[0].type) {
  331. case '付费趋势':
  332. if (b?.amountSumTrend) {
  333. data = b?.amountSumTrend
  334. return <div className={style.dbox}>
  335. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  336. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  337. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  338. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  339. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  340. </div>
  341. }
  342. return '--'
  343. }
  344. }
  345. return '--'
  346. },
  347. }]
  348. },
  349. {
  350. label: '操作',
  351. data: [
  352. {
  353. title: '操作',
  354. dataIndex: 'cz',
  355. label: '操作',
  356. default: 45,
  357. align: 'center',
  358. width: 75,
  359. render: (a: number, b: any) => {
  360. if (b?.costDate === '总计') {
  361. return '--'
  362. }
  363. return b?.gameId ? <a onClick={() => rechargeTrendHandle(b)}>复充趋势</a> : '--'
  364. },
  365. }
  366. ]
  367. }
  368. ]
  369. }
  370. export default columnsNature12