72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller\app\agent;
|
|
|
|
use app\common\controller\Api;
|
|
use think\Db;
|
|
/**
|
|
* 钱包
|
|
*/
|
|
class Wallet extends Api
|
|
{
|
|
|
|
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
|
|
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
|
|
//如果接口已经设置无需登录,那也就无需鉴权了
|
|
//
|
|
// 无需登录的接口,*表示全部
|
|
protected $noNeedLogin = [];
|
|
// 无需鉴权的接口,*表示全部
|
|
protected $noNeedRight = ['*'];
|
|
|
|
public function getMoney(){
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取资产信息
|
|
* @return void
|
|
*/
|
|
public function getMoneyLog(){
|
|
$limit = input('limit',10);
|
|
$page = input('page',1);
|
|
$mode = input('mode',0);
|
|
$time = input('time',time());
|
|
|
|
$type = input('type','money');
|
|
|
|
|
|
$where = [
|
|
'user_id'=>$this->auth->id
|
|
];
|
|
|
|
$startOfMonth = strtotime(date('Y-m-01',$time)); // 获取当前月份的第一天的时间戳
|
|
$endOfMonth = strtotime(date('Y-m-t 23:59:59',$time)); // 获取当前月份的最后一天的时间戳
|
|
|
|
$rows = new \app\api\model\app\agent\Money();
|
|
|
|
if($mode == 1){
|
|
$rows->where('before', 'exp', Db::raw('> `after`'));
|
|
}else if($mode == 2){
|
|
$rows->where('before', 'exp', Db::raw('< `after`'));
|
|
}
|
|
|
|
$list = $rows
|
|
->where($where)
|
|
->limit($limit)->page($page)
|
|
->where('createtime', 'BETWEEN', [$startOfMonth, $endOfMonth])
|
|
->order('createtime','desc')
|
|
->select();
|
|
|
|
$data = [];
|
|
|
|
if(!empty($list)){
|
|
foreach ($list as $item){
|
|
$item['value'] = $type=='money' ? $item['money'] : $item['score'];
|
|
$item['value'] = $item['value'] > 0 ? '+'.$item['value'] : $item['value'];
|
|
}
|
|
}
|
|
|
|
$this->success('获取成功', $list);
|
|
}
|
|
} |