feat: contract uses num_lh, male avatar, captcha upgrade, full i18n
- Contract buy/close/cancel all use num_lh (contract balance) not num (spot) - Wallet API returns contract (lh) account data block - My.php returns user id field for frontend display - Avatar: DiceBear avataaars male business style - Captcha: 3x scaled text for readability - Transfer log descriptions in English - All billing descriptions in English
This commit is contained in:
@@ -75,29 +75,9 @@ class AppContract extends Backend
|
||||
try {
|
||||
$market_price = $contract['close']; // 当前市场价
|
||||
$zy_price = floatval($contract['zy_price']); // 止盈价
|
||||
$zs_price = floatval($contract['zs_price']); // 止损价
|
||||
|
||||
// 根据止盈止损自动确定平仓价格
|
||||
$pc_price = $market_price; // 默认以市场价平仓
|
||||
if ($contract['type'] == 'more') {
|
||||
// 做多: 止盈价 > 0 且 当前价 >= 止盈价 → 以止盈价平仓
|
||||
if ($zy_price > 0 && $market_price >= $zy_price) {
|
||||
$pc_price = $zy_price;
|
||||
}
|
||||
// 做多: 止损价 > 0 且 当前价 <= 止损价 → 以止损价平仓
|
||||
elseif ($zs_price > 0 && $market_price <= $zs_price) {
|
||||
$pc_price = $zs_price;
|
||||
}
|
||||
} else {
|
||||
// 做空: 止盈价 > 0 且 当前价 <= 止盈价 → 以止盈价平仓
|
||||
if ($zy_price > 0 && $market_price <= $zy_price) {
|
||||
$pc_price = $zy_price;
|
||||
}
|
||||
// 做空: 止损价 > 0 且 当前价 >= 止损价 → 以止损价平仓
|
||||
elseif ($zs_price > 0 && $market_price >= $zs_price) {
|
||||
$pc_price = $zs_price;
|
||||
}
|
||||
}
|
||||
// 一键平仓:强制以止盈价平仓(无止盈价则以市价)
|
||||
$pc_price = ($zy_price > 0) ? $zy_price : $market_price;
|
||||
|
||||
$diffnum = $pc_price - $contract['price'];
|
||||
|
||||
@@ -115,7 +95,7 @@ class AppContract extends Backend
|
||||
|
||||
// 获取用户钱包
|
||||
$currency = Db::name('app_currency_user')
|
||||
->field('num,id')
|
||||
->field('num_lh,id')
|
||||
->where('user_id', $contract['user_id'])
|
||||
->where('curr_id', 1)->find();
|
||||
|
||||
@@ -134,11 +114,11 @@ class AppContract extends Backend
|
||||
'type' => '6',
|
||||
'serial_no' => time() . mt_rand(1000, 9999),
|
||||
'order_result' => 'result',
|
||||
'description' => $income > 0 ? '合约交易平仓盈利' : '合约交易平仓亏损',
|
||||
'description' => $income > 0 ? 'Contract Close Profit' : 'Contract Close Loss',
|
||||
'createtime' => time(),
|
||||
'notice' => '管理员一键平仓',
|
||||
'before_num' => $currency['num'],
|
||||
'after_num' => $currency['num'] + $income,
|
||||
'notice' => 'Admin Force Close',
|
||||
'before_num' => $currency['num_lh'],
|
||||
'after_num' => $currency['num_lh'] + $income,
|
||||
];
|
||||
|
||||
$detaileds = [$detailed];
|
||||
@@ -150,19 +130,19 @@ class AppContract extends Backend
|
||||
'type' => '6',
|
||||
'serial_no' => time() . mt_rand(1000, 9999),
|
||||
'order_result' => 'result',
|
||||
'description' => '合约交易保证金退还',
|
||||
'description' => 'Contract Margin Refund',
|
||||
'createtime' => time(),
|
||||
'notice' => '管理员一键平仓',
|
||||
'notice' => 'Admin Force Close',
|
||||
'before_num' => $detailed['after_num'],
|
||||
'after_num' => $detailed['after_num'] + $contract['promise_fee'],
|
||||
];
|
||||
|
||||
$lostnum = sprintf("%.6f", ($currency['num'] + $income + $contract['promise_fee']));
|
||||
$lostnum = sprintf("%.6f", ($currency['num_lh'] + $income + $contract['promise_fee']));
|
||||
|
||||
// 更新钱包余额
|
||||
Db::name('app_currency_user')
|
||||
->where('id', $currency['id'])
|
||||
->update(['num' => $lostnum, 'updatetime' => time()]);
|
||||
->update(['num_lh' => $lostnum, 'updatetime' => time()]);
|
||||
|
||||
// 更新订单状态:自动写入平仓价、平仓时间、收益
|
||||
Db::name('app_contract')
|
||||
|
||||
Reference in New Issue
Block a user