Commit 1c1180ff authored by shajiaiming's avatar shajiaiming

fix

parent f85af2b0
...@@ -106,8 +106,7 @@ class PlatformCoinsController extends BaseController ...@@ -106,8 +106,7 @@ class PlatformCoinsController extends BaseController
$platform_id = Yii::$app->request->post('platform_id', ''); $platform_id = Yii::$app->request->post('platform_id', '');
$coins_address = Yii::$app->request->post('platform_coins', ''); $coins_address = Yii::$app->request->post('platform_coins', '');
$type = Yii::$app->request->post('type', ''); $type = Yii::$app->request->post('type', '');
$mobile = Yii::$app->request->post('mobile', ''); $contact = Yii::$app->request->post('contact', '');
$mail = Yii::$app->request->post('mail', '');
$header = Yii::$app->request->headers; $header = Yii::$app->request->headers;
$deviceCode = $header['FZM-REQUEST-UUID'] ?? null; $deviceCode = $header['FZM-REQUEST-UUID'] ?? null;
...@@ -126,48 +125,28 @@ class PlatformCoinsController extends BaseController ...@@ -126,48 +125,28 @@ class PlatformCoinsController extends BaseController
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功']; return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
} }
$item_array = [];
foreach ($coins_address as $item) { foreach ($coins_address as $item) {
$platform_coins_arr = explode(',', $item); $platform_coins_arr = explode(',', $item);
$coin_name = $platform_coins_arr[0]; $coin_name = $platform_coins_arr[0];
$coins_address = $platform_coins_arr[1]; $coins_address = $platform_coins_arr[1];
if (empty($coin_name) || empty($coins_address)) continue; 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(); $isExistModel = CoinPlatformCoins::find()->where(['coins_name' => $coin_name, 'coins_address' => $coins_address, 'contact' => $contact])->one();
if (!empty($isExistModel) && empty($isExistModel->deviceCode)) { if ($isExistModel) {
$isExistModel->update_time = date('Y-m-d H:i:s');
} else {
$isExistModel->coins_name = $coin_name;
$isExistModel->coins_address = $coins_address;
$isExistModel->type = $type;
$isExistModel->deviceCode = $deviceCode; $isExistModel->deviceCode = $deviceCode;
$isExistModel->save(); $isExistModel->platform_id = $platform_id;
continue; $isExistModel->device = $device;
$isExistModel->version = $version;
$isExistModel->contact = $contact;
} }
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) { $isExistModel->save();
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if (!empty($isExistModel) && $isExistModel->deviceCode == $deviceCode) {
continue;
};
$item_array[] = [
$coin_name,
$coins_address,
$type,
$deviceCode,
$platform_id,
$device,
$version,
$mobile,
$mail
];
}
if (empty($item_array)) {
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
} }
$result = CoinPlatformCoins::batchImport($item_array); return ['code' => $this->code, 'data' => $this->data, 'msg' => $this->msg];
if (!$result) {
return ['code' => -1, 'data' => null, 'msg' => '数据导入失败'];
}
return ['code' => 0, 'data' => null, 'msg' => '数据导入成功'];
} }
public function actionRelation() public function actionRelation()
......
...@@ -26,14 +26,14 @@ class CoinPlatformCoins extends BaseActiveRecord ...@@ -26,14 +26,14 @@ class CoinPlatformCoins extends BaseActiveRecord
{ {
return [ return [
[['coins_name', 'coins_address', 'type', 'deviceCode', 'platform_id'], 'required'], [['coins_name', 'coins_address', 'type', 'deviceCode', 'platform_id'], 'required'],
[['device', 'version', 'mobile', 'mail'], 'safe'], [['device', 'version', 'contact'], 'safe'],
]; ];
} }
public function scenarios() public function scenarios()
{ {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['coins_name', 'coins_address', 'type', 'deviceCode', 'platform_id', 'device', 'version', 'mobile', 'mail'], self:: SCENARIOS_CREATE => ['coins_name', 'coins_address', 'type', 'deviceCode', 'platform_id', 'device', 'version', 'contact'],
]; ];
return array_merge(parent:: scenarios(), $scenarios); return array_merge(parent:: scenarios(), $scenarios);
} }
......
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