本文整理汇总了PHP中Area::getZoneID方法的典型用法代码示例。如果您正苦于以下问题:PHP Area::getZoneID方法的具体用法?PHP Area::getZoneID怎么用?PHP Area::getZoneID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area::getZoneID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionGetExtRoutingCode
public function actionGetExtRoutingCode()
{
$result = array('status' => 'error', 'data' => '');
$data = array();
if (isset($_GET['country']) && isset($_GET['postal'])) {
$country = ucfirst($_GET['country']);
$postal = $_GET['postal'];
if ($country != 'Indonesia') {
$routings = RateCompany::model()->findAllByAttributes(array('is_international' => 1));
if (count($routings) != 0) {
foreach ($routings as $routing) {
array_push($data, array('code' => $routing->code));
}
$result = array('status' => 'success', 'data' => $data, 'service_type' => 'International');
}
} else {
$routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $postal));
if ($routing instanceof IntraCityRouting) {
array_push($data, array('code' => $routing->code));
$result = array('status' => 'success', 'data' => $data, 'service_type' => 'City Courier');
} else {
$area = Area::getZoneID($postal);
if (!!$area) {
$routings = RateCompany::model()->findAllByAttributes(array('is_domestic' => 1));
if (count($routings) != 0) {
foreach ($routings as $routing) {
array_push($data, array('code' => $routing->code));
}
$result = array('status' => 'success', 'data' => $data, 'service_type' => 'Domestic');
}
}
}
}
echo CJSON::encode($result);
Yii::app()->end();
}
}
示例2: actionImportCSV
public function actionImportCSV()
{
ini_set('max_execution_time', 300);
$this->layout = '//layouts/column2';
$model = new UserImportForm();
$failed_to_insert = array();
$exist_postcode = array();
$next_kg = -1;
$first_kg = -1;
$min_trans = -1;
$max_trans = -1;
$zone_id = -1;
$district_id = -1;
if (isset($_POST['UserImportForm'])) {
$model->attributes = $_POST['UserImportForm'];
if ($model->validate()) {
$csvFile = CUploadedFile::getInstance($model, 'file');
$tempLoc = $csvFile->getTempName();
$rawdatas = file($tempLoc);
try {
$connection = Yii::app()->db;
$transaction = $connection->beginTransaction();
$sql = "INSERT INTO rate_domestic (service_id, origin_id, first_kg, next_kg, min_transit_time,max_transit_time,zone_id,district_id) VALUES(:service_id, :origin_id, :first_kg, :next_kg, :min_transit_time, :max_transit_time,:zone_id,:district_id)";
$command = $connection->createCommand($sql);
$command->bindValue(":service_id", $model->service_id, PDO::PARAM_INT);
$command->bindValue(":origin_id", $model->origin_id, PDO::PARAM_INT);
$command->bindParam(':zone_id', $zone_id);
$command->bindParam(':district_id', $district_id);
$command->bindParam(':first_kg', $first_kg);
$command->bindParam(':next_kg', $next_kg);
$command->bindParam(':min_transit_time', $min_trans);
$command->bindParam(':max_transit_time', $max_trans);
foreach ($rawdatas as $rates) {
$rate = explode(',', $rates);
if (!in_array($rate[0], $exist_postcode, true)) {
$exist_postcode[] = $rate[0];
// var_dump($rate[1]);
// if (!is_numeric($rate[1]) || !is_numeric($rate[2]) || !is_numeric($rate[3]))
// {
// $failed_to_insert[] = $rate[0];
// continue;
// }
$postcode_data = Area::getZoneID($rate[0]);
$checkZoneId = RateDomestic::checkZoneId($model->service_id, $model->origin_id, $postcode_data['zone_id']);
if ($checkZoneId) {
continue;
}
$first_kg = $rate[1];
$next_kg = $rate[2];
$min_trans = $rate[3];
$max_trans = $rate[4];
$zone_id = $postcode_data['zone_id'];
$district_id = $postcode_data['district_id'];
if (!!$postcode_data) {
$exec = $command->execute();
}
}
}
$transaction->commit();
} catch (Exception $e) {
CVarDumper::dump($e, 10, TRUE);
exit;
$transaction->rollBack();
}
}
}
$this->render("importcsv", array('model' => $model));
}
示例3: bulkOrder
public static function bulkOrder($rawdatas, $customer, $contact, $routing_code)
{
$failed = array();
$success = array();
$line_error = array();
$counter = 0;
$column = array();
foreach ($rawdatas as $data) {
$valid_area = true;
if ($counter++ == 0) {
continue;
}
$column = explode(',', $data);
$shipment = new Shipment();
if (count($column) == 21) {
//account detail
$shipment->setAttribute('customer_id', $customer->id);
$shipment->setAttribute('origin_code', $routing_code);
//shipper_detail
$shipment->setAttribute('shipper_name', trim($column[2]));
$shipment->setAttribute('shipper_company_name', trim($column[1]));
$shipment->setAttribute('shipper_address', trim($column[3]));
$shipment->setAttribute('shipper_city', trim($column[5]));
$shipment->setAttribute('shipper_country', trim($column[6]));
$shipment->setAttribute('shipper_postal', trim($column[7]));
$shipment->setAttribute('shipper_phone', trim($column[4]));
//receiver_detail
$shipment->setAttribute('receiver_name', trim($column[9]));
$shipment->setAttribute('receiver_company_name', trim($column[8]));
$shipment->setAttribute('receiver_address', trim($column[10]));
$shipment->setAttribute('receiver_city', trim($column[12]));
$shipment->setAttribute('receiver_country', trim($column[13]));
$shipment->setAttribute('receiver_postal', trim($column[14]));
$shipment->setAttribute('receiver_phone', trim($column[11]));
//shipment_detail
$shipment->setAttribute('type', 'document');
$shipment->setAttribute('payer', 'shipper');
$shipment->setAttribute('payby', 'account');
$shipment->setAttribute('pieces', trim($column[15]));
$shipment->setAttribute('package_weight', trim($column[16]));
$shipment->setAttribute('package_value', trim($column[17]));
$shipment->setAttribute('service_type', trim($column[18]));
$shipment->setAttribute('service_id', trim($column[19]));
$shipment->setAttribute('service_code', trim($column[20]));
$shipment->setAttribute('destination_code', trim($column[0]));
$customer_rate = CustomerDiscount::getCustomerDiscountRate($shipment->service_id, $shipment->customer_id);
if (!!$customer_rate) {
if ($customer_rate['discount'] == null) {
$customer_rate['discount'] = 0;
}
switch ($shipment->service_type) {
case 'City Courier':
$rate = RateCity::model()->findByAttributes(array('service_id' => $shipment->service_id));
if ($rate instanceof RateCity) {
if ($customer_rate['harga_invoice'] != 0) {
$price = $customer_rate['harga_invoice'] * RateCity::increment($shipment->package_weight, $rate->weight_inc);
} else {
$price = ($rate->price - $rate->price * ($customer_rate['discount'] / 100)) * RateCity::increment($shipment->package_weight, $rate->weight_inc);
}
$price_vendor = ($rate->price - $rate->price * ($customer_rate['vendor_discount'] / 100)) * RateCity::increment($shipment->package_weight, $rate->weight_inc);
} else {
$area = Area::getZoneID($shipment->receiver_postal);
if (!$area) {
$price = 0;
$price_vendor = 0;
$valid_area = false;
} else {
$price = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight, $customer_rate['discount']);
$price_vendor = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight, $customer_rate['vendor_discount']);
}
}
break;
case 'Domestic':
$area = Area::getZoneID($shipment->receiver_postal);
if (!$area) {
$price = 0;
$price_vendor = 0;
$valid_area = false;
} else {
$price = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight, $customer_rate['discount']);
$price_vendor = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight, $customer_rate['vendor_discount']);
}
break;
case 'International':
$zone = FALSE;
if ($shipment->service_code == 'IEX') {
$country = $shipment->receiver_country;
} else {
if ($shipment->service_code == 'IMX') {
$country = $shipment->shipper_country;
}
}
$zone = ZoneInternational::getZoneCountryData($country);
if (!!$zone) {
$price = RateInternational::getRatePrice($shipment->service_id, $shipment->package_weight, $shipment->type, $zone, $customer_rate['discount']);
$price_vendor = RateInternational::getRatePrice($shipment->service_id, $shipment->package_weight, $shipment->type, $zone, $customer_rate['vendor_discount']);
} else {
$price = 0;
$price_vendor = 0;
$valid_area = false;
//.........这里部分代码省略.........
示例4: actionGetExtRate
public function actionGetExtRate()
{
if (Yii::app()->request->isAjaxRequest) {
$result = array('status' => 'error', 'data' => '');
$data = array();
if (isset($_POST['Shipment'])) {
$shipment = new Shipment();
$shipment->setAttributes($_POST['Shipment']);
switch ($shipment->service_type) {
case 'City Courier':
$rate = RateCity::model()->findByAttributes(array('service_id' => $shipment->service_id));
if ($rate instanceof RateCity) {
$price = $rate->price * RateCity::increment($shipment->package_weight, $rate->weight_inc);
} else {
$area = Area::getZoneID($shipment->receiver_postal);
$price = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight);
}
$result = array('status' => 'success', 'data' => $price);
break;
case 'Domestic':
$area = Area::getZoneID($shipment->receiver_postal);
$price = RateDomestic::getRatePrice($shipment->service_id, 1, $area['district_id'], $area['zone_id'], $shipment->package_weight);
$result = array('status' => 'success', 'data' => $price);
break;
case 'International':
$zone = FALSE;
if ($shipment->service_code == 'IEX') {
$country = $shipment->receiver_country;
} else {
if ($shipment->service_code == 'IMX') {
$country = $shipment->shipper_country;
}
}
$zone = ZoneInternational::getZoneCountryData($country);
if (!!$zone) {
$price = RateInternational::getRatePrice($shipment->service_id, $shipment->package_weight, $shipment->type, $zone);
$result = array('status' => 'success', 'data' => $price);
}
break;
case '':
continue;
}
}
echo CJSON::encode($result);
Yii::app()->end();
}
}