61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
|
defined('WXAPP_APP') or exit('No direct script access allowed');
|
|
|
|
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
|
|
|
class BizAccountLog extends Wxapp
|
|
{
|
|
function __construct($inputs, $app_key)
|
|
{
|
|
parent::__construct($inputs, $app_key);
|
|
$this->load->model('biz/biz_accountLog_model', 'accountlog_model');
|
|
$this->load->library('bizAccount');
|
|
}
|
|
|
|
public function get_lists()
|
|
{
|
|
$params = $this->input_param();
|
|
$bizId = $this->get_biz_id();
|
|
$bizAccount = new BizAccount();
|
|
$account = $bizAccount->getAccountBizId($bizId,true);
|
|
$sumUseMoney = $sumRechangeMoney = 0;
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
!$page && $page = 1;
|
|
!$size && $size = 20;
|
|
$where = ['account_id' => $account['id']];
|
|
if ($params['type']) {
|
|
$where['trade_type'] = $params['type'];
|
|
}
|
|
if ($params['month']) {
|
|
$month = $params['month'];
|
|
$where['c_time>='] = strtotime("first day of $month");
|
|
$where['c_time<='] = strtotime("last day of $month");;
|
|
}
|
|
$total = $this->accountlog_model->count($where);
|
|
$lists = [];
|
|
if ($total > 0) {
|
|
$rows = $this->accountlog_model->select($where, 'id desc', $page, $size);
|
|
if ($page == 1) {
|
|
$sumIn = $this->accountlog_model->sum('money_in', $where);
|
|
$sumRechangeMoney = $sumIn['money_in'];
|
|
$sumOut = $this->accountlog_model->sum('money_out', $where);
|
|
$sumUseMoney = $sumOut['money_out'];
|
|
}
|
|
foreach ($rows as $item) {
|
|
$temp = [
|
|
'id' => $item['id'],
|
|
'content' => $item['descrip'],
|
|
'money' => $item['money_in'] > 0 ? "+{$item['money_in']}" : "-{$item['money_out']}",
|
|
'time' => date('m-d H:i:s', $item['c_time']),
|
|
];
|
|
$lists[] = $temp;
|
|
}
|
|
}
|
|
$count = count($lists);
|
|
return [
|
|
'list' => $lists, 'total' => $count, 'sumRecharge' => $sumRechangeMoney,
|
|
'sumUseMoney' => $sumUseMoney, 'leftMoney' => $account['money_left']
|
|
];
|
|
}
|
|
} |