3 changed files with 101 additions and 0 deletions
@ -0,0 +1,79 @@ |
|||
<?php |
|||
|
|||
namespace app\logic; |
|||
|
|||
use app\model\AdminUser; |
|||
use app\model\ZoneAmountParam; |
|||
|
|||
class InitData |
|||
{ |
|||
|
|||
public function init() |
|||
{ |
|||
$admin = AdminUser::where('id','>=',1)->find(); |
|||
if ($admin) return false; |
|||
|
|||
$this->createAdmin(); |
|||
$this->createZoneAmountParam(); |
|||
$this->createZone(); |
|||
} |
|||
|
|||
|
|||
public function createAdmin() |
|||
{ |
|||
AdminUser::createAdmin(); |
|||
return true; |
|||
} |
|||
|
|||
public function createZoneAmountParam() |
|||
{ |
|||
|
|||
$ZoneAmountParam = new ZoneAmountParam(); |
|||
$query = $ZoneAmountParam->where('id','>=',1)->find(); |
|||
if ($query) return false; |
|||
|
|||
$defaultArr = [ |
|||
['amount' => '10.00', 'weight' => 10], |
|||
['amount' => '20.00', 'weight' => 20], |
|||
['amount' => '30.00', 'weight' => 10], |
|||
['amount' => '50.00', 'weight' => 50], |
|||
['amount' => '100.00', 'weight' => 40], |
|||
['amount' => '500.00', 'weight' => 30], |
|||
['amount' => '1000.00', 'weight' => 20], |
|||
['amount' => '100000.00', 'weight' => 10], |
|||
['amount' => '1000000.00', 'weight' => 1], |
|||
]; |
|||
$ZoneAmountParam->saveAll($defaultArr); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
public function createZone() |
|||
{ |
|||
$Zone = new \app\model\Zone(); |
|||
$query = $Zone->where('id','>=',1)->find(); |
|||
if ($query) return false; |
|||
|
|||
$defaultArr = [ |
|||
['title' => '3元专区'], |
|||
['title' => '5元专区'], |
|||
['title' => '10元专区'], |
|||
['title' => '20元专区'], |
|||
['title' => '30元专区'], |
|||
['title' => '50元专区'] |
|||
]; |
|||
|
|||
foreach ($defaultArr as $data) { |
|||
|
|||
$zone = \app\model\Zone::create($data); |
|||
$zone_id = $zone->id; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
Loading…
Reference in new issue