/** * 物流对应的国家列表 */ 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(); }
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)); }
/** * 添加订单第三步 */ function add_again() { /*权限检查*/ role::check('order_add'); if (!$_POST) { remind::set(Kohana::lang('o_order.change_site'), 'order/order_add', 'error'); } $user_id = $this->input->post('user_id'); $email = $this->input->post('email'); /* 存放用户添加货品的信息 */ $cart_data = array(); /* 订单产品的总价 */ $good_price = 0; $shipping_price = 10; $good_info = array(); $address_info = array(); /* 得到国家列表*/ $country_query_struct = array('where' => array('active' => 1), 'orderby' => array('id' => 'ASC')); $country_list = Mycountry::instance()->query_assoc($country_query_struct); if (empty($country_list)) { remind::set(Kohana::lang('o_order.no_country'), 'order/order_add', 'error'); } /* 得到默认地址信息*/ $address_query_struct = array('where' => array('user_id' => $user_id), 'limit' => array('per_page' => 1, 'offset' => 0), 'orderby' => array('date_add' => 'DESC')); $address = Myaddress::instance()->query_assoc($address_query_struct); if (!empty($address)) { foreach ($address as $value) { $address_info = $value; } } /*得到站点物流方式*/ $carrier_list = DeliveryService::get_instance()->select_list(); if (empty($carrier_list)) { remind::set(Kohana::lang('o_order.no_carrier'), 'order/order_add', 'error'); } $query_struct = array('where' => array()); $currency_info = Mycurrency::instance()->query_assoc($query_struct); /*处理已选中货品信息*/ $good_amount = $this->input->post('amount'); foreach ($good_amount as $key => $value) { if ($value <= 0) { continue; } $good = ProductService::get_instance()->get($key); if ($good['store'] <= 0 && $value > 999) { $value = 999; } if ($good['store'] > 0 && $value > $good['store']) { $value = $good['store']; } /* 计算总价 */ $good_price += $good['price'] * $value; $good['cart_num'] = $value; $good_info[] = $good; $cart_data[$key] = $value; } /*session*/ $this->session = Session::instance(); $this->session->set('cart_data', $cart_data); /*模板输出*/ $this->template->content = new view("order/order_add_3"); $this->template->content->good_price = $good_price; $this->template->content->shipping_price = $shipping_price; $this->template->content->user_id = $user_id; $this->template->content->email = $email; $this->template->content->country_list = $country_list; $this->template->content->carrier_list = $carrier_list; $this->template->content->currency_info = $currency_info; $this->template->content->address_info = $address_info; $this->template->content->good_info = $good_info; }
/** * 显示退货单细节 */ public function return_detail($id) { /* 权限检查*/ role::check('order_doc_return'); $return = Myorder_return_log::instance($id)->get(); $ship_status = Kohana::config('order.ship_status'); $return_list = array(); $return_list['id'] = $return['id']; //退货单id $return_list['return_num'] = $return['return_num']; //退货单号 $return_list['order_num'] = Myorder::instance($return['order_id'])->get('order_num'); //订单号 $return_list['carrier'] = DeliveryService::get_instance()->get_delivery_name($return['carrier_id']); $return_list['email'] = $return['email']; //用户邮箱 $return_list['manager'] = Mymanager::instance($return['manager_id'])->get('username'); //操作员 $return_list['currency'] = $return['currency']; //币种 $return_list['total_shipping'] = $return['total_shipping']; //运费金额 $return_list['return_status'] = $ship_status[$return['return_status_id']]['name']; //退货状态 $return_list['content_admin'] = $return['content_admin']; //管理员备注 $return_list['content_user'] = $return['content_user']; //用户备注 $return_list['date_add'] = $return['date_add']; //添加时间 /* 得到订单货品信息 */ $return_list['return_data'] = array(); $return_data = unserialize($return['return_data']); $order_products = Myorder_product::instance()->get_order_products_by_order_id($return['order_id']); foreach ($order_products as $val) { foreach ($return_data as $k => $v) { if ($v['id'] == $val['id']) { $return_list['return_data'][$k]['SKU'] = $val['SKU']; $return_list['return_data'][$k]['name'] = $val['name']; $return_list['return_data'][$k]['attribute_style'] = empty($val['attribute_style']) ? '默认' : $val['attribute_style']; $return_list['return_data'][$k]['quantity'] = $val['quantity']; $return_list['return_data'][$k]['sendnum'] = isset($v['send_num']) ? $v['send_num'] : '未知'; $return_list['return_data'][$k]['returnnum'] = $v['return_num']; } } } $this->template = new View('layout/commonfix_html'); $this->template->content = new view("order/order_doc/doc_detail/return_detail"); $this->template->content->return_list = $return_list; }
public static function get_delivery($id) { return DeliveryService::get_instance()->get($id); }