Переглянути джерело

feat: add multi-currency support and currency selection across orders and settlements

jerry 1 місяць тому
батько
коміт
9b4f980c90

+ 34 - 11
src/app/admin/orders/new/page.tsx

@@ -12,6 +12,7 @@ import AdminUserSelect from '@/components/common/AdminUserSelect';
 import { ImageUploadField } from '@/components/common/ImageUploadField';
 import { SchemaProperty, VasAgency } from '@/types';
 import { toast } from 'react-hot-toast';
+import { SUPPORTED_CURRENCIES, getCurrencySymbol } from '@/lib/currency';
 
 export default function AdminCreateOrderPage() {
   const router = useRouter();
@@ -22,10 +23,11 @@ export default function AdminCreateOrderPage() {
 
   // 2. 渠道与分润归属状态
   const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
+  const [handlerId, setHandlerId] = useState<string>('');
   const [agencies, setAgencies] = useState<VasAgency[]>([]);
   const [selectedAgencyId, setSelectedAgencyId] = useState<string>('');
-  const [handlerId, setHandlerId] = useState<string>('');
-  const [customPrice, setCustomPrice] = useState<string>(''); // 单位: 元
+  const [customPrice, setCustomPrice] = useState<string>(''); // 单位: 元/欧/刀
+  const [currency, setCurrency] = useState<string>('CNY'); // 结算币种代码
 
   // 2.5 收款时机与收款登记状态
   const [paymentTiming, setPaymentTiming] = useState<'pay_later' | 'paid_now'>('pay_later');
@@ -79,7 +81,10 @@ export default function AdminCreateOrderPage() {
       return;
     }
 
-    // 默认价格填充 (分转元): 优先取 price_amount,兼顾 base_price
+    // 默认价格与币种填充: 优先取 price_amount,兼顾 base_price
+    const prodCurrency = (selectedProduct.price_currency || selectedProduct.currency || 'CNY').toUpperCase();
+    setCurrency(prodCurrency);
+
     if (selectedProduct.price_amount !== undefined) {
       setCustomPrice((selectedProduct.price_amount / 100).toFixed(2));
     } else if (selectedProduct.base_price !== undefined) {
@@ -160,8 +165,9 @@ export default function AdminCreateOrderPage() {
         return toast.error('请选择合作中介机构');
       }
       if (selectedAgency && finalAmountCents !== undefined && finalAmountCents < selectedAgency.min_floor_price) {
+        const sym = getCurrencySymbol(currency);
         return toast.error(
-          `录入价格 ¥${(finalAmountCents / 100).toFixed(2)} 低于该中介协议最低结算底价 ¥${(selectedAgency.min_floor_price / 100).toFixed(2)}!`
+          `录入价格 ${sym}${(finalAmountCents / 100).toFixed(2)} 低于该中介协议最低结算底价 ${sym}${(selectedAgency.min_floor_price / 100).toFixed(2)}!`
         );
       }
     }
@@ -179,6 +185,7 @@ export default function AdminCreateOrderPage() {
         agency_id: channelType === 'agency' ? selectedAgencyId : undefined,
         handler_id: channelType === 'website' ? undefined : handlerId.trim(),
         final_amount: finalAmountCents,
+        currency: currency,
         payment_timing: paymentTiming,
         payment_method: paymentTiming === 'paid_now' ? paymentMethod : undefined,
         external_trade_no: paymentTiming === 'paid_now' ? (externalTradeNo.trim() || undefined) : undefined,
@@ -457,12 +464,28 @@ export default function AdminCreateOrderPage() {
               {/* 金额输入及差额提示 */}
               <div className="pt-3 border-t-2 border-dashed border-neutral-300 grid grid-cols-1 md:grid-cols-2 gap-4">
                 <div>
-                  <label className="text-xs font-black text-black uppercase block mb-1">
-                    [ {paymentTiming === 'pay_later' ? '约定应收金额 (元)' : '实际到账金额 (元)'} ] <span className="text-rose-600">*</span>
-                  </label>
+                  <div className="flex items-center justify-between mb-1">
+                    <label className="text-xs font-black text-black uppercase">
+                      [ {paymentTiming === 'pay_later' ? '约定应收金额' : '实际到账金额'} ] <span className="text-rose-600">*</span>
+                    </label>
+                    <div className="flex items-center gap-1.5">
+                      <span className="text-[10px] text-neutral-500 font-bold uppercase">币种:</span>
+                      <select
+                        value={currency}
+                        onChange={(e) => setCurrency(e.target.value)}
+                        className="px-2 py-0.5 border-2 border-black bg-amber-100 text-xs font-black cursor-pointer shadow-[1px_1px_0px_#000] focus:outline-hidden"
+                      >
+                        {SUPPORTED_CURRENCIES.map((c) => (
+                          <option key={c.code} value={c.code}>
+                            {c.name}
+                          </option>
+                        ))}
+                      </select>
+                    </div>
+                  </div>
                   <div className="relative">
                     <span className="absolute left-3 top-2.5 text-xs font-bold text-black pointer-events-none">
-                      ¥
+                      {getCurrencySymbol(currency)}
                     </span>
                     <input
                       type="number"
@@ -471,12 +494,12 @@ export default function AdminCreateOrderPage() {
                       value={customPrice}
                       onChange={(e) => setCustomPrice(e.target.value)}
                       placeholder="商品指导价"
-                      className="w-full pl-7 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-black focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+                      className="w-full pl-8 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-black focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
                     />
                   </div>
                   <div className="text-[10px] text-neutral-500 font-mono mt-1 flex items-center justify-between">
                     <span>
-                      商品指导标价: ¥{((selectedProduct.price_amount || selectedProduct.base_price || 0) / 100).toFixed(2)}
+                      商品指导标价: {getCurrencySymbol(selectedProduct.price_currency || 'CNY')}{((selectedProduct.price_amount || selectedProduct.base_price || 0) / 100).toFixed(2)} ({selectedProduct.price_currency || 'CNY'})
                     </span>
                     {customPrice && !isNaN(Number(customPrice)) && (
                       <span className={`font-bold ${
@@ -486,7 +509,7 @@ export default function AdminCreateOrderPage() {
                           ? 'text-emerald-700'
                           : 'text-neutral-500'
                       }`}>
-                        差额: ¥{((Number(customPrice) * 100 - (selectedProduct.price_amount || 0)) / 100).toFixed(2)}
+                        差额: {Number(customPrice) * 100 >= (selectedProduct.price_amount || 0) ? '+' : ''}{getCurrencySymbol(currency)}{((Number(customPrice) * 100 - (selectedProduct.price_amount || 0)) / 100).toFixed(2)}
                       </span>
                     )}
                   </div>

+ 19 - 11
src/components/admin/orders/OrderDetailDrawer.tsx

@@ -28,6 +28,7 @@ import { getPaymentProviderIcon } from '@/components/admin/payments/paymentIcons
 import { ExtendedOrderDetail, PaymentRecord } from '@/types';
 import { toast } from 'react-hot-toast';
 import { paymentService, orderService, userService } from '@/lib/services';
+import { getCurrencySymbol } from '@/lib/currency';
 
 const FIELD_DISPLAY_ORDER = [
   'surname',
@@ -212,7 +213,7 @@ export default function OrderDetailDrawer({
   const isCancelled = (order.status || '').toLowerCase() === 'cancelled';
 
   const formatMoney = (amount: number, curr = currency) => {
-    const symbol = curr === 'CNY' ? '¥' : curr === 'USD' ? '$' : `${curr} `;
+    const symbol = getCurrencySymbol(curr);
     return `${symbol}${(amount / 100).toFixed(2)}`;
   };
 
@@ -610,16 +611,23 @@ export default function OrderDetailDrawer({
                             {pay.provider} // {pay.channel}
                           </span>
 
-                          <div className="flex items-center gap-1.5">
-                            <span className="font-bold text-black font-mono">
-                              {formatMoney(pay.amount, pay.currency)}
-                            </span>
-                            <span
-                              className={`px-1.5 py-0.2 text-[10px] font-black uppercase border border-black ${isPaySucceeded ? 'bg-amber-300 text-black' : 'bg-neutral-200 text-neutral-600'
-                                }`}
-                            >
-                              {pay.status}
-                            </span>
+                          <div className="flex flex-col items-end gap-0.5">
+                            <div className="flex items-center gap-1.5">
+                              <span className="font-bold text-black font-mono">
+                                {formatMoney(pay.amount, pay.currency)}
+                              </span>
+                              <span
+                                className={`px-1.5 py-0.2 text-[10px] font-black uppercase border border-black ${isPaySucceeded ? 'bg-amber-300 text-black' : 'bg-neutral-200 text-neutral-600'
+                                  }`}
+                              >
+                                {pay.status}
+                              </span>
+                            </div>
+                            {pay.base_currency && pay.base_currency !== pay.currency && pay.base_amount ? (
+                              <span className="text-[10px] text-neutral-500 font-mono">
+                                原标价: {formatMoney(pay.base_amount, pay.base_currency)}
+                              </span>
+                            ) : null}
                           </div>
                         </div>
 

+ 25 - 17
src/components/admin/orders/OrderPaymentModal.tsx

@@ -8,6 +8,7 @@ import { paymentService } from '@/lib/services';
 import LocalTime from '@/components/common/LocalTime';
 import { getPaymentProviderIcon } from '@/components/admin/payments/paymentIcons';
 import { OrderDetail, PaymentRecord } from '@/types';
+import { getCurrencySymbol } from '@/lib/currency';
 
 interface OrderPaymentModalProps {
   isOpen: boolean;
@@ -48,7 +49,7 @@ export default function OrderPaymentModal({
   };
 
   const handleForceSuccess = async (payment: PaymentRecord) => {
-    const amountStr = `${(payment.amount / 100).toFixed(2)} ${payment.currency}`;
+    const amountStr = `${getCurrencySymbol(payment.currency)}${(payment.amount / 100).toFixed(2)} ${payment.currency}`;
     const ok = await retroConfirm({
       title: '[ HIGH RISK // 强制核销入账确认 ]',
       message: `您确定要将支付单 #${payment.id} (${payment.provider}) 强制核销为“支付成功”吗?\n\n核销金额: ${amountStr}\n\n⚠️ 请务必确认实际银行账户或第三方后台已确实到账。`,
@@ -130,7 +131,7 @@ export default function OrderPaymentModal({
             <div>
               <span className="text-[10px] text-neutral-500 font-bold uppercase block">应付核算</span>
               <span className="font-black text-black">
-                {order.base_currency === 'CNY' ? '¥' : order.base_currency} {((order.final_amount ?? order.base_amount) / 100).toFixed(2)}
+                {getCurrencySymbol(order.base_currency)}{((order.final_amount ?? order.base_amount) / 100).toFixed(2)} ({order.base_currency || 'CNY'})
               </span>
             </div>
             <div>
@@ -186,21 +187,28 @@ export default function OrderPaymentModal({
                         <span className="w-2 h-2 bg-black inline-block" />
                         <span>{p.provider} // {p.channel}</span>
                       </div>
-                      <div className="flex items-center gap-2">
-                        <span className="font-mono font-black text-base text-black">
-                          {p.currency === 'CNY' ? '¥' : p.currency} {(p.amount / 100).toFixed(2)}
-                        </span>
-                        <span
-                          className={`px-2 py-0.5 text-[10px] font-black uppercase border border-black ${
-                            isSucceeded
-                              ? 'bg-amber-300 text-black'
-                              : isFailed
-                                ? 'bg-neutral-200 text-neutral-500'
-                                : 'bg-white text-black'
-                          }`}
-                        >
-                          {p.status}
-                        </span>
+                      <div className="flex flex-col items-end gap-0.5">
+                        <div className="flex items-center gap-2">
+                          <span className="font-mono font-black text-base text-black">
+                            {getCurrencySymbol(p.currency)}{(p.amount / 100).toFixed(2)} {p.currency}
+                          </span>
+                          <span
+                            className={`px-2 py-0.5 text-[10px] font-black uppercase border border-black ${
+                              isSucceeded
+                                ? 'bg-amber-300 text-black'
+                                : isFailed
+                                  ? 'bg-neutral-200 text-neutral-500'
+                                  : 'bg-white text-black'
+                            }`}
+                          >
+                            {p.status}
+                          </span>
+                        </div>
+                        {p.base_currency && p.base_currency !== p.currency && p.base_amount ? (
+                          <span className="text-[10px] text-neutral-500 font-mono">
+                            原标价: {getCurrencySymbol(p.base_currency)}{(p.base_amount / 100).toFixed(2)} {p.base_currency}
+                          </span>
+                        ) : null}
                       </div>
                     </div>
 

+ 2 - 1
src/components/admin/orders/OrderTable.tsx

@@ -19,6 +19,7 @@ import {
 } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
 import { OrderDetail, ExtendedOrderDetail } from '@/types';
+import { getCurrencySymbol } from '@/lib/currency';
 
 interface OrderTableProps {
   orders: ExtendedOrderDetail[];
@@ -202,7 +203,7 @@ export default function OrderTable({
     const base = order.base_amount || 0;
     const final = order.final_amount !== undefined ? order.final_amount : base;
     const isAdjusted = final !== base;
-    const symbol = currency === 'CNY' ? '¥' : currency === 'USD' ? '$' : `${currency} `;
+    const symbol = getCurrencySymbol(currency);
 
     return (
       <div className="flex flex-col font-mono">

+ 30 - 8
src/components/admin/orders/RegisterPaymentModal.tsx

@@ -6,6 +6,7 @@ import { toast } from 'react-hot-toast';
 import { orderService } from '@/lib/services';
 import { OrderDetail } from '@/types';
 import { ImageUploadField } from '@/components/common/ImageUploadField';
+import { SUPPORTED_CURRENCIES, getCurrencySymbol } from '@/lib/currency';
 
 interface RegisterPaymentModalProps {
   isOpen: boolean;
@@ -22,6 +23,7 @@ export default function RegisterPaymentModal({
 }: RegisterPaymentModalProps) {
   const [loading, setLoading] = useState(false);
   const [amount, setAmount] = useState<string>('');
+  const [currency, setCurrency] = useState<string>('CNY');
   const [paymentMethod, setPaymentMethod] = useState<string>('wechat');
   const [externalTradeNo, setExternalTradeNo] = useState<string>('');
   const [voucherUrl, setVoucherUrl] = useState<string>('');
@@ -35,6 +37,7 @@ export default function RegisterPaymentModal({
         ? (order.base_amount / 100).toFixed(2)
         : '';
       setAmount(defaultAmount);
+      setCurrency((order.base_currency || (order as any).currency || 'CNY').toUpperCase());
       setPaymentMethod('wechat');
       setExternalTradeNo('');
       setVoucherUrl('');
@@ -58,13 +61,15 @@ export default function RegisterPaymentModal({
       await orderService.registerPayment({
         order_id: order.id,
         amount: amountCents,
+        currency: currency,
         payment_method: paymentMethod,
         external_trade_no: externalTradeNo.trim() || undefined,
         voucher_url: voucherUrl.trim() || undefined,
         note: note.trim() || undefined,
       });
 
-      toast.success(`实收金额 ¥${numAmount.toFixed(2)} 登记成功!已生成核销入账流水。`);
+      const sym = getCurrencySymbol(currency);
+      toast.success(`实收金额 ${sym}${numAmount.toFixed(2)} (${currency}) 登记成功!已生成核销入账流水。`);
       onSuccess();
       onClose();
     } catch (err: any) {
@@ -126,21 +131,38 @@ export default function RegisterPaymentModal({
           <div>
             <span className="text-[10px] text-neutral-500 font-bold uppercase block">当前账面应付</span>
             <span className="font-black text-amber-900">
-              ¥{order.final_amount !== undefined ? (order.final_amount / 100).toFixed(2) : '-'}
+              {getCurrencySymbol(order.base_currency || (order as any).currency || 'CNY')}
+              {order.final_amount !== undefined ? (order.final_amount / 100).toFixed(2) : '-'} ({(order.base_currency || (order as any).currency || 'CNY').toUpperCase()})
             </span>
           </div>
         </div>
 
         {/* Form Body */}
         <form onSubmit={handleSubmit} className="p-5 overflow-y-auto space-y-4 text-xs font-mono">
-          {/* 实收金额 */}
+          {/* 实收金额与币种 */}
           <div>
-            <label className="block text-xs font-black uppercase text-black mb-1">
-              [ 1. 实际到账金额 (元) ] <span className="text-rose-600">*</span>
-            </label>
+            <div className="flex items-center justify-between mb-1">
+              <label className="block text-xs font-black uppercase text-black">
+                [ 1. 实际到账金额 ] <span className="text-rose-600">*</span>
+              </label>
+              <div className="flex items-center gap-1.5">
+                <span className="text-[10px] text-neutral-500 font-bold uppercase">实收币种:</span>
+                <select
+                  value={currency}
+                  onChange={(e) => setCurrency(e.target.value)}
+                  className="px-2 py-0.5 border-2 border-black bg-amber-100 text-xs font-black cursor-pointer shadow-[1px_1px_0px_#000] focus:outline-hidden"
+                >
+                  {SUPPORTED_CURRENCIES.map((c) => (
+                    <option key={c.code} value={c.code}>
+                      {c.name}
+                    </option>
+                  ))}
+                </select>
+              </div>
+            </div>
             <div className="relative">
               <span className="absolute left-3 top-2.5 text-sm font-bold text-black pointer-events-none">
-                ¥
+                {getCurrencySymbol(currency)}
               </span>
               <input
                 type="number"
@@ -154,7 +176,7 @@ export default function RegisterPaymentModal({
               />
             </div>
             <p className="text-[10px] text-neutral-500 mt-1">
-              可根据实际收款修改(如发生优惠折扣、抹零或追加加急费),提交后将同步更新订单最终应收结算价。
+              可根据实际收款修改金额与币种(支持人民币、欧元、美元等),提交后将同步更新订单最终应收结算价与流水。
             </p>
           </div>
 

+ 67 - 45
src/components/admin/settlement/SettlementEngineTab.tsx

@@ -33,6 +33,7 @@ import { retroConfirm } from '@/lib/dialog';
 import SettlementPeriodDetailModal from './SettlementPeriodDetailModal';
 import LocalTime from '@/components/common/LocalTime';
 import AdminUserSelect from '@/components/common/AdminUserSelect';
+import { getCurrencySymbol } from '@/lib/currency';
 
 export default function SettlementEngineTab() {
   // Preset State: 'current_month' | 'last_month' | 'custom'
@@ -426,7 +427,11 @@ export default function SettlementEngineTab() {
             <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000]">
               <span className="text-[10px] text-neutral-500 uppercase font-black block">订单实收总营业额</span>
               <div className="text-xl font-black text-black mt-1">
-                ¥{(previewResult.total_revenue / 100).toFixed(2)}
+                {previewResult.revenue_by_currency && Object.keys(previewResult.revenue_by_currency).length > 0
+                  ? Object.entries(previewResult.revenue_by_currency)
+                      .map(([curr, amt]) => `${getCurrencySymbol(curr)}${(amt / 100).toFixed(2)}`)
+                      .join(' + ')
+                  : `¥${(previewResult.total_revenue / 100).toFixed(2)}`}
               </div>
               <span className="text-[9px] text-neutral-400 block mt-0.5">合伙公账统一收入</span>
             </div>
@@ -444,13 +449,17 @@ export default function SettlementEngineTab() {
               <div className="text-xl font-black text-amber-700 mt-1">
                 ¥{(previewResult.avg_cost / 100).toFixed(2)}
               </div>
-              <span className="text-[9px] text-neutral-400 block mt-0.5">每单均摊成本</span>
+              <span className="text-[9px] text-neutral-400 block mt-0.5">CNY订单每单均摊</span>
             </div>
 
             <div className="bg-amber-100 border-2 border-black p-4 shadow-[3px_3px_0px_#000] col-span-2 sm:col-span-1">
               <span className="text-[10px] text-neutral-600 uppercase font-black block">全平台可分配净毛利</span>
               <div className="text-xl font-black text-black mt-1">
-                ¥{(previewResult.net_profit / 100).toFixed(2)}
+                {previewResult.profit_by_currency && Object.keys(previewResult.profit_by_currency).length > 0
+                  ? Object.entries(previewResult.profit_by_currency)
+                      .map(([curr, amt]) => `${getCurrencySymbol(curr)}${(amt / 100).toFixed(2)}`)
+                      .join(' + ')
+                  : `¥${(previewResult.net_profit / 100).toFixed(2)}`}
               </div>
               <span className="text-[9px] text-neutral-700 font-bold block mt-0.5">实收 - 耗材</span>
             </div>
@@ -518,13 +527,13 @@ export default function SettlementEngineTab() {
                           {p.role_description}
                         </td>
                         <td className="px-4 py-3 font-bold font-mono">
-                          ¥{(p.gross_amount / 100).toFixed(2)}
+                          {getCurrencySymbol(p.currency || 'CNY')}{(p.gross_amount / 100).toFixed(2)}
                         </td>
                         <td className="px-4 py-3 font-bold font-mono text-rose-600">
-                          {p.fault_penalty > 0 ? `-¥${(p.fault_penalty / 100).toFixed(2)}` : '¥0.00'}
+                          {p.fault_penalty > 0 ? `-${getCurrencySymbol(p.currency || 'CNY')}${(p.fault_penalty / 100).toFixed(2)}` : `${getCurrencySymbol(p.currency || 'CNY')}0.00`}
                         </td>
                         <td className="px-4 py-3 font-black font-mono text-emerald-800 bg-amber-50 text-sm">
-                          ¥{(p.net_payout / 100).toFixed(2)}
+                          {getCurrencySymbol(p.currency || 'CNY')}{(p.net_payout / 100).toFixed(2)}
                         </td>
                       </tr>
                     );
@@ -585,47 +594,60 @@ export default function SettlementEngineTab() {
                     </tr>
                   </thead>
                   <tbody className="bg-white divide-y border-neutral-200">
-                    {previewResult.details.map((d) => (
-                      <tr key={d.order_id} className="hover:bg-amber-50/50">
-                        <td className="px-3 py-2 font-bold">#{d.order_id}</td>
-                        <td className="px-3 py-2">
-                          <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
-                            {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
-                          </span>
-                        </td>
-                        <td className="px-3 py-2 text-neutral-700">
-                          {d.handler_name ? (
-                            <span>
-                              <strong className="text-black">{d.handler_name}</strong>
-                              <span className="text-[10px] text-neutral-400 block font-mono">
-                                {d.handler_id}
-                              </span>
+                    {previewResult.details.map((d) => {
+                      const sym = getCurrencySymbol(d.currency || 'CNY');
+                      return (
+                        <tr key={d.order_id} className="hover:bg-amber-50/50">
+                          <td className="px-3 py-2 font-bold">#{d.order_id}</td>
+                          <td className="px-3 py-2">
+                            <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
+                              {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
                             </span>
-                          ) : (
-                            d.handler_id || '-'
-                          )}
-                        </td>
-                        <td className="px-3 py-2 text-neutral-700">
-                          {d.developer_name ? (
-                            <span>
-                              <strong className="text-emerald-800">{d.developer_name}</strong>
-                              <span className="text-[10px] text-neutral-400 block font-mono">
-                                {d.developer_id}
+                          </td>
+                          <td className="px-3 py-2 text-neutral-700">
+                            {d.handler_name ? (
+                              <span>
+                                <strong className="text-black">{d.handler_name}</strong>
+                                <span className="text-[10px] text-neutral-400 block font-mono">
+                                  {d.handler_id}
+                                </span>
                               </span>
-                            </span>
-                          ) : (
-                            d.developer_id || '-'
-                          )}
-                        </td>
-                        <td className="px-3 py-2 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 text-blue-700">¥{(d.tech_fee / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 text-purple-700">¥{(d.sales_fee / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 text-amber-700">¥{(d.partner_a_amount / 100).toFixed(2)}</td>
-                        <td className="px-3 py-2 text-amber-700">¥{(d.partner_b_amount / 100).toFixed(2)}</td>
-                      </tr>
-                    ))}
+                            ) : (
+                              d.handler_id || '-'
+                            )}
+                          </td>
+                          <td className="px-3 py-2 text-neutral-700">
+                            {d.developer_name ? (
+                              <span>
+                                <strong className="text-emerald-800">{d.developer_name}</strong>
+                                <span className="text-[10px] text-neutral-400 block font-mono">
+                                  {d.developer_id}
+                                </span>
+                              </span>
+                            ) : (
+                              d.developer_id || '-'
+                            )}
+                          </td>
+                          <td className="px-3 py-2 font-bold font-mono">
+                            {sym}{(d.order_amount / 100).toFixed(2)}
+                          </td>
+                          <td className="px-3 py-2 text-rose-600 font-mono">-{sym}{(d.avg_cost / 100).toFixed(2)}</td>
+                          <td className="px-3 py-2 font-black text-black font-mono">{sym}{(d.net_profit / 100).toFixed(2)}</td>
+                          <td className="px-3 py-2 text-blue-700 font-mono">{sym}{(d.tech_fee / 100).toFixed(2)}</td>
+                          <td className="px-3 py-2 text-purple-700 font-mono">
+                            {d.handler_id ? (
+                              `${sym}${(d.sales_fee / 100).toFixed(2)}`
+                            ) : (
+                              <span className="text-[10px] text-purple-700 bg-purple-50 px-1.5 py-0.5 border border-purple-300 font-bold">
+                                平分甲乙
+                              </span>
+                            )}
+                          </td>
+                          <td className="px-3 py-2 text-amber-700 font-bold font-mono">{sym}{(d.partner_a_amount / 100).toFixed(2)}</td>
+                          <td className="px-3 py-2 text-amber-700 font-bold font-mono">{sym}{(d.partner_b_amount / 100).toFixed(2)}</td>
+                        </tr>
+                      );
+                    })}
                   </tbody>
                 </table>
               </div>

+ 44 - 28
src/components/admin/settlement/SettlementPeriodDetailModal.tsx

@@ -7,6 +7,7 @@ import { settlementService } from '@/lib/services';
 import { X, Receipt, CheckCircle, ExternalLink, Download } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
 import { toast } from 'react-hot-toast';
+import { getCurrencySymbol } from '@/lib/currency';
 
 interface Props {
   isOpen: boolean;
@@ -133,12 +134,14 @@ export default function SettlementPeriodDetailModal({ isOpen, onClose, period }:
                             </span>
                           </td>
                           <td className="px-3 py-2 text-neutral-700 font-sans">{p.role_description}</td>
-                          <td className="px-3 py-2 font-bold">¥{(p.gross_amount / 100).toFixed(2)}</td>
-                          <td className="px-3 py-2 text-rose-600 font-bold">
-                            {p.fault_penalty > 0 ? `-¥${(p.fault_penalty / 100).toFixed(2)}` : '¥0.00'}
+                          <td className="px-3 py-2 font-bold font-mono">
+                            {getCurrencySymbol(p.currency || 'CNY')}{(p.gross_amount / 100).toFixed(2)}
                           </td>
-                          <td className="px-3 py-2 font-black text-emerald-700 bg-amber-50/50">
-                            ¥{(p.net_payout / 100).toFixed(2)}
+                          <td className="px-3 py-2 text-rose-600 font-bold font-mono">
+                            {p.fault_penalty > 0 ? `-${getCurrencySymbol(p.currency || 'CNY')}${(p.fault_penalty / 100).toFixed(2)}` : `${getCurrencySymbol(p.currency || 'CNY')}0.00`}
+                          </td>
+                          <td className="px-3 py-2 font-black text-emerald-700 bg-amber-50/50 font-mono">
+                            {getCurrencySymbol(p.currency || 'CNY')}{(p.net_payout / 100).toFixed(2)}
                           </td>
                         </tr>
                       );
@@ -173,29 +176,42 @@ export default function SettlementPeriodDetailModal({ isOpen, onClose, period }:
                   </tr>
                 </thead>
                 <tbody className="divide-y border-neutral-200">
-                  {details.map((d) => (
-                    <tr key={d.order_id} className="hover:bg-neutral-50">
-                      <td className="px-3 py-1.5 font-bold">#{d.order_id}</td>
-                      <td className="px-3 py-1.5">
-                        <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
-                          {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
-                        </span>
-                      </td>
-                      <td className="px-3 py-1.5 text-neutral-700">
-                        {d.handler_name ? `${d.handler_name} (${d.handler_id})` : (d.handler_id || '-')}
-                      </td>
-                      <td className="px-3 py-1.5 text-neutral-700">
-                        {d.developer_name ? `${d.developer_name} (${d.developer_id})` : (d.developer_id || '-')}
-                      </td>
-                      <td className="px-3 py-1.5 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 text-blue-700">¥{(d.tech_fee / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 text-purple-700">¥{(d.sales_fee / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 text-amber-700">¥{(d.partner_a_amount / 100).toFixed(2)}</td>
-                      <td className="px-3 py-1.5 text-amber-700">¥{(d.partner_b_amount / 100).toFixed(2)}</td>
-                    </tr>
-                  ))}
+                  {details.map((d) => {
+                    const sym = getCurrencySymbol(d.currency || 'CNY');
+                    return (
+                      <tr key={d.order_id} className="hover:bg-neutral-50">
+                        <td className="px-3 py-1.5 font-bold">#{d.order_id}</td>
+                        <td className="px-3 py-1.5">
+                          <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
+                            {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
+                          </span>
+                        </td>
+                        <td className="px-3 py-1.5 text-neutral-700 font-sans">
+                          {d.handler_name ? `${d.handler_name} (${d.handler_id})` : (d.handler_id || '-')}
+                        </td>
+                        <td className="px-3 py-1.5 text-neutral-700 font-sans">
+                          {d.developer_name ? `${d.developer_name} (${d.developer_id})` : (d.developer_id || '-')}
+                        </td>
+                        <td className="px-3 py-1.5 font-bold font-mono">
+                          {sym}{(d.order_amount / 100).toFixed(2)}
+                        </td>
+                        <td className="px-3 py-1.5 text-rose-600 font-mono">-{sym}{(d.avg_cost / 100).toFixed(2)}</td>
+                        <td className="px-3 py-1.5 font-black text-black font-mono">{sym}{(d.net_profit / 100).toFixed(2)}</td>
+                        <td className="px-3 py-1.5 text-blue-700 font-mono">{sym}{(d.tech_fee / 100).toFixed(2)}</td>
+                        <td className="px-3 py-1.5 text-purple-700 font-mono">
+                          {d.handler_id ? (
+                            `${sym}${(d.sales_fee / 100).toFixed(2)}`
+                          ) : (
+                            <span className="text-[10px] text-purple-700 bg-purple-50 px-1.5 py-0.5 border border-purple-200 font-bold">
+                              平分甲乙
+                            </span>
+                          )}
+                        </td>
+                        <td className="px-3 py-1.5 text-amber-700 font-bold font-mono">{sym}{(d.partner_a_amount / 100).toFixed(2)}</td>
+                        <td className="px-3 py-1.5 text-amber-700 font-bold font-mono">{sym}{(d.partner_b_amount / 100).toFixed(2)}</td>
+                      </tr>
+                    );
+                  })}
                 </tbody>
               </table>
             </div>

+ 40 - 0
src/lib/currency.ts

@@ -0,0 +1,40 @@
+// src/lib/currency.ts
+
+export interface CurrencyItem {
+  code: string;
+  symbol: string;
+  name: string;
+}
+
+export const SUPPORTED_CURRENCIES: CurrencyItem[] = [
+  { code: 'CNY', symbol: '¥', name: '人民币 (CNY)' },
+  { code: 'EUR', symbol: '€', name: '欧元 (EUR)' },
+  { code: 'USD', symbol: '$', name: '美元 (USD)' },
+  { code: 'GBP', symbol: '£', name: '英镑 (GBP)' },
+  { code: 'HKD', symbol: 'HK$', name: '港币 (HKD)' },
+];
+
+/**
+ * 获取币种符号,默认人民币 ¥
+ */
+export const getCurrencySymbol = (code?: string): string => {
+  if (!code) return '¥';
+  const c = code.trim().toUpperCase();
+  if (c === 'EUR') return '€';
+  if (c === 'USD') return '$';
+  if (c === 'GBP') return '£';
+  if (c === 'HKD') return 'HK$';
+  if (c === 'JPY') return '¥';
+  if (c === 'CNY' || c === 'RMB') return '¥';
+  return `${c} `;
+};
+
+/**
+ * 格式化分单位金额为货币显示串,如 ¥100.00 / €50.00 / $200.00
+ */
+export const formatMoney = (amountCents?: number | null, currency: string = 'CNY'): string => {
+  if (amountCents === undefined || amountCents === null) return '-';
+  const num = (amountCents / 100).toFixed(2);
+  const sym = getCurrencySymbol(currency);
+  return `${sym}${num}`;
+};

+ 2 - 0
src/lib/services/orderService.ts

@@ -59,6 +59,7 @@ export const orderService = {
     agency_id?: string | null;
     handler_id?: string | null;
     final_amount?: number | null;
+    currency?: string;
     payment_timing?: 'pay_later' | 'paid_now';
     payment_method?: string;
     external_trade_no?: string;
@@ -75,6 +76,7 @@ export const orderService = {
   async registerPayment(payload: {
     order_id: string;
     amount: number; // 分
+    currency?: string;
     payment_method: string;
     external_trade_no?: string;
     voucher_url?: string;

+ 2 - 0
src/types/order.ts

@@ -9,6 +9,8 @@ export interface PaymentRecord {
   channel: string;
   amount: number;
   currency: string;
+  base_amount?: number;
+  base_currency?: string;
   status: string;
   created_at: string;
   external_trade_no?: string;

+ 6 - 0
src/types/settlement.ts

@@ -107,6 +107,7 @@ export interface SettlementPayoutItem {
   gross_amount: number; // 分润金额(分)
   fault_penalty: number; // 过错赔偿抵扣(分)
   net_payout: number; // 实际应支付金额(分)
+  currency?: string; // 币种 (CNY, EUR, USD等)
 }
 
 /**
@@ -121,6 +122,9 @@ export interface SettlementOrderDetail {
   developer_id?: string | null;
   developer_name?: string | null;
   order_amount: number; // 订单实收(分)
+  currency?: string; // 实际交易流水币种代码 (如 'EUR', 'CNY')
+  original_amount?: number; // 原始标价/支付金额(分)
+  original_currency?: string; // 原始币种代码 (如 'EUR', 'USD', 'CNY')
   avg_cost: number; // 单均公共耗材(分)
   net_profit: number; // 单笔净利(分)
   tech_fee: number; // 20% 技术版权
@@ -185,6 +189,8 @@ export interface SettlementPreviewResponse {
   total_cost: number;
   avg_cost: number;
   net_profit: number;
+  revenue_by_currency?: Record<string, number>;
+  profit_by_currency?: Record<string, number>;
   payout_summary: SettlementPayoutItem[];
   cost_breakdown: Record<string, number>;
   details: SettlementOrderDetail[];