| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace ghs\controllers;
- use bizGhs\custom\classes\CustomBalanceChangeClass;
- use bizGhs\custom\classes\CustomClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class CustomBalanceChangeController extends BaseController
- {
- public $guestAccess = [];
- //欠款变动明细
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $export = $get['export'] ?? 0;
- $where = [];
- $where['mainId'] = $this->mainId;
- $searchTime = $get['searchTime'] ?? '';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
- } else {
- if ($export == 1) {
- util::fail('请选择时间');
- }
- }
- if ($export == 1) {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- if (isset($where['addTime']) == false) {
- util::fail('请选时间段');
- }
- $start = $where['addTime'][1][0];
- $end = $where['addTime'][1][1];
- $monthTime = bcmul(31, 86400);
- $startArea = strtotime($start);
- $endArea = strtotime($end);
- $diff = bcsub($endArea, $startArea);
- if ($diff > $monthTime) {
- util::fail('最长可导出一个月');
- }
- }
- $customId = $get['customId'] ?? 0;
- if (!empty($customId)) {
- $custom = CustomClass::getById($customId);
- CustomClass::valid($custom, $this->shopId);
- $where['customId'] = $customId;
- }
- $respond = CustomBalanceChangeClass::getChangeList($where);
- if ($export == 1) {
- CustomBalanceChangeClass::exportData($respond, $this->mainId);
- }
- util::success($respond);
- }
- }
|