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:
@@ -96,8 +96,21 @@ class Wallet extends Api
|
||||
);
|
||||
}
|
||||
}
|
||||
$paixu = array_column($curr_arr, "usdt_price");
|
||||
array_multisort($paixu, SORT_DESC, $curr_arr);
|
||||
// 前三位固定:USDT > BTC > ETH,其余按持仓价值降序
|
||||
$pin_order = ['USDT' => 0, 'BTC' => 1, 'ETH' => 2];
|
||||
$pinned = [null, null, null];
|
||||
$rest = [];
|
||||
foreach ($curr_arr as $item) {
|
||||
$uname = strtoupper($item['name']);
|
||||
if (isset($pin_order[$uname])) {
|
||||
$pinned[$pin_order[$uname]] = $item;
|
||||
} else {
|
||||
$rest[] = $item;
|
||||
}
|
||||
}
|
||||
$paixu = array_column($rest, "usdt_price");
|
||||
array_multisort($paixu, SORT_DESC, $rest);
|
||||
$curr_arr = array_merge(array_filter($pinned, function($v){ return $v !== null; }), $rest);
|
||||
//添加EVT数据
|
||||
if($evt == 0){
|
||||
$inser = array(
|
||||
@@ -108,7 +121,20 @@ class Wallet extends Api
|
||||
Db::name("app_currency_user")->insert($inser);
|
||||
}
|
||||
$all_usdt = $count_xh_usdt+$count_lh_num+$count_fb_num;
|
||||
|
||||
// 合约交易总利润(盈 - 亏)
|
||||
$profit_in = Db::name('app_detailed')
|
||||
->where('user_id', $user_id)
|
||||
->where('description', 'Contract Close Profit')
|
||||
->sum('price');
|
||||
$profit_out = Db::name('app_detailed')
|
||||
->where('user_id', $user_id)
|
||||
->where('description', 'Contract Close Loss')
|
||||
->sum('price');
|
||||
$total_profit = sprintf("%.2f", ($profit_in ?: 0) - ($profit_out ?: 0));
|
||||
|
||||
$data = array(
|
||||
"total_profit" => $total_profit,
|
||||
"all" => array(
|
||||
"count_btc" => sprintf("%.8f",$all_usdt/$btc_price),
|
||||
"count_usdt" => sprintf("%.2f",$all_usdt),
|
||||
@@ -127,11 +153,11 @@ class Wallet extends Api
|
||||
"count_usdt" => sprintf("%.2f",$count_fb_num),
|
||||
"fb_arr" => $fb_arr,
|
||||
),
|
||||
// "lh" => array(
|
||||
// "count_btc" => sprintf("%.8f",$count_lh_num/$btc_price),
|
||||
// "count_usdt" => sprintf("%.2f",$count_lh_num),
|
||||
// "lh_arr" => $lh_arr,
|
||||
// ),
|
||||
"lh" => array(
|
||||
"count_btc" => sprintf("%.8f",$count_lh_num/$btc_price),
|
||||
"count_usdt" => sprintf("%.2f",$count_lh_num),
|
||||
"lh_arr" => $lh_arr,
|
||||
),
|
||||
);
|
||||
$this->success("ok",$data);
|
||||
}
|
||||
@@ -737,7 +763,7 @@ class Wallet extends Api
|
||||
'price' => $apy_num,
|
||||
'cart' => '2',
|
||||
'type' => '2',
|
||||
'description' => '提币APY手续费',
|
||||
'description' => 'Withdrawal APY Fee',
|
||||
'createtime' => time(),
|
||||
'before_num' => $user_apy['num'],
|
||||
'after_num' => $user_apy['num'] - $apy_num,
|
||||
@@ -775,7 +801,7 @@ class Wallet extends Api
|
||||
'price' => $params['num'],
|
||||
'cart' => '2',
|
||||
'type' => '2',
|
||||
'description' => '提币出账',
|
||||
'description' => 'Withdrawal',
|
||||
'createtime' => time(),
|
||||
'before_num' => $user_curr['num'],
|
||||
'after_num' => $user_curr['num'] - $params['num'],
|
||||
@@ -810,9 +836,9 @@ class Wallet extends Api
|
||||
{
|
||||
$user_id = $this->auth->id;
|
||||
$zhuanghu = array(
|
||||
['id'=>1,"name"=>__("现货账户")],
|
||||
['id'=>2,"name"=>__("法币账户")],
|
||||
['id'=>3,"name"=>__("合约账户")],
|
||||
['id'=>1,"name"=>"Spot"],
|
||||
['id'=>2,"name"=>"Fiat"],
|
||||
['id'=>3,"name"=>"Contract"],
|
||||
);
|
||||
//获取可划转币种 + 汇率用于实时价格转换
|
||||
$curr = Db::name("app_currency a")->field("a.id as curr_id,a.name,a.exchange,b.num,b.num_fb,b.num_lh")
|
||||
@@ -892,8 +918,8 @@ class Wallet extends Api
|
||||
if($user_curr_coin['num'] < $num){
|
||||
$this->error(__("余额不足"));
|
||||
}
|
||||
$left_msg = "现货账户";
|
||||
$right_msg = "合约账户";
|
||||
$left_msg = "Spot";
|
||||
$right_msg = "Contract";
|
||||
|
||||
//redis防重复
|
||||
$symbol = "transfer_sub" . $this->auth->id;
|
||||
@@ -911,12 +937,12 @@ class Wallet extends Api
|
||||
// 记录
|
||||
Db::name("app_detailed")->insert([
|
||||
"user_id" => $user_id, "curr_id" => $curr_id, "price" => $num,
|
||||
"cart" => 2, "type" => 8, "description" => $curr['name']." ".$left_msg."转到".$right_msg."(≈".$usdt_amount." USDT)",
|
||||
"cart" => 2, "type" => 8, "description" => $curr['name']." ".$left_msg." to ".$right_msg." (≈".$usdt_amount." USDT)",
|
||||
"createtime" => time(), "before_num" => $user_curr_coin['num'], "after_num" => $user_curr_coin['num'] - $num,
|
||||
]);
|
||||
Db::name("app_detailed_lh")->insert([
|
||||
"user_id" => $user_id, "curr_id" => 1, "price" => $usdt_amount,
|
||||
"cart" => 1, "type" => 1, "description" => $curr['name']." ".$left_msg."转到".$right_msg."(按".$exchange_rate."转换)",
|
||||
"cart" => 1, "type" => 1, "description" => $curr['name']." ".$left_msg." to ".$right_msg." (rate:".$exchange_rate.")",
|
||||
"createtime" => time(), "before_num" => $user_curr_usdt['num_lh'], "after_num" => $user_curr_usdt['num_lh'] + $usdt_amount,
|
||||
]);
|
||||
Db::name("app_transfer_log")->insert([
|
||||
@@ -938,8 +964,8 @@ class Wallet extends Api
|
||||
if($user_curr_usdt['num_lh'] < $num){
|
||||
$this->error(__("合约账户余额不足"));
|
||||
}
|
||||
$left_msg = "合约账户";
|
||||
$right_msg = "现货账户";
|
||||
$left_msg = "Contract";
|
||||
$right_msg = "Spot";
|
||||
|
||||
$symbol = "transfer_sub" . $this->auth->id;
|
||||
$submited = pushRedis($symbol);
|
||||
@@ -953,12 +979,12 @@ class Wallet extends Api
|
||||
->update(['num' => $user_curr_coin['num'] + $btc_amount]);
|
||||
Db::name("app_detailed_lh")->insert([
|
||||
"user_id" => $user_id, "curr_id" => 1, "price" => $num,
|
||||
"cart" => 2, "type" => 1, "description" => $left_msg."转到".$curr['name']." ".$right_msg,
|
||||
"cart" => 2, "type" => 1, "description" => $left_msg." to ".$curr['name']." ".$right_msg,
|
||||
"createtime" => time(), "before_num" => $user_curr_usdt['num_lh'], "after_num" => $user_curr_usdt['num_lh'] - $num,
|
||||
]);
|
||||
Db::name("app_detailed")->insert([
|
||||
"user_id" => $user_id, "curr_id" => $curr_id, "price" => $btc_amount,
|
||||
"cart" => 1, "type" => 8, "description" => $num." USDT → ".$btc_amount." ".$curr['name']."(按".$exchange_rate."转换)",
|
||||
"cart" => 1, "type" => 8, "description" => $num." USDT → ".$btc_amount." ".$curr['name']." (rate:".$exchange_rate.")",
|
||||
"createtime" => time(), "before_num" => $user_curr_coin['num'], "after_num" => $user_curr_coin['num'] + $btc_amount,
|
||||
]);
|
||||
Db::name("app_transfer_log")->insert([
|
||||
@@ -981,19 +1007,19 @@ class Wallet extends Api
|
||||
$user_curr = Db::name("app_currency_user")->where("curr_id",$curr_id)->where("user_id",$user_id)->find();
|
||||
switch ($left_id) {
|
||||
case 1:
|
||||
$left_msg = "现货账户";
|
||||
$left_msg = "Spot";
|
||||
$left_field = "num";
|
||||
$left_table = "app_detailed";
|
||||
$left_type = 8;
|
||||
break;
|
||||
case 2:
|
||||
$left_msg = "法币账户";
|
||||
$left_msg = "Fiat";
|
||||
$left_field = "num_fb";
|
||||
$left_table = "app_detailed_fb";
|
||||
$left_type = 1;
|
||||
break;
|
||||
case 3:
|
||||
$left_msg = "合约账户";
|
||||
$left_msg = "Contract";
|
||||
$left_field = "num_lh";
|
||||
$left_table = "app_detailed_lh";
|
||||
$left_type = 1;
|
||||
@@ -1004,19 +1030,19 @@ class Wallet extends Api
|
||||
}
|
||||
switch ($right_id) {
|
||||
case 1:
|
||||
$right_msg = "现货账户";
|
||||
$right_msg = "Spot";
|
||||
$right_field = "num";
|
||||
$right_table = "app_detailed";
|
||||
$right_type = 8;
|
||||
break;
|
||||
case 2:
|
||||
$right_msg = "法币账户";
|
||||
$right_msg = "Fiat";
|
||||
$right_field = "num_fb";
|
||||
$right_table = "app_detailed_fb";
|
||||
$right_type = 1;
|
||||
break;
|
||||
case 3:
|
||||
$right_msg = "合约账户";
|
||||
$right_msg = "Contract";
|
||||
$right_field = "num_lh";
|
||||
$right_table = "app_detailed_lh";
|
||||
$right_type = 1;
|
||||
@@ -1041,7 +1067,7 @@ class Wallet extends Api
|
||||
"price" => $num,
|
||||
"cart" => 2,
|
||||
"type" => $left_type,
|
||||
"description" => $left_msg."转到".$right_msg,
|
||||
"description" => $left_msg." to ".$right_msg,
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr[$left_field],
|
||||
"after_num" => $user_curr[$left_field] - $num,
|
||||
@@ -1052,7 +1078,7 @@ class Wallet extends Api
|
||||
"price" => $num,
|
||||
"cart" => 1,
|
||||
"type" => $right_type,
|
||||
"description" => $left_msg."转到".$right_msg,
|
||||
"description" => $left_msg." to ".$right_msg,
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr[$right_field],
|
||||
"after_num" => $user_curr[$right_field] + $num,
|
||||
@@ -1063,7 +1089,7 @@ class Wallet extends Api
|
||||
"form" => $left_id,
|
||||
"to" => $right_id,
|
||||
"num" => $num,
|
||||
"msg" => $left_msg."转到".$right_msg,
|
||||
"msg" => $left_msg." to ".$right_msg,
|
||||
"addtime" => time(),
|
||||
);
|
||||
$curr_update = array(
|
||||
|
||||
Reference in New Issue
Block a user