Commit 8add2c6c authored by shajiaiming's avatar shajiaiming

dapp trade log

parent aa154486
......@@ -12,13 +12,25 @@ use api\base\BaseController;
use common\models\psources\CoinDailyStatistics;
use common\models\psources\CoinDailyNumbers;
use common\models\psources\CoinDailyTimes;
use common\service\chain33\Chain33Service;
use Yii;
class VisitStatisticsController extends BaseController
{
/**
* 单个DAPP停留时长
*
* @param string $dapp_name
* @param string $identify
* @param string $duration
* @param string $dapp_address
* @param string $coins_address
* @param string $platform_id
* @return array
*/
public function actionIndex()
{
$dapp_name = Yii::$app->request->get('dapp_name', '');
$identify = Yii::$app->request->get('identify', '');
$duration = Yii::$app->request->get('duration', '');
......@@ -50,6 +62,16 @@ class VisitStatisticsController extends BaseController
}
}
/**
* 日打开/进入DAPP的个数/次数
*
* @param string $dapp_name
* @param string $dapp_address
* @param string $coins_address
* @param string $platform_id
* @return array
*/
public function actionDailyTimes()
{
$dapp_name = Yii::$app->request->get('dapp_name', '');
......@@ -82,4 +104,46 @@ class VisitStatisticsController extends BaseController
return ['code' => -1,'data' => [], 'msg' => current($model_coinDailyTimes->firstErrors)];
}
}
/**
* 获取coin地址下DAPP交易信息
*
* @param string $coins_address
* @return array
*/
public function actionDappResult()
{
$coins_address = Yii::$app->request->get('coins_address', '');
if(empty($coins_address)){
return ['code' => -1,'data' => [], 'msg' => '缺少必要的参数'];
}
$service = new Chain33Service();
$result = $service->getDappTradeResult($coins_address);
if( 0 !== $result['code']){
return ['code' => -1,'data' => [], 'msg' => $result['msg']];
}
$queryResultItems = $result['result'] ?? [];
if(empty($queryResultItems)){
return ['code' => -1,'data' => [], 'msg' => 'error'];
}
$resultJSON = json_decode($queryResultItems['queryResultItems'][0]['resultJSON'],true);
$betting_times = $resultJSON['betting_times'] ?? 0;
$betting_amount = $resultJSON['betting_amount'] ?? 0;
$earnings = $resultJSON['earnings'] ?? 0;
$data = [
'betting_times' => $betting_times,
'betting_amount' => $betting_amount,
'earnings' => $earnings
];
return ['code' => 0,'data' => $data, 'msg' => 'ok'];
}
}
\ No newline at end of file
......@@ -63,6 +63,32 @@ class Chain33Service
}
/**
* 获取coin地址下DAPP交易信息
*
* @param string|array $address
* @return array
*/
public function getDappTradeResult($address)
{
$params = [
'execer' => 'wasm',
'funcName' => 'WasmGetContractTable',
'payload' => [
'contractName' => 'user.p.tschain.user.wasm.dice',
'items' => [
[
'tableName' => 'addrinfo',
'key' => 'addrinfo-' . $address
]
]
]
];
return $this->send($params);
}
/**
* 获取地址下的所有token资产
*
* @param string|array $address
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment