getTargets(); $this->outputInfo(sprintf("総件数:%d件", $targets->count())); foreach ($targets as $target) { try { $this->handleData($target); } catch (SkipException $e) { $this->outputWarn($e->getMessage()); } } return self::RESULTCODE_SUCCESS; } public function handleData(YuchoPaymentResult|SmbcPayment|SmbcAccountTransferResult|BankCheckResult|CreditcardAutoPaymentResult $payment) { $manager = new PoolTransferManager(); $manager->moveToPool($payment); } /** * @return Collection */ public function getTargets() { /** * @var Collection */ $ret = collect(); // ゆうちょ振込 $query = YuchoPaymentResult::getQuery()->whereNotIn(YuchoPaymentResult::FIELD_POOL_DONE, ["済"]) ->whereNotNull(YuchoPaymentResult::FIELD_CUSTOMER_CODE) ->where(YuchoPaymentResult::FIELD_PAYMENT_AMOUNT, 0, KintoneRecordQueryOperator::GT); $targets = YuchoPaymentResult::getAccess()->all($query); $ret->concat($targets); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("ゆうちょ件数:%d件", $targets->count())); // コンビニ支払 $query = SmbcPayment::getQuery()->whereNotIn(SmbcPayment::FIELD_POOL_DONE, ["済"]) ->whereNotNull(SmbcPayment::FIELD_CUSTOMER_CODE) ->where(SmbcPayment::FIELD_PAYMENT_AMOUNT, 0, KintoneRecordQueryOperator::GT) ->whereIn(SmbcPayment::FIELD_STATUS, [SmbcPaymentStatus::S002_決済結果待ち]); $targets = SmbcPayment::getAccess()->all($query); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("コンビニ支払:%d件", $targets->count())); // 口座振替 $query = SmbcAccountTransferResult::getQuery()->whereNotIn(SmbcAccountTransferResult::FIELD_POOL_DONE, ["済"]) ->whereNotNull(SmbcAccountTransferResult::FIELD_CUSTOMER_CODE) ->where(SmbcAccountTransferResult::FIELD_PAYMENT_AMOUNT, 0, KintoneRecordQueryOperator::GT); $targets = SmbcAccountTransferResult::getAccess()->all($query); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("口座振替:%d件", $targets->count())); // バンクチェック $query = BankCheckResult::getQuery()->whereNotIn(BankCheckResult::FIELD_POOL_DONE, ["済"]) ->whereNotNull(BankCheckResult::FIELD_CUSTOMER_CODE) ->where(BankCheckResult::FIELD_REMAINING_AMOUNT, 0, KintoneRecordQueryOperator::LE); $targets = BankCheckResult::getAccess()->all($query); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("バンクチェック 支払完了:%d件", $targets->count())); // バンクチェック 支払期限切れ $query = BankCheckResult::getQuery()->whereNotIn(BankCheckResult::FIELD_POOL_DONE, ["済"]) ->whereNotNull(BankCheckResult::FIELD_CUSTOMER_CODE) ->where(BankCheckResult::FIELD_REMAINING_AMOUNT, 0, KintoneRecordQueryOperator::NEQ) ->whereDate(BankCheckResult::FIELD_PAYMENT_EXPIRES_DATE, DateUtil::now(), KintoneRecordQueryOperator::LT); $targets = BankCheckResult::getAccess()->all($query); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("バンクチェック 支払期限切れ:%d件", $targets->count())); // クレジットカード $query = CreditcardAutoPaymentResult::getQuery()->whereNotIn(CreditcardAutoPaymentResult::FIELD_POOL_DONE, ["済"]) ->whereNotNull(CreditcardAutoPaymentResult::FIELD_CUSTOMER_CODE) ->where(CreditcardAutoPaymentResult::FIELD_PAYMENT_AMOUNT, 0, KintoneRecordQueryOperator::GT); $targets = CreditcardAutoPaymentResult::getAccess()->all($query); CollectionUtil::pushAll($ret, $targets); $this->outputInfo(sprintf("クレジットカード支払 :%d件", $targets->count())); return $ret; } }