request->get(); $ghsId = $get['ghsId'] ?? 0; $endTime = $get['endTime']??''; if(empty($ghsId)){ util::success([]); } $ghs = GhsClass::getById($ghsId,true); if(empty($ghs)){ util::success([]); } if($ghs->ownMainId != $this->mainId){ util::fail('不是你的供货商'); } $where = []; $where['ghsId'] = $ghsId; if(!empty($endTime)){ $time = bcadd(strtotime($endTime),86400); $endDate = date("Y-m-d 00:00:00",$time); $where['addTime<']=$endDate; } $list = GhsDebtRecordClass::getRecordList($where); util::success($list); } //应收款统计 ssh 20240528 public function actionPastList() { $get = Yii::$app->request->get(); $export = $get['export'] ?? 0; $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today'; $startTime = $get['startTime'] ?? ''; $endTime = $get['endTime'] ?? ''; $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true); $end = $period['endTime']; $ghsList = GhsClass::getAllByCondition(['ownMainId' => $this->mainId], null, 'id,name,mobile', 'id'); $currentDate = date('Y-m-d 00:00:00', bcadd(strtotime($end),86400)); $totalAmount = 0; if(!empty($ghsList)){ foreach($ghsList as $key => $ghs){ $ghsId = $ghs['id']??0; $change = GhsDebtRecordClass::getByCondition(['ghsId'=>$ghsId,'addTime<'=>$currentDate],true,'addTime DESC'); $amount = $change->balance ?? 0; $totalAmount = bcadd($totalAmount,$amount,2); $ghsList[$key]['currentDebAmount'] =$amount; } $ghsList = array_values($ghsList); } if ($export == 1) { $mainId = $this->mainId; if (empty($ghsList)) { util::fail('没有数据需要导出'); } ini_set('memory_limit', '2045M'); set_time_limit(0); GhsDebtRecordClass::exportPastList($ghsList, $mainId); util::stop(); } util::success(['list' => $ghsList, 'totalAmount' => $totalAmount]); } }