| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * hdApp 中央钱包(可用余额)接口
- */
- namespace hd\controllers;
- use bizHd\shop\classes\MainWalletChangeClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class MainWalletController extends BaseController
- {
- public $guestAccess = [];
- /**
- * 钱包变动明细分页 + 区间汇总
- * GET:page、searchTime、startTime、endTime、capitalType(可选)
- */
- public function actionChangeList()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['mainId'] = $this->mainId;
- if (isset($get['capitalType']) && $get['capitalType'] !== '') {
- $where['capitalType'] = (int) $get['capitalType'];
- }
- $searchTime = $get['searchTime'] ?? 'today';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- $list = MainWalletChangeClass::getChangeList($where);
- $summaryAmount = MainWalletChangeClass::getSummaryAmount($where);
- $main = $this->main;
- $walletBalance = $main->walletBalance ?? '0.00';
- $list['summary'] = [
- 'totalRecharge' => $summaryAmount['recharge'],
- 'totalConsume' => $summaryAmount['consume'],
- 'walletBalance' => round((float) $walletBalance, 2),
- ];
- util::success($list);
- }
- }
|