当前位置: 首页>>代码示例>>PHP>>正文


PHP Shipment::setAttributes方法代码示例

本文整理汇总了PHP中Shipment::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Shipment::setAttributes方法的具体用法?PHP Shipment::setAttributes怎么用?PHP Shipment::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shipment的用法示例。


在下文中一共展示了Shipment::setAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionGetExtTypeService

 public function actionGetExtTypeService()
 {
     $result = array('status' => 'error', 'data' => '');
     $data = array();
     if (isset($_REQUEST['Shipment'])) {
         $shipment = new Shipment();
         $shipment->setAttributes($_REQUEST['Shipment']);
         if ($shipment->customer_id != '') {
             $join = 'INNER JOIN product_service t2 ON t.id = t2.product_id INNER JOIN service_detail t3 ON t2.id = t3.product_service_id INNER JOIN rate_company_service t4 ON t4.id = t3.rate_company_service_id JOIN rate_company t5 ON t5.id = t4.rate_company_id JOIN customer_discount t6 ON t3.id = t6.service_id';
             $select = 't4.id as service_id,t2.name as service_name,t2.code,t4.name as carrier_service,t5.name vendor_name,t6.use_rate';
         } else {
             $join = 'INNER JOIN product_service t2 ON t.id = t2.product_id INNER JOIN service_detail t3 ON t2.id = t3.product_service_id INNER JOIN rate_company_service t4 ON t4.id = t3.rate_company_service_id JOIN rate_company t5 ON t5.id = t4.rate_company_id';
             $select = 't4.id as service_id,t2.name as service_name,t2.code,t4.name as carrier_service,t5.name vendor_name';
         }
         $cek_routing = RateCompany::model()->findByAttributes(array('code' => $shipment->destination_code));
         $criteria = new CDbCriteria();
         $criteria->join = $join;
         $criteria->select = $select;
         $criteria->addSearchCondition('t.name', $shipment->service_type);
         if ($shipment->customer_id != '') {
             $criteria->params[':customer_id'] = $shipment->customer_id;
             $criteria->addCondition('t6.customer_id =:customer_id AND use_rate = 1');
         }
         if ($shipment->service_type == 'City Courier') {
             if ($cek_routing instanceof RateCompany) {
                 $criteria->addSearchCondition('t5.code', $shipment->destination_code);
             } else {
                 $criteria->addSearchCondition('t5.id', 5);
             }
         }
         if ($shipment->service_type == 'Domestic') {
             $criteria->addSearchCondition('t5.code', $shipment->destination_code);
         }
         if ($shipment->service_type == 'International') {
             $criteria->addSearchCondition('t5.code', $shipment->destination_code);
             if (ucfirst($shipment->receiver_country) != 'indonesia') {
                 $criteria->addSearchCondition('t2.id', 10);
             } else {
                 $criteria->addSearchCondition('t2.id', 11);
             }
         }
         $builder = new CDbCommandBuilder(Yii::app()->db->Schema);
         $command = $builder->createFindCommand('product', $criteria);
         $services = $command->queryAll();
         if (!!$services) {
             $result = array('status' => 'success', 'data' => $services);
         }
     }
     echo CJSON::encode($result);
     Yii::app()->end();
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:51,代码来源:ServiceController.php

示例2: 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();
     }
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:47,代码来源:ShipmentController.php


注:本文中的Shipment::setAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。