|
@@ -12,6 +12,7 @@ import AdminUserSelect from '@/components/common/AdminUserSelect';
|
|
|
import { ImageUploadField } from '@/components/common/ImageUploadField';
|
|
import { ImageUploadField } from '@/components/common/ImageUploadField';
|
|
|
import { SchemaProperty, VasAgency } from '@/types';
|
|
import { SchemaProperty, VasAgency } from '@/types';
|
|
|
import { toast } from 'react-hot-toast';
|
|
import { toast } from 'react-hot-toast';
|
|
|
|
|
+import { SUPPORTED_CURRENCIES, getCurrencySymbol } from '@/lib/currency';
|
|
|
|
|
|
|
|
export default function AdminCreateOrderPage() {
|
|
export default function AdminCreateOrderPage() {
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -22,10 +23,11 @@ export default function AdminCreateOrderPage() {
|
|
|
|
|
|
|
|
// 2. 渠道与分润归属状态
|
|
// 2. 渠道与分润归属状态
|
|
|
const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
|
|
const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
|
|
|
|
|
+ const [handlerId, setHandlerId] = useState<string>('');
|
|
|
const [agencies, setAgencies] = useState<VasAgency[]>([]);
|
|
const [agencies, setAgencies] = useState<VasAgency[]>([]);
|
|
|
const [selectedAgencyId, setSelectedAgencyId] = useState<string>('');
|
|
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 收款时机与收款登记状态
|
|
// 2.5 收款时机与收款登记状态
|
|
|
const [paymentTiming, setPaymentTiming] = useState<'pay_later' | 'paid_now'>('pay_later');
|
|
const [paymentTiming, setPaymentTiming] = useState<'pay_later' | 'paid_now'>('pay_later');
|
|
@@ -79,7 +81,10 @@ export default function AdminCreateOrderPage() {
|
|
|
return;
|
|
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) {
|
|
if (selectedProduct.price_amount !== undefined) {
|
|
|
setCustomPrice((selectedProduct.price_amount / 100).toFixed(2));
|
|
setCustomPrice((selectedProduct.price_amount / 100).toFixed(2));
|
|
|
} else if (selectedProduct.base_price !== undefined) {
|
|
} else if (selectedProduct.base_price !== undefined) {
|
|
@@ -160,8 +165,9 @@ export default function AdminCreateOrderPage() {
|
|
|
return toast.error('请选择合作中介机构');
|
|
return toast.error('请选择合作中介机构');
|
|
|
}
|
|
}
|
|
|
if (selectedAgency && finalAmountCents !== undefined && finalAmountCents < selectedAgency.min_floor_price) {
|
|
if (selectedAgency && finalAmountCents !== undefined && finalAmountCents < selectedAgency.min_floor_price) {
|
|
|
|
|
+ const sym = getCurrencySymbol(currency);
|
|
|
return toast.error(
|
|
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,
|
|
agency_id: channelType === 'agency' ? selectedAgencyId : undefined,
|
|
|
handler_id: channelType === 'website' ? undefined : handlerId.trim(),
|
|
handler_id: channelType === 'website' ? undefined : handlerId.trim(),
|
|
|
final_amount: finalAmountCents,
|
|
final_amount: finalAmountCents,
|
|
|
|
|
+ currency: currency,
|
|
|
payment_timing: paymentTiming,
|
|
payment_timing: paymentTiming,
|
|
|
payment_method: paymentTiming === 'paid_now' ? paymentMethod : undefined,
|
|
payment_method: paymentTiming === 'paid_now' ? paymentMethod : undefined,
|
|
|
external_trade_no: paymentTiming === 'paid_now' ? (externalTradeNo.trim() || undefined) : 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 className="pt-3 border-t-2 border-dashed border-neutral-300 grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
|
<div>
|
|
<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">
|
|
<div className="relative">
|
|
|
<span className="absolute left-3 top-2.5 text-xs font-bold text-black pointer-events-none">
|
|
<span className="absolute left-3 top-2.5 text-xs font-bold text-black pointer-events-none">
|
|
|
- ¥
|
|
|
|
|
|
|
+ {getCurrencySymbol(currency)}
|
|
|
</span>
|
|
</span>
|
|
|
<input
|
|
<input
|
|
|
type="number"
|
|
type="number"
|
|
@@ -471,12 +494,12 @@ export default function AdminCreateOrderPage() {
|
|
|
value={customPrice}
|
|
value={customPrice}
|
|
|
onChange={(e) => setCustomPrice(e.target.value)}
|
|
onChange={(e) => setCustomPrice(e.target.value)}
|
|
|
placeholder="商品指导价"
|
|
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>
|
|
|
<div className="text-[10px] text-neutral-500 font-mono mt-1 flex items-center justify-between">
|
|
<div className="text-[10px] text-neutral-500 font-mono mt-1 flex items-center justify-between">
|
|
|
<span>
|
|
<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>
|
|
</span>
|
|
|
{customPrice && !isNaN(Number(customPrice)) && (
|
|
{customPrice && !isNaN(Number(customPrice)) && (
|
|
|
<span className={`font-bold ${
|
|
<span className={`font-bold ${
|
|
@@ -486,7 +509,7 @@ export default function AdminCreateOrderPage() {
|
|
|
? 'text-emerald-700'
|
|
? 'text-emerald-700'
|
|
|
: 'text-neutral-500'
|
|
: '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>
|
|
</span>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|