Commit 1c1180ff authored by shajiaiming's avatar shajiaiming

fix

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