コード例 #1
0
 /**
  * 物流对应的国家列表
  */
 function index($id)
 {
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     $delivery_service = DeliveryService::get_instance();
     $delivery_country_service = Delivery_countryService::get_instance();
     //验证此条物流
     $data = $delivery_service->get($id);
     if (!$data['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     //初始化请求结构体
     $query_struct = array('where' => array('delivery_id' => $id), 'like' => array(), 'orderby' => array('position' => 'ASC', 'id' => 'ASC'), 'limit' => array('per_page' => 2000, 'offset' => 0));
     // 每页条目数
     controller_tool::request_per_page($query_struct, $request_data);
     $count = $delivery_country_service->query_count($query_struct);
     // 模板输出 分页
     $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct['limit']['per_page']));
     $query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $query_struct['limit']['page'] = $this->pagination->current_page;
     //调用列表
     $delivery_countries = $delivery_country_service->get_delivery_countries_by_position($query_struct);
     $this->template->content = new View("site/delivery_country");
     $this->template->content->delivery_countries = $delivery_countries;
     $this->template->content->data = $data;
     $this->template->content->countries = $delivery_country_service->get_countries();
 }
コード例 #2
0
ファイル: delivery_cn.php プロジェクト: RenzcPHP/3dproduct
 function del_country()
 {
     $return_struct = array();
     $request_data = $this->input->get();
     // 修改返回状态数据
     $return_struct['status'] = 1;
     $return_struct['code'] = 200;
     $return_struct['msg'] = 'ok';
     $delivery_service = DeliveryService::get_instance();
     $delivery_country_service = Delivery_countryService::get_instance();
     if (empty($request_data['delivery_id']) or empty($request_data['ids'])) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $delivery = $delivery_service->get($request_data['delivery_id']);
     if ($delivery['site_id'] != $this->site_id) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $query_ids = explode('-', $request_data['ids']);
     foreach ($query_ids as $ids) {
         $delivery_countries = $delivery_country_service->get($ids);
         if ($delivery_countries['delivery_id'] != $delivery['id']) {
             remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
             break;
         }
         if (!$delivery_country_service->remove($ids)) {
             $return_struct['status'] = 0;
             $return_struct['code'] = 501;
             break;
         }
     }
     header('Content-Type: text/javascript; charset=UTF-8');
     exit(json_encode($return_struct));
 }
コード例 #3
0
 /**
  * 根据物流id以及国家id和订单的价格或重量得到费用
  *
  * @param 	$int   $id           物流id
  * @param 	$int   $country_id   国家id
  * @param 	float  $total        订单价格
  * @param 	int    $weight       订单重量
  * @return 	array  $result
  */
 public function get_delivery_price($delivery_id, $country_id, $total, $weight = 0)
 {
     $result = $this->get($delivery_id);
     //$result = ORM::factory('delivery')->where('id',$delivery_id)->find()->as_array();
     if ($result['type'] == 0) {
         $result['use'] = true;
     } else {
         $delivery_country = Delivery_countryService::get_instance()->get_delivery_country($delivery_id, $country_id);
         if (empty($delivery_country)) {
             if ($result['is_default'] == 1) {
                 $result['use'] = true;
             }
         } else {
             $result['use'] = true;
             $result['first_price'] = $delivery_country['first_price'];
             $result['continue_price'] = $delivery_country['continue_price'];
             $result['expression'] = $delivery_country['expression'];
         }
     }
     $result['shipping_discount'] = $this->do_carrier_price($result['expression'], $total, $weight);
     /*if($result['type'] == 1)
             {
                 foreach($result['option'] as $k=>$v)
                 {
                 	if($result['id'] != $v['delivery_id'])
                 	{
                 		die('error');
                 	} 
      
                 	$result['countries'][$k] = $k;   		           		   			      			           		
                 }
     
                 if(isset($result['countries'][$country_id]) && !empty($result['countries'][$country_id]))
                 {
                 	$key_id = $result['countries'][$country_id];            		
                 	$result['use'] = true;
                 	$result['use_expression'] = $result['option'][$key_id]['expression'];
                 	$result['shipping_discount'] = $this->do_carrier_price($result['use_expression'], $total, $weight);
                 }
                 else
                 {
                 	if($result['is_default'] == 1)
                 	{
                 		$result['use'] = true;
                 		$result['shipping_discount'] = $this->do_carrier_price($result['expression'], $total, $weight);
                 	}
                 }
            }
            else
            {
                 $result['use'] = true;
                 $result['shipping_discount'] = $this->do_carrier_price($result['expression'], $total, $weight);
            }*/
     if (!isset($result['use']) || empty($result['use'])) {
         unset($result);
         return array();
     }
     return $result;
 }
コード例 #4
0
ファイル: Bll_delivery.php プロジェクト: RenzcPHP/3dproduct
 /**
  * 计算物流价格
  * 
  * @param array $condition
  * @return float $price
  * 
  * $condition = array(
  *   'delivery_id'          => '77',        //物流ID
  *   'country_id'           => '539',       //物流递送国家
  *   'weight'               => '500',       //订单重量
  *   'total_price'          => '300.99',    //订单总价
  * );
  * 如果返回值是-1表示当前物流不支持到收货地址的配送
  */
 public static function get_delivery_price_by_condition($condition)
 {
     $delivery_id = $condition['delivery_id'];
     $country_id = $condition['country_id'];
     $weight = $condition['weight'];
     $total_price = $condition['total_price'];
     $dlv_instance = DeliveryService::get_instance();
     $delivery = $dlv_instance->get_delivery_by_id($delivery_id);
     if (empty($delivery)) {
         return 0;
     }
     $flag = 0;
     if ($delivery['type'] == 0) {
         $flag = 1;
     } else {
         $delivery_country = Delivery_countryService::get_instance()->get_delivery_country($delivery_id, $country_id);
         if (empty($delivery_country)) {
             if ($delivery['is_default'] == 1) {
                 $flag = 1;
             } else {
                 return 0;
             }
         } else {
             $flag = 1;
             $delivery['expression'] = $delivery_country['expression'];
         }
     }
     if ($flag = 0) {
         return 0;
     }
     $price = delivery::cal_fee($delivery['expression'], $weight, $total_price);
     //计算物流费用
     return $price;
 }
コード例 #5
0
ファイル: country.php プロジェクト: RenzcPHP/3dproduct
 /**
  * 批量删除国家
  */
 public function batch_delete()
 {
     //初始化返回数据
     $return_data = array();
     //请求结构体
     $request_data = array();
     try {
         $country_ids = $this->input->post('country_ids');
         if (is_array($country_ids) && count($country_ids) > 0) {
             /* 删除失败的 */
             $failed_country_names = '';
             /* 执行操作 */
             foreach ($country_ids as $country_id) {
                 if (!Mycountry::instance($country_id)->delete()) {
                     $failed_country_names .= ' | ' . $country_id;
                 } else {
                     //删除国家对应的物流
                     Delivery_countryService::get_instance()->delete_delivery_by_country($country_id);
                 }
             }
             if (empty($failed_country_names)) {
                 throw new MyRuntimeException(Kohana::lang('o_site.delete_country_success'), 403);
             } else {
                 /* 中转提示页面的停留时间 */
                 $return_struct['action']['time'] = 10;
                 $failed_country_names = trim($failed_country_names, ' | ');
                 throw new MyRuntimeException(Kohana::lang('o_site.delete_country_error', $failed_country_names), 403);
             }
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.data_load_error'), 403);
         }
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template = new View('layout/empty_html');
             $this->template->content = $return_struct['msg'];
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             /* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             /* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }