|
|
@@ -6,7 +6,7 @@ use app\api\logic\WelfareLoginc;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\LedgerFrozenChangeModel;
|
|
|
use app\common\model\ProductLists;
|
|
|
-use app\common\model\ProductOrder;
|
|
|
+use app\common\model\LedgerTeacChangeModel;
|
|
|
use app\common\model\LedgerTeacAngelChangeModel;
|
|
|
use app\common\model\UserModel;
|
|
|
use app\common\model\LedgerTokenChangeModel;
|
|
|
@@ -102,9 +102,6 @@ class Ledger extends Api
|
|
|
$paginator = (new LedgerTeacAngelChangeModel());
|
|
|
$res['data'] = $paginator->where($where)->order('id DESC')->paginate($this->pageSize);
|
|
|
break;
|
|
|
- case 'smh':
|
|
|
- $paginator = (new LedgerSmhChangeModel());
|
|
|
- break;
|
|
|
default:
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
break;
|
|
|
@@ -161,7 +158,8 @@ class Ledger extends Api
|
|
|
public function getGiftDesc()
|
|
|
{
|
|
|
$this->success('', ['chabao'=>['value' => getConfig('chabao_giveaway'), 'text' => getConfig('chabao_giveaway_txt')],
|
|
|
- 'frozen'=>['value' => getConfig('frozen_transfer'), 'text' => getConfig('frozen_transfer_txt')]]);
|
|
|
+ 'frozen'=>['value' => getConfig('frozen_transfer'), 'text' => getConfig('frozen_transfer_txt')],
|
|
|
+ 'teac'=>['value' => config('app.teac_giveaway'), 'text' => config('app.teac_giveaway_txt')]]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -176,8 +174,7 @@ class Ledger extends Api
|
|
|
if(empty($amount) || empty($account)){
|
|
|
$this->error(__('Parameter error'));
|
|
|
}
|
|
|
- $real = bcsub($amount, bcmul(getConfig('chabao_giveaway'), $amount, 2), 2) ; // 手续费
|
|
|
-
|
|
|
+ $real = bcsub($amount, bcmul(config('app.teac_giveaway'), $amount, 2), 2) ; // 手续费
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -202,6 +199,42 @@ class Ledger extends Api
|
|
|
$this->success('ok');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Teac赠送 0x
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function teacGift(UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
+ {
|
|
|
+ $amount = $this->request->post('amount'); // 茶宝
|
|
|
+ $account= $this->request->post('account', ''); // 账号
|
|
|
+ $type = (strlen($account) > 11)? 0: 1; // type: 0地址 1uid
|
|
|
+ if(empty($amount) || empty($account)){
|
|
|
+ $this->error(__('Parameter error'));
|
|
|
+ }
|
|
|
+ $real = bcsub($amount, bcmul(getConfig('teac_giveaway'), $amount, 2), 2) ; // 手续费
|
|
|
+ // 启动事务
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account);
|
|
|
+ if(empty($user)) throw new Exception(__("赠送用户不存在"));
|
|
|
+ if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));
|
|
|
+ $chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
+ if(bccomp($amount, $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"), 15001);
|
|
|
+
|
|
|
+ // 更新USDT和账变
|
|
|
+ $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TEAC, -$amount, LedgerTeacChangeModel::GiftPay, $user['id']);
|
|
|
+
|
|
|
+ $ledgerWalletModel->changeWalletAccount($user['id'], Asset::TEAC, $real, LedgerTeacChangeModel::GiftReceipt, $this->auth->id);
|
|
|
+ // 提交事务
|
|
|
+ Db::commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
+ }
|
|
|
+ $this->success('ok');
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -215,11 +248,9 @@ class Ledger extends Api
|
|
|
$parems = $this->request->post();
|
|
|
Log::write('提现自动打款回调参数:','info');
|
|
|
Log::info(json_encode($parems));
|
|
|
-
|
|
|
if(empty($parems)){
|
|
|
$this->error("回调参数为空");
|
|
|
}
|
|
|
-
|
|
|
if($parems['code'] != 1){
|
|
|
$this->error("本次提现失败");
|
|
|
}
|