public function lists($map = array(), $order = '', $page = 1, $page_size = 10)
 {
     $field = 'id,class_id,title,authorize_code,thumb,ctime';
     $list = $this->_list($map, $field, $order);
     if (empty($list)) {
         return array();
     }
     //查询知识分类
     $class_id = array_column($list, 'class_id');
     $class_map['id'] = array('in', $class_id);
     $class_field = 'id,name,thumb';
     $class_list = D('KnowClass')->_list($class_map, $class_field);
     if (empty($class_list)) {
         return array();
     }
     ArrayHelper::ArrayKeyReplace($class_list, 'id', 'class_id');
     ArrayHelper::ArrayKeyReplace($class_list, 'name', 'class_name');
     ArrayHelper::ArrayKeyReplace($class_list, 'thumb', 'class_thumb');
     $class_list = array_column($class_list, null, 'class_id');
     //合并数据
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $class_list[$_v['class_id']]);
     }
     return $list;
 }
Example #2
0
 /**
  * 站内信记录
  * @param  array   $map       查询条件
  * @param  string  $field     查询字段
  * @param  string  $order     排序规则
  * @param  integer $page      页数
  * @param  integer $page_size 每页条数
  * @return array             记录数据
  */
 public function lists($map = array(), $field = '', $order = '', $page = 0, $page_size = 10)
 {
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询会员列表数据
     $user_id = array_column($list, 'user_id');
     $user_id = array_merge($user_id, array_column($list, 'to_user_id'));
     $user_map['id'] = array('in', $user_id);
     $user_list = D('User')->_list($user_map, 'id, username, name');
     $user_list = ArrayHelper::array_key_replace($user_list, 'id', 'user_id');
     $user_list = array_column($user_list, null, 'user_id');
     $to_user_list = ArrayHelper::array_key_replace($user_list, array('user_id', 'username', 'name'), array('to_user_id', 'to_username', 'to_name'));
     //合并数据
     foreach ($list as $_k => $_v) {
         if ($_v['user_id'] == 0) {
             $_v['username'] = '管理员';
             $list[$_k] = array_merge($_v, $to_user_list[$_v['to_user_id']]);
         } else {
             if ($_v['to_user_id'] == 0) {
                 $_v['to_username'] = '管理员';
                 $list[$_k] = array_merge($_v, $user_list[$_v['user_id']]);
             } else {
                 $list[$_k] = array_merge($_v, $user_list[$_v['user_id']], $to_user_list[$_v['to_user_id']]);
             }
         }
     }
     return $list;
 }
 public function lists($map = array(), $order = '', $page = 0, $page_size = 10)
 {
     $field = 'id,pid,name,type,url,key,level';
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询父栏目
     $pid = array_column($list, 'pid');
     $pid = array_filter($pid);
     if (empty($pid)) {
         return $list;
     }
     $parent_map['id'] = array('in', $pid);
     $parent_field = 'id,name';
     $parent_list = $this->_list($parent_map, $parent_field);
     ArrayHelper::ArrayKeyReplace($parent_list, 'id', 'pid');
     ArrayHelper::ArrayKeyReplace($parent_list, 'name', 'parent_name');
     $parent_list = array_column($parent_list, null, 'pid');
     //合并数据
     foreach ($list as $_k => $_v) {
         if ($_v['pid'] != 0) {
             $list[$_k] = array_merge($_v, $parent_list[$_v['pid']]);
         }
     }
     return $list;
 }
 public function lists($map = array(), $field = '', $order = '', $page = 0, $page_size = 0)
 {
     $pk = $this->pk;
     //主键
     $field = empty($field) ? $this->selectFields : $fields;
     $order = empty($order) ? $pk . ' desc' : $order;
     if ($page === 0) {
         $list = $this->where($map)->field($field)->order($order)->select();
     } else {
         $page_index = ($page - 1) * $page_size;
         $list = $this->where($map)->field($field)->order($order)->limit($page_index . ',' . $page_size)->select();
     }
     if (empty($list)) {
         return $list;
     }
     //查询会员表
     $member_id = array_column($list, 'member_id');
     $member_id = array_unique($member_id);
     $member_map['id'] = array('in', $member_id);
     $member_list = D('Member')->_list($member_map, 'id,username');
     $member_list = ArrayHelper::array_key_replace($member_list, 'id', 'member_id');
     $member_list = array_column($member_list, null, 'member_id');
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $member_list[$_v['member_id']]);
     }
     return $list;
 }
 /**
  * 新增前置操作,获取所有栏目
  * @method _before_add
  */
 public function _before_add()
 {
     $catalog_list = D('Catalog')->_list(array(), 0, 10, '', 'id asc,sort desc');
     $catalog_list = ArrayHelper::tree($catalog_list);
     $last_id = D('Article')->getLastId();
     $id = $last_id + 1;
     $this->assign('catalog_list', $catalog_list);
     $this->assign('id', $id);
     //为文章分配id
 }
Example #6
0
 /**
  * 获取单个管理员信息
  * @method get
  * @param  array  $map [description]
  * @return [type]      [description]
  */
 public function get($map = array())
 {
     $info = $this->_get($map);
     if (empty($info)) {
         return false;
     }
     $group_map['group_id'] = $info['group_id'];
     $group_info = D('Group')->_get($group_map);
     $group_info = ArrayHelper::array_key_replace($group_info, array('id', 'name'), array('group_id', 'group_name'));
     $info = array_merge($info, $group_info);
     return $info;
 }
Example #7
0
 /**
  * 权限页面
  * @method permission
  * @return [type]     [description]
  */
 public function permission()
 {
     $model = D('Node');
     $node_map['is_enable'] = 1;
     $node_list = $model->_list(array(), 0, 0, '', 'id asc,sort desc');
     $node_list = ArrayHelper::tree($node_list);
     $this->assign('node_list', $node_list);
     //获取组拥有的权限
     $group_id = I('gid');
     $group_node_list = $model->getListByGroupId($group_id);
     $this->assign('group_node_list', $group_node_list);
     $this->display();
 }
 public function create()
 {
     $list = D('Menu')->lists(array(), 'pid asc');
     //构造自定义菜单数据
     foreach ($list as $_k => $_v) {
         if ($_v['pid'] == 0) {
             $_list[$_v['id']]['name'] = $_v['name'];
             switch ($_v['type']) {
                 case 1:
                     $_list[$_v['id']]['type'] = 'click';
                     $_list[$_v['id']]['key'] = $_v['key'];
                     break;
                 case 2:
                     $_list[$_v['id']]['type'] = 'view';
                     $_list[$_v['id']]['url'] = $_v['url'];
                     break;
             }
         } else {
             $_list[$_v['pid']]['sub_button'][$_v['id']]['name'] = $_v['name'];
             switch ($_v['type']) {
                 case 1:
                     $_list[$_v['pid']]['sub_button'][$_v['id']]['type'] = 'click';
                     $_list[$_v['pid']]['sub_button'][$_v['id']]['key'] = $_v['key'];
                     break;
                 case 2:
                     $_list[$_v['pid']]['sub_button'][$_v['id']]['type'] = 'view';
                     $_list[$_v['pid']]['sub_button'][$_v['id']]['url'] = htmlspecialchars_decode($_v['url']);
                     break;
             }
         }
     }
     $list = ArrayHelper::array_number_key($_list);
     foreach ($list as $_k => $_v) {
         if (isset($_v['sub_button'])) {
             $_temp = ArrayHelper::array_number_key($_v['sub_button']);
             $list[$_k]['sub_button'] = $_temp;
         }
     }
     //创建自定义菜单
     $options = array('token' => C('TOKEN'), 'encodingaeskey' => C('ENCODINGAESKEY'), 'appid' => C('APPID'), 'appsecret' => C('APPSECRET'));
     $wechat = new Wechat($options);
     $wechat->valid(true);
     $lists['button'] = $list;
     $create_result = $wechat->createMenu($lists);
     if ($create_result) {
         $this->success('创建成功,24小时内生效');
     } else {
         $this->error($wechat->errMsg);
     }
 }
 public function lists()
 {
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询会员列表数据
     $user_id = array_column($list, 'user_id');
     $user_map['id'] = array('in', $user_id);
     $user_list = D('User')->_list($user_map, 'id, username, name');
     $user_list = ArrayHelper::array_key_replace($user_list, 'id', 'user_id');
     $user_list = array_column($user_list, null, 'user_id');
     //合并数据
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $user_list[$_v['user_id']]);
     }
     return $list;
 }
Example #10
0
 public function lists($map = array(), $field = '', $order = '', $page = 1, $page_size = 10)
 {
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询会员表
     $member_id = array_column($list, 'member_id');
     $member_id = array_unique($member_id);
     $member_map['id'] = array('in', $member_id);
     $member_list = D('Member')->_list($member_map, 'id,username');
     $member_list = ArrayHelper::array_key_replace($member_list, 'id', 'member_id');
     $member_list = array_column($member_list, null, 'member_id');
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $member_list[$_v['member_id']]);
     }
     return $list;
 }
 public function lists($map = array(), $order = '', $page = 1, $page_size = 10)
 {
     $field = 'id,class_id,name,mobile,wechat_number,recommend,work_date,month_sale,brand,reason,province,city,source,is_approve';
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询代理分类
     $class_id = array_column($list, 'class_id');
     $class_map['id'] = array('in', $class_id);
     $class_field = 'id,name,price';
     $class_list = D('AgentClass')->_list($class_map, $class_field);
     ArrayHelper::ArrayKeyReplace($class_list, 'id', 'class_id');
     ArrayHelper::ArrayKeyReplace($class_list, 'name', 'class_name');
     $class_list = array_column($class_list, null, 'class_id');
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $class_list[$_v['class_id']]);
     }
     return $list;
 }
 public function lists($map = array(), $order = '', $page = 1, $page_size = 10)
 {
     $field = 'id,key_id,title,desc,pic,url,ctime';
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //查询关键词
     $key_id = array_column($list, 'key_id');
     $key_map['id'] = array('in', $key_id);
     $key_field = 'id,name';
     $key_list = D('Keywords')->_list($key_map, $key_field);
     ArrayHelper::ArrayKeyReplace($key_list, 'id', 'key_id');
     ArrayHelper::ArrayKeyReplace($key_list, 'name', 'key_name');
     $key_list = array_column($key_list, null, 'key_id');
     //合并数据
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $key_list[$_v['key_id']]);
     }
     return $list;
 }
 /**
  * 获取管理员列表
  * @param  array   $map       查询条件
  * @param  string  $order     排序规则
  * @param  integer $page      页数
  * @param  integer $page_size 每页条数
  * @return array              查询出的数据
  */
 public function lists($map = array(), $order = '', $page = 1, $page_size = 10)
 {
     //获取管理员列表
     $field = 'id,group_id,username,password,nickname,ctime';
     $list = $this->_list($map, $field, $order, $page, $page_size);
     if (empty($list)) {
         return array();
     }
     //获取组列表
     $group_id = array_column($list, 'group_id');
     $group_map['id'] = array('in', $group_id);
     $group_list = D('Group')->lists($group_map);
     ArrayHelper::ArrayKeyReplace($group_list, 'id', 'group_id');
     ArrayHelper::ArrayKeyReplace($group_list, 'name', 'group_name');
     $group_list = array_column($group_list, null, 'group_id');
     //合并数据
     foreach ($list as $_k => $_v) {
         $list[$_k] = array_merge($_v, $group_list[$_v['group_id']]);
     }
     return $list;
 }
 /**
  * 权限管理
  */
 public function permission()
 {
     $map['is_show'] = 1;
     $node_list = D('Node')->lists($map, 'pid asc,id asc');
     $node_list = ArrayHelper::array2_filter($node_list, 'is_show', 0);
     $node_list = array_column($node_list, null, 'id');
     $list = array();
     foreach ($node_list as $_k => $_v) {
         if (intval($_v['pid']) === 0) {
             $list[$_k] = $_v;
         } else {
             $list[$_v['pid']]['child_list'][] = $_v;
         }
     }
     $list = ArrayHelper::array_number_key($list);
     // dump($list);exit();
     // 查询拥有的权限
     $has_map['group_id'] = I('id');
     $has_node_list = D('GroupNodeMap')->_list($has_map, 'node_id');
     $has_node_list = array_column($has_node_list, 'node_id');
     $this->assign('node_list', $list);
     $this->assign('has_node_list', $has_node_list);
     $this->display();
 }
Example #15
0
 public function get($map = array(), $fields = '', $order = '')
 {
     $info = $this->_get($map);
     if (empty($info)) {
         return false;
     }
     $level_map['id'] = $info['level_id'];
     $level_info = D('UserLevel')->_get($level_map);
     $level_info = ArrayHelper::array_key_replace($level_info, array('id', 'name'), array('level_id', 'level_name'));
     $info = array_merge($info, $level_info);
     return $info;
 }
 /**
  * 获取左侧菜单列表
  * @method menu
  * @return array 菜单列表
  */
 private function menu()
 {
     $node_list = session('node_list');
     $node_list = ArrayHelper::array2_filter($node_list, 'is_show', 0);
     $node_list = array_column($node_list, null, 'id');
     $list = array();
     foreach ($node_list as $_k => $_v) {
         if (intval($_v['pid']) === 0) {
             $list[$_k] = $_v;
         } else {
             $list[$_v['pid']]['child_list'][] = $_v;
         }
     }
     $list = ArrayHelper::array_number_key($list);
     return $list;
 }
Example #17
0
 public function match()
 {
     $AssistModel = D('Assist');
     $EarnModel = D('Earn');
     //舍列表
     $assist_map['surplus_money'] = array('neq', 0);
     $assist = $AssistModel->_list($assist_map, '', 'id asc');
     //得列表
     $earn_map['surplus_money'] = array('neq', 0);
     $earn = $EarnModel->_list($earn_map, '', 'id asc');
     if (empty($assist) || empty($earn)) {
         $this->success('匹配完成');
     }
     $assist_list = array();
     $earn_list = array();
     //拆分舍和得列表为100
     foreach ($assist as $_k => $_v) {
         $_count = $_v['surplus_money'] / 100;
         for ($i = 0; $i < $_count; $i++) {
             $_assist_list = $_v;
             $_assist_list['surplus_money'] = 100;
             array_push($assist_list, $_assist_list);
         }
     }
     foreach ($earn as $_k => $_v) {
         $_count = $_v['surplus_money'] / 100;
         for ($i = 0; $i < $_count; $i++) {
             $_earn_list = $_v;
             $_earn_list['surplus_money'] = 100;
             array_push($earn_list, $_earn_list);
         }
     }
     //舍和得开始匹配
     foreach ($earn_list as $_k => $_v) {
         //取出提供帮助列表中和获取收益不是同一个用户的数据
         $assist_id = false;
         foreach ($assist_list as $_i => $_j) {
             if ($_j['user_id'] != $_v['user_id']) {
                 $assist_id = $_j['id'];
                 unset($assist_list[$_i]);
                 break;
             }
         }
         if ($assist_id === false) {
             break;
         }
         $earn_list[$_k]['assist_id'] = $assist_id;
     }
     //匹配成订单
     $order_list = array();
     foreach ($earn_list as $_k => $_v) {
         $key = $_v['id'] . '+' . $_v['assist_id'];
         if (isset($order_list[$key])) {
             $order_list[$key]['money'] += $_v['surplus_money'];
         } else {
             $order_list[$key]['assist_id'] = $_v['assist_id'];
             $order_list[$key]['earn_id'] = $_v['id'];
             $order_list[$key]['money'] = $_v['surplus_money'];
         }
     }
     $assist = array_column($assist, null, 'id');
     $earn = array_column($earn, null, 'id');
     foreach ($order_list as $_k => $_v) {
         $assist[$_v['assist_id']]['surplus_money'] -= $_v['money'];
         if ($assist[$_v['assist_id']]['surplus_money'] == 0) {
             $assist[$_v['assist_id']]['status'] = 1;
         }
         $earn[$_v['earn_id']]['surplus_money'] -= $_v['money'];
         if ($earn[$_v['earn_id']]['surplus_money'] == 0) {
             $earn[$_v['earn_id']]['status'] = 1;
         }
     }
     $assist = ArrayHelper::array_number_key($assist);
     $earn = ArrayHelper::array_number_key($earn);
     $order_list = ArrayHelper::array_number_key($order_list);
     $OrderModel = D('Order');
     $OrderModel->startTrans();
     $save_assist_result = $AssistModel->addAll($assist, array(), true);
     $save_earn_result = $EarnModel->addAll($earn, array(), true);
     $save_order_result = $OrderModel->insertAll($order_list);
     if ($save_assist_result && $save_earn_result && $save_order_result) {
         $OrderModel->commit();
         $this->success('匹配成功');
     } else {
         $OrderModel->rollback();
         $this->error('匹配失败');
     }
 }