<?php

namespace app\user\controller;

use app\user\model\UserScore as UserScoreModel;
use fastphp\base\Controller;

class UserScore extends Controller
{
    public function export()
    {
        $user_score_model = new UserScoreModel;

        $list = $user_score_model->field('UpdateTime,UserName,OperateUserName,ScoreTypeName,RestAmount1,ScoreValue,RestAmount2,Remark')->fetchAll();
        
        \exportToCsv('test.csv',['创建时间','会员号','操作人员','资金项目','操作前余额','金额','操作后余额','备注'],$list);
    }

    /**
     * @description: 获取资金明细列表
     * @param {*}
     * @return {*}
     */    
    public function getList() {
        $data = json_decode(file_get_contents("php://input"),true);
        $page = 0;
        if (isset($data['page'])) {
            $page = ($data['page'] - 1) * 50;
        }
        $user_score_model = new UserScoreModel;
        $list = $user_score_model->getListPage(['UserId'=>$this->userinfo['UserId']],'*','id desc',"$page,50");
        echo json_encode($list);
    }
}
