|
|
@@ -308,7 +308,7 @@ class Ledger extends Api
|
|
|
if(empty($amount) || empty($account)){
|
|
|
$this->error(__('Parameter error'));
|
|
|
}
|
|
|
- $real = bcsub($amount, bcmul(config('teac_angel'), $amount, 2), 2) ; // 手续费
|
|
|
+ $real = bcsub($amount, bcmul(getConfig('teac_angel'), $amount, 2), 2) ; // 手续费
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -333,7 +333,41 @@ class Ledger extends Api
|
|
|
$this->success('ok');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * teac生态的转账
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function teacEcologyTransfer(UserModel $userModel, LedgerWalletModel $ledgerWalletModel, LedgerTeacEcolyChangeModel $LedgerTeacAngelChangeModel)
|
|
|
+ {
|
|
|
+ $amount = $this->request->post('amount'); // 茶宝
|
|
|
+ $account= $this->request->post('account', ''); // 账号
|
|
|
+ if(empty($amount) || empty($account)){
|
|
|
+ $this->error(__('Parameter error'));
|
|
|
+ }
|
|
|
+ $real = bcsub($amount, bcmul(config('teac_ecoly'), $amount, 2), 2) ; // 手续费
|
|
|
+ // 启动事务
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account);
|
|
|
+ if(empty($user)) throw new Exception(__("赠送用户不存在"));
|
|
|
+ if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));
|
|
|
+ $teac = $ledgerWalletModel::getTeacAngel($this->auth->id);
|
|
|
+ if(bccomp($amount, $teac, 2) > 0) throw new Exception(__("余额不足请前往充值"), 15001);
|
|
|
+
|
|
|
+ // 更新USDT和账变
|
|
|
+ $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TEAC_ANGEL, -$amount, LedgerTeacEcolyChangeModel::GiftPay, $user['id']);
|
|
|
+
|
|
|
+ $re=$ledgerWalletModel->changeWalletAccount($user['id'], Asset::TEAC_ANGEL, $real, LedgerTeacEcolyChangeModel::GiftReceipt, $this->auth->id);
|
|
|
+
|
|
|
+ // 提交事务
|
|
|
+ Db::commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
+ }
|
|
|
+ $this->success('ok');
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|