Commit e32250b7 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

fix See merge request !462
parents 56dcefed ca337d62
...@@ -179,19 +179,22 @@ class PlatformCoinsController extends BaseController ...@@ -179,19 +179,22 @@ class PlatformCoinsController extends BaseController
foreach ($data as $val) { foreach ($data as $val) {
$address = $val['address'] ?? null; $address = $val['address'] ?? null;
$mobile = $val['mobile'] ?? null; $mobile = $val['mobile'] ?? null;
if (empty($address) || empty($mobile)) continue; $mail = $val['mail'] ?? null;
if (empty($address) || empty($mobile) || empty($mail)) continue;
$count = CoinAddress::find()->where(['address' => $address, 'mobile' => $mobile])->count(); $count = CoinAddress::find()->where(['address' => $address, 'mobile' => $mobile, 'mail' => $mail])->count();
if ($count > 0) continue; if ($count > 0) continue;
$item_array[] = [ $item_array[] = [
$address, $address,
$mobile, $mobile,
$mail
]; ];
} }
if (empty($item_array)) { if (empty($item_array)) {
goto doEnd; goto doEnd;
} }
$result = CoinAddress::batchImport(Tools::super_unique($item_array)); $result = CoinAddress::batchImport(Tools::super_unique($item_array));
if (!$result) { if (!$result) {
$this->code = -1; $this->code = -1;
......
...@@ -24,14 +24,14 @@ class CoinAddress extends BaseActiveRecord ...@@ -24,14 +24,14 @@ class CoinAddress extends BaseActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['address', 'mobile'], 'required'], [['address', 'mobile', 'mail'], 'required'],
]; ];
} }
public function scenarios() public function scenarios()
{ {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['address', 'mobile'], self:: SCENARIOS_CREATE => ['address', 'mobile', 'mail'],
]; ];
return array_merge(parent:: scenarios(), $scenarios); return array_merge(parent:: scenarios(), $scenarios);
} }
...@@ -48,10 +48,10 @@ class CoinAddress extends BaseActiveRecord ...@@ -48,10 +48,10 @@ class CoinAddress extends BaseActiveRecord
return false; return false;
} }
try { try {
$result = self::getDb()->createCommand()->batchInsert(self::tableName(), ['address', 'mobile'], $datas)->execute(); $result = self::getDb()->createCommand()->batchInsert(self::tableName(), ['address', 'mobile', 'mail'], $datas)->execute();
return $result; return $result;
} catch (\Exception $e) { } catch (\Exception $e) {
var_dump($e->getMessage());exit;
} }
return false; return false;
} }
......
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