|
|
@@ -16,16 +16,48 @@ class CustomBalanceChangeController extends BaseController
|
|
|
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;
|
|
|
}
|
|
|
- $list = CustomBalanceChangeClass::getChangeList($where);
|
|
|
- util::success($list);
|
|
|
+ $respond = CustomBalanceChangeClass::getChangeList($where);
|
|
|
+ if ($export == 1) {
|
|
|
+ CustomBalanceChangeClass::exportData($respond, $this->mainId);
|
|
|
+ }
|
|
|
+ util::success($respond);
|
|
|
}
|
|
|
|
|
|
}
|