Commit 126ec313 authored by clone's avatar clone

后台收入列表

parent ca3d4063
......@@ -2,6 +2,7 @@
namespace app\api\service;
use app\model\UAccountBalance;
use app\model\UAccountCheck;
use app\model\Users;
......@@ -56,6 +57,13 @@ class AccountBalanceService{
return $res;
}
public function getBalanceCount($params){
$balanceCount = $this->m_account_balance->getBalanceCount($params);
$accountCheckModel = new UAccountCheck();
$checkCount = $accountCheckModel->getCheckCount($params);
return $balanceCount + $checkCount ;
}
/**
* 获取客户信息
......
......@@ -16,16 +16,24 @@ class AccountBalance extends Basic{
}
/**
* @return \think\Response
*/
public function userAccountBalanceList()
{
$params = $this->params;
$params = array(
/* $params = array(
"create_time_start" => '2019-03-14 11:03:10',
"create_time_end" => '2019-03-15 11:03:10',
"user_phone" => '6471',
"user_id" => '111',
);
$result["list"] = $this->s_account_balance->getBalanceList($params);
);*/
$data = $this->s_account_balance->getBalanceList($params);
if(count($data) <= 0){
return $this->response("200", "null");
}
$result["list"] = $data;
$result["total"] = $this->s_account_balance->getBalanceCount($params);
return $this->response("200", "success!", $result);
}
......
......@@ -9,12 +9,20 @@ class UAccountBalance extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'u_account_balance';
private $db_;
public function addBalance($data) {
$time = date("Y-m-d H:i:s", time());
public function __construct($data = [])
{
$this->db_ = Db::table($this->table);
parent::__construct($data);
}
public function addBalance($data)
{
$time = date("Y-m-d H:i:s", time());
$data['create_time'] = $time;
$data['update_time'] = $time;
$data["status"] = 0;
$data["status"] = 0;
return $this->insert($data);
}
......@@ -22,40 +30,49 @@ class UAccountBalance extends Model
public function getBalanceList($params)
{
$pageNo = empty($params['pageNo']) ? 0 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$pageNo = empty($params['pageNo']) ? 0 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where_str = "";
if (!empty($params['create_time_start']) && !empty($params['create_time_end'])) {
$where_str .= " and create_time BETWEEN '".$params['create_time_start']. " 00:00:00' AND '" .$params['create_time_end'] . " 23:59:59'";
$where_str .= " and create_time BETWEEN '" . $params['create_time_start'] . " 00:00:00' AND '" . $params['create_time_end'] . " 23:59:59'";
}
if (!empty($params['user_phone'])) {
$where_str .= " and user_phone LIKE '%".$params['user_phone']."%'";
$where_str .= " and user_phone LIKE '%" . $params['user_phone'] . "%'";
}
if (!empty($params['user_id'])) {
$where_str .= " and user_id = {$params['user_phone']}" ;
$where_str .= " and user_id = {$params['user_id']}";
}
$sql = "SELECT
*
FROM
(
( SELECT id, user_id,source_id , money, user_name,create_time, 1 AS is_essay FROM `u_account_balance` WHERE `status` = 0 $where_str) UNION
$sql = "SELECT * FROM (
( SELECT id, user_id,source_id, money, user_name,create_time, 1 AS is_essay FROM `u_account_balance` WHERE `status` = 0 $where_str) UNION
( SELECT id, user_id,0 as source_id ,money, user_name,create_time, 2 AS is_essay FROM `u_account_check` WHERE `status` IN ( 0, 1, 2 ) $where_str)
) AS aaa
ORDER BY
`create_time` DESC
LIMIT {$pageNo},
{$pageSize}";
) AS aaa ORDER BY `create_time` DESC LIMIT {$pageNo}, {$pageSize}";
$result = $this->query($sql);
echo $this->getLastSql();
//echo $this->getLastSql();
return $result;
}
/**
* @param $params
* @return int|string
*/
public function getBalanceCount($params)
{
$where_arr = [];
if (!empty($params['create_time_start']) && !empty($params['create_time_end'])){
$where_arr['create_time'] = array('between', array($params['create_time_start'], $params['create_time_end']));
}
if (!empty($params['user_phone']) ){
$where_arr['user_phone'] = array("like", "%" . trim($params['user_phone']) . "%");
}
if (!empty($params['user_id'])) {
$where_arr['user_id'] = $params['user_id'];
}
$where_arr['status'] = 0;
$result = $this->db_
->field("id")
->where($where_arr)
->count();
return $result;
}
......
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User: fuju
* Date: 2019/3/14
* Time: 14:13
*/
class UAccountCheck extends Model{
// 设置当前模型对应的完整数据表名称
protected $table = 'u_account_check';
private $db_;
public function __construct($data = [])
{
$this->db_ = Db::table($this->table);
parent::__construct($data);
}
/**
* @param $params
* @return int|string
*/
public function getCheckCount($params)
{
$where_arr = [];
if (!empty($params['create_time_start']) && !empty($params['create_time_end'])){
$where_arr['create_time'] = array('between', array($params['create_time_start'], $params['create_time_end']));
}
if (!empty($params['user_phone']) ){
$where_arr['user_phone'] = array("like", "%" . trim($params['user_phone']) . "%");
}
if (!empty($params['user_id'])) {
$where_arr['user_id'] = $params['user_id'];
}
$where_arr['status'] = array("in", "0,1,2");;
$result = $this->db_
->field("id")
->where($where_arr)
->count();
return $result;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment