PayDetailService.php 743 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\admin\service\order;
  3. use app\model\PayDetail;
  4. use support\Db;
  5. class PayDetailService
  6. {
  7. public static function checkPaying()
  8. {
  9. Db::beginTransaction();
  10. try {
  11. $timeUnix = strtotime("-30 minutes");
  12. $payDetails = PayDetail::where('pay_status', 'WAITING')
  13. ->where('pay_addtimes', '<', $timeUnix)
  14. ->get();
  15. foreach ($payDetails as $payDetail) {
  16. // 订单主表
  17. PayDetail::where('pay_id', $payDetail->pay_id)->update([
  18. 'pay_status' => 'CANCEL',
  19. ]);
  20. }
  21. Db::commit();
  22. } catch (\Exception $e) {
  23. Db::rollBack();
  24. }
  25. }
  26. }