ui: checkout pays seller by seller only (drop unified checkout), per-seller auto-convert

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ZHU MINCHAOandClaude Sonnet 5.5 committed 2026-11-04 11:25:06 +08:00
1 parent 2d40df81bd
commit 00182c4ce6
4 files changed
+48 -94

No files matched your search

+2 -2
View File
@@ -8,8 +8,8 @@
- "Web3 黑市"改名"Web3 商店"(页签、升级项、提示;黑市声望是游戏派系,名字不变)。
- 点左栏卖家后,右栏最前面是商家信息:名称与地址、成交数、好评、到货天数、收的币、是否接受提前放款;平台是"立即到货"和收的币。
- 购物车:货架上的"购买"改成加入购物车(同一件再点数量 +1,封顶库存);商店页右下角悬浮购物车按钮("购物车 N",点开进结算页,结算后清零;读档清空)。
- 结算页两栏:左边购物车详情(按商家分组,每行 -、数量、+、删除,接受提前放款的商家可选托管 / 提前放款,合计);右边付款:统一结算(选钱包里的一种币,一次合约签名,商家不收这种币的部分按 8% 滑点自动换币)或逐家付款(每家选它收的币、生成账单、在钱包里转账)。
- 游戏内验证:平台加两件、再加一家商家的货,购物车 3 件;结算页两栏显示正常,选 CRA 时提示"其中 62 信用点需换币";统一结算签名一次后日志"自动换币:66.96 CRA → 0.6212 PSC",两家的货都成交,购物车清零。没验证:逐家付款(生成账单)、部分失败的消息、英文界面、卖货页的付款面板。
- 结算页两栏:左边购物车详情(按商家分组,每行 -、数量、+、删除,接受提前放款的商家可选托管 / 提前放款,合计);右边付款:每家商家的收款地址不同,所以只做逐家付款——每家选它收的币、生成账单、在钱包里转账;钱包里别的币够付时,每家还有自动换币(多付 8% 滑点、签名一次付清这一家)。统一结算已去掉。
- 游戏内验证:平台加两件、再加一家商家的货,购物车 3 件;结算页两栏显示正常,每家商家各一块付款选项(收的币、需付金额、钱包余额、生成账单、够付时的自动换币),点平台的"生成账单"得到平台收款地址和金额。自动换币在改成逐家之前验证过(66.96 CRA → 0.6212 PSC 后成交);改后的逐家自动换币和账单付清没有再走一遍,也没验证英文界面。
- 黑市买货页重排(`ui-trial` 分支):左栏是卖家列表(平台和各商家,选中行反色,商家写类型和缩写地址),右栏是 3 列货架;币种和数量不再摆在货架上方。点"购买"后右栏换成付款面板:数量(库存内 ×1 / ×5 / ×10)、付款方式(商家接受提前放款时才有)、合计、付款币种(该商家收的币)和"生成账单";下面是自动换币——钱包里别的币(够付)按 8% 滑点换成商家收的币,一次合约签名完成(`BmAutoSwapSlip`);没有够用的币时写明。上架费、改价费、一键上架同样在付款面板里选币(平台收 PSC、CRT、CRA)。各类商家收的币:硬件技术类 PSC / CRT,违禁和个人卖家 CRT / 匿名币,农业养殖水务酿酒 PSC / CRA(`Merchants.Accepts`,界面里限制,域层下单不限)。游戏内验证:平台买一件商品,CRC 自动换币 224.64 CRC → 2.0842 PSC(208 信用点等值)后成交,货进储藏区;直接生成账单显示收款地址和金额;商家货架切换和付款面板正常。没有验证:卖货页改价、一键上架的付款面板、英文界面、数量选择(库存只有 1 件)。
- 钱包页按钮:操作键放到数据格右边的纸面上(和顶栏页签同样的黑色触控键,不再压在污点字段上);选中行只反色数据格;状态"已连接"靠右。
- 新手期调整:低端显卡算力提高——RTX 60 1.0 → 1.8 H、RX 70 0.8 → 1.4 H(价格、耗电不变)。开局送的一矿架一卡,第 1–7 天日均净收入 14 → 33(电网电价),第 15–30 天 6 → 18;再买满 4 张同款卡的矿架 33 → 82/天,每加一张约 10 天回本(原来 24 天)。每张卡每千瓦时的产出仍低于中高端,一个矿架只有 4 个槽位,满槽 4×RTX60 约 7 H,4×RTX70 是 20 H,中后期自然要换更高档次。ops `research/starter` 有各档位的逐段结果。
@@ -266,7 +266,7 @@ black.kind.Contraband.3,Contraband (high)
black.kind.Tech,High-tech (markup)
nightlog.bm.ready,"Black market: {0} arrived; a courier will come by once you open."
item.web3guide.name,Web3 Handbook
item.web3guide.desc,"Bank: depositing turns credits into CRC in your Poinbase account; withdrawing turns CRC back into credits and goes through compliance screening, which looks at the Poinbase account's taint. Trading: buys are paid in the quote coin, sells in the traded coin. Mixer: pick a coin, amount and rounds; each round takes a fee and lowers taint, rounds equal days of waiting, and the coins come back to the same address; the more you deposit, the worse the cleaning. Hardware wallets: on-chain coins sit in PLEDGER hardware wallets, each with its own balances and taint; open and connect them on the terminal's Wallets page. The Web3 page's trading, black market and mixer use the connected wallet, and coin-paying customers and mining rewards go into it too. Payments (black market, mixer, Ponero desk, listing fees) start as an invoice on the terminal; type the payee address on the wallet and hold ✓ to sign. The last two characters of an address are a checksum, so a one-character typo is usually caught; once in a while it happens to be valid and the coins go to an address nobody uses. DEX swaps also need a signature on the wallet. RatDigg miners (M1 / M2 / M3) are standalone machines with far more hash than a card and a lower power draw per hash; they need a battery, take modules and use no rig slots. Only the black market's miner dealers sell them, gated by black-market standing (M1 40, M2 60, M3 80), sometimes second-hand. When one burns out, repair it by putting electronic components in its repair slot in order; it comes back 20 health lower. Somewhere between day 50 and day 90 a "miner era" arrives, announced in the paper a few days earlier: the big farms halve their power costs, network hash climbs, GPU miners are diluted and low-end cards barely earn, while miners still do fine. Perps: the Perps tab on Poinbase uses your account CRC as margin, up to 5× on PSC and 3× on SPARK, one position per product, never long and short at once. Fills are worse than the quote (more so for bigger orders, like the spot pool) and opening and closing both cost a fee. Liquidation is checked only overnight against the day's average price: equity under 10% of notional wipes the margin. There is also a nightly funding payment; when the price is above its 7-day average, longs pay shorts. If a liquidation loses more than the margin, the insurance fund covers the gap; when it runs dry (a SPARK collapse can do that) winning positions are auto-deleveraged and give up half their profit; anything beyond that becomes your debt. Debt grows 2% a day, is repaid first from CRC in the account every night, blocks new positions and cash-outs, and after seven days items in your shop are seized to cover it; whatever is still short is written off and the perp account is banned for 30 days. Poinbase is a custodial account and can withdraw straight to the connected wallet; depositing from a wallet means sending to Poinbase's deposit address, which takes only CRC and PSC. More hardware wallets are sold by Dr. Jackson; drag one onto the trading terminal to add it, up to 5. The black market has cheaper ones. A wallet you no longer want can be destroyed on the Wallets page once its coins are moved out. Transfers pay a fee: slow, normal or fast, and gas prices rise and fall over roughly a week; when the network is congested fees rise and slow transactions may be dropped from the mempool. Check the full address before sending. Staking: CRA staked in the Revolution pool earns a daily rate that compounds into the stake; withdrawing means requesting first and waiting four days, with no interest while waiting and no way to take it early. The pool pays from a subsidy fund; when it runs low the rate is cut and word of big holders pulling out may spread. Treat that as a warning: once it collapses CRA is worthless within three days and four days of unlocking is too slow. The balance token SPARK can be minted and burned against CRA at the going price (with a fee); its price swings hard and crashes with the collapse. Staking, minting and burning are contract calls and need a signature on the wallet. Black market: coin only, no CRC, 30% above normal channels, with extra markup on high-tech goods and GPUs; the coin you pay leaves its share of taint with the seller and the goods carry no stolen tag; GPUs may be fake, inspect them yourself. Orders are cheaper than spot but take days and may be intercepted; merchants sell by type at their own price factor, 5+ items get 5% off and 10+ get 10% off, and a bulk merchant appears at random with the lowest prices but six days of waiting; escrow costs 5%, is released on delivery and refunded if the seller runs; advance release takes another 10% off, but a scammer keeps the money and only sellers with 30+ trades accept; the platform itself can rug, be taken over by enforcement, or a seller can be arrested, after which your orders get traced and crime logged; forum rumors can be warnings. An intercepted parcel sometLine truncated
item.web3guide.desc,"Bank: depositing turns credits into CRC in your Poinbase account; withdrawing turns CRC back into credits and goes through compliance screening, which looks at the Poinbase account's taint. Trading: buys are paid in the quote coin, sells in the traded coin. Mixer: pick a coin, amount and rounds; each round takes a fee and lowers taint, rounds equal days of waiting, and the coins come back to the same address; the more you deposit, the worse the cleaning. Hardware wallets: on-chain coins sit in PLEDGER hardware wallets, each with its own balances and taint; open and connect them on the terminal's Wallets page. The Web3 page's trading, black market and mixer use the connected wallet, and coin-paying customers and mining rewards go into it too. Payments (black market, mixer, Ponero desk, listing fees) start as an invoice on the terminal; type the payee address on the wallet and hold ✓ to sign. The last two characters of an address are a checksum, so a one-character typo is usually caught; once in a while it happens to be valid and the coins go to an address nobody uses. DEX swaps also need a signature on the wallet. RatDigg miners (M1 / M2 / M3) are standalone machines with far more hash than a card and a lower power draw per hash; they need a battery, take modules and use no rig slots. Only the black market's miner dealers sell them, gated by black-market standing (M1 40, M2 60, M3 80), sometimes second-hand. When one burns out, repair it by putting electronic components in its repair slot in order; it comes back 20 health lower. Somewhere between day 50 and day 90 a "miner era" arrives, announced in the paper a few days earlier: the big farms halve their power costs, network hash climbs, GPU miners are diluted and low-end cards barely earn, while miners still do fine. Perps: the Perps tab on Poinbase uses your account CRC as margin, up to 5× on PSC and 3× on SPARK, one position per product, never long and short at once. Fills are worse than the quote (more so for bigger orders, like the spot pool) and opening and closing both cost a fee. Liquidation is checked only overnight against the day's average price: equity under 10% of notional wipes the margin. There is also a nightly funding payment; when the price is above its 7-day average, longs pay shorts. If a liquidation loses more than the margin, the insurance fund covers the gap; when it runs dry (a SPARK collapse can do that) winning positions are auto-deleveraged and give up half their profit; anything beyond that becomes your debt. Debt grows 2% a day, is repaid first from CRC in the account every night, blocks new positions and cash-outs, and after seven days items in your shop are seized to cover it; whatever is still short is written off and the perp account is banned for 30 days. Poinbase is a custodial account and can withdraw straight to the connected wallet; depositing from a wallet means sending to Poinbase's deposit address, which takes only CRC and PSC. More hardware wallets are sold by Dr. Jackson; drag one onto the trading terminal to add it, up to 5. The black market has cheaper ones. A wallet you no longer want can be destroyed on the Wallets page once its coins are moved out. Transfers pay a fee: slow, normal or fast, and gas prices rise and fall over roughly a week; when the network is congested fees rise and slow transactions may be dropped from the mempool. Check the full address before sending. Staking: CRA staked in the Revolution pool earns a daily rate that compounds into the stake; withdrawing means requesting first and waiting four days, with no interest while waiting and no way to take it early. The pool pays from a subsidy fund; when it runs low the rate is cut and word of big holders pulling out may spread. Treat that as a warning: once it collapses CRA is worthless within three days and four days of unlocking is too slow. The balance token SPARK can be minted and burned against CRA at the going price (with a fee); its price swings hard and crashes with the collapse. Staking, minting and burning are contract calls and need a signature on the wallet. Black market: coin only, no CRC, 30% above normal channels, with extra markup on high-tech goods and GPUs; the coin you pay leaves its share of taint with the seller and the goods carry no stolen tag; GPUs may be fake, inspect them yourself. Orders are cheaper than spot but take days and may be intercepted; merchants sell by type at their own price factor, 5+ items get 5% off and 10+ get 10% off, and a bulk merchant appears at random with the lowest prices but six days of waiting; escrow costs 5%, is released on delivery and refunded if the seller runs; advance release takes another 10% off, but a scammer keeps the money and only sellers with 30+ trades accept; the platform itself can rug, be taken over by enforcement, or a seller can be arrested, after which your orders get traced and crime logged; forum rumors can be warnings. An intercepted parcel sometLine truncated
courier.odd1,...Package is here.
courier.odd2,"(His hand stays in his pocket.) Sign here."
courier.sign,Sign
@@ -800,17 +800,9 @@ cart.fab,Cart {0}
cart.h,Cart
cart.empty,The cart is empty.
cart.added,Added to cart: {0}
cart.all,Pay all at once
cart.each,Pay per seller
cart.back,Back to shop
cart.nocoin,No usable coin in the wallet.
bpay.coin2,Pay with (coins in the wallet)
cart.swapped,"{0} to convert (includes {1}% slippage)"
cart.pay,Pay all (one signature)
cart.done,"Paid for {0} items."
cart.partial,"Paid for {0} items; {1} failed (stock or balance)."
cart.short,"{0}: not enough coin to convert; not paid."
cart.sum,"Shop cart {0} items, pay {2} {1} (with auto-convert)"
black.info.accepts,Takes: {0}
black.info.advance.yes,advance release accepted
black.info.advance.no,no advance release
@@ -265,7 +265,7 @@ black.kind.Contraband.3,违禁品(高)
black.kind.Tech,高科技物品(加价)
nightlog.bm.ready,"黑市:{0} 到货,开店后会有快递员上门。"
item.web3guide.name,Web3 手册
item.web3guide.desc,"银行:存入把信用点换成 Poinbase 账户里的 CRC;提取把 CRC 换回信用点,要过合规审查,审查看 Poinbase 账户的污点。交易:买入按计价币的数量支付,卖出按所交易币的数量卖出。混币器:选币种、填数量和轮数,每轮扣手续费并降低污点,轮数即等待天数,到期提回同一个地址;存入越多,清洗越差。硬件钱包:链上的币放在 PLEDGER 硬件钱包里,每个钱包的余额和污点各算各的;在终端的钱包页打开、连接。Web3 页的交易、黑市、混币器用已连接的钱包,用币付款的顾客和挖矿收益也进它。付款(黑市、混币器、Ponero 兑换处、上架费)先在终端开账单,再在钱包里手输收款地址、按住 ✓ 签名;地址末尾两位是校验位,输错一位多半会被拦下,偶尔碰巧合法,币就转进了没人用的地址。DEX 兑换也要在钱包上签名。Poinbase 是托管账户,可以直接提到已连接的钱包;从钱包充值要转到 Poinbase 的充值地址,只收 CRC 和 PSC。更多硬件钱包向杰克逊博士购买,拖到交易终端上添加,最多 5 个;黑市上也有更便宜的。不要的钱包可以在钱包页销毁,要先把币转走。转账要付手续费,分慢、普通、快三档,gas 价格大约一周一个起落;网络拥堵时手续费变贵,慢档可能被挤出内存池。转账前核对完整地址。质押:把 CRA 质押进革命军质押池每天有日息,利息并入本金;取出要先申请,等四天才到账,等待期间没有利息,也不能提前拿。质押池靠补贴池付息,补贴池见底会降息,有时还会传出大户撤出的消息,那是预兆:一旦崩盘,三天内 CRA 就一文不值,四天的解锁期来不及。平衡代币 SPARK 可以和 CRA 按价格互相铸销(收手续费),价格波动很大,崩盘时会跟着暴跌。质押、铸销都是合约调用,要在钱包上签名。RatDigg 矿机(M1 / M2 / M3)是独立的机器,算力比显卡大得多、耗电更省,要放电池才挖,可以放模块,不占矿架槽位;只在黑市的矿机商那里有,要黑市声望(M1 40、M2 60、M3 80),偶尔有二手的。暴毙后要往修理槽里放电子元件按顺序修好,修好健康少 20。第 50 到 90 天之间会有一次"矿机时代",提前几天上报纸预告,之后大矿场的耗电成本砍半,全网算力涨上去,显卡矿工的收益被摊薄,低档显卡几乎不赚钱,矿机还行。永续合约:Poinbase 的"永续"页,用账户里的 CRC 当保证金,PSC 最高 5 倍、SPARK 最高 3 倍,一个品种只有一个仓位,不能同时多空。成交价比现价差一截(单越大差得越多,和现货池一样),开平仓还收手续费。强平只在夜里按当天均价检查,权益不到名义价值的 10% 就被强平,保证金没了;每晚还有资金费,价格比近 7 天均价高时多头付给空头。强平后亏光保证金还不够的缺口,先由保险基金垫,基金见底(SPARK 崩盘这类大行情会抽干它)后盈利的仓位会被自动减仓、少拿一半盈利,再不够就记成你的欠款:欠款每天涨 2%,账户里的 CRC 每晚先拿去还,没还清不能开仓、不能出金,七天不还就没收店里的物品抵债,抵不够的核销并拉黑永续账户 30 天。黑市:只收币,不收 CRC,价格比正常渠道贵 30%,高科技物品和显卡另有加价;付出去的币带着按比例的污点留在卖家那边,货不带赃物标签;显卡不保证真假,自己鉴定。订单比现货便宜,要等几天,路上可能被截获;商家按类型卖货,价格系数各不相同,一次订 5 件以上 95 折、10 件以上 9 折,大宗商家随机出现,价格最低但要等六天;托管多付 5% 托管费,收货后放款,卖家跑路时退款;提前放款再打九折,卖家若是骗子钱就没了,只有成交 30 单以上的卖家接受;平台自己也可能跑路,也可能被执法接管,或者卖家落网,之后你的订单会被追查、记罪证;论坛上的传闻可以当预兆。被截获的包裹有时会变成执法人员上门:签收当场记罪证并查封,拒签只损失货款。出售:在黑市的卖货页把储藏区里的违禁品、高科技物品和显卡上架,标价是参考价的 0.6 到 1.8 倍。倍率越高成交越慢(0.9 以下约一天,1.0 约两天,1.8 约十四天),货款带污点的可能性和比例也越高,近 7 天出售的量越大,污点越重;同时最多上架 10 件,上架收 5% 上架费,上架后可以改价(收 2% 改价费,标价按参考价重算,成交的快慢跟着新倍率走),成交扣 8% 抽成,货款托管 3 天后进钱包;卖假卡可能被买家看穿而退货,拉低好评;平台跑路时上架的货和未放款的货款都没了Line truncated
item.web3guide.desc,"银行:存入把信用点换成 Poinbase 账户里的 CRC;提取把 CRC 换回信用点,要过合规审查,审查看 Poinbase 账户的污点。交易:买入按计价币的数量支付,卖出按所交易币的数量卖出。混币器:选币种、填数量和轮数,每轮扣手续费并降低污点,轮数即等待天数,到期提回同一个地址;存入越多,清洗越差。硬件钱包:链上的币放在 PLEDGER 硬件钱包里,每个钱包的余额和污点各算各的;在终端的钱包页打开、连接。Web3 页的交易、黑市、混币器用已连接的钱包,用币付款的顾客和挖矿收益也进它。付款(黑市、混币器、Ponero 兑换处、上架费)先在终端开账单,再在钱包里手输收款地址、按住 ✓ 签名;地址末尾两位是校验位,输错一位多半会被拦下,偶尔碰巧合法,币就转进了没人用的地址。DEX 兑换也要在钱包上签名。Poinbase 是托管账户,可以直接提到已连接的钱包;从钱包充值要转到 Poinbase 的充值地址,只收 CRC 和 PSC。更多硬件钱包向杰克逊博士购买,拖到交易终端上添加,最多 5 个;黑市上也有更便宜的。不要的钱包可以在钱包页销毁,要先把币转走。转账要付手续费,分慢、普通、快三档,gas 价格大约一周一个起落;网络拥堵时手续费变贵,慢档可能被挤出内存池。转账前核对完整地址。质押:把 CRA 质押进革命军质押池每天有日息,利息并入本金;取出要先申请,等四天才到账,等待期间没有利息,也不能提前拿。质押池靠补贴池付息,补贴池见底会降息,有时还会传出大户撤出的消息,那是预兆:一旦崩盘,三天内 CRA 就一文不值,四天的解锁期来不及。平衡代币 SPARK 可以和 CRA 按价格互相铸销(收手续费),价格波动很大,崩盘时会跟着暴跌。质押、铸销都是合约调用,要在钱包上签名。RatDigg 矿机(M1 / M2 / M3)是独立的机器,算力比显卡大得多、耗电更省,要放电池才挖,可以放模块,不占矿架槽位;只在黑市的矿机商那里有,要黑市声望(M1 40、M2 60、M3 80),偶尔有二手的。暴毙后要往修理槽里放电子元件按顺序修好,修好健康少 20。第 50 到 90 天之间会有一次"矿机时代",提前几天上报纸预告,之后大矿场的耗电成本砍半,全网算力涨上去,显卡矿工的收益被摊薄,低档显卡几乎不赚钱,矿机还行。永续合约:Poinbase 的"永续"页,用账户里的 CRC 当保证金,PSC 最高 5 倍、SPARK 最高 3 倍,一个品种只有一个仓位,不能同时多空。成交价比现价差一截(单越大差得越多,和现货池一样),开平仓还收手续费。强平只在夜里按当天均价检查,权益不到名义价值的 10% 就被强平,保证金没了;每晚还有资金费,价格比近 7 天均价高时多头付给空头。强平后亏光保证金还不够的缺口,先由保险基金垫,基金见底(SPARK 崩盘这类大行情会抽干它)后盈利的仓位会被自动减仓、少拿一半盈利,再不够就记成你的欠款:欠款每天涨 2%,账户里的 CRC 每晚先拿去还,没还清不能开仓、不能出金,七天不还就没收店里的物品抵债,抵不够的核销并拉黑永续账户 30 天。黑市:只收币,不收 CRC,价格比正常渠道贵 30%,高科技物品和显卡另有加价;付出去的币带着按比例的污点留在卖家那边,货不带赃物标签;显卡不保证真假,自己鉴定。订单比现货便宜,要等几天,路上可能被截获;商家按类型卖货,价格系数各不相同,一次订 5 件以上 95 折、10 件以上 9 折,大宗商家随机出现,价格最低但要等六天;托管多付 5% 托管费,收货后放款,卖家跑路时退款;提前放款再打九折,卖家若是骗子钱就没了,只有成交 30 单以上的卖家接受;平台自己也可能跑路,也可能被执法接管,或者卖家落网,之后你的订单会被追查、记罪证;论坛上的传闻可以当预兆。被截获的包裹有时会变成执法人员上门:签收当场记罪证并查封,拒签只损失货款。出售:在黑市的卖货页把储藏区里的违禁品、高科技物品和显卡上架,标价是参考价的 0.6 到 1.8 倍。倍率越高成交越慢(0.9 以下约一天,1.0 约两天,1.8 约十四天),货款带污点的可能性和比例也越高,近 7 天出售的量越大,污点越重;同时最多上架 10 件,上架收 5% 上架费,上架后可以改价(收 2% 改价费,标价按参考价重算,成交的快慢跟着新倍率走),成交扣 8% 抽成,货款托管 3 天后进钱包;卖假卡可能被买家看穿而退货,拉低好评;平台跑路时上架的货和未放款的货款都没了Line truncated
courier.odd1,……东西到了。
courier.odd2,"(他的手一直放在口袋里)在这儿签个字。"
courier.sign,签收
@@ -799,17 +799,9 @@ cart.fab,购物车 {0}
cart.h,购物车
cart.empty,购物车是空的。
cart.added,已加入购物车:{0}
cart.all,统一结算
cart.each,逐家付款
cart.back,返回商店
cart.nocoin,钱包里没有可用的币。
bpay.coin2,付款币种(钱包里的币)
cart.swapped,"其中 {0} 需换币(含 {1}% 滑点)"
cart.pay,统一结算(签名一次)
cart.done,"已结算 {0} 件。"
cart.partial,"已结算 {0} 件,{1} 件没成(库存或余额不足)。"
cart.short,"{0}:钱包里的币不够换,没有结算。"
cart.sum,"商店购物车 {0} 件,付 {2} {1}(含自动换币)"
black.info.accepts,收币:{0}
black.info.advance.yes,接受提前放款
black.info.advance.no,不接受提前放款
+44 -74
View File
@@ -1459,13 +1459,13 @@ namespace Decentralized
private sealed class CartLine { public int Seller; public BmGood Good; public int Qty; }
private static readonly List<CartLine> _cart = new List<CartLine>();
private static bool _checkout, _ckEach;
private static string _ckCoin;
private static bool _checkout;
private static readonly Dictionary<int, string> _ckSwap = new Dictionary<int, string>();
private static readonly Dictionary<int, PayMode> _ckMode = new Dictionary<int, PayMode>();
private static readonly Dictionary<int, string> _ckGroupCoin = new Dictionary<int, string>();
/// <summary>读档或换局时清空购物车(货架对象已经不是同一批了)。</summary>
public static void ClearCart() { _cart.Clear(); _checkout = false; _ckMode.Clear(); _ckGroupCoin.Clear(); }
public static void ClearCart() { _cart.Clear(); _checkout = false; _ckMode.Clear(); _ckGroupCoin.Clear(); _ckSwap.Clear(); }
private static int StockOf(BmGood g) => g is BmOffer o ? o.Qty : ((BmListing)g).Qty;
@@ -1551,7 +1551,7 @@ namespace Decentralized
b.AddSeparator();
}
/// <summary>结算页:左栏是购物车详情(按商家分组,可增减数量、删除),右栏是付款选项(统一结算,或逐家生成账单)。</summary>
/// <summary>结算页:左栏是购物车详情(按商家分组,可增减数量、删除),右栏是付款:每家商家收款地址不同,所以逐家付款。</summary>
private static void CheckoutPage(CustomUIBuilder b, SaveData d)
{
CartValidate(d);
@@ -1594,42 +1594,13 @@ namespace Decentralized
{
r.AddHeader(L.T("bpay.h"));
if (_cart.Count == 0) { r.AddButton(L.T("cart.back"), () => { _checkout = false; Open(); }); return; }
r.BeginRow(4f);
PledgerSkin.Pick(r, L.T("cart.all"), !_ckEach, () => { _ckEach = false; Open(); }, _picked);
PledgerSkin.Pick(r, L.T("cart.each"), _ckEach, () => { _ckEach = true; Open(); }, _picked);
r.End();
if (!_ckEach) UnifiedPay(r, d, w, groups.Select(g => g.Key).ToList());
else foreach (var g in groups) GroupPay(r, d, w, g.Key);
foreach (var g in groups) GroupPay(r, d, w, g.Key);
r.AddSpace(4f);
r.AddButton(L.T("cart.back"), () => { _checkout = false; _message = null; Open(); });
});
}
/// <summary>统一结算:选一种币,一次合约签名付清全部商家;商家不收这种币的部分按 8% 滑点自动换。</summary>
private static void UnifiedPay(CustomUIBuilder r, SaveData d, Wallet w, List<int> sellers)
{
var coins = new[] { Assets.PSC, Assets.CRT, Assets.CRA, Assets.CRC, Assets.SPARK, Assets.Ponero }.Where(a => w.Avail(a) > 1e-9 && Session.Price(a) > 0).ToList();
if (coins.Count == 0) { r.AddLabel(L.T("cart.nocoin"), "cart_nocoin_dim"); return; }
if (_ckCoin == null || !coins.Contains(_ckCoin)) _ckCoin = coins[0];
r.AddLabel(L.T("bpay.coin2"), "bpay_coin_dim");
r.BeginRow(4f);
foreach (var a in coins) { string asset = a; PledgerSkin.Pick(r, asset, asset == _ckCoin, () => { _ckCoin = asset; Open(); }, _picked); }
r.End();
double credits = 0, swapped = 0;
foreach (int s in sellers)
{
double c = GroupCredits(d, s);
bool direct = AcceptsOf(d, s).Contains(_ckCoin);
credits += direct ? c : c * (1 + Tuning.BmAutoSwapSlip);
if (!direct) swapped += c;
}
double need = WalletWindow.RoundUp(credits / Session.Price(_ckCoin));
r.AddLabel(L.T("bpay.need", WalletWindow.Amt(need), _ckCoin, Fmt.Num(w.Avail(_ckCoin))), "bpay_need_dim");
if (swapped > 0) r.AddLabel(L.T("cart.swapped", Fmt.Credits(swapped), (Tuning.BmAutoSwapSlip * 100).ToString("0", CultureInfo.InvariantCulture)), "cart_swapped_dim");
r.AddButton(L.T("cart.pay"), () => CheckoutAll(_ckCoin, need));
}
/// <summary>逐家付款:每家商家单独选它收的币,生成账单,在钱包里转账。</summary>
/// <summary>逐家付款:这家商家收的币里选一种,生成账单在钱包里转账;也可以用钱包里别的币自动换币(多付滑点)一次签名付清。</summary>
private static void GroupPay(CustomUIBuilder r, SaveData d, Wallet w, int seller)
{
var acc = AcceptsOf(d, seller);
@@ -1649,6 +1620,44 @@ namespace Decentralized
_checkout = false;
BeginPay(AddressOf(d, seller), summary, coin, credits, pw => { var r2 = ExecGroup(seller, lines, mode, coin, pw); Finish(CartMessage(r2.items, r2.failed)); });
});
double slipped = credits * (1 + Tuning.BmAutoSwapSlip);
var sources = w.Balances.Keys.Where(a => !acc.Contains(a) && a != Assets.Ponero && Session.Price(a) > 0 && w.Avail(a) * Session.Price(a) >= slipped).ToList();
if (sources.Count == 0) return;
if (!_ckSwap.TryGetValue(seller, out var src) || !sources.Contains(src)) src = _ckSwap[seller] = sources[0];
r.AddLabel(L.T("bpay.swap.h", coin), "bpay_swap_dim");
r.BeginRow(4f);
foreach (var s in sources) { string sc = s; PledgerSkin.Pick(r, sc, sc == src, () => { _ckSwap[seller] = sc; Open(); }, _picked); }
r.End();
double needSrc = WalletWindow.RoundUp(slipped / Session.Price(src));
r.AddLabel(L.T("bpay.swap.need", WalletWindow.Amt(needSrc), src, (Tuning.BmAutoSwapSlip * 100).ToString("0", CultureInfo.InvariantCulture)), "bpay_swap_need_dim");
r.AddButton(L.T("bpay.swap.btn"), () => SwapGroup(seller, coin, src, credits, needSrc));
}
/// <summary>自动换币并结算一家商家:一次合约调用,先把别的币按滑点换成这家收的币,再下单。</summary>
private static void SwapGroup(int seller, string coin, string src, double credits, double needSrc)
{
var d = Session.Data;
var lines = _cart.Where(l => l.Seller == seller).ToList();
var mode = ModeOf(d, seller);
string summary = ShopName(d, seller) + " ×" + lines.Sum(l => l.Qty);
_checkout = false;
_message = L.T("hw.wait");
Open();
WalletWindow.OpenForBill(new WalletWindow.Bill
{
Contract = true, Asset = src, Amount = needSrc, Spend = needSrc,
Summary = L.T("bpay.swap.sum", summary, src, WalletWindow.Amt(needSrc), coin),
Execute = pw =>
{
if (pw.Avail(src) + 1e-9 < needSrc) { Finish(L.T("msg.balance")); return; }
double got = credits / Session.Price(coin) * 1.002;
pw.Add(src, -needSrc); pw.Add(coin, got); pw.RecordBuy(coin, got, credits);
CandleChart.Trade(src, credits); CandleChart.Trade(coin, credits);
Log.Info($"自动换币:{needSrc:0.####} {src} → {got:0.####} {coin}({credits:0} 信用点等值)");
var r2 = ExecGroup(seller, lines, mode, coin, pw);
Finish(CartMessage(r2.items, r2.failed));
},
});
}
private static void Finish(string message)
@@ -1683,45 +1692,6 @@ namespace Decentralized
private static string CartMessage(int items, int failed) => failed == 0 ? L.T("cart.done", items) : L.T("cart.partial", items, failed);
/// <summary>统一结算:一次合约签名;每家商家不收所选币时,先按滑点换成它收的币再付。</summary>
private static void CheckoutAll(string coin, double need)
{
var d = Session.Data;
var lines = _cart.ToList();
_checkout = false;
_message = L.T("hw.wait");
Open();
WalletWindow.OpenForBill(new WalletWindow.Bill
{
Contract = true, Asset = coin, Amount = need, Spend = need,
Summary = L.T("cart.sum", lines.Sum(l => l.Qty), coin, WalletWindow.Amt(need)),
Execute = pw =>
{
var msgs = new List<string>(); int doneItems = 0, doneFailed = 0;
foreach (var g in lines.GroupBy(l => l.Seller))
{
int seller = g.Key;
var acc = AcceptsOf(d, seller);
double credits = g.Sum(l => LineCredits(d, l));
string asset = acc.Contains(coin) ? coin : acc[0];
if (asset != coin)
{
double src = credits * (1 + Tuning.BmAutoSwapSlip) / Session.Price(coin);
if (pw.Avail(coin) + 1e-9 < src) { msgs.Add(L.T("cart.short", ShopName(d, seller))); doneFailed += g.Sum(l => l.Qty); continue; }
double got = credits / Session.Price(asset) * 1.002;
pw.Add(coin, -src); pw.Add(asset, got); pw.RecordBuy(asset, got, credits);
CandleChart.Trade(coin, credits); CandleChart.Trade(asset, credits);
Log.Info($"自动换币:{src:0.####} {coin} → {got:0.####} {asset}({credits:0} 信用点等值)");
}
var r3 = ExecGroup(seller, g.ToList(), ModeOf(d, seller), asset, pw);
doneItems += r3.items; doneFailed += r3.failed;
}
msgs.Insert(0, CartMessage(doneItems, doneFailed));
Finish(string.Join(" ", msgs));
},
});
}
private static string MerchantLabel(BmSeller s, bool shortName = false) => L.T("merchant." + s.Type) + " " + (shortName ? ChainAddress.Short(s.Name) : s.Name);
private static int _merchant = -1;