Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

346 wiersze
18 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Box
  7. // Button,
  8. // FormLabel,
  9. } from '@mui/material';
  10. import * as React from "react";
  11. import * as HttpUtils from "utils/HttpUtils";
  12. import * as UrlUtils from "utils/ApiPathConst";
  13. // import { useNavigate } from "react-router-dom";
  14. // import FpsIcon from "assets/images/icons/fps.svg";
  15. import { useLocation } from 'react-router-dom';
  16. // import {paymentPath} from "auth/utils";
  17. // import {poll} from "utils/Utils";
  18. import * as DateUtils from "utils/DateUtils"
  19. import Loadable from 'components/Loadable';
  20. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  21. const PaymentDetails = Loadable(React.lazy(() => import('../Details_Public/PaymentDetails')));
  22. const DataGrid = Loadable(React.lazy(() => import('../Details_Public/DataGrid')));
  23. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  24. import {FormattedMessage,useIntl} from "react-intl";
  25. const BackgroundHead = {
  26. backgroundImage: `url(${titleBackgroundImg})`,
  27. width: '100%',
  28. height: '100%',
  29. backgroundSize: 'contain',
  30. backgroundRepeat: 'no-repeat',
  31. backgroundColor: '#0C489E',
  32. backgroundPosition: 'right'
  33. }
  34. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  35. const AckPage = () => {
  36. // const navigate = useNavigate()
  37. const location = useLocation();
  38. // const [locationData, setLocationData] = React.useState({});
  39. const [paymentData, setPaymentData] = React.useState({});
  40. const [locationData, setLocationData] = React.useState({});
  41. const [responeData, setResponeDataData] = React.useState({});
  42. const [itemList, setItemList] = React.useState([]);
  43. // const [paymentId, setPaymentId] = React.useState("");
  44. const [transactionData, setTransactionData] = React.useState({});
  45. // const [transactionDate, setTransactionDate] = React.useState("");
  46. // const [transactionTime, setTransactionTime] = React.useState("");
  47. const [onReady, setOnReady] = React.useState(false);
  48. // const paymentStatusApi = "/api/payment/status/";
  49. const [onDownload, setOnDownload] = React.useState(false);
  50. const intl = useIntl();
  51. const { locale } = intl;
  52. React.useEffect(() => {
  53. if (location.state != undefined) {
  54. setLocationData(location.state)
  55. }
  56. }, []);
  57. React.useEffect(() => {
  58. if (Object.keys(locationData).length > 0){
  59. loadForm();
  60. }
  61. }, [locationData]);
  62. React.useEffect(() => {
  63. // console.log(responeData)
  64. if(Object.keys(responeData).length > 0){
  65. setTransactionData(responeData)
  66. }
  67. }, [responeData]);
  68. React.useEffect(() => {
  69. // console.log(paymentData)
  70. // console.log(transactionData)
  71. if(Object.keys(transactionData).length > 0 ){
  72. setOnReady(true);
  73. }
  74. }, [transactionData]);
  75. const loadForm = () => {
  76. // const dateTime = paymentData.transactionDateTime;
  77. // const date = new Date(dateTime);
  78. // const trnDate = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear();
  79. // const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
  80. // setTransactionDate(trnDate)
  81. // setTransactionTime(trnTime)
  82. // let transactionid = localStorage.getItem("transactionid")
  83. // let webtoken = localStorage.getItem("webtoken")
  84. let transactionid = locationData.transactionid
  85. HttpUtils.post({
  86. url: UrlUtils.PAYMENT_CALLBACK_STATUS_API,
  87. params:{
  88. "apprefid": transactionid,
  89. // "webtoken": webtoken,
  90. // "paymentId": localStorage.getItem("paymentId"),
  91. "transactionid":Number(transactionid)
  92. },
  93. onSuccess: function(responseData){
  94. localStorage.removeItem("webtoken");
  95. localStorage.removeItem("transactionid");
  96. responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, intl.formatMessage({id: "dateStrFormat"}));
  97. responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss");
  98. setResponeDataData(responseData.transactionData)
  99. setItemList(responseData.paymentItemList)
  100. setPaymentData(responseData.data);
  101. // if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") {
  102. // }
  103. // HttpUtils.post({
  104. // url: UrlUtils.PAYMENT_SAVE,
  105. // params: {
  106. // id: localStorage.getItem("paymentId"),
  107. // transNo: responseData.transactionid,
  108. // transDateTime: new Date(responseData.paymentdetail.time).toISOString(),
  109. // egisRefNo: responseData.paymentdetail.paymentid,
  110. // status: responseData.paymentdetail.result.paymentstatuscode,
  111. // payload: responseData
  112. // },
  113. // onSuccess: function (responseData2) {
  114. // responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY");
  115. // responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss");
  116. // setItemList(responseData2.paymentItemList)
  117. // setPaymentData(responseData2.data);
  118. // // localStorage.removeItem("paymentId");
  119. // // setPaymentId(responseData2.id)
  120. // }
  121. // });
  122. }
  123. });
  124. // setTransactionData(
  125. // {
  126. // "amount": 999.99,
  127. // "currencycode": "HKD",
  128. // "paymentdetail": {
  129. // "attemptno": 1,
  130. // "channel": "MobileWallet",
  131. // "paymentid": "C202310268000681",
  132. // "paymentmethod": "04",
  133. // "result": {
  134. // "canretry": "Y",
  135. // "description": "CANC - Cancelled by user or Payment Server.",
  136. // "paymentstatuscode": "CANC",
  137. // "rejectreasoncode": "Payment Cancelled. [PAY-E-9022]"
  138. // },
  139. // "subtype": "FPS",
  140. // "time": "2023-10-26T09:02:17Z[UTC]"
  141. // },
  142. // "transactionid": "20231026170103921"
  143. // }
  144. // )
  145. }
  146. const doPrint = () => {
  147. // window.print();
  148. setOnDownload(true)
  149. const local = locale
  150. HttpUtils.fileDownload({
  151. // url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local,
  152. url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+paymentData.id+"/"+local,
  153. onResponse:()=>{
  154. setOnDownload(false)
  155. },
  156. onError:()=>{
  157. setOnDownload(false)
  158. }
  159. });
  160. };
  161. return (
  162. !onReady ?
  163. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  164. <Grid item>
  165. <LoadingComponent />
  166. </Grid>
  167. </Grid>
  168. :
  169. transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ?
  170. (
  171. <div>
  172. <style>
  173. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  174. </style>
  175. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center">
  176. <Grid className="printHidden" item xs={12} width="100%">
  177. <div style={BackgroundHead} width="100%">
  178. <Stack direction="row" height='70px'>
  179. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>
  180. <FormattedMessage id="publicNoticePaymentSuccess"/>
  181. </Typography>
  182. </Stack>
  183. </div>
  184. </Grid>
  185. {/*row 1*/}
  186. <Grid item xs={12} md={12} spacing={2} sx={{ textAlign: "center" }}>
  187. <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>
  188. {/* 您的申請和付款已收到 */}
  189. <FormattedMessage id="MSG.paymentMsg"/>
  190. </Typography>
  191. <Grid container justifyContent="center" direction="column" spacing={2} sx={{ p: 2 }} alignitems="stretch" >
  192. <Grid item className="printOrder" xs={12} md={12} sx={{ pt: 2 }} style={{ height: '100%', order: 1 }}>
  193. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  194. <PaymentDetails
  195. formData={paymentData}
  196. doPrint={doPrint}
  197. onDownload={onDownload}
  198. style={{
  199. display: "flex",
  200. height: "100%",
  201. flex: 1
  202. }}
  203. />
  204. </Box>
  205. </Grid>
  206. <Grid item xs={12} md={12} sx={{ pt: 1, pb: 2 }} style={{ height: '100%', order: 2 }}>
  207. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  208. <DataGrid
  209. recordList={itemList}
  210. />
  211. </Box>
  212. </Grid>
  213. </Grid>
  214. </Grid>
  215. {/*row 2*/}
  216. </Grid >
  217. </div>
  218. ) :
  219. (transactionData.paymentdetail?.result?.paymentstatuscode === "CANC" ?
  220. <div>
  221. <style>
  222. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  223. </style>
  224. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  225. <Grid className="printHidden" item xs={12} width="100%">
  226. <div style={BackgroundHead} width="100%">
  227. <Stack direction="row" height='70px'>
  228. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>
  229. <FormattedMessage id="publicNoticePaymentCancel"/>
  230. </Typography>
  231. </Stack>
  232. </div>
  233. </Grid>
  234. {/*row 1*/}
  235. <Grid item xs={12} md={12} >
  236. <Grid container justifyContent="flex-start" alignItems="center" >
  237. <center>
  238. <Grid item xs={12} md={8} >
  239. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  240. {/* 付款取消訊息: */}
  241. <FormattedMessage id="MSG.paymentCancelMsg1"/>
  242. <br /><br />
  243. <FormattedMessage id="MSG.paymentCancelMsg2"/>
  244. <br /><br />
  245. <FormattedMessage id="MSG.paymentCancelMsg3"/>
  246. <br />
  247. <FormattedMessage id="MSG.paymentCancelMsg4"/>
  248. <br /><br />
  249. <FormattedMessage id="MSG.paymentCancelMsg5"/>
  250. <br />
  251. <FormattedMessage id="MSG.paymentCancelMsg6"/>
  252. <br />
  253. <FormattedMessage id="MSG.paymentCancelMsg7"/>
  254. <br /><br />
  255. <FormattedMessage id="MSG.paymentCancelMsg8"/>
  256. </Typography>
  257. </Grid>
  258. </center>
  259. </Grid>
  260. </Grid>
  261. {/*row 2*/}
  262. </Grid >
  263. </div>
  264. :
  265. <div>
  266. <style>
  267. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  268. </style>
  269. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }}direction="column" justifyContent="flex-start" alignItems="center" >
  270. <Grid className="printHidden" item xs={12} width="100%">
  271. <div style={BackgroundHead} width="100%">
  272. <Stack direction="row" height='70px'>
  273. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>
  274. <FormattedMessage id="publicNoticePaymentFail"/>
  275. </Typography>
  276. </Stack>
  277. </div>
  278. </Grid>
  279. {/*row 1*/}
  280. <Grid item xs={12} md={12} >
  281. <Grid container justifyContent="flex-start" alignItems="center" >
  282. <center>
  283. <Grid item xs={12} md={8} >
  284. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  285. <FormattedMessage id="MSG.paymentFailMsg1"/>
  286. <br /><br />
  287. <FormattedMessage id="MSG.paymentFailMsg2"/>
  288. <br /><br />
  289. <ul>
  290. <li>
  291. <FormattedMessage id="MSG.paymentFailMsg3"/>
  292. </li>
  293. <li>
  294. <FormattedMessage id="MSG.paymentFailMsg4"/>
  295. </li>
  296. <li>
  297. <FormattedMessage id="MSG.paymentFailMsg5"/>
  298. </li>
  299. </ul>
  300. <br /><br />
  301. <FormattedMessage id="MSG.paymentFailMsg6"/>
  302. <br /><br />
  303. <ul>
  304. <li>
  305. <FormattedMessage id="MSG.paymentFailMsg7"/>
  306. </li>
  307. <li>
  308. <FormattedMessage id="MSG.paymentFailMsg8"/>
  309. </li>
  310. <li>
  311. <FormattedMessage id="MSG.paymentFailMsg9"/>
  312. </li>
  313. </ul>
  314. <br /><br />
  315. <FormattedMessage id="MSG.paymentFailMsg10"/>
  316. </Typography>
  317. </Grid>
  318. </center>
  319. </Grid>
  320. </Grid>
  321. {/*row 2*/}
  322. </Grid >
  323. </div>
  324. )
  325. );
  326. };
  327. export default AckPage;