namespace JiDangJia.Contracts; // 同一份品类定义驱动发布表单、筛选与服务器校验。 public sealed record SupplyField(string Key,string Label,bool Required=false,string Kind="text",Dictionary? Choices=null,string? Hint=null); public static class CommunityCatalog { public const string DefaultNotice="⚠️风险告知:社群仅作为行业交流信息发布平台,我司不参与、不介入各方之间的交易磋商、资金往来,不收取交易佣金。平台无法核验所有发布信息的真实性,交易前请自行核实货品、资质,线下查验,谨慎交易,一切交易风险由交易双方自行承担。"; public static Dictionary Intents=>new(){["SALE"]="出货",["BUY"]="收货",["SOURCING"]="配货代购",["OTHER"]="其他"}; public static Dictionary CreditLevels=>new(){["GOOD"]="良好",["EXCELLENT"]="优秀",["FLAGSHIP"]="旗舰",["RISK"]="风险",["HIGH_RISK"]="高风险"}; public static Dictionary Categories=>new(){["BULLION"]="投资性贵金属",["METAL_JEWELRY"]="贵金属首饰",["SCRAP"]="贵金属旧料",["LUXURY"]="奢侈品",["GEM"]="珠宝玉石",["CAR"]="汽车",["PROPERTY"]="房产",["OTHER"]="其他"}; public static Dictionary Metals=>new(){["GOLD"]="黄金",["SILVER"]="白银",["PLATINUM"]="铂金",["OTHER"]="其他"}; public static Dictionary Conditions=>new(){["NEW"]="全新",["IDLE"]="闲置",["90"]="九成新",["80"]="八成新",["70"]="七成新",["60"]="六成新",["50"]="五成新",["BROKEN"]="破损"}; public static Dictionary Prices=>new(){["FIXED"]="固定价",["RTG_BUY"]="融通金回收价 +/-",["RTG_SELL"]="融通金销售价 +/-",["SGE"]="上交所价格 +/-"}; public static Dictionary Deliveries=>new(){["COD"]="到付",["FREE"]="包邮",["MEET"]="面交"}; public static Dictionary CategoriesFor(string intent)=>intent=="OTHER"?new(){["OTHER"]="其他"}:intent=="SOURCING"?new(){["METAL_JEWELRY"]="贵金属首饰",["OTHER"]="其他"}:Categories; public static Dictionary Subcategories(string category,string intent)=>intent is "SOURCING" or "OTHER"?new():Subcategories(category); public static bool DefaultIcon(SupplyCard? supply,ServiceCard? service=null)=>supply is {Intent:"SOURCING",Category:"METAL_JEWELRY"}||service is {Category:not "OTHER"}; public static int PhotoLimit(string category,string intent)=>intent=="OTHER"?9:intent=="SOURCING"?(category=="METAL_JEWELRY"?0:3):PhotoLimit(category); public static Dictionary Subcategories(string category)=>category switch { "BULLION" or "METAL_JEWELRY" or "SCRAP"=>Metals, "LUXURY"=>new(){["BAG"]="包",["WATCH"]="表",["CLOTHING"]="鞋服",["ACCESSORY"]="配饰",["OTHER"]="其他"}, "GEM"=>new(){["DIAMOND"]="钻石",["JADE"]="玉石",["OTHER"]="其他"}, "CAR"=>new(){["STANDARD"]="标准",["NONSTANDARD"]="非标"}, _=>new() }; public static int PhotoLimit(string category)=>category switch{"BULLION" or "METAL_JEWELRY"=>2,"LUXURY"=>6,"GEM"=>4,"CAR"=>3,_=>6}; public static List Fields(string category,string intent) { if(intent=="OTHER")return []; if(intent=="SOURCING")return category=="METAL_JEWELRY"? [new("supportsExchange","是否支持黄料兑换",true,"choice",new(){["YES"]="是",["NO"]="否"}),new("exchangeRatio","兑换比例",Hint:"如 1:0.998,支持黄料兑换时必填"),new("shippingFrom","发货地",true)]:[new("shippingFrom","发货地",true)]; var yesNo=new Dictionary{["NO"]="无",["YES"]="有"}; var fields=category switch { "BULLION"=>new List{new("productType","品类",Hint:"金条、银条、金币等"),new("source","源头类型",true,"choice",new(){["NONE"]=intent=="BUY"?"无要求":"无品牌",["BANK"]="银行",["MEMBER"]="会员单位",["RTG"]="融通金",["CUSTOM"]="自定义"}),new("sourceCustom","自定义源头"),new("purity","纯度",Hint:"如 AU9999"),new("weight","克重(克)",true,"number"),new("minimumWeight","多少克起拿","SALE"==intent,"number"),new("priceMode","价格方式",true,"choice",Prices),new("price","价格 / 加减金额",true,"signed",Hint:"固定价填单价;加减价填如 +2 或 -3"),new("invoice","发票",true,"choice",new(){["NO"]="无",["YES"]="有",["AVAILABLE"]="可开"})}, "METAL_JEWELRY"=>new(){new("brand","品牌"),new("purity","纯度"),new("weight","克重(克)",false,"number"),new("modelSize","型号尺寸"),new("price","价格(元)",false,"number"),new("condition","成色",false,"choice",Conditions),new("accessories","附件")}, "SCRAP"=>new(){new("purity","纯度"),new("weight","克重(克)",false,"number")}, "LUXURY"=>new(){new("brand","品牌"),new("series","系列"),new("model","型号"),new("size","尺寸"),new("remark","备注"),new("price","价格(元)",false,"number"),new("condition","成色",false,"choice",Conditions)}, "GEM"=>new(){new("brand","品牌"),new("size","尺寸 / 号数",Hint:"号数或长 × 宽 × 高"),new("carat","克拉",false,"number"),new("weight","整体克重(克)",false,"number"),new("mainMaterial","主体材质"),new("accessoryMaterial","配件材质"),new("certificate","证书",false,"choice",yesNo),new("issuer","发证单位"),new("price","价格(元)",false,"number"),new("condition","成色",false,"choice",Conditions)}, "CAR"=>new(){new("brand","品牌"),new("model","型号"),new("registrationDate","上牌日期",false,"date"),new("mileage","公里数",false,"number"),new("registeredCity","户籍地"),new("price","价格(元)",false,"number"),new("documents","证件情况",false,"choice",new(){["FULL"]="全套",["PARTIAL"]="非全"}),new("remark","备注"),new("condition","成色",false,"choice",Conditions)}, "PROPERTY"=>new(){new("area","面积(平方米)",false,"number"),new("propertyType","房产类型",false,"choice",new(){["OLD"]="老旧",["ELEVATOR"]="电梯房",["HOUSE"]="洋房",["VILLA"]="别墅",["NONRESIDENTIAL"]="非民宅",["OTHER"]="其他"}),new("layout","户型"),new("price","价格(元)",false,"number"),new("remark","备注")}, _=>new(){new("brand","品牌"),new("price","价格(元)",false,"number"),new("condition","成色",false,"choice",Conditions),new("remark","备注")} }; fields.Add(new("shippingFrom",category=="PROPERTY"?"房产地址":"发货地",true));return fields; } public static string Name(Dictionary values,string key)=>values.GetValueOrDefault(key,key); public static string PriceLabel(SupplyCard supply) { var f=supply.Fields;var value=f.GetValueOrDefault("price","");if(value.Length==0)return "价格面议"; var mode=f.GetValueOrDefault("priceMode","FIXED");if(mode=="FIXED")return "¥"+value+(supply.Category=="BULLION"?" / 克":""); return (mode=="RTG_BUY"?"融回":mode=="RTG_SELL"?"融销":"上交")+(value.StartsWith('-')||value.StartsWith('+')?value:"+"+value)+" 元/克"; } }