更新注释
This commit is contained in:
@@ -7,10 +7,15 @@ use common\models\ChargeCashPayRecord;
|
||||
use common\models\Ledger;
|
||||
|
||||
/**
|
||||
* @doc-module 分账
|
||||
* @doc-module 待付
|
||||
*/
|
||||
class ChargeCashController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* 待付列表
|
||||
*
|
||||
* @return \yii\data\ActiveDataProvider
|
||||
*/
|
||||
public function actionList()
|
||||
{
|
||||
// TODO 待完善
|
||||
@@ -51,44 +56,61 @@ class ChargeCashController extends BaseAdminController
|
||||
return $this->create($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计代付金额
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function actionCount()
|
||||
{
|
||||
// 查询充值提现记录
|
||||
$query = ChargeCashPayRecord::find();
|
||||
// 筛选状态为2的记录
|
||||
$list = $query->where(['status' => 2])->all();
|
||||
|
||||
// 初始化各时间段的充值提现金额
|
||||
$today = 0; // 今日
|
||||
$yesterday = 0; // 昨天
|
||||
$week = 0; // 本周
|
||||
$month = 0; // 本月
|
||||
$total = 0;
|
||||
$total = 0; // 总计
|
||||
// 遍历记录,按时间累加各时间段的金额
|
||||
foreach ($list as $item) {
|
||||
// 今日的记录
|
||||
if ($item->updated_at >= strtotime(date('Y-m-d'))) {
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
$week = bcadd($week, $item->charge_cash, 2);
|
||||
$month = bcadd($month, $item->charge_cash, 2);
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
// 昨天的记录
|
||||
} elseif ($item->updated_at >= strtotime(date('Y-m-d', strtotime('-1 day'))) && $item->updated_at < strtotime(date('Y-m-d'))) {
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
$week = bcadd($week, $item->charge_cash, 2);
|
||||
$month = bcadd($month, $item->charge_cash, 2);
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
// 本周的记录
|
||||
} elseif ($item->updated_at >= strtotime(date('Y-m-d', strtotime('-7 day'))) && $item->updated_at < strtotime(date('Y-m-d', strtotime('-1 day')))) {
|
||||
$week = bcadd($week, $item->charge_cash, 2);
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
$month = bcadd($month, $item->charge_cash, 2);
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
// 本月的记录
|
||||
} elseif ($item->updated_at >= strtotime(date('Y-m-01'))) {
|
||||
$month = bcadd($month, $item->charge_cash, 2);
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
// 本年的记录
|
||||
} elseif ($item->updated_at >= strtotime(date('Y-01-01'))) {
|
||||
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
// 更早的记录
|
||||
} else {
|
||||
$total = bcadd($total, $item->charge_cash, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// 返回各时间段的充值提现金额
|
||||
return [
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
|
||||
Reference in New Issue
Block a user