|
|
@@ -6,17 +6,13 @@ use app\api\logic\WelfareLoginc;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\logic\BscApi;
|
|
|
use app\common\model\LedgerFrozenChangeModel;
|
|
|
+use app\common\model\ProductLists;
|
|
|
use app\common\model\ProductOrder;
|
|
|
-use app\common\model\ProductsModel;
|
|
|
use app\common\model\RwaExchangeRecordModel;
|
|
|
use app\common\model\UserModel;
|
|
|
-use app\common\model\LedgerSmhChangeModel;
|
|
|
-use app\common\model\LedgerTeacChangeModel;
|
|
|
use app\common\model\LedgerTokenChangeModel;
|
|
|
-use app\common\model\LedgerUsdtChangeModel;
|
|
|
use app\common\model\LedgerWalletModel;
|
|
|
use app\common\model\OfflineWithdrawRecordModel;
|
|
|
-use fast\Action;
|
|
|
use think\Log;
|
|
|
use think\Env;
|
|
|
use think\Db;
|
|
|
@@ -219,24 +215,27 @@ class Ledger extends Api
|
|
|
}
|
|
|
|
|
|
$welfare_config = config('welfare_rede');
|
|
|
- if (!in_array($coin, $welfare_config['welfare_rede']['currency'])) {
|
|
|
+ if (!in_array($coin, $welfare_config['currency'])) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
|
|
|
- $BscApi = new BscApi($welfare_config['welfare_rede']['contract_address'][$coin]);
|
|
|
- $result_coin = $BscApi->getTransactionRecordsByAddress($coin_from_address, $welfare_config['welfare_rede']['transfer_address'], 49990000);
|
|
|
+ $BscApi = new BscApi($welfare_config['contract_address'][$coin]);
|
|
|
+ $result_coin = $BscApi->getTransactionRecordsByAddress($coin_from_address, $welfare_config['transfer_address'], 49990000);
|
|
|
if ($result_coin['code'] == 0) {
|
|
|
$this->error($result_coin['msg']);
|
|
|
}
|
|
|
+ Log::info($result_coin, '代币所有转入记录');
|
|
|
$coin_list = [];
|
|
|
foreach ($result_coin['data'] as $value) {
|
|
|
- if ($value['amount'] == $welfare_config['welfare_rede']['currency_price'][$coin]) {
|
|
|
+ if ($value['amount'] == $welfare_config['currency_price'][$coin]) {
|
|
|
$coin_list[] = $value;
|
|
|
}
|
|
|
}
|
|
|
if (empty($coin_list)) {
|
|
|
$this->error('未识别到代币转入记录');
|
|
|
}
|
|
|
+ Log::info($coin_list, '代币精准转入记录');
|
|
|
+
|
|
|
$coin_data = [];
|
|
|
foreach ($coin_list as $item) {
|
|
|
$check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
|
|
|
@@ -248,21 +247,26 @@ class Ledger extends Api
|
|
|
if (empty($coin_data)) {
|
|
|
$this->error('未识别到新代币转入记录');
|
|
|
}
|
|
|
+ Log::info($coin_list, '代币可用转入记录');
|
|
|
|
|
|
- $BscApi = new BscApi($welfare_config['welfare_rede']['contract_address']['USDT']);
|
|
|
- $result_usdt = $BscApi->getTransactionRecordsByAddress($usdt_from_address, $welfare_config['welfare_rede']['transfer_address'], 49990000);
|
|
|
+ $BscApi = new BscApi($welfare_config['contract_address']['USDT']);
|
|
|
+ $result_usdt = $BscApi->getTransactionRecordsByAddress($usdt_from_address, $welfare_config['transfer_address'], 49990000);
|
|
|
if ($result_usdt['code'] == 0) {
|
|
|
$this->error($result_usdt['msg']);
|
|
|
}
|
|
|
+ Log::info($result_usdt, 'USDT所有转入记录');
|
|
|
+
|
|
|
$usdt_list = [];
|
|
|
- foreach ($usdt_list['data'] as $value) {
|
|
|
- if ($value['amount'] == $welfare_config['welfare_rede']['currency_price']['USDT']) {
|
|
|
+ foreach ($result_usdt['data'] as $value) {
|
|
|
+ if ($value['amount'] == $welfare_config['currency_price']['USDT']) {
|
|
|
$usdt_list[] = $value;
|
|
|
}
|
|
|
}
|
|
|
if (empty($usdt_list)) {
|
|
|
$this->error('未识别到USDT转入记录');
|
|
|
}
|
|
|
+ Log::info($usdt_list, 'USDT精准转入记录');
|
|
|
+
|
|
|
$usdt_data = [];
|
|
|
foreach ($usdt_list as $item) {
|
|
|
$check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
|
|
|
@@ -274,6 +278,8 @@ class Ledger extends Api
|
|
|
if (empty($usdt_data)) {
|
|
|
$this->error('未识别到新USDT转入记录');
|
|
|
}
|
|
|
+ Log::info($usdt_list, 'USDT可用入记录');
|
|
|
+
|
|
|
$order_no = date('YmdHis') . rand(1000, 9999);
|
|
|
$inster_data = [
|
|
|
[
|
|
|
@@ -282,7 +288,7 @@ class Ledger extends Api
|
|
|
'user_id' => $this->auth->id,
|
|
|
'symbol' => $coin,
|
|
|
'amount' => $coin_data['amount'],
|
|
|
- 'product_id' => $welfare_config['welfare_rede']['product_id'],
|
|
|
+ 'product_id' => $welfare_config['product_id'],
|
|
|
'from_address' => $coin_data['from'],
|
|
|
'to_address' => $coin_data['to'],
|
|
|
'status' => 200,
|
|
|
@@ -294,27 +300,27 @@ class Ledger extends Api
|
|
|
'user_id' => $this->auth->id,
|
|
|
'symbol' => 'USDT',
|
|
|
'amount' => $usdt_data['amount'],
|
|
|
- 'product_id' => $welfare_config['welfare_rede']['product_id'],
|
|
|
+ 'product_id' => $welfare_config['product_id'],
|
|
|
'from_address' => $usdt_data['from'],
|
|
|
'to_address' => $usdt_data['to'],
|
|
|
'status' => 200,
|
|
|
'create_time' => time(),
|
|
|
]
|
|
|
];
|
|
|
+ Log::info($inster_data, '插入数据');
|
|
|
|
|
|
- $product_id = $welfare_config['welfare_rede']['product_id'];
|
|
|
- $product_info = (new ProductsModel())->where('id', $product_id)->find();
|
|
|
+ $product_id = $welfare_config['product_id'];
|
|
|
+ $product_info = (new ProductLists())->where('id', $product_id)->find();
|
|
|
if (empty($product_info)) {
|
|
|
$this->error('产品不存在');
|
|
|
}
|
|
|
try {
|
|
|
Db::startTrans();
|
|
|
- (new RwaExchangeRecordModel())->saveAll($inster_data);
|
|
|
-
|
|
|
- $rs = WelfareLoginc::setUserProductOrder(1, false, $order_no, $product_info['price'], $product_info['product_id'], $this->auth->id, ProductOrder::Exchange);
|
|
|
- if($rs && $product_info['price'] >= config('min_rwa_price')){
|
|
|
- (new UserModel())->updateForRwaNum($this->auth->id, UserModel::getByParentId($user_id), 1, '+');
|
|
|
- }
|
|
|
+ $rs = Db::name('rwa_exchange_record')->fetchSql(false)->insertAll($inster_data);
|
|
|
+// dump($rs);
|
|
|
+// $rs = (new RwaExchangeRecordModel())->saveAll($inster_data);
|
|
|
+ //发放产品
|
|
|
+ $rs = WelfareLoginc::setUserProductOrder(1, false, $order_no, 0, $product_info['id'], $this->auth->id, ProductOrder::Exchange);
|
|
|
Db::commit();
|
|
|
$this->success('ok', $order_no);
|
|
|
} catch (Exception $e) {
|