Browse Source

perf: 订单记录金额订单概要取amountNew

kuns 3 months ago
parent
commit
ddd7f395e8
1 changed files with 18 additions and 63 deletions
  1. 18 63
      component/accountPages/paymentRecordPageComponent.tsx

+ 18 - 63
component/accountPages/paymentRecordPageComponent.tsx

@@ -39,59 +39,6 @@ const PaymentRecordPageComponent = () => {
     const [loading, setLoading] = useState(false);
     const [loading1, setLoading1] = useState(false);
 
-    // useEffect(() => {
-    //     const fetchTransactionRecord = async () => {
-    //         try {
-    //             const response = await walletService.getTransactionRecord();
-    //             console.log('response', response);
-    //             const formattedData: TransactionRecordItem[] = response
-    //                 .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
-    //                 .map((item: any) => {
-    //                     let description;
-    //                     if (item.type === 'wallet') {
-    //                         switch (item.goods_name) {
-    //                             case 'withdrawl':
-    //                                 description = '充電完成-退回餘額';
-    //                                 break;
-    //                             case 'Penalty':
-    //                                 description = '繳付罰款';
-    //                                 break;
-    //                             case 'Book a connector':
-    //                                 description = '預約充電費用';
-    //                                 break;
-    //                             case 'Walk In':
-    //                                 description = '充電費用';
-    //                                 break;
-    //                             default:
-    //                                 description = '充電';
-    //                         }
-    //                     } else {
-    //                         description = '錢包增值';
-    //                     }
-    //                     return {
-    //                         date: convertToHKTime(item.createdAt).hkDate,
-    //                         description: description,
-    //                         amount: item.amount,
-    //                         actual_total_power:
-    //                             item.actual_total_power !== undefined &&
-    //                             item.actual_total_power !== null &&
-    //                             item.actual_total_power !== '' &&
-    //                             !isNaN(Number(item.actual_total_power))
-    //                                 ? item.actual_total_power
-    //                                 : '-'
-    //                     };
-    //                 });
-    //             setTransactionRecord(formattedData.slice(0, 10));
-    //             console.log('transactionRecord', transactionRecord);
-    //         } catch (error) {
-    //             console.log(error);
-    //         }
-    //     };
-    //     fetchTransactionRecord();
-    // }, []);
-
-    //fetch transaction record
-
     useEffect(() => {
         const fetchTransactionRecord = async () => {
             try {
@@ -138,15 +85,22 @@ const PaymentRecordPageComponent = () => {
                         return {
                             date: convertToHKTime(item.createdAt).hkDate,
                             description: description,
-                            amount:
-                                item.type === 'qfpay' ||
-                                item.goods_name === 'Penalty' ||
-                                item.goods_name === 'manual_refund' ||
-                                item.goods_name === 'manual_deduction'
-                                    ? item.amount
-                                    : item.current_price && item.actual_total_power
-                                      ? (item.current_price * item.actual_total_power).toFixed(1)
-                                      : '-',
+                            amount: (() => {
+                                if (item.goods_name === 'Walk In') {
+                                    return item.amountNew ? (item.amountNew).toFixed(1) : '0';
+                                } else {
+                                    if (item.type === 'qfpay' || 
+                                        item.goods_name === 'Penalty' || 
+                                        item.goods_name === 'manual_refund' || 
+                                        item.goods_name === 'manual_deduction') {
+                                        return item.amount;
+                                    } else {
+                                        return item.current_price && item.actual_total_power
+                                            ? (item.current_price * item.actual_total_power).toFixed(1)
+                                            : '-';
+                                    }
+                                }
+                            })(),
                             actual_total_power:
                                 item.goods_name === 'manual_refund' || item.goods_name === 'manual_deduction'
                                     ? '-'
@@ -166,6 +120,7 @@ const PaymentRecordPageComponent = () => {
                         };
                     });
                 setTransactionRecord(formattedData.slice(0, 10));
+                console.log('ddd', formattedData);
             } catch (error) {}
         };
         fetchTransactionRecord();
@@ -186,7 +141,7 @@ const PaymentRecordPageComponent = () => {
                     >
                         <PreviousPageBlackSvg />
                     </Pressable>
-                    <Text style={{ fontSize: 45, marginVertical: 25 }}>订单記錄</Text>
+                    <Text style={{ fontSize: 45, marginVertical: 25 }}>訂單記錄</Text>
                 </View>
                 <View className="">
                     <ImageBackground