<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/20
 * Time: 13:39
 */

class FansAction extends CommonAction
{
    public function index()
    {
        $fans = D('Shopfavorites');
        //实例化fans模型
        $map = array('shop_id' => $this->shop_id);
        //查询条件
        if ($keyword = $this->_post('keyword', 'htmlspecialchars')) {
            $maps['nickname|mobile'] = array('like','%'.trim($keyword).'%');
            $Users = D('Users');
            $user = $Users->where($maps)->select();
            foreach ($user as $k => $val) {
                if ($val['user_id']) {
                    $user_ids[$val['user_id']] = $val['user_id'];
                }
            }
            if (!empty($user)) {
                $map['user_id'] = array('in',$user_ids);
            }else{
                $rs = array(
                    'success' =>true,
                    'keyword'=> $keyword,
                    'list'=>'',
                    'error_msg'=>''
                );
                die(json_encode($rs));
            }

        }
        $count = $fans->where($map)->count();
        // 查询满足要求的总记录数
        $maxpage=ceil($count/6);
        $page = $this->_param('page', 'htmlspecialchars')?$this->_param('page', 'htmlspecialchars'):1;
        $list = $fans->where($map)->order(array('favorites_id' => 'desc'))->page($page.',6')->select();
        $user_ids = array();
        foreach ($list as $k => $val) {
            if ($val['user_id']) {
                $users=D('Users')->where(array('user_id'=>$val['user_id']))->find();
                //print_r($users);
                $list[$k]['username']=$users['nickname'];
                $list[$k]['mobile']=$users['mobile'];
            }
        }

        $rs = array(
            'success' =>true,
            'keyword'=> $keyword,
            'list'=> $list,
            'page'=> $page,
            'maxpage'=>$maxpage,
            'error_msg'=>''
        );
        die(json_encode($rs));
    }
    /*public function add($user_id = 0)
    {
        $fans = D('Shopfavorites');
        $uid = (int) $user_id;
        $user = D('Users')->find($user_id);
        $shop = D('shop')->find($this->shop_id);
        if ($this->isPost()) {
            $integral = (int) $_POST['integral'];
            if ($integral <= 0) {
                $this->fengmiMsg('请输入正确的积分');
            }
            if ($this->member['integral'] < $integral) {
                $this->fengmiMsg('您的账户积分不足');
            }
            D('Users')->addIntegral($this->uid, -$integral, '赠送会员积分');
            D('Users')->addIntegral($user_id, $integral, '获得商家赠送积分');
            $this->fengmiMsg('赠送积分成功!', U('store/fans/index'));
        } else {
            $this->assign('shop', $shop);
            $this->assign('jifen', $this->member['integral']);
            $this->assign('user', $user);
            $this->display();
        }
    }*/
}<commit_msg>testzzz<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/20
 * Time: 13:39
 */

class FansAction extends CommonAction
{
    public function index()
    {
        $fans = D('Shopfavorites');
        //实例化fans模型
        $map = array('shop_id' => $this->shop_id);
        //查询条件
        if ($keyword = $this->_post('keyword', 'htmlspecialchars')) {
            $maps['nickname|mobile'] = array('like','%'.trim($keyword).'%');
            $Users = D('Users');
            $user = $Users->where($maps)->select();
            foreach ($user as $k => $val) {
                if ($val['user_id']) {
                    $user_ids[$val['user_id']] = $val['user_id'];
                }
            }
            if (!empty($user)) {
                $map['user_id'] = array('in',$user_ids);
            }else{
                $rs = array(
                    'success' =>true,
                    'keyword'=> $keyword,
                    'list'=>'',
                    'error_msg'=>''
                );
                die(json_encode($rs));
            }

        }
        $count = $fans->where($map)->count();
        // 查询满足要求的总记录数
        $maxpage=ceil($count/6);
        $page = $this->_param('page', 'htmlspecialchars')?$this->_param('page', 'htmlspecialchars'):1;
        $list = $fans->where($map)->order(array('favorites_id' => 'desc'))->page($page.',6')->select();
        $user_ids = array();
        foreach ($list as $k => $val) {
            if ($val['user_id']) {
                $users=D('Users')->where(array('user_id'=>$val['user_id']))->find();
                //print_r($users);
                $list[$k]['username']=$users['nickname'];
                $list[$k]['mobile']=$users['mobile'];
                $list[$k]['face']=$users['face'];
            }
        }

        $rs = array(
            'success' =>true,
            'keyword'=> $keyword,
            'list'=> $list,
            'page'=> $page,
            'maxpage'=>$maxpage,
            'error_msg'=>''
        );
        die(json_encode($rs));
    }
    /*public function add($user_id = 0)
    {
        $fans = D('Shopfavorites');
        $uid = (int) $user_id;
        $user = D('Users')->find($user_id);
        $shop = D('shop')->find($this->shop_id);
        if ($this->isPost()) {
            $integral = (int) $_POST['integral'];
            if ($integral <= 0) {
                $this->fengmiMsg('请输入正确的积分');
            }
            if ($this->member['integral'] < $integral) {
                $this->fengmiMsg('您的账户积分不足');
            }
            D('Users')->addIntegral($this->uid, -$integral, '赠送会员积分');
            D('Users')->addIntegral($user_id, $integral, '获得商家赠送积分');
            $this->fengmiMsg('赠送积分成功!', U('store/fans/index'));
        } else {
            $this->assign('shop', $shop);
            $this->assign('jifen', $this->member['integral']);
            $this->assign('user', $user);
            $this->display();
        }
    }*/
}
{'fraction_non_alphanumeric': 0.20868536667793172, 'fraction_numerical': 0.005407232173031429, 'mean_word_length': 1.6686203787195673, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4883439', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1903, 'n_words': 273}