RefundOrder.jsx 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. import React, { useState, useEffect } from 'react';
  2. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  3. import { Form, Pagination, Button, Icon, message, Modal, Table, Select, Input, DatePicker } from 'antd';
  4. import router from 'umi/router';
  5. import moment from 'moment';
  6. import className from 'classnames';
  7. import Cell from '../../components/Cell';
  8. import styles from './style.less';
  9. import { fetch, apis } from '../../utils/request';
  10. import request from '../../utils/request';
  11. import AuthButton from '@/components/AuthButton';
  12. import Swiper from './components/Swiper';
  13. import { regFenToYuan } from '@/utils/money';
  14. import Refund from './components/Refund'
  15. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  16. function header(props) {
  17. // 获取初始化数据
  18. const [data, setData] = useState({})
  19. const [row, setRow] = useState({})
  20. const [demandIdList, setDemandIdList] = useState([])
  21. const [visible, setVisible] = useState(false)
  22. const [refundVisible, setRefundVisible] = useState(false)
  23. const [inputValue, setValue] = useState('')
  24. const [swiperList, setSwiperList] = useState([])
  25. const orgId = props.orgId || ''
  26. useEffect(() => {
  27. getList({ pageNum: 1, pageSize: 10, orderType: 'refund' });
  28. }, [])
  29. // 查询列表
  30. const getList = (params) => {
  31. request({ ...apis.fund.taOrgOrder, params: { ...params, orgId, } }).then((data) => {
  32. console.log(data)
  33. setData(data)
  34. })
  35. }
  36. // 提交事件
  37. const handleSubmit = (e, props) => {
  38. e.preventDefault();
  39. props.form.validateFields((err, values) => {
  40. if (!err) {
  41. let { LocalDate, ...submitValue } = values
  42. if (null != LocalDate && LocalDate.length > 0) {
  43. const [startDate, endDate] = LocalDate
  44. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  45. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  46. } else {
  47. submitValue.startDate = null
  48. submitValue.endDate = null
  49. }
  50. getList({ pageNum: 1, pageSize: 10, orderType: 'refund', ...submitValue })
  51. }
  52. });
  53. }
  54. const changePageNum = (pageNumber) => {
  55. let { LocalDate, ...submitValue } = props.form.getFieldsValue()
  56. if (null != LocalDate && LocalDate.length > 0) {
  57. const [startDate, endDate] = LocalDate
  58. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  59. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  60. } else {
  61. submitValue.startDate = null
  62. submitValue.endDate = null
  63. }
  64. getList({ pageNum: pageNumber, pageSize: 10, orderType: 'refund', ...submitValue })
  65. }
  66. const look = (list) => {
  67. setSwiperList(list)
  68. }
  69. /**
  70. *
  71. *
  72. * @param {*} props
  73. * @returns
  74. */
  75. const columns = [
  76. {
  77. title: '订单编号',
  78. dataIndex: 'tradeNo',
  79. key: 'tradeNo',
  80. align: 'center',
  81. },
  82. {
  83. title: '退款组织',
  84. dataIndex: 'miniAppName',
  85. key: 'miniAppName',
  86. align: 'center',
  87. },
  88. {
  89. title: '退款金额',
  90. dataIndex: 'amount',
  91. key: 'amount',
  92. align: 'center',
  93. render: (x, row) => <span>{regFenToYuan(x)}</span>
  94. },
  95. {
  96. title: '退款创建时间',
  97. dataIndex: 'createDate',
  98. key: 'createDate',
  99. align: 'center',
  100. render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  101. },
  102. {
  103. title: '退款状态',
  104. dataIndex: 'auditStatus',
  105. key: 'auditStatus',
  106. align: 'center',
  107. render: (x, row) => <><span>{row.auditStatus == 'checking' ? '已申请' : row.auditStatus == 'agree' ? '已退款' : '已驳回'}</span></>
  108. },
  109. {
  110. title: '驳回原因',
  111. dataIndex: 'auditResult',
  112. key: 'auditResult',
  113. align: 'center',
  114. render: (x, row) => <>{row.tradingStatus == 'fail' && <span>{row.auditResult}</span>}</>
  115. },
  116. {
  117. title: '退款凭证',
  118. dataIndex: 'certificateUrlList',
  119. key: 'certificateUrlList',
  120. align: 'center',
  121. render: (x, row) => (
  122. <>
  123. {
  124. (x || []).length > 0 &&
  125. <>
  126. <span className={styles.blue} onClick={() => look(row.certificateUrlList)}>
  127. 查看
  128. </span></>
  129. }
  130. </>
  131. ),
  132. },
  133. {
  134. title: '操作',
  135. dataIndex: 'handle',
  136. key: 'handle',
  137. align: 'center',
  138. width: '120px',
  139. render: (x, row) => (
  140. <>
  141. {
  142. row.auditStatus == 'checking' &&
  143. <>
  144. <span style={{ color: '#FF925C', cursor: 'pointer', marginRight: '16px' }} onClick={() => refund(row)}>
  145. 退款
  146. </span>
  147. <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={() => reject(row)}>
  148. 驳回
  149. </span></>
  150. }
  151. </>
  152. ),
  153. },
  154. ];
  155. function handleReset() {
  156. props.form.resetFields();
  157. getList({ pageNum: 1, pageSize: 10, orderType: 'refund' })
  158. }
  159. const handleOk = () => {
  160. if (inputValue) {
  161. request({
  162. ...apis.fund.reject, urlData: { id: row.orderId }, data: {
  163. auditResult: inputValue,
  164. orgId: row.orgId,
  165. }
  166. }).then((data) => {
  167. console.log(data)
  168. getList({ pageNum: 1, pageSize: 10, orderType: 'refund' });
  169. })
  170. setVisible(false)
  171. setValue('')
  172. } else {
  173. message.warning('驳回原因不能为空');
  174. }
  175. }
  176. const handleCancel = () => {
  177. setVisible(false)
  178. setRefundVisible(false)
  179. }
  180. const reject = row => {
  181. setVisible(true)
  182. setRow(row)
  183. }
  184. const refund = (row) => {
  185. setRefundVisible(true)
  186. console.log(row, 'row')
  187. setRow(row)
  188. }
  189. const toDeatil = () => {
  190. if (orgId) {
  191. props.onToDetail()
  192. } else {
  193. router.push({
  194. pathname: '/fundManagement/AccountDetail',
  195. query: {
  196. orgId: row.orgId,
  197. },
  198. });
  199. }
  200. }
  201. const bohui = () => {
  202. setRefundVisible(false)
  203. setVisible(true)
  204. }
  205. const orderRefund = () => {
  206. getList({ pageNum: 1, pageSize: 10, orderType: 'refund' });
  207. setRefundVisible(false)
  208. }
  209. // 导出
  210. const exportList = () => {
  211. const { LocalDate, ...submitValue } = props.form.getFieldsValue()
  212. if (null != LocalDate && LocalDate.length > 0) {
  213. const [startDate, endDate] = LocalDate
  214. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  215. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  216. } else {
  217. submitValue.startDate = null
  218. submitValue.endDate = null
  219. }
  220. request({ ...apis.fund.refundOrderExport, params: { orderType: 'refund', orgId, ...submitValue } }).then(data => {
  221. if (!data) {
  222. return
  223. }
  224. const url = window.URL.createObjectURL(new Blob([data]))
  225. const link = document.createElement('a')
  226. link.style.display = 'none'
  227. link.href = url
  228. link.setAttribute('download', '退款订单表.xlsx')
  229. document.body.append(link)
  230. link.click()
  231. }).catch()
  232. }
  233. const { getFieldDecorator } = props.form
  234. const lastColumns = props.organize == 'hidden' ? columns.filter(x => x.title != '退款组织') : columns
  235. return (
  236. <>
  237. <Modal
  238. visible={visible}
  239. title="驳回退款"
  240. onOk={() => handleOk()}
  241. onCancel={() => handleCancel()}
  242. footer={[
  243. <Button key="back" size="large" onClick={() => handleCancel()}>取消</Button>,
  244. <Button key="submit" type="primary" size="large" onClick={() => handleOk()}>确认</Button>,
  245. ]}
  246. >
  247. <div style={{ display: 'flex', alignItems: 'center', margin: '30px 0' }}>驳回原因
  248. <span style={{ color: 'red' }}>*</span><Input value={inputValue} onChange={e => setValue(e.target.value)} style={{ marginLeft: '10px', width: '80%' }} placeholder="请输入驳回原因" />
  249. </div>
  250. </Modal>
  251. <Modal
  252. visible={refundVisible}
  253. title="退款审核"
  254. onOk={() => orderRefund()}
  255. onCancel={() => handleCancel()}
  256. footer={[
  257. <Refund key="back" size="large" orgId={row.orgId} accountId={row.accountId} amount={row.amount || '0'} onClick={() => orderRefund()} orderId={row.orderId} />,
  258. <Button key="submit" type="primary" size="large" onClick={() => bohui()}>驳回</Button>,
  259. ]}
  260. ><div>
  261. <p>1.请核对账户余额等是否正常,且预留了足够的活动余额。异常请核对企业账单后与企业相关人员沟通并确认点击驳回申请</p>
  262. <p className={styles.flexRow}>
  263. <span>退款金额: <span className={styles.red}>{regFenToYuan(row.amount) || '0'}元</span></span>
  264. <span>账户余额:<span className={styles.red}>{regFenToYuan(row.realBalance) || '0'}元</span></span>
  265. <span className={styles.blue} onClick={() => toDeatil()}>查看账户详情</span>
  266. </p>
  267. <p>2.请到微信商户平台使用企业付款或充值订单退款等方式退款,或使用微信转账/银行卡转账/企业对公转账等方式退款</p>
  268. <p>3.退款完成后,截图保留凭证并点击确认退款</p>
  269. </div>
  270. </Modal>
  271. < Swiper list={swiperList} onClose={() => setSwiperList([])} />
  272. <Form layout="inline" onSubmit={e => handleSubmit(e, props)} style={{ marginBottom: '16px' }}>
  273. <Form.Item>
  274. {getFieldDecorator('tradeNo')(
  275. <Input
  276. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  277. placeholder="订单编号"
  278. />,
  279. )}
  280. </Form.Item>
  281. {
  282. props.organize != 'hidden' &&
  283. <Form.Item>
  284. {getFieldDecorator('miniAppName')(
  285. <Input
  286. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  287. placeholder="退款组织"
  288. />,
  289. )}
  290. </Form.Item>
  291. }
  292. <Form.Item>
  293. {getFieldDecorator('auditStatus')(
  294. <Select style={{ width: '180px' }} placeholder="退款状态">
  295. <Select.Option value="">全部</Select.Option>
  296. <Select.Option value="checking">已申请</Select.Option>
  297. <Select.Option value="agree">已退款</Select.Option>
  298. <Select.Option value="unAgree">已驳回</Select.Option>
  299. </Select>,
  300. )}
  301. </Form.Item>
  302. <Form.Item>
  303. <span style={{ marginRight: '10px' }}>退款时间段:</span>
  304. {getFieldDecorator('LocalDate')(
  305. <RangePicker placeholder={['开始时间', '结束时间']} />,
  306. )}
  307. </Form.Item>
  308. <Form.Item>
  309. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  310. 搜索
  311. </Button>
  312. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  313. 重置
  314. </Button>
  315. </Form.Item>
  316. </Form>
  317. <div>
  318. <Button type="danger" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={() => exportList()} >导出</Button>
  319. </div>
  320. <Table rowKey={r => r.tradeNo} dataSource={data.records} columns={lastColumns} pagination={false} />
  321. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  322. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
  323. </div>
  324. </>
  325. )
  326. }
  327. const WrappedHeader = Form.create({ name: 'header' })(header);
  328. export default WrappedHeader