getPond(); GrantPond::where('id',$pondData->{'id'})->increment('grand_total',$distribution->{'lk_num'}); GrantItem::create([ 'm_id' => $distribution->{'m_id'}, 'contract_id' => $distribution->{'id'}, 'add_money' => $distribution->{'lk_num'}, ]); } function getPond() { $pondData = GrantPond::where('status', 1)->first(); if (empty($pondData)) { $pondData=$this->creationPond(); } else { //验证累计时间 $endDate= Carbon::parse($pondData->{'end_date'}, config('app.timezone'))->format('Y-m-d H:i:s'); if($endDateupdate(['status' => 2]); $pondData=$this->creationPond(); } } return $pondData; } private function creationPond(){ return GrantPond::create([ 'grand_total'=>0, 'average_money' => 0, 'total_num' => 0, 'status' => 1, 'end_date' => $this->getEndDate(), 'distribute_date' => $this->getDistributeDate(), 'pond_sn' => IndentNumServer::creatServer()->getIndentNum(2) ]); } /** * 获取发放时间 * @return false|string */ function getDistributeDate(){ $date = date('d'); if ($date <= 5) { $distributeDate = date('Y-m-10 00:00:00'); } elseif ($date <= 15) { $distributeDate = date('Y-m-20 00:00:00'); } elseif ($date <= 25) { $distributeDate = date('Y-m-d 00:00:00',strtotime(date('Y-m-1 00:00:00',strtotime('+1 month')))-1); }else { $distributeDate = date('Y-m-10 00:00:00',strtotime('+1 month')); } return $distributeDate; } /** * 获取积累时间 * @return false|string */ function getEndDate() { $date = date('d'); if ($date <= 5) { $endDate = date('Y-m-5 00:00:00'); } elseif ($date <= 15) { $endDate = date('Y-m-15 00:00:00'); } elseif ($date <= 25) { $endDate = date('Y-m-25 00:00:00'); }else { $endDate = date('Y-m-5 00:00:00',strtotime('+1 month')); } return $endDate; } }