RechargeOrder.jsx 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, Breadcrumb, DatePicker } from 'antd';
  3. import router from 'umi/router';
  4. import moment from 'moment';
  5. import Navigate from '@/components/Navigate'
  6. import apis from '../../../../services/apis';
  7. import request from '../../../../utils/request';
  8. import AuthButton from '@/components/AuthButton';
  9. import ShowVoucher from './ShowVoucher';
  10. const { RangePicker } = DatePicker
  11. const { Option } = Select
  12. function RechargeOrder(props) {
  13. // const [taNoticeList, setTaNoticeList] = useState([])
  14. const [data, setData] = useState({})
  15. const [showVoucher, setShowVoucher] = useState({})
  16. // {
  17. // visible: false,
  18. // bannerList: ['//njcj.oss-cn-shanghai.aliyuncs.com/miniapp/upload/images/1591609582282-1584614514971-504167f68a5d43ee693949b26498ef21.jpg', '//njcj.oss-cn-shanghai.aliyuncs.com/miniapp/upload/images/1591609582282-1584614514971-504167f68a5d43ee693949b26498ef21.jpg'],
  19. // },
  20. // )
  21. useEffect(() => {
  22. getList({ pageNum: 1, pageSize: 10 });
  23. }, [])
  24. // 查询列表
  25. const getList = params => {
  26. const { LocalDate, ...values } = params
  27. if (LocalDate != null && LocalDate.length > 0) {
  28. const [payStartTime, payEndTime] = LocalDate
  29. values.payStartTime = `${moment(payStartTime).format('YYYY-MM-DDT00:00:00')}Z`;
  30. values.payEndTime = `${moment(payEndTime).format('YYYY-MM-DDT23:59:59')}Z`;
  31. } else {
  32. values.payStartTime = null
  33. values.payEndTime = null
  34. }
  35. // if (params.payStartTime) {
  36. // params.payStartTime = `${moment(params.payStartTime).format('YYYY-MM-DDT00:00:00')}Z`;
  37. // }
  38. // if (params.payEndTime) {
  39. // params.payEndTime = `${moment(params.payEndTime).format('YYYY-MM-DDT23:59:59')}Z`;
  40. // }
  41. request({ ...apis.funds.czlist, params: { ...values } }).then(data => {
  42. setData(data)
  43. })
  44. }
  45. const openImg = data => {
  46. setShowVoucher(
  47. {
  48. visible: true,
  49. bannerList: data,
  50. },
  51. )
  52. }
  53. const changePageNum = e => {
  54. props.form.validateFields((err, values) => {
  55. if (!err) {
  56. // eslint-disable-next-line no-console
  57. console.log('提交数据: ', values)
  58. getList({ pageNum: e, pageSize: 10, ...values })
  59. }
  60. });
  61. }
  62. function handleSubmit(e) {
  63. e.preventDefault();
  64. props.form.validateFields((err, values) => {
  65. if (!err) {
  66. // eslint-disable-next-line no-console
  67. console.log('提交数据: ', values)
  68. getList({ pageNum: 1, pageSize: 10, ...values })
  69. }
  70. });
  71. }
  72. function handleReset() {
  73. props.form.resetFields();
  74. getList({ pageNum: 1, pageSize: 10 })
  75. }
  76. const columns = [
  77. {
  78. title: '订单编号',
  79. dataIndex: 'tradeNo',
  80. key: 'tradeNo',
  81. align: 'center',
  82. },
  83. {
  84. title: '充值金额',
  85. dataIndex: 'amount',
  86. key: 'amount',
  87. align: 'center',
  88. render: x => <><span>{x / 100 || ''}</span></>,
  89. },
  90. {
  91. title: '充值方式',
  92. dataIndex: 'isOffline',
  93. key: 'isOffline',
  94. align: 'center',
  95. render: x => <><span>{x ? '运营手工充值' : '业务线上充值'}</span></>,
  96. },
  97. {
  98. title: '下单时间',
  99. dataIndex: 'createDate',
  100. key: 'createDate',
  101. align: 'center',
  102. render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  103. },
  104. {
  105. title: '充值凭证',
  106. dataIndex: 'certificateUrlList',
  107. key: 'certificateUrlList',
  108. align: 'center',
  109. render: (x, row) => <>{row.certificateUrlList == null ? '' : <Navigate onClick={() => openImg(x)}>查看</Navigate>}</>,
  110. },
  111. {
  112. title: '充值状态',
  113. dataIndex: 'tradingStatus',
  114. key: 'tradingStatus',
  115. align: 'center',
  116. render: (x, row) => <><span>{row.tradingStatus == 'processing' ? '待支付' : (row.tradingStatus == 'success' ? '已支付' : '失败')}</span></>,
  117. },
  118. {
  119. title: '支付时间',
  120. dataIndex: 'payDate',
  121. key: 'payDate',
  122. align: 'center',
  123. render: (x, row) => <><span>{row.payDate == null ? "" : `${moment(row.payDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  124. },
  125. ]
  126. const { getFieldDecorator } = props.form
  127. function download(data) {
  128. // if (!data) {
  129. // console.log('234')
  130. // return
  131. // }
  132. const url = window.URL.createObjectURL(new Blob([data]))
  133. const link = document.createElement('a')
  134. link.style.display = 'none'
  135. link.href = url
  136. link.setAttribute('download', '充值订单.xlsx')
  137. document.body.append(link)
  138. link.click()
  139. }
  140. const exportReport = () => {
  141. const requestParams = props.form.getFieldsValue();
  142. const { LocalDate, ...values } = requestParams
  143. if (LocalDate != null && LocalDate.length > 0) {
  144. const [payStartTime, payEndTime] = LocalDate
  145. values.payStartTime = `${moment(payStartTime).format('YYYY-MM-DDT00:00:00')}Z`;
  146. values.payEndTime = `${moment(payEndTime).format('YYYY-MM-DDT23:59:59')}Z`;
  147. } else {
  148. values.payStartTime = null
  149. values.payEndTime = null
  150. }
  151. // if (requestParams.payStartTime) {
  152. // requestParams.payStartTime = `${moment(requestParams.payStartTime).format('YYYY-MM-DDT00:00:00')}Z`;
  153. // }
  154. // if (requestParams.payEndTime) {
  155. // requestParams.payEndTime = `${moment(requestParams.payEndTime).format('YYYY-MM-DDT23:59:59')}Z`;
  156. // }
  157. request({ ...apis.funds.czexportList, responseType: 'blob', params: { ...values } }).then(data => {
  158. download(data)
  159. }).catch()
  160. }
  161. return (
  162. <>
  163. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  164. <Form.Item>
  165. {getFieldDecorator('tradeNo')(
  166. <Input
  167. placeholder="订单编号"
  168. />,
  169. )}
  170. </Form.Item>
  171. <Form.Item>
  172. {getFieldDecorator('LocalDate')(
  173. <RangePicker placeholder={['支付开始时间', '支付结束时间']} />,
  174. )}
  175. </Form.Item>
  176. {/* <Form.Item>
  177. {getFieldDecorator('payStartTime')(
  178. <DatePicker placeholder="支付开始时间" />,
  179. )}
  180. </Form.Item>
  181. <Form.Item>
  182. {getFieldDecorator('payEndTime')(
  183. <DatePicker placeholder="支付结束时间" />,
  184. )}
  185. </Form.Item> */}
  186. <Form.Item>
  187. {getFieldDecorator('isOffline')(
  188. <Select style={{ width: '180px' }} placeholder="充值方式">
  189. <Option value="">全部</Option>
  190. <Option value={0}>业务线上充值</Option>
  191. <Option value={1}>运营手工充值</Option>
  192. </Select>,
  193. )}
  194. </Form.Item>
  195. <Form.Item>
  196. {getFieldDecorator('tradingStatus')(
  197. <Select style={{ width: '180px' }} placeholder="充值状态">
  198. <Option value="">全部</Option>
  199. <Option value="processing">待支付</Option>
  200. <Option value="success">已支付</Option>
  201. <Option value="fail">失败</Option>
  202. </Select>,
  203. )}
  204. </Form.Item>
  205. {/* <Form.Item>
  206. {getFieldDecorator('tel')(
  207. <Input
  208. placeholder="充值方式"
  209. />,
  210. )}
  211. </Form.Item>
  212. <Form.Item>
  213. {getFieldDecorator('tel')(
  214. <Input
  215. placeholder="充值状态"
  216. />,
  217. )}
  218. </Form.Item> */}
  219. <Form.Item>
  220. <Button type="primary" htmlType="submit"> 搜索</Button>
  221. <Button style={{ marginLeft: 8 }} onClick={handleReset}>重置</Button>
  222. </Form.Item>
  223. </Form>
  224. <div style={{ marginTop: '20px' }}>
  225. <AuthButton name="admin.funds.account.export" noRight={null}>
  226. <Button type="primary" onClick={() => exportReport()} style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} >导出</Button>
  227. </AuthButton>
  228. </div>
  229. <Table dataSource={data.records} columns={columns} pagination={false} style={{ marginTop: '20px' }} />
  230. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  231. <Pagination
  232. showQuickJumper
  233. defaultCurrent={1}
  234. total={data.total} onChange={e => changePageNum(e)} current={data.current} />
  235. </div>
  236. {showVoucher.visible && <ShowVoucher bannerList={showVoucher.bannerList} closeSwiper={() => setShowVoucher({ visible: false })} />}
  237. </>
  238. )
  239. }
  240. const WrappedRechargeOrder = Form.create({ name: 'RechargeOrder' })(RechargeOrder);
  241. export default WrappedRechargeOrder