coupon-admin/app/controller/manager/Bill.php

106 lines
4.0 KiB
PHP

<?php
namespace app\controller\manager;
/*流水查看*/
use app\model\CouponBill;
use app\repository\BillRepository;
class Bill extends Base
{
/**
* 流水列表
*
* @return Json|View
*/
public function index()
{
$startTime = input("start_time/s", date("Y-m-d H:i:s", strtotime(date("Y-m-d") . " -1 month")));
$endTime = input("end_time/s", date("Y-m-d 00:00:00"));
if ($this->request->isPost()) {
$repo = BillRepository::getInstance();
$keyword = $this->request->param('keyword/s', '');
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$orders = ['a.id' => 'desc'];
$list = $repo->billList($page, $size, $keyword, $startTime, $endTime, $orders);
$list['agency_money_sum'] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::agency_money, $keyword, $startTime, $endTime);
$list['admin_money_sum'] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::admin_money, $keyword, $startTime, $endTime);
$list['consumer_money_sum'] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::consumer_money, $keyword, $startTime, $endTime);
return $this->json(0, 'success', $list);
}
$this->data["agency_money_sum"] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::agency_money);
$this->data["admin_money_sum"] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::admin_money);
$this->data["consumer_money_sum"] = BillRepository::getInstance()->getAgencyMoneySum(CouponBill::consumer_money);
$this->data["startTime"] = $startTime;
$this->data["endTime"] = $endTime;
return $this->view();
}
/**
* 充值流水
*
* @return Json|View
* @throws Exception
*/
public function recharge()
{
$startTime = input("start_time/s", date("Y-m-d H:i:s", strtotime(date("Y-m-d") . " -1 month")));
$endTime = input("end_time/s", date("Y-m-d 00:00:00"));
if ($this->request->isPost()) {
$repo = BillRepository::getInstance();
$keyword = $this->request->param('keyword/s', '');
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$orders = ['a.id' => 'desc'];
$list = $repo->rechargeBillList($page, $size, $keyword, $startTime, $endTime, $orders);
$list['recharge_money_sum'] = BillRepository::getInstance()->getRechargeMoneySum($keyword, $startTime, $endTime);
return $this->json(0, 'success', $list);
}
$this->data["recharge_money_sum"] = BillRepository::getInstance()->getRechargeMoneySum();
$this->data["startTime"] = $startTime;
$this->data["endTime"] = $endTime;
return $this->view();
}
/**
* 扣款流水
*
* @return Json|View
* @throws Exception
*/
public function deduction()
{
$startTime = input("start_time/s", date("Y-m-d H:i:s", strtotime(date("Y-m-d") . " -1 month")));
$endTime = input("end_time/s", date("Y-m-d 00:00:00"));
if ($this->request->isPost()) {
$repo = BillRepository::getInstance();
$keyword = $this->request->param('keyword/s', '');
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$orders = ['a.id' => 'desc'];
$list = $repo->deductionBillList($page, $size, $keyword, $startTime, $endTime, $orders);
$list['deduction_money_sum'] = BillRepository::getInstance()->getDeductionMoneySum($keyword,$startTime, $endTime);
return $this->json(0, 'success', $list);
}
$this->data["deduction_money_sum"] = BillRepository::getInstance()->getDeductionMoneySum();
$this->data["startTime"] = $startTime;
$this->data["endTime"] = $endTime;
return $this->view();
}
}