Beispiel #1
0
 /**
  * 添加订单第三步
  */
 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;
 }
Beispiel #2
0
 /**
  * ajax编辑
  */
 function ajax_edit()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented');
     //权限验证
     role::check('user_edit');
     $countries = array();
     $id = intval($this->input->get('id'));
     if (!$id) {
         $return_struct['code'] = 400;
         $return_struct['msg'] = Kohana::lang('o_global.bad_request');
         exit(json_encode($return_struct));
     }
     $address = Myaddress::instance($id)->get();
     $query_struct = array('where' => array('active' => 1), 'orderby' => array('position' => 'DESC', 'name' => 'ASC'));
     $site_countries = Mycountry::instance()->query_assoc($query_struct);
     foreach ($site_countries as $val) {
         $countries[$val['iso_code']] = $val['name'];
     }
     $return_template = $this->template = new View('user/address_edit');
     $this->template->address = $address;
     $this->template->countries = $countries;
     $return_str = $return_template->render();
     $return_struct['status'] = 1;
     $return_struct['code'] = 200;
     $return_struct['msg'] = 'Success';
     $return_struct['content'] = $return_str;
     exit(json_encode($return_struct));
 }