You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.8 KiB
79 lines
1.8 KiB
<?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' => 10],
|
|
['amount' => '30.00', 'weight' => 10],
|
|
['amount' => '50.00', 'weight' => 10],
|
|
['amount' => '100.00', 'weight' => 10],
|
|
['amount' => '500.00', 'weight' => 10],
|
|
['amount' => '1000.00', 'weight' => 10],
|
|
['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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|