mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
implementing new data structure for segment_constant table
This commit is contained in:
@@ -24,6 +24,11 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(CurrenciesTableSeeder::class);
|
||||
|
||||
$this->call(CompaniesTableSeeder::class);
|
||||
|
||||
$this->call(SegmentsTableSeeder::class);
|
||||
|
||||
$this->call(SegmentConstantsTableSeeder::class);
|
||||
|
||||
// $this->call(OrdersTableSeeder::class);
|
||||
}
|
||||
}
|
||||
@@ -9,126 +9,128 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SegmentConstantsTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
|
||||
private function insertData($segment_id=1, $reference, $array_data)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
|
||||
DB::table('segment_constants')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'segment_id' => 1,
|
||||
'reference' => SegmentConstants::BASE_PRICE,
|
||||
'value' => json_encode([
|
||||
'2022-05-01'=> '0.00',
|
||||
'2022-05-02'=> '0.00',
|
||||
]),
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'segment_id' => 1,
|
||||
'reference' => SegmentConstants::WAREHOUSE_RATE,
|
||||
'value' => json_encode([
|
||||
'7' =>[
|
||||
'amount' => '0.00',
|
||||
],
|
||||
'6' =>[
|
||||
'amount' => '0.00',
|
||||
],
|
||||
]),
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'segment_id' => 1,
|
||||
'reference' => SegmentConstants::STATE_RATE,
|
||||
'value' => json_encode([
|
||||
'1' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'2' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'3' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'4' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'5' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'6' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'7' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'8' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'9' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'10' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'11' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'12' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'13' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'14' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'15' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
],
|
||||
'16' =>[
|
||||
'center' => '10.00',
|
||||
'outstation' => '2.00'
|
||||
]
|
||||
]),
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'segment_id' => 1,
|
||||
'reference' => SegmentConstants::CENTER_POSTCODE,
|
||||
'value' => json_encode(['80050','80100','80150','80200','80250','80300','80350','80400','80500','80506','80508','80516','80519','80534','80536','80542','80546','80558','80560','80564','80568','80578','80584','80586','80590','80592','80594','80596','80600','80604','80608','80620','80622','80628','80644','80648','80662','80664','80668','80670','80672','80673','80676','80700','80710','80720','80730','80900','80902','80904','80906','80908','80988','80990','81000','81100','81200','81300','81310']),
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'segment_id' => 1,
|
||||
'reference' => SegmentConstants::OUTSTATION_POSTCODE,
|
||||
'value' => json_encode(['80000']),
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'segment_id' => 2,
|
||||
'reference' => SegmentConstants::CUSTOMER_RATE,
|
||||
'value' => json_encode([
|
||||
'id'=> 1,
|
||||
'price' => 15,
|
||||
]),
|
||||
],
|
||||
'segment_id' => $segment_id,
|
||||
'reference' => $reference,
|
||||
'value' => json_encode($array_data)
|
||||
]);
|
||||
DB::commit();
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
// insert base prices
|
||||
$n_days = 10; // for the 10 days ahead
|
||||
$today = date("Y-m-d");
|
||||
$prices = [];
|
||||
for($ii=0; $ii<$n_days;$ii++){
|
||||
$prices[] = [
|
||||
"date" => date('Y-m-d', strtotime($today. ' + '.$ii.' days')),
|
||||
"price" => rand(10, 30) / 10
|
||||
];
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::BASE_PRICE, $prices);
|
||||
|
||||
// insert state prices
|
||||
$prices = [];
|
||||
for($ii=1; $ii<=16;$ii++){
|
||||
$prices[] = [
|
||||
'state_id' => $ii,
|
||||
'center' => '10.00',
|
||||
'outstation'=> '2.00'
|
||||
];
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::STATE_RATE, $prices);
|
||||
|
||||
// insert warehouse prices
|
||||
$prices = [];
|
||||
for($ii=1; $ii<=7;$ii++){
|
||||
$prices[] = [
|
||||
'warehouse_id' => $ii,
|
||||
'amount' => '1.'.$ii
|
||||
];
|
||||
}
|
||||
$this->insertData(1, SegmentConstants::WAREHOUSE_RATE, $prices);
|
||||
|
||||
// insert center postcodes
|
||||
$prices = [
|
||||
[ 'post_code' => '80050' ],
|
||||
[ 'post_code' => '80100' ],
|
||||
[ 'post_code' => '80150' ],
|
||||
[ 'post_code' => '80200' ],
|
||||
[ 'post_code' => '80250' ],
|
||||
[ 'post_code' => '80300' ],
|
||||
[ 'post_code' => '80350' ],
|
||||
[ 'post_code' => '80400' ],
|
||||
[ 'post_code' => '80500' ],
|
||||
[ 'post_code' => '80506' ],
|
||||
[ 'post_code' => '80508' ],
|
||||
[ 'post_code' => '80516' ],
|
||||
[ 'post_code' => '80519' ],
|
||||
[ 'post_code' => '80534' ],
|
||||
[ 'post_code' => '80536' ],
|
||||
[ 'post_code' => '80542' ],
|
||||
[ 'post_code' => '80546' ],
|
||||
[ 'post_code' => '80558' ],
|
||||
[ 'post_code' => '80560' ],
|
||||
[ 'post_code' => '80564' ],
|
||||
[ 'post_code' => '80568' ],
|
||||
[ 'post_code' => '80578' ],
|
||||
[ 'post_code' => '80584' ],
|
||||
[ 'post_code' => '80586' ],
|
||||
[ 'post_code' => '80590' ],
|
||||
[ 'post_code' => '80592' ],
|
||||
[ 'post_code' => '80594' ],
|
||||
[ 'post_code' => '80596' ],
|
||||
[ 'post_code' => '80600' ],
|
||||
[ 'post_code' => '80604' ],
|
||||
[ 'post_code' => '80608' ],
|
||||
[ 'post_code' => '80620' ],
|
||||
[ 'post_code' => '80622' ],
|
||||
[ 'post_code' => '80628' ],
|
||||
[ 'post_code' => '80644' ],
|
||||
[ 'post_code' => '80648' ],
|
||||
[ 'post_code' => '80662' ],
|
||||
[ 'post_code' => '80664' ],
|
||||
[ 'post_code' => '80668' ],
|
||||
[ 'post_code' => '80670' ],
|
||||
[ 'post_code' => '80672' ],
|
||||
[ 'post_code' => '80673' ],
|
||||
[ 'post_code' => '80676' ],
|
||||
[ 'post_code' => '80700' ],
|
||||
[ 'post_code' => '80710' ],
|
||||
[ 'post_code' => '80720' ],
|
||||
[ 'post_code' => '80730' ],
|
||||
[ 'post_code' => '80900' ],
|
||||
[ 'post_code' => '80902' ],
|
||||
[ 'post_code' => '80904' ],
|
||||
[ 'post_code' => '80906' ],
|
||||
[ 'post_code' => '80908' ],
|
||||
[ 'post_code' => '80988' ],
|
||||
[ 'post_code' => '80990' ],
|
||||
[ 'post_code' => '81000' ],
|
||||
[ 'post_code' => '81100' ],
|
||||
[ 'post_code' => '81200' ],
|
||||
[ 'post_code' => '81300' ],
|
||||
[ 'post_code' => '81310' ]
|
||||
];
|
||||
$this->insertData(1, SegmentConstants::CENTER_POSTCODE, $prices);
|
||||
|
||||
// insert outstation prices
|
||||
$prices = [
|
||||
['post_code' => '80000' ]
|
||||
];
|
||||
$this->insertData(1, SegmentConstants::OUTSTATION_POSTCODE, $prices);
|
||||
|
||||
// insert customer prices
|
||||
$prices = [
|
||||
['id'=> 1, 'price' => 15 ]
|
||||
];
|
||||
$this->insertData(2, SegmentConstants::CUSTOMER_RATE, $prices);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user