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:
li
2026-04-05 13:05:37 +08:00
parent 733982a2be
commit 7d7f53b356
6 changed files with 154 additions and 154 deletions
@@ -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')
+41 -41
View File
@@ -331,56 +331,56 @@ class Common extends Api
*/
public function captcha()
{
$a = mt_rand(1, 20);
$b = mt_rand(1, 20);
$operators = ['+', '-'];
$op = $operators[array_rand($operators)];
if ($op == '-' && $a < $b) {
// 确保减法结果非负
$tmp = $a; $a = $b; $b = $tmp;
// 生成4位随机大写英文字母
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; // 去掉易混淆的 I O
$answer = '';
for ($i = 0; $i < 4; $i++) {
$answer .= $chars[mt_rand(0, strlen($chars) - 1)];
}
$answer = ($op == '+') ? ($a + $b) : ($a - $b);
$text = "{$a} {$op} {$b} = ?";
// 生成唯一key标识本次验证码
$captcha_key = md5(uniqid(mt_rand(), true));
cache('captcha_' . $captcha_key, strtoupper($answer), 300);
// 将答案存入缓存(使用ThinkPHP缓存,5分钟过期)
cache('captcha_' . $captcha_key, strval($answer), 300);
// 先在小画布绘制文字,再等比放大 → 让内置字体看起来更大
$smallW = 100;
$smallH = 32;
$small = imagecreatetruecolor($smallW, $smallH);
$smallBg = imagecolorallocate($small, 240, 244, 250);
imagefilledrectangle($small, 0, 0, $smallW, $smallH, $smallBg);
// 生成验证码图片
$width = 200;
$height = 60;
// 干扰线(小画布上)
for ($i = 0; $i < 3; $i++) {
$lc = imagecolorallocate($small, mt_rand(160, 210), mt_rand(160, 210), mt_rand(160, 210));
imageline($small, mt_rand(0, $smallW), mt_rand(0, $smallH), mt_rand(0, $smallW), mt_rand(0, $smallH), $lc);
}
// 文字(内置最大字号5,字符宽9px)
$fontSize = 5;
$charW = imagefontwidth($fontSize);
$charH = imagefontheight($fontSize);
$totalW = $charW * 4;
$startX = ($smallW - $totalW) / 2;
$startY = ($smallH - $charH) / 2;
for ($i = 0; $i < 4; $i++) {
$tc = imagecolorallocate($small, mt_rand(10, 70), mt_rand(10, 70), mt_rand(10, 70));
imagestring($small, $fontSize, (int)($startX + $i * $charW), (int)$startY, $answer[$i], $tc);
}
// 放大3倍到输出画布
$scale = 3;
$width = $smallW * $scale;
$height = $smallH * $scale;
$img = imagecreatetruecolor($width, $height);
imagecopyresampled($img, $small, 0, 0, 0, 0, $width, $height, $smallW, $smallH);
imagedestroy($small);
// 背景色
$bgColor = imagecolorallocate($img, 240, 244, 250);
imagefilledrectangle($img, 0, 0, $width, $height, $bgColor);
// 干扰线
for ($i = 0; $i < 5; $i++) {
$lineColor = imagecolorallocate($img, mt_rand(100, 200), mt_rand(100, 200), mt_rand(100, 200));
imageline($img, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $lineColor);
// 干扰点(放大后再叠加,避免被放大模糊)
for ($i = 0; $i < 60; $i++) {
$dc = imagecolorallocate($img, mt_rand(150, 230), mt_rand(150, 230), mt_rand(150, 230));
imagesetpixel($img, mt_rand(0, $width), mt_rand(0, $height), $dc);
}
// 干扰点
for ($i = 0; $i < 50; $i++) {
$dotColor = imagecolorallocate($img, mt_rand(100, 255), mt_rand(100, 255), mt_rand(100, 255));
imagesetpixel($img, mt_rand(0, $width), mt_rand(0, $height), $dotColor);
}
// 文字颜色
$textColor = imagecolorallocate($img, mt_rand(10, 80), mt_rand(10, 80), mt_rand(10, 80));
// 使用内置字体绘制文字
$fontSize = 5; // imagestring内置字体最大5
$textWidth = imagefontwidth($fontSize) * strlen($text);
$textHeight = imagefontheight($fontSize);
$x = ($width - $textWidth) / 2;
$y = ($height - $textHeight) / 2;
imagestring($img, $fontSize, $x, $y, $text, $textColor);
// 输出为base64
ob_start();
imagepng($img);
$imgData = ob_get_clean();
@@ -406,7 +406,7 @@ class Common extends Api
if ($answer === false || $answer === null) {
return false;
}
$result = (trim($captcha_code) === trim($answer));
$result = (strtoupper(trim($captcha_code)) === strtoupper(trim($answer)));
// 验证后立即删除,防止重放
cache('captcha_' . $captcha_key, null);
return $result;
+34 -34
View File
@@ -163,7 +163,7 @@ class Contract extends Api
}
$currency = Db::name('app_currency_user')
->field('num,id')
->field('num_lh,id')
->where('user_id',$this->auth->id)
->where('curr_id',1)->find();
//需要保证金
@@ -260,7 +260,7 @@ class Contract extends Api
//是否开启APT手续费
if($this->auth->apy_pay == 1){
if($currency['num'] < ($promisefee))
if($currency['num_lh'] < ($promisefee))
{
lopRedis($symbol);
$this->error(__('账号余额不足'));
@@ -285,16 +285,16 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易手续费',
'description' => 'Contract Fee',
'createtime' => time(),
'notice' => '合约交易手续费',
'notice' => 'Contract Fee',
'before_num' => $user_apy['num'],
'after_num' => $user_apy['num'] - $fee,
];
$lostnum = $currency['num'] - $promisefee;
$lostnum = $currency['num_lh'] - $promisefee;
$fee_type = 1;
}else{
if($currency['num'] < ($promisefee+$fee))
if($currency['num_lh'] < ($promisefee+$fee))
{
lopRedis($symbol);
$this->error(__('账号余额不足'));
@@ -307,13 +307,13 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易手续费',
'description' => 'Contract Fee',
'createtime' => time(),
'notice' => '合约交易手续费',
'before_num' => $currency['num'],
'after_num' => $currency['num'] - $fee,
'notice' => 'Contract Fee',
'before_num' => $currency['num_lh'],
'after_num' => $currency['num_lh'] - $fee,
];
$lostnum = $currency['num'] - $promisefee - $fee;
$lostnum = $currency['num_lh'] - $promisefee - $fee;
$fee_type = 1;
}
$contract = [
@@ -338,16 +338,16 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易保证金',
'description' => 'Contract Margin',
'createtime' => time(),
'notice' => '合约交易保证金',
'before_num' => $currency['num'],
'notice' => 'Contract Margin',
'before_num' => $currency['num_lh'],
'after_num' => $lostnum,
];
Db::startTrans();
try {
Db::name('app_currency_user')->where('id',$currency['id'])->update(['num'=>$lostnum,'updatetime'=>time()]);
Db::name('app_currency_user')->where('id',$currency['id'])->update(['num_lh'=>$lostnum,'updatetime'=>time()]);
if($this->auth->apy_pay == 1){
Db::name('app_currency_user')->where('id',$user_apy['id'])->update(['num'=>$user_apy['num'] - $fee]);
}
@@ -528,7 +528,7 @@ class Contract extends Api
$income = sprintf('%.6f',$income);
$currency = Db::name('app_currency_user')
->field('num,id')
->field('num_lh,id')
->where('user_id',$this->auth->id)
->where('curr_id',1)->find();
@@ -540,18 +540,18 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易平仓',
'description' => 'Contract Close',
'createtime' => time(),
'notice' => '合约交易平仓',
'before_num' => $currency['num'],
'after_num' => $currency['num'] + $income,
'notice' => 'Contract Close',
'before_num' => $currency['num_lh'],
'after_num' => $currency['num_lh'] + $income,
];
if($income >0 ){
$detailed['cart'] = '1';
$detailed['description'] = '合约交易平仓盈利';
$detailed['description'] = 'Contract Close Profit';
}else{
$detailed['cart'] = '2';
$detailed['description'] = '合约交易平仓亏损';
$detailed['description'] = 'Contract Close Loss';
}
$detaileds[] = $detailed;
@@ -563,18 +563,18 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易保证金',
'description' => 'Contract Margin',
'createtime' => time(),
'notice' => '合约交易保证金',
'notice' => 'Contract Margin',
'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::startTrans();
try {
$ret = Db::name('app_currency_user')
->where('id',$currency['id'])->update(['num'=>$lostnum,'updatetime'=>time()]);
->where('id',$currency['id'])->update(['num_lh'=>$lostnum,'updatetime'=>time()]);
if(!$ret)
{
lopRedis($symbol);
@@ -627,7 +627,7 @@ class Contract extends Api
$this->error(__("操作频繁"));
}
$currency = Db::name('app_currency_user')
->field('num,id')
->field('num_lh,id')
->where('user_id',$this->auth->id)
->where('curr_id',1)->find();
@@ -639,18 +639,18 @@ class Contract extends Api
'type' => '6',
'serial_no' => time().Random::build('numeric',4),
'order_result' => 'result',
'description' => '合约交易保证金及手续费',
'description' => 'Contract Margin & Fee Refund',
'createtime' => time(),
'notice' => '合约交易保证金及手续费',
'before_num' => $currency['num'],
'after_num' => $currency['num'] + $contract['promise_fee'] + $contract['fee'],
'notice' => 'Contract Margin & Fee Refund',
'before_num' => $currency['num_lh'],
'after_num' => $currency['num_lh'] + $contract['promise_fee'] + $contract['fee'],
];
$lostnum = sprintf("%.6f",($currency['num'] + $contract['promise_fee'] + $contract['fee']));
$lostnum = sprintf("%.6f",($currency['num_lh'] + $contract['promise_fee'] + $contract['fee']));
Db::startTrans();
try {
$ret = Db::name('app_currency_user')
->where('id',$currency['id'])->update(['num'=>$lostnum,'updatetime'=>time()]);
->where('id',$currency['id'])->update(['num_lh'=>$lostnum,'updatetime'=>time()]);
if(!$ret)
{
lopRedis($symbol);
+2 -1
View File
@@ -35,8 +35,9 @@ class My extends Api
$is_angel = false;
}
$data = [
'id' => $this->auth->id,
'user_id' => $this->auth->id,
'avatar' => Config::get('site.image_url').$this->auth->avatar,
'avatar' => (strpos($this->auth->avatar, 'http') === 0) ? $this->auth->avatar : Config::get('site.image_url').$this->auth->avatar,
'nickname' => $this->auth->nickname,
'email' => $this->auth->email,
'is_auth' => $auth['status'],
+11 -18
View File
@@ -47,7 +47,8 @@ class User extends Api
$ret = $this->auth->login($account, $password);
if ($ret) {
$userinfo = $this->auth->getUserinfo();
$userinfo['avatar'] = Config::get("site.image_url").$userinfo['avatar'];
$_av = $userinfo['avatar'];
$userinfo['avatar'] = (strpos($_av, 'http') === 0) ? $_av : Config::get("site.image_url").$_av;
$data = ['userinfo' => $userinfo];
//对接公链
@@ -174,7 +175,7 @@ class User extends Api
$this->error(__('请输入邀请码'));
}
$extend['nickname'] = "用户". rand(1000000, 9999999);
$extend['nickname'] = $email ? $email : $mobile;
// if($referral_code){ //判断上级推荐码和id
$w["referral_code"] = array( "eq" , $referral_code );
$p_info = Db::name('user')->field("id,path")->where($w)->find();
@@ -186,7 +187,9 @@ class User extends Api
}
// }
$extend['pay_pwd'] = strtoupper(md5(strtoupper(md5($pwd2.'skund'))));
$extend['avatar'] = Config::get("site.default_avatar");
// 生成随机虚拟头像 (DiceBear avataaars - 男性商务风格)
$avatarSeed = md5(uniqid(mt_rand(), true));
$extend['avatar'] = 'https://api.dicebear.com/9.x/avataaars/png?seed=' . $avatarSeed . '&size=200&top=shortHairShortFlat,shortHairShortRound,shortHairShortWaved,shortHairSides,shortHairTheCaesar,shortHairShortCurly&clothing=blazerAndSweater,blazerAndShirt&clothingColor=262e33,3c4f5c,65c9ff,25557c,929598';
$extend['referral_code'] = $this->create_invite_code(); //推荐码
//注册钱包eth
$ret = $this->auth->register($username, $password, $email, $mobile, $extend);
@@ -292,25 +295,15 @@ class User extends Api
{
$newpassword = $this->request->request("newpassword");
$captcha = $this->request->request("captcha");
$captcha_key = $this->request->request("captcha_key", "");
$types = $this->request->request("types");
$type = $this->request->request("type","mobile");//email
if (!$newpassword || !$captcha) {
$this->error(__('请输入完整信息'));
}
if($type == "email"){
$user = \app\common\model\User::getByEmail($this->auth->email);
$ret = Ems::check($user['email'], $captcha, 'resetpwd');
if (!$ret && $captcha!=157258) {
$this->error(__('验证码错误'));
}
Ems::flush($user['email'], 'resetpwd');
}else{
$user = \app\common\model\User::getByMobile($this->auth->mobile);
$ret = Sms::check($user['mobile'], $captcha, 'resetpwd');
if (!$ret && $captcha!=157258) {
$this->error(__('验证码错误'));
}
Sms::flush($user['mobile'], 'resetpwd');
// 使用图形验证码(4位大写字母)代替邮箱/短信OTP
$captchaOk = \app\api\controller\Common::checkCaptcha($captcha_key, $captcha);
if (!$captchaOk) {
$this->error(__('验证码错误'));
}
//模拟一次登录
+55 -29
View File
@@ -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(