123456789101112131415161718192021222324252627282930 |
- <?php
- namespace app\admin\service\order;
- use app\model\PayDetail;
- use support\Db;
- class PayDetailService
- {
- public static function checkPaying()
- {
- Db::beginTransaction();
- try {
- $timeUnix = strtotime("-30 minutes");
- $payDetails = PayDetail::where('pay_status', 'WAITING')
- ->where('pay_addtimes', '<', $timeUnix)
- ->get();
- foreach ($payDetails as $payDetail) {
- // 订单主表
- PayDetail::where('pay_id', $payDetail->pay_id)->update([
- 'pay_status' => 'CANCEL',
- ]);
- }
- Db::commit();
- } catch (\Exception $e) {
- Db::rollBack();
- }
- }
- }
|