-
-
Save y1j2t/8de067a0a6145ab0ba2c825bf38278fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Optimizing { | |
protected function newGetCodeV2($storehouse, $info, $config){ | |
if ($storehouse['us_area'] == StorehouseConstant::US_SOUTH) { | |
if ($storehouse['name'] != 'KC-GA2'){ | |
//1.实重在0-70lbs且无oversize | |
if ($info['weight'] <= 70 && !in_array($info['type'], [3])) { // oversize | |
return $config['US_SOUTH']['normal']['oversize'] ?? 'GANW-FEDEX-HD'; | |
//1.0-70lbs且有oversize 2.70lbs以上全部 | |
} else { | |
return $config['US_SOUTH']['normal']['normal'] ?? 'GANW-FEDEX-GROUND'; | |
} | |
} | |
} | |
$config = $this->newGetCodeAreaConf($storehouse, $config); | |
if (in_array($info['type'], [3, 4])) { | |
// oversize or out-space | |
$code = $config['oversize'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'oversize'); | |
} elseif ($info['weight'] > 70) { | |
$code = $config['ahs_weight'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'ahs_weight'); | |
} elseif ($info['weight'] >= 47 && $info['weight'] <= 70) { | |
// AHS Weight | |
$code = $config['weight_range'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'weight_range'); | |
} elseif ($info['type'] == 1) { | |
// AHS DIM | |
$code = $config['ahs'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'ahs'); | |
} elseif ($info['weight'] >= 16 && $info['weight'] <= 46) { | |
// normal | |
$code = $config['normal'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'normal'); | |
} else { | |
// UPS | |
$code = $config['ups'] ?? $this->newGetCodeDefVal($storehouse['us_area'], 'normal'); | |
} | |
return $code; | |
} | |
private function newGetCodeAreaConf($storehouse, $config){ | |
if ($storehouse['us_area'] == StorehouseConstant::US_WEST) { | |
return $config['US_WEST']['normal']; | |
} elseif ($storehouse['us_area'] == StorehouseConstant::US_SOUTH) { | |
if ($storehouse['name'] == 'KC-GA2') { | |
return $config['US_SOUTH']['GA']; | |
} | |
} else { | |
return $config['US_EAST']['normal']; | |
} | |
} | |
private function newGetCodeDefVal($area, $index){ | |
switch ($area){ | |
case StorehouseConstant::US_WEST: | |
return [ | |
'oversize' => 'FEDEXOVERSIZE', | |
'ahs_weight' => 'FEDEX-OS-GROUND', | |
'weight_range' => 'FEDEX-WEIGHT-HOME', | |
'ahs' => 'FEDEX-WEIGHT-HOME', | |
'normal' => 'FEDEX-HOMEDELIVERY', | |
'ups' => 'UPSGROUND', | |
][$index]; | |
case StorehouseConstant::US_SOUTH: | |
return [ | |
'oversize' => 'FEDEXOVERSIZE', | |
'ahs_weight' => 'GASA-FEDEX-GROUND', | |
'weight_range' => 'GASA-FEDEX-HD', | |
'ahs' => 'GASA-FEDEX-HD', | |
'normal' => 'FEDEX-HOMEDELIVERY', | |
'ups' => 'UPSGROUND', | |
][$index]; | |
default: | |
return [ | |
'oversize' => 'FEDEXOVERSIZE', | |
'ahs_weight' => 'FEDEX-GROUND', | |
'weight_range' => 'FEDEX-HD-NJ', | |
'ahs' => 'FEDEX-HD-NJ', | |
'normal' => 'FEDEX-HOMEDELIVERY', | |
'ups' => 'UPSGROUND', | |
][$index]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment