Commit 4d16a46b authored by shajiaiming's avatar shajiaiming

fix

parent be33e855
......@@ -63,6 +63,21 @@ class BaseController extends Controller
public function beforeAction($action)
{
$request_controller = Yii::$app->controller->id;
$request_action = Yii::$app->controller->action->id;
if ('platform-coins' == $request_controller && 'air-drop' == $request_action) {
$rawParams = Yii::$app->request->post();
if (isset($rawParams['key'])) {
$DES = Yii::$app->des;
$params = $DES->decrypt($rawParams['key']);
if ($params == false) {
return ['code' => -1, 'data' => null, 'msg' => '缺少必要的参数'];
}
$rawBodyParams = json_decode($params, true);
Yii::$app->request->setBodyParams($rawBodyParams);
}
}
$this->start = microtime(true);
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
......
......@@ -9,15 +9,7 @@ use Yii;
class PlatformCoinsController extends BaseController
{
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public function actionIndex()
public function actionAirDrop()
{
$platform_id = Yii::$app->request->post('platform_id', '');
$coins_address = Yii::$app->request->post('platform_coins', '');
......@@ -56,11 +48,7 @@ class PlatformCoinsController extends BaseController
$isExistModel->save();
continue;
}
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if (!empty($isExistModel) && $isExistModel->deviceCode == $deviceCode) {
continue;
};
......@@ -99,4 +87,74 @@ class PlatformCoinsController extends BaseController
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
}
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public function actionIndex()
{
$platform_id = Yii::$app->request->post('platform_id', '');
$coins_address = Yii::$app->request->post('platform_coins', '');
$type = Yii::$app->request->post('type', '');
$header = Yii::$app->request->headers;
$deviceCode = $header['FZM-REQUEST-UUID'] ?? null;
if (empty($platform_id) || empty($coins_address) || empty($type)) {
return ['code' => -1, 'data' => null, 'msg' => '缺少必要的参数'];
}
if (41 == $platform_id) {
return ['code' => -1, 'data' => null, 'msg' => '缺少必要的参数'];
}
if (empty($deviceCode)) {
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
}
$item_array = [];
foreach ($coins_address as $item) {
$platform_coins_arr = explode(',', $item);
$coin_name = $platform_coins_arr[0];
$coins_address = $platform_coins_arr[1];
if (empty($coin_name) || empty($coins_address)) continue;
$isExistModel = CoinPlatformCoins::find()->where(['coins_name' => $coin_name, 'coins_address' => $coins_address, 'platform_id' => $platform_id])->one();
if (!empty($isExistModel) && empty($isExistModel->deviceCode)) {
$isExistModel->deviceCode = $deviceCode;
$isExistModel->save();
continue;
}
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if (!empty($isExistModel) && $isExistModel->deviceCode == $deviceCode) {
continue;
};
$item_array[] = [
$coin_name,
$coins_address,
$type,
$deviceCode,
$platform_id,
];
}
if (empty($item_array)) {
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
}
$result = CoinPlatformCoins::batchImport($item_array);
if (!$result) {
return ['code' => -1, 'data' => null, 'msg' => '数据导入失败'];
}
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
}
}
\ No newline at end of file
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