|
|
@@ -119,14 +119,17 @@ class Ledger extends Api
|
|
|
public function frozenTransfer(UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
{
|
|
|
$amount = $this->request->post('amount'); // 茶宝
|
|
|
- $account= $this->request->post('account', ''); // 账号
|
|
|
- if(empty($amount) || empty($account)) $this->error(__('Parameter error'));
|
|
|
+ $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('frozen_transfer'), $amount, 2), 2) ; // 手续费
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- // type: 0x, 地址 1uid
|
|
|
- $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account);
|
|
|
+
|
|
|
+ $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account);
|
|
|
if(empty($user)) throw new Exception(__("赠送用户不存在"));
|
|
|
if($user['id'] == $this->auth->id) throw new Exception(__("赠送用户不能是自己"));
|
|
|
|
|
|
@@ -168,14 +171,17 @@ class Ledger extends Api
|
|
|
{
|
|
|
$amount = $this->request->post('amount'); // 茶宝
|
|
|
$account= $this->request->post('account', ''); // 账号
|
|
|
- if(empty($amount) || empty($account)) $this->error(__('Parameter error'));
|
|
|
+ $type = (strlen($account) > 11)? 0: 1; // type: 0地址 1uid
|
|
|
+ if(empty($amount) || empty($account)){
|
|
|
+ $this->error(__('Parameter error'));
|
|
|
+ }
|
|
|
$real = bcsub($amount, bcmul(getConfig('chabao_giveaway'), $amount, 2), 2) ; // 手续费
|
|
|
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- // type: 0x地址 1uid
|
|
|
- $user = (substr($account, 0, 2) == '0x')? $userModel->getByAddress($account): $userModel->getByUid($account);
|
|
|
+
|
|
|
+ $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);
|