|
|
@@ -118,7 +118,6 @@ class Ledger extends Api
|
|
|
{
|
|
|
$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'));
|
|
|
}
|
|
|
@@ -127,7 +126,7 @@ class Ledger extends Api
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
- $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account);
|
|
|
+ $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(__("赠送用户不能是自己"));
|
|
|
|
|
|
@@ -169,8 +168,7 @@ class Ledger extends Api
|
|
|
public function chabaoGift(UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
{
|
|
|
$amount = $this->request->post('amount'); // 茶宝
|
|
|
- $account= $this->request->post('account', ''); // 账号
|
|
|
- $type = (strlen($account) > 11)? 0: 1; // type: 0地址 1uid
|
|
|
+ $account= $this->request->post('account', ''); // 账号
|
|
|
if(empty($amount) || empty($account)){
|
|
|
$this->error(__('Parameter error'));
|
|
|
}
|
|
|
@@ -178,8 +176,7 @@ class Ledger extends Api
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
-
|
|
|
- $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account);
|
|
|
+ $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(__("赠送用户不能是自己"));
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
@@ -207,7 +204,6 @@ class Ledger extends Api
|
|
|
{
|
|
|
$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'));
|
|
|
}
|
|
|
@@ -215,8 +211,7 @@ class Ledger extends Api
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
-
|
|
|
- $user = (empty($type))? $userModel->getByAddress($account): $userModel->getById($account);
|
|
|
+ $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(__("赠送用户不能是自己"));
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|