/** * 数据列表 */ public function index() { role::check('product_attribute'); $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); // 执行业务逻辑 //* 初始化默认查询结构体 */ $query_struct_default = array('where' => array('apply' => self::ATTRIBUTE_TYPE), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'page' => 1)); //* 初始化当前查询结构体 */ $query_struct_current = array(); //* 设置合并默认查询条件到当前查询结构体 */ $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('name' => 'ASC'), 3 => array('name' => 'DESC'), 4 => array('order' => 'ASC'), 5 => array('order' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $attribute_service = AttributeService::get_instance(); $count = $attribute_service->count($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $attribute_service->get_attribute_options($query_struct_current); //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View('product/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = '规格管理'; $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $request_data, $return_struct); } }
/** * 物流对应的地区列表 */ function index($id) { if (!$id) { remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error'); } $deliverycn_service = DeliverycnService::get_instance(); $deliverycn_region_service = Deliverycn_regionService::get_instance(); //验证此条物流 $data = $deliverycn_service->get($id); if (!$data['id']) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } //初始化请求结构体 $query_struct = array('where' => array('deliverycn_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 = $deliverycn_region_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; //调用列表 $deliverycn_regions = $deliverycn_region_service->get_delivery_regions_by_position($query_struct); $this->template->content = new View("site/deliverycn/region"); $this->template->content->deliverycn_regions = $deliverycn_regions; $this->template->content->data = $data; $this->template->content->regions = $deliverycn_region_service->get_regions(); }
/** * 数据列表 */ public function index() { role::check('product_rush'); $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = $rid = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); // 执行业务逻辑 //* 初始化默认查询结构体 */ $query_struct_current = array('where' => array(), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'page' => 1)); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('title' => 'ASC'), 3 => array('title' => 'DESC'), 4 => array('start_time' => 'ASC'), 5 => array('end_time' => 'DESC'), 6 => array('position' => 'DESC'), 7 => array('position' => 'ASC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $product_rush_service = Product_rushService::get_instance(); $count = $product_rush_service->count($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $product_rush_service->index($query_struct_current); foreach ($return_data['list'] as $pd) { $rid[$pd['product_id']] = true; } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View('product/' . $this->class_name . '/' . __FUNCTION__, array('rid' => $rid)); //* 变量绑定 */ $this->template->title = '抢购商品管理'; $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
/** * 显示商品列表 */ public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); $request_data['status'] = isset($request_data['status']) ? (int) $request_data['status'] : 0; $struct = product::get_struct($request_data); $query_struct_current = $struct['query']; $query_struct_current['where']['type'] = array(ProductService::PRODUCT_TYPE_GOODS, ProductService::PRODUCT_TYPE_CONFIGURABLE, ProductService::PRODUCT_TYPE_ASSEMBLY); $request_struct_current = $struct['request']; // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); $return_data = BLL_Product::index($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; //* 如果是ajax请求缩减返回的字段 ==根据业务逻辑定制== */ if ($this->is_ajax_request()) { $requestkeys = array('id', 'category_id', 'title', 'store', 'on_sale', 'price', 'sku'); array_walk($return_data['assoc'], 'util::simplify_return_array', $requestkeys); } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { //* html 输出 ==根据业务逻辑定制== */ //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; $this->template->content->request_struct = $request_struct_current; $this->template->content->query_struct = $query_struct_current; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
/** * 商户留言列表 */ public function index() { $request_data = $this->input->get(); $message_service = MessageService::get_instance(); $true = FALSE; //判断用户的角色是不是管理员 if ($this->manager_is_admin == 1) { $true = TRUE; } //初始化请求结构体 $query_struct = array('where' => array(), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); if ($true != TRUE) { $query_struct['where']['manager_id'] = $this->manager_id; } //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('manager_id' => 'ASC'), 3 => array('manager_id' => 'DESC'), 4 => array('status' => 'ASC'), 5 => array('status' => 'DESC'), 6 => array('title' => 'ASC'), 7 => array('title' => 'DESC'), 8 => array('email' => 'ASC'), 9 => array('email' => 'DESC'), 10 => array('create_timestamp' => 'ASC'), 11 => array('create_timestamp' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'), 14 => array('is_reply' => 'ASC'), 15 => array('is_reply' => 'DESC')); // 排序处理 $orderby = controller_tool::orderby($orderby_arr); if (isset($orderby) && !empty($orderby)) { $query_struct['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct, $request_data); $count = $message_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; if ($true === TRUE) { $messages = $message_service->messages($query_struct); $this->template->content = new View("manage/message_manage_list"); $this->template->content->messages = $messages; $this->template->content->count = $count; } else { $messages = $message_service->get_message_reply_by_site_manage_role($query_struct); $this->template->content = new View("manage/message_list"); $this->template->content->messages = $messages; $this->template->content->count = $count; } }
/** * 数据列表 */ public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); $return_data = array(); $request_data = $this->input->get(); /* 初始化默认查询结构体 */ $query_struct_default = array('like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'page' => 1)); /* 初始化当前查询结构体 */ $query_struct_current = array(); //* 设置合并默认查询条件到当前查询结构体 */ $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('type' => 'ASC'), 3 => array('type' => 'DESC'), 4 => array('version' => 'ASC'), 5 => array('version' => 'DESC'), 6 => array('agent_detail' => 'ASC'), 7 => array('agent_detail' => 'DESC'), 8 => array('ip' => 'ASC'), 9 => array('ip' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('date_upd' => 'ASC'), 13 => array('date_upd' => 'DESC'), 14 => array('quantity' => 'ASC'), 15 => array('quantity' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $kc_browser_stat = Mykc_browser_stat::instance(); $count = $kc_browser_stat->count($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = Mykc_browser_stat::instance()->lists($query_struct_current); $return_struct['content'] = $return_data; $content = new View($this->class_name . '_' . __FUNCTION__); /* 变量绑定 */ $this->template->title = '浏览器详细信息'; $this->template->content = $content; $this->template->content->request_data = $request_data; /* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; }
public function index() { $request_data = $this->input->get(); $delivery_service = DeliveryService::get_instance(); //初始化请求结构体 $query_struct = array('where' => array(), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('url' => 'ASC'), 3 => array('url' => 'DESC'), 4 => array('name' => 'ASC'), 5 => array('name' => 'DESC'), 6 => array('position' => 'ASC'), 7 => array('position' => 'DESC'), 8 => array('delay' => 'ASC'), 9 => array('delay' => 'DESC'), 10 => array('active' => 'ASC'), 11 => array('active' => 'DESC'), 12 => array('type' => 'ASC'), 13 => array('type' => 'DESC'), 14 => array('is_default' => 'ASC'), 15 => array('is_default' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); if (isset($orderby) && !empty($orderby)) { $query_struct['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct, $request_data); $count = $delivery_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; //调用列表 $deliveries = $delivery_service->query_assoc($query_struct); $this->template->content = new View("site/delivery_cn_list"); $this->template->content->deliveries = $deliveries; }
public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); $site_ids = role::get_site_ids(); if (empty($site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } if (empty($request_data['classify_id']) or !isset($request_data['site_id']) or !in_array($request_data['site_id'], $site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400); } $struct = product::get_struct($request_data, $request_data['site_id']); $query_struct_current = $struct['query']; $request_struct_current = $struct['request']; $query_struct_current['where']['status'] = 1; $query_struct_current['where']['type'] = 0; $query_struct_current['where']['classify_id'] = $request_data['classify_id']; $query_struct_current['where']['goods_attributeoption_relation_struct_default'] = array('', '{"items":[]}'); // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); try { $return_data = BLL_Product::index($query_struct_current); foreach ($return_data['assoc'] as $index => $product) { $product['pictures'] = BLL_Product_Picture::get($product['id']); $product['picrels'] = array_keys($product['pictures']); $return_data['assoc'][$index] = $product; } // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; } catch (MyRuntimeException $ex) { //* ==根据业务逻辑定制== */ //FIXME 根据service层的异常做一些对应处理并抛出用户友好的异常Message throw $ex; } //* 如果是ajax请求缩减返回的字段 ==根据业务逻辑定制== */ if ($this->is_ajax_request()) { $requestkeys = array('id', 'site_id', 'category_id', 'title', 'uri_name', 'store', 'on_sale', 'goods_price', 'sku'); array_walk($return_data['assoc'], 'util::simplify_return_array', $requestkeys); } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { //* html 输出 ==根据业务逻辑定制== */ $this->template = new View('layout/commonfix_html'); //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/product/merge/list'); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; $this->template->content->request_struct = $request_struct_current; $this->template->content->query_struct = $query_struct_current; $this->template->content->site_id = $request_data['site_id']; $this->template->content->classify_id = $request_data['classify_id']; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->title = Kohana::config('site.name'); } // end of request type determine } 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->content = $return_struct; } 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; } } }
public function products() { role::check('product_collection'); $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //数据验证 if (!isset($request_data['id']) || !is_numeric($request_data['id'])) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } $collection_service = CollectionService::get_instance(); $collection = $collection_service->get($request_data['id']); //业务逻辑 //默认查询结构 $relation_query_struct = array('where' => array('collection_id' => $request_data['id']), 'orderby' => array('id' => 'asc')); // 排序处理 //列表排序 $relation_orderby_arr = array(0 => array('order' => 'DESC'), 1 => array('order' => 'ASC')); $relations = Collection_product_relationService::get_instance()->index($relation_query_struct); $product_ids = array(); $relation_products = array(); $relation_product_ids = array(); foreach ($relations as $relation) { $relation_products[$relation['product_id']]['relation_id'] = $relation['id']; $relation_products[$relation['product_id']]['relation_order'] = $relation['order']; $product_ids[] = $relation['product_id']; $relation_product_ids[$relation['product_id']] = true; } $products = array(); //初始化返回数据 if (isset($request_data['orderby']) && isset($relation_orderby_arr[$request_data['orderby']])) { $relation_query_struct['orderby'] = array_merge($relation_orderby_arr[$request_data['orderby']], $relation_query_struct['orderby']); $relations = Collection_product_relationService::get_instance()->index($relation_query_struct); $relation_products = array(); foreach ($relations as $relation) { $relation_products[$relation['product_id']]['relation_id'] = $relation['id']; $relation_products[$relation['product_id']]['relation_order'] = $relation['order']; } if (!empty($product_ids)) { $query_struct = array('where' => array('id' => $product_ids)); $product_service = ProductService::get_instance(); $results = $product_service->index($query_struct); $result_products = array(); foreach ($results as $val) { $result_products[$val['id']] = $val; } $categorys = CategoryService::get_instance()->get_categories(); //$brands = BrandService::get_instance()->get_brands(); foreach ($relation_products as $key => $val) { if (isset($result_products[$key])) { $products[$key] = $result_products[$key] + $val; if (isset($categorys[$result_products[$key]['category_id']])) { $products[$key]['category'] = $categorys[$result_products[$key]['category_id']]['title']; } } } $total = count($products); // 每页条目数 controller_tool::request_per_page($relation_query_struct, $request_data); $per_page = $relation_query_struct['limit']['per_page']; /*分页处理*/ $this->pagination = new Pagination(array('base_url' => url::current(), 'uri_segment' => 'page', 'total_items' => $total, 'items_per_page' => $per_page)); $current_page = $this->pagination->current_page; $offset = (int) min(max(0, ($current_page - 1) * $per_page), max(0, $total - 1)); if (!empty($products)) { $products = array_slice($products, $offset, $per_page); } } } else { if (!empty($product_ids)) { $struct = product::get_struct($request_data); $query_struct = $struct['query']; $request_struct = $struct['request']; $query_struct['where']['id'] = $product_ids; $product_service = ProductService::get_instance(); $total = $product_service->count($query_struct); // 排序处理 //列表排序 $orderby_arr = array(2 => array('sku' => 'ASC'), 3 => array('sku' => 'DESC'), 4 => array('name_manage' => 'ASC'), 5 => array('name_manage' => 'DESC'), 6 => array('title' => 'ASC'), 7 => array('title' => 'DESC'), 8 => array('category_id' => 'ASC'), 9 => array('category_id' => 'DESC'), 10 => array('on_sale' => 'ASC'), 11 => array('on_sale' => 'DESC'), 12 => array('goods_price' => 'ASC'), 13 => array('goods_price' => 'DESC')); if (isset($request_data['orderby']) && isset($orderby_arr[$request_data['orderby']])) { $query_struct['orderby'] = $orderby_arr[$request_data['orderby']]; } // 每页条目数 controller_tool::request_per_page($query_struct, $request_data); //分页处理 $this->pagination = new Pagination(array('total_items' => $total, 'items_per_page' => $query_struct['limit']['per_page'])); $query_struct['limit']['page'] = $this->pagination->current_page; $results = $product_service->index($query_struct); $result_products = array(); foreach ($results as $val) { $result_products[$val['id']] = $val; } $categorys = CategoryService::get_instance()->get_categories(); //$brands = BrandService::get_instance()->get_brands(); foreach ($result_products as $key => $val) { if (isset($relation_products[$key])) { $products[$key] = $val + $relation_products[$key]; if (isset($categorys[$val['category_id']])) { $products[$key]['category'] = $categorys[$val['category_id']]['title']; } } } } } //echo kohana::debug($relation_query_struct); if (empty($products)) { //分页处理 $this->pagination = new Pagination(array('total_items' => 0, 'items_per_page' => 20)); } //echo kohana::debug($products); $return_data['products'] = $products; $return_data['collection'] = $collection; //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View('product/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->relation_product_ids = $relation_product_ids; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
/** * 订单列表 */ public function index($status = NULL) { $time_expired = 60 * 60 * 2; //将要过期时间 $time_delay = 5 * 60; //过期延迟显示时间 //$mklasttime = mktime(date("H"), date("i"), date("s"), date("m"), date("d")-5, date("Y")); //$last_time = date('Y-m-d H:i:s', $mklasttime); //初始化默认查询结构体 $query_struct_default = array('where' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 10, 'page' => 1)); if (!empty($status)) { switch ($status) { case 'hasbuy': $query_struct_default['where']['status'] = 0; break; case 'noprint': $query_struct_default['where']['status'] = 1; break; case 'beexpired': $query_struct_default['where']['date_end <'] = date("Y-m-d H:i:s", time() + $time_expired); //当离方案截止时间小于2小时时为将要到期 $query_struct_default['where']['date_end >'] = tool::get_date(); break; case 'hasexpired': $query_struct_default['where']['date_end <'] = date("Y-m-d H:i:s", time() + $time_delay); $query_struct_default['where']['status'] = array(0); break; case 'hasprint': $query_struct_default['where']['status'] = 2; break; case 'nobonus': $query_struct_default['where']['status'] = 3; break; case 'hasbonus': $query_struct_default['where']['status'] = 4; break; case 'givehonus': $query_struct_default['where']['status'] = 5; break; case 'cancel': $query_struct_default['where']['status'] = 6; break; default: } } //d($query_struct_default); /* 搜索功能 */ $search_arr = array('id', 'order_num', 'username'); $search_value = $this->input->get('search_value'); $search_type = $this->input->get('search_type'); $where_view = array(); //$query_struct_default['where']['date_end >='] = tool::get_date(); if (strlen($this->input->get('start_time')) > 0) { $query_struct_default['where']['date_add >='] = $this->input->get('start_time') . ' 00:00:00'; $where_view['start_time'] = $this->input->get('start_time'); } if (strlen($this->input->get('end_time')) > 0) { $query_struct_default['where']['date_add <='] = $this->input->get('end_time') . ' 00:00:00'; $where_view['end_time'] = $this->input->get('end_time'); } if ($search_arr) { foreach ($search_arr as $value) { if ($search_type == $value && strlen($search_value) > 0) { if ($value == 'lastname') { $userobj = user::get_instance(); $userinfo = $userobj->get_search($search_value); $userid = $userinfo['id']; $query_struct_default['where']['start_user_id'] = $userid; $query_struct_default['where']['user_id'] = $userid; } else { $query_struct_default['like'][$value] = $search_value; } } } $where_view['search_type'] = $search_type; $where_view['search_value'] = $search_value; } $request_data = $this->input->get(); //初始化当前查询结构体 $query_struct_current = array(); //设置合并默认查询条件到当前查询结构体 $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } $query_struct_current['orderby'] = $orderby; //每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $return_data['count'] = $this->order_basic_obj->count($query_struct_current); //统计数量 /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $this->order_basic_obj->query_assoc($query_struct_current); //$return_data['ticket_type'] = Kohana::config('ticket_type'); /* $planobj = plan::get_instance(); $i = 0; foreach ($return_data['list'] as $rowlist) { $planobj->get_result($return_data['list'][$i]); if(empty($return_data['list'][$i]['detail'])) { unset($return_data['list'][$i]); } $i++; } //d($return_data['list']); $return_data['status'] = $status; $return_data['time_expired'] = $time_expired; //d($return_data['list']); $return_data['site_config'] = Kohana::config('site_config.site'); $host = $_SERVER['HTTP_HOST']; $dis_site_config = Kohana::config('distribution_site_config'); if (array_key_exists($host, $dis_site_config) == true && isset($dis_site_config[$host])) { $return_data['site_config']['site_title'] = $dis_site_config[$host]['site_name']; $return_data['site_config']['keywords'] = $dis_site_config[$host]['keywords']; $return_data['site_config']['description'] = $dis_site_config[$host]['description']; } */ $this->template->content = new View("order/order_index", $return_data); $this->template->content->where = $where_view; }
public function index() { role::check('product_auction'); $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array(); $request_data = $this->input->get(); $experience = $this->input->get('experience', 0); $query_struct_current = array('where' => array('status!=' => 2, 'experience' => $experience)); //列表排序 $orderby_arr = array(1 => array('name' => 'ASC'), 2 => array('name' => 'DESC'), 3 => array('price_start' => 'ASC'), 4 => array('price_start' => 'DESC'), 5 => array('time_end' => 'ASC'), 6 => array('time_end' => 'DESC')); // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); if (isset($request_data['orderby']) && isset($orderby_arr[$request_data['orderby']])) { $query_struct_current['orderby'] = $orderby_arr[$request_data['orderby']]; } //调用服务执行查询 $auction_service = Product_auctionService::get_instance(); $count = $auction_service->count($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $products = array(); $product_ids = array(); $relation_products = array(); $relation_product_ids = array(); $categorys = CategoryService::get_instance()->get_categories(); $relations = $auction_service->index($query_struct_current); foreach ($relations as $k => $relation) { $relation_product_ids[$relation['product_id']] = $relation['product_id']; $relation['category'] = ''; if ($relation['category_ids']) { $relation['category_ids'] = explode(',', $relation['category_ids']); foreach ($relation['category_ids'] as $cid) { $relation['category'] .= isset($categorys[$cid]) ? $categorys[$cid]['title'] . ',' : ''; } } $relations[$k] = $relation; } if (empty($relations)) { //分页处理 $this->pagination = new Pagination(array('total_items' => 0, 'items_per_page' => 20)); } $return_data['products'] = $relations; //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View('product/auction/index', array('experience' => $experience)); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->relation_product_ids = $relation_product_ids; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
/** * 数据列表 */ public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('site_list' => array(), 'list' => array()); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //* 权限验证 */ $site_id = site::id(); if ($site_id == 0) { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } role::check('inquiry_subject', $site_id, 0); // 执行业务逻辑 //* 初始化默认查询结构体 */ $query_struct_default = array('where' => array('site_id' => $site_id), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'page' => 1)); //* 初始化当前查询结构体 */ $query_struct_current = array(); //* 设置合并默认查询条件到当前查询结构体 */ $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'ASC'), 1 => array('id' => 'DESC'), 2 => array('name' => 'ASC'), 3 => array('name' => 'DESC'), 4 => array('update_timestamp' => 'ASC'), 5 => array('update_timestamp' => 'DESC'), 6 => array('position' => 'ASC'), 7 => array('position' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $inquieysubject_service = InquirysubjectService::get_instance(); $count = $inquieysubject_service->count($query_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $inquieysubject_service->index($query_struct_current); //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View($this->package . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = '商品咨询主题管理'; $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->site_id = $site_id; } // end of request type determine } 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->content = $return_struct; } 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; } } }
/** * 咨询列表 */ public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //* 初始化默认查询结构体 ==根据业务逻辑定制== */ $request_struct_default = array('type' => NULL, 'keyword' => NULL); //* 初始化请求结构体 */ $request_struct_current = array(); $product_all_ids = array(); $product_get_ids = array(); $product_id = 0; //* 设置合并默认请求结构数据到当前请求结构体 */ $request_struct_current = array_merge($request_struct_current, $request_struct_default); //* 初始化默认查询结构体 ==根据业务逻辑定制== */ $query_struct_default = array('where' => array(), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => Kohana::config('my.items_per_page'), 'page' => 1)); //* 初始化当前查询结构体 */ $query_struct_current = array(); //* 设置合并默认查询条件到当前查询结构体 */ $query_struct_current = array_merge($query_struct_current, $query_struct_default); $data = ProductinquiryService::get_instance()->index($query_struct_current); foreach ($data as $key => $val) { if (isset($product_all_ids[$val['product_id']])) { unset($data[$key]); } else { $product_all_ids[$val['product_id']] = $val['product_id']; } } if (isset($request_data['is_show']) and in_array(trim($request_data['is_show']), array(ProductinquiryService::SHOW_NOTIN_FRONT, ProductinquiryService::SHOW_IN_FRONT))) { $query_struct_current['where']['is_show'] = trim($request_data['is_show']); } //* 当前支持的查询业务逻辑 ==根据业务逻辑定制== */ if (isset($request_data['type']) && isset($request_data['keyword']) && !empty($request_data['keyword'])) { switch ($request_data['type']) { case 'sku': $products = ProductService::get_instance()->query_assoc(array('like' => array('sku' => trim($request_data['keyword'])))); if (empty($products)) { $product_id = 0; } else { foreach ($products as $val) { if (in_array($val['id'], $product_all_ids)) { $product_get_ids[$val['id']] = $val['id']; } } } if (is_array($product_get_ids) && count($product_get_ids) > 0) { $query_struct_current['where']['product_id'] = $product_get_ids; } else { $query_struct_current['where']['product_id'] = $product_id; } $request_struct_current['keyword'] = trim($request_data['keyword']); break; case 'email': $query_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_struct_current['keyword'] = $query_struct_current['like'][$request_data['type']]; /* $query_struct_current['where'][$request_data['type']] = trim($request_data['keyword']); $request_struct_current['keyword'] = $query_struct_current['where'][$request_data['type']]; */ break; case 'subject': $query_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_struct_current['keyword'] = $query_struct_current['like'][$request_data['type']]; /* $query_struct_current['where'][$request_data['type']] = trim($request_data['keyword']); $request_struct_current['keyword'] = $query_struct_current['where'][$request_data['type']]; */ break; } $request_struct_current['type'] = $request_data['type']; } //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('site_id' => 'ASC'), 3 => array('site_id' => 'DESC'), 4 => array('is_show' => 'ASC'), 5 => array('is_show' => 'DESC'), 6 => array('product_id' => 'ASC'), 7 => array('product_id' => 'DESC'), 8 => array('user_id' => 'ASC'), 9 => array('user_id' => 'DESC'), 10 => array('email' => 'ASC'), 11 => array('email' => 'DESC'), 12 => array('create_timestamp' => 'ASC'), 13 => array('create_timestamp' => 'DESC'), 14 => array('ip' => 'ASC'), 15 => array('ip' => 'DESC'), 16 => array('status' => 'ASC'), 17 => array('status' => 'DESC'), 18 => array('subject' => 'ASC'), 19 => array('subject' => 'DESC'), 20 => array('reply_content' => 'ASC'), 21 => array('reply_content' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //print_r($query_struct_current); try { //* 调用后端服务获取数据 */ $productinquiry_service = ProductinquiryService::get_instance(); $return_data['count'] = $productinquiry_service->count($query_struct_current); $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['offset'] = $this->pagination->sql_offset; $query_struct_current['limit']['page'] = $this->pagination->current_page; //查询 $return_data['assoc'] = $productinquiry_service->index($query_struct_current); $product_ids = array(); $user_ids = array(); foreach ($return_data['assoc'] as $inquiries) { if (!empty($inquiries['user_id'])) { $user_ids[$inquiries['user_id']] = TRUE; } if (!empty($inquiries['product_id'])) { $product_ids[$inquiries['product_id']] = TRUE; } } $products = array(); $users = array(); if (!empty($product_ids)) { foreach (ProductService::get_instance()->query_assoc(array('where' => array('id' => array_keys($product_ids)))) as $product) { $products[$product['id']] = $product; } } if (!empty($user_ids)) { foreach (ORM::factory('user')->in('id', array_keys($user_ids))->find_all() as $user) { $user = $user->as_array(); $users[$user['id']] = $user; } } } catch (MyRuntimeException $ex) { //* ==根据业务逻辑定制== */ //FIXME 根据service层的异常做一些对应处理并抛出用户友好的异常Message throw $ex; } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { //* html 输出 ==根据业务逻辑定制== */ //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; $this->template->content->request_struct = $request_struct_current; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->title = Kohana::config('site.name'); $this->template->content->products = $products; $this->template->content->users = $users; } // end of request type determine } 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->content = $return_struct; } 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; } } }
public function index() { role::check('promotion_promotion'); // 初始化默认查询条件 $request_struct_current = array('where' => array(), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); // 收集请求数据 $request_data = $this->input->get(); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('id' => 'ASC'), 3 => array('id' => 'DESC'), 4 => array('pmta_name' => 'ASC'), 5 => array('pmta_name' => 'DESC'), 6 => array('pmta_time_begin' => 'ASC'), 7 => array('pmta_time_begin' => 'DESC'), 8 => array('pmta_time_end' => 'ASC'), 9 => array('pmta_time_end' => 'DESC'), 10 => array('meta_title' => 'ASC'), 11 => array('meta_title' => 'DESC'), 12 => array('frontend_description' => 'ASC'), 13 => array('frontend_description' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $request_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($request_struct_current, $request_data); // 当前支持的查询业务逻辑 if (isset($request_data['type']) && isset($request_data['keyword']) && !empty($request_data['keyword'])) { switch ($request_data['type']) { case 'id': $request_struct_current['where'][$request_data['type']] = intval(trim($request_data['keyword'])); $request_data['keyword'] = $request_struct_current['where'][$request_data['type']]; break; case 'pmta_name': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; case 'meta_title': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; case 'frontend_description': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; case 'backend_description': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; } } $count = Mypromotion_activity::instance()->count($request_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $request_struct_current['limit']['per_page'])); $request_struct_current['limit']['offset'] = $this->pagination->sql_offset; $promotion_activity_list = Mypromotion_activity::instance()->lists($request_struct_current); foreach ($promotion_activity_list as $key => $rs) { $promotion_list = Mypromotion::instance()->list_by_pmtaid($rs['id']); $promotion_activity_list[$key]['promotions'] = array(); foreach ($promotion_list as $keyp => $_promotion) { $promotion_activity_list[$key]['promotions'][$keyp]['id'] = $_promotion['id']; $promotion_activity_list[$key]['promotions'][$keyp]['description'] = $_promotion['pmt_description']; $promotion_activity_list[$key]['promotions'][$keyp]['time_begin'] = $_promotion['time_begin']; $promotion_activity_list[$key]['promotions'][$keyp]['time_end'] = $_promotion['time_end']; } } // 模板输出 $this->template->content = new View("promotion/promotion_activity_list"); // 变量绑定 $this->template->content->promotion_activity_list = $promotion_activity_list; $this->template->content->count = $count; $this->template->content->request_data = $request_data; }
public function index() { role::check('promotion_coupon'); // 初始化默认查询条件 $request_struct_current = array('where' => array('is_front' => 0), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); // 收集请求数据 $request_data = $this->input->get(); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('cpn_name' => 'ASC'), 3 => array('cpn_name' => 'DESC'), 4 => array('id' => 'ASC'), 5 => array('id' => 'DESC'), 6 => array('cpn_prefix' => 'ASC'), 7 => array('cpn_prefix' => 'DESC'), 8 => array('cpn_type' => 'ASC'), 9 => array('cpn_type' => 'DESC'), 10 => array('disabled' => 'ASC'), 11 => array('disabled' => 'DESC'), 12 => array('cpn_gen_quantity' => 'ASC'), 13 => array('cpn_gen_quantity' => 'DESC'), 14 => array('cpn_time_begin' => 'ASC'), 15 => array('cpn_time_begin' => 'DESC'), 16 => array('cpn_time_end' => 'ASC'), 17 => array('cpn_time_end' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $request_struct_current['orderby'] = $orderby; } // 每页条目数 controller_tool::request_per_page($request_struct_current, $request_data); //显示前台添加的优惠券 if (isset($request_data['is_front'])) { $request_struct_current['where']['is_front'] = intval($request_data['is_front']); $request_data['is_front'] = $request_struct_current['where']['is_front']; } // 当前支持的查询业务逻辑 if (isset($request_data['type']) && isset($request_data['keyword']) && !empty($request_data['keyword'])) { switch ($request_data['type']) { case 'id': $request_struct_current['where'][$request_data['type']] = intval(trim($request_data['keyword'])); header("Charset=utf-8"); $request_data['keyword'] = $request_struct_current['where'][$request_data['type']]; break; case 'cpn_name': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; case 'cpn_prefix': $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']); $request_data['keyword'] = $request_struct_current['like'][$request_data['type']]; break; } } $count = Mycoupon::instance()->count($request_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $request_struct_current['limit']['per_page'])); $request_struct_current['limit']['offset'] = $this->pagination->sql_offset; $coupon_list = Mycoupon::instance()->lists($request_struct_current); $i = 0; foreach ($coupon_list as $key => $rs) { //$coupon_list[$key] = $value; //$coupon_list[$key]['site'] = Mysite::instance($rs['site_id'])->get(); //$used_coupon_name = !isset(${'used_coupons' . $rs['site_id']}) && ${'used_coupons' . $rs['site_id']} = Myused_coupon::instance()->get_used_coupon_codes($rs['site_id']); $request_struct = array('where' => array('cpn_id' => $rs['id'])); $cpn_promotions = Mycpn_promotion::instance()->lists($request_struct); $count = count($cpn_promotions); //打折只能有一条规则,如果没有(添加时错误)或多添加,则删除这条优惠方案 if ($count != 1) { //Mycpn_promotion::instance()->delete_by_couponid($rs['id']); Mycoupon::instance()->delete($rs['id']); unset($coupon_list[$key]); } else { $cpn_promotion = array_shift($cpn_promotions); $coupon_scheme = Mycoupon_scheme::instance($cpn_promotion['cpns_id'])->get(); $coupon_list[$key]['cpn_promotion'] = $cpn_promotion; $coupon_list[$key]['coupon_scheme'] = $coupon_scheme; } } // 模板输出 $this->template->content = new View("promotion/coupon_list"); // 变量绑定 $this->template->content->coupon_list = $coupon_list; $this->template->content->count = $count; $this->template->content->request_data = $request_data; }
public function user_money($user_id = NULL, $acid = NULL, $log_type = NULL) { role::check('user_account'); $return_data = array(); //初始化默认查询结构体 $query_struct_default = array('orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 10, 'page' => 1)); $return_data['get']['user_id'] = NULL; $return_data['get']['acid'] = NULL; $return_data['get']['log_type'] = NULL; if (!empty($user_id)) { $query_struct_default['where']['user_id'] = $user_id; $return_data['get']['user_id'] = $user_id; } if (!empty($acid)) { $query_struct_default['where']['account_log_id'] = $acid; $return_data['get']['acid'] = $acid; } if (!empty($log_type)) { $query_struct_default['where']['log_type'] = $log_type; $return_data['get']['log_type'] = $log_type; } $request_data = $this->input->get(); $timebeg = $this->input->get('begintime'); $timeend = $this->input->get('endtime'); if (!empty($timebeg)) { $query_struct_default['where']['add_time >='] = $timebeg; } if (!empty($timeend)) { $query_struct_default['where']['add_time <='] = $timeend; } //初始化当前查询结构体 $query_struct_current = array(); //设置合并默认查询条件到当前查询结构体 $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } $query_struct_current['orderby'] = $orderby; //每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $acobj = Money_logService::get_instance(); $return_data['count'] = $acobj->count($query_struct_current); //统计数量 $sum_list = $acobj->query_assoc($query_struct_current); $return_data['USER_MONEY']['in'] = 0; $return_data['USER_MONEY']['out'] = 0; $return_data['BONUS_MONEY']['in'] = 0; $return_data['BONUS_MONEY']['out'] = 0; $return_data['FREE_MONEY']['in'] = 0; $return_data['FREE_MONEY']['out'] = 0; foreach ($sum_list as $rowsum) { if ($rowsum['log_type'] == 'USER_MONEY') { if ($rowsum['is_in'] == 1) { $return_data['USER_MONEY']['out'] += $rowsum['price']; } else { $return_data['USER_MONEY']['in'] += $rowsum['price']; } } elseif ($rowsum['log_type'] == 'BONUS_MONEY') { if ($rowsum['is_in'] == 1) { $return_data['BONUS_MONEY']['out'] += $rowsum['price']; } else { $return_data['BONUS_MONEY']['in'] += $rowsum['price']; } } elseif ($rowsum['log_type'] == 'FREE_MONEY') { if ($rowsum['is_in'] == 1) { $return_data['FREE_MONEY']['out'] += $rowsum['price']; } else { $return_data['FREE_MONEY']['in'] += $rowsum['price']; } } } /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $acobj->query_assoc($query_struct_current); $money_type = Kohana::config('money_type'); $i = 0; foreach ($return_data['list'] as $rowlist) { $return_data['list'][$i] = $rowlist; $return_data['list'][$i]['type_name'] = empty($account_type[$rowlist['log_type']]) ? '' : $account_type[$rowlist['log_type']]; $i++; } $return_data['user'] = user::get_instance()->get($id); /* 用户列表模板 */ $this->template->content = new View("user/user_money"); /* 调用列表 */ $this->template->content->data = $return_data; $this->template->content->money_type = $money_type; }
/** * 订单列表 */ public function index($status = 'all') { /* 权限检查 订单列表 */ role::check('user_draw_money_review'); //初始化默认查询结构体 $query_struct_default = array('orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 10, 'page' => 1)); switch ($status) { case 'review': role::check('user_draw_money_review'); $query_struct_default['where']['status'] = 0; break; case 'hasreview': role::check('user_draw_money_review'); $query_struct_default['where']['status'] = 1; break; case 'reviewfail': role::check('user_draw_money_input'); $query_struct_default['where']['status'] = 2; break; case 'hascharge': role::check('user_draw_money_charge'); $query_struct_default['where']['status'] = 3; break; case 'chargefail': $query_struct_default['where']['status'] = 4; break; case 'chargewin': $query_struct_default['where']['status'] = 5; break; default: } /* 搜索功能 */ $search_arr = array('id', 'money', 'account', 'truename', 'bank_name', 'province', 'city', 'bank_found'); $search_value = $this->input->get('search_value'); $search_type = $this->input->get('search_type'); $where_view = array(); if ($search_arr) { foreach ($search_arr as $value) { if ($search_type == $value && strlen($search_value) > 0) { $query_struct_default['like'][$value] = $search_value; } } $where_view['search_type'] = $search_type; $where_view['search_value'] = $search_value; } $request_data = $this->input->get(); //初始化当前查询结构体 $query_struct_current = array(); //设置合并默认查询条件到当前查询结构体 $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } $query_struct_current['orderby'] = $orderby; //每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 $acobj = User_draw_moneyService::get_instance(); $return_data['count'] = $acobj->count($query_struct_current); //统计数量 /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $acobj->query_assoc($query_struct_current); $return_data['account_type'] = Kohana::config('ticket_type'); $i = 0; $managers = array(); $users = array(); foreach ($return_data['list'] as $rowlist) { $return_data['list'][$i] = $rowlist; $return_data['list'][$i]['other'] = json_decode($rowlist['other']); $users[$rowlist['user_id']] = $rowlist['user_id']; if (!empty($rowlist['manager_id'])) { $managers[$rowlist['manager_id']] = $rowlist['manager_id']; } $i++; } $userobj = user::get_instance(); $return_data['users'] = array(); $return_data['managers'] = array(); foreach ($users as $rowuser) { $return_data['users'][$rowuser] = $userobj->get($rowuser); } foreach ($managers as $rowman) { $managers[$rowman] = Mymanager::instance($rowman)->get(); if (!empty($managers[$rowman])) { $return_data['managers'][$rowman] = $managers[$rowman]['username']; } } $return_data['managers'] = $managers; $return_data['status'] = $status; $this->template->content = new View("order/user_draw_money", $return_data); $this->template->content->where = $where_view; }
/** * 订单列表 */ public function index($status = 'all') { //初始化默认查询结构体 $query_struct_default = array('orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 10, 'page' => 1)); switch ($status) { case 'noticket': $query_struct_default['where']['status'] = 0; break; case 'hasticket': $query_struct_default['where']['status'] = 1; break; case 'hasbonus': $query_struct_default['where']['status'] = 2; break; case 'hasprice': $query_struct_default['where']['bonus > '] = 0; $query_struct_default['where']['status'] = 2; break; case 'invalid': $query_struct_default['where']['status'] = -1; break; case 'confirm_invalid': $query_struct_default['where']['status'] = -2; break; case 'input_bonus': $query_struct_default['where']['bonus'] = -9999; $query_struct_default['where']['status'] = 2; break; case 'ticket_tj': $query_struct_default['where']['status > '] = 0; $query_struct_default['where']['port > '] = 0; if (strlen($this->input->get('start_time')) == 0) { $query_struct_default['where']['time_print >= '] = date('Y-m-d') . ' 02:00:00'; } if (strlen($this->input->get('end_time')) == 0) { $mklasttime = mktime(2, 0, 0, date("m"), date("d") + 1, date("Y")); $lasttime = date('Y-m-d H:i:s', $mklasttime); $query_struct_default['where']['time_print <= '] = $lasttime . ' 02:00:00'; } default: } /* 搜索功能 */ $search_arr = array('id', 'order_id'); $search_value = $this->input->get('search_value'); $search_type = $this->input->get('search_type'); $where_view = array(); if (strlen($this->input->get('start_time')) > 0) { $query_struct_default['where']['time_print >='] = $this->input->get('start_time') . ' 02:00:00'; $where_view['start_time'] = $this->input->get('start_time'); } if (strlen($this->input->get('end_time')) > 0) { $query_struct_default['where']['time_print <='] = $this->input->get('end_time') . ' 02:00:00'; $where_view['end_time'] = $this->input->get('end_time'); } if ($search_arr) { foreach ($search_arr as $value) { if ($search_type == $value && strlen($search_value) > 0) { //$query_struct_default['like'][$value] = $search_value; $query_struct_default['where'][$value . ' = '] = $search_value; } } $where_view['search_type'] = $search_type; $where_view['search_value'] = $search_value; } $request_data = $this->input->get(); //初始化当前查询结构体 $query_struct_current = array(); //设置合并默认查询条件到当前查询结构体 $query_struct_current = array_merge($query_struct_current, $query_struct_default); //列表排序 $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC')); $orderby = controller_tool::orderby($orderby_arr); // 排序处理 if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) { $query_struct_current['orderby'] = $orderby; } $query_struct_current['orderby'] = $orderby; //每页条目数 controller_tool::request_per_page($query_struct_current, $request_data); //调用服务执行查询 //$acobj = Ticket_numService::get_instance(); $return_data['count'] = $this->order_detail_obj->count($query_struct_current); //统计数量 /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); $query_struct_current['limit']['page'] = $this->pagination->current_page; $return_data['list'] = $this->order_detail_obj->query_assoc($query_struct_current); /* $total_money = 0; if ($status == 'ticket_tj') { $query = 'select sum(price) as total_money from order_details where status > 0'; foreach ($query_struct_current as $key => $val) { if ($key == 'like') { foreach ($val as $k => $v) { $query .= ' and '.$k.'="'.$v.'"'; } } if ($key == 'where') { foreach ($val as $k => $v) { $query .= ' and '.$k.'"'.$v.'"'; } } } $db = Database::instance(); $total_money_results = $db->query($query); foreach ($total_money_results as $total_money_result) { $total_money += $total_money_result->total_money; } } */ //$return_data['account_type'] = Kohana::config('ticket_type'); /* $i = 0; $plan_ids = array(); $managers = array(); foreach ($return_data['list'] as $rowlist) { $plan_ids[$rowlist['ticket_type']][$rowlist['plan_id']] = $rowlist['plan_id']; $return_data['list'][$i] = $rowlist; if (!empty($rowlist['manager_id'])) { $managers[$rowlist['manager_id']] = $rowlist['manager_id']; } $i++; } */ //$return_data['total_money'] = $total_money; $users = array(); $return_data['plans'] = array(); $return_data['plans_basic'] = array(); /* $planobj = plan::get_instance(); foreach ($plan_ids as $key => $rowplan) { foreach ($rowplan as $senplan) { $return_data['plans'][$key][$senplan] = $planobj->get_plan_by_tid($senplan, $key); if (!empty($return_data['plans'][$key][$senplan])) { $users[$return_data['plans'][$key][$senplan]['user_id']] = $return_data['plans'][$key][$senplan]['user_id']; } if (empty($return_data['plans_basic'][$return_data['plans'][$key][$senplan]['basic_id']])) { $return_data['plans_basic'][$return_data['plans'][$key][$senplan]['basic_id']] = Plans_basicService::get_instance()->get_by_ordernum($return_data['plans'][$key][$senplan]['basic_id']); } } } */ /* $userobj = user::get_instance(); $return_data['users'] = array(); $return_data['managers'] = array(); $return_data['status'] = $status; foreach($users as $rowuser) { $return_data['users'][$rowuser] = $userobj->get($rowuser); } foreach ($managers as $rowman) { $managers[$rowman] = Mymanager::instance($rowman)->get(); if (!empty($managers[$rowman])) { $managers[$rowman] = $managers[$rowman]['username']; } } $return_data['managers'] = $managers; $return_data['site_config'] = Kohana::config('site_config.site'); $host = $_SERVER['HTTP_HOST']; $dis_site_config = Kohana::config('distribution_site_config'); if (array_key_exists($host, $dis_site_config) == true && isset($dis_site_config[$host])) { $return_data['site_config']['site_title'] = $dis_site_config[$host]['site_name']; $return_data['site_config']['keywords'] = $dis_site_config[$host]['keywords']; $return_data['site_config']['description'] = $dis_site_config[$host]['description']; } */ $this->template->content = new View("order/detail_list", $return_data); $this->template->content->where = $where_view; }
public function category_features() { // 初始化默认查询条件 $request_struct_current = array('where' => array('site_id' => NULL), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); // 收集请求数据 $request_data = $this->input->get(); $category_id = $request_data['id']; // 验证 - 数据有效性 $category = Mycategory::instance($category_id)->get(); if (!$category['id']) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } /* b2c类型的站点列表 */ $site_id_list = role::check('product_virtual_category', 0, 0); // 权限验证 if (empty($site_id_list)) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } if (!in_array($category['site_id'], $site_id_list)) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } // 排序处理 controller_tool::request_orderby($request_struct_current, $request_data); // 每页条目数 controller_tool::request_per_page($request_struct_current, $request_data); // 站点查询 $request_struct_current['where']['site_id'] = $category['site_id']; //当前查询 $request_struct_current['where']['category_id'] = $category['id']; $count = Mycategory_feature::instance()->count($request_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $request_struct_current['limit']['per_page'])); $request_struct_current['limit']['offset'] = $this->pagination->sql_offset; $category_feature_list = Mycategory_feature::instance()->lists($request_struct_current); foreach ($category_feature_list as $key => $rs) { $category_feature_list[$key]['site'] = Mysite::instance($rs['site_id'])->get(); if ($rs['type'] == 1) { $category_feature_list[$key]['type'] = '规格'; $category_feature_list[$key]['group_id'] = Myattribute_group::instance($rs['group_id'])->get('name'); $category_feature_list[$key]['value_id'] = Myattribute::instance($rs['value_id'])->get('name'); } if ($rs['type'] == 2) { $category_feature_list[$key]['type'] = '附加属性'; $category_feature_list[$key]['group_id'] = Myfeature_group::instance($rs['group_id'])->get('name'); $category_feature_list[$key]['value_id'] = Myfeature::instance($rs['value_id'])->get('name'); } } // 模板输出 $this->template->content = new View("product/virtualcategory_features"); // 变量绑定 $this->template->content->category_feature_list = $category_feature_list; $this->template->content->count = $count; // 当前应用专用数据 $this->template->content->data = $category; }