request->post(); $current = time(); $list = ClearClass::getAllByCondition(['shopId' => $this->shopId, 'status' => PurchaseClearClass::STATUS_AWAIT_PAY], null, '*', null, true); if (!empty($list)) { foreach ($list as $item) { $deadline = $item->deadline; $deadTime = strtotime($deadline); if ($current > $deadTime) { $item->status = PurchaseClearClass::STATUS_EXPIRE; $item->save(); } else { util::fail('还有结算订单待付款'); } } } $post['sjId'] = $this->sjId; $post['shopId'] = $this->shopId; $post['clearStyle'] = dict::getDict('clearStyle', 'gys2KmGys'); $post['customShopAdminId'] = $this->shopAdminId; $post['customShopId'] = $this->shopId ?? 0; $shopAdmin = $this->shopAdmin; $shopAdminName = $shopAdmin['name'] ?? ''; $post['customShopAdminName'] = $shopAdminName; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $respond = ClearClass::addOrder($post); $transaction->commit(); util::success($respond); } catch (\Exception $e) { $transaction->rollBack(); Yii::info("下单失败原因:" . $e->getMessage()); util::fail('下单失败'); } } }