false, 'message' => '用户买入物品撮合执行失败:' . $e->getMessage(), 'matched_orders' => 0, 'total_amount' => '0.00000', ]; } } /** * 执行单个商品的用户卖出物品撮合(带事务处理) * * @param int $itemId 商品ID * @param int $batchSize 批处理大小 * @return array 撮合结果 */ public static function executeUserSellItemMatchForItem(int $itemId, int $batchSize = 100): array { try { return DB::transaction(function () use ($itemId, $batchSize) { return MexMatchLogic::executeUserSellItemMatchForItem($itemId, $batchSize); }); } catch (\Exception $e) { return [ 'success' => false, 'message' => '用户卖出物品撮合执行失败:' . $e->getMessage(), 'matched_orders' => 0, 'total_amount' => '0.00000', ]; } } /** * 获取用户买入物品撮合统计信息 * * @return array 统计信息 */ public static function getUserBuyItemMatchStats(): array { return MexMatchLogic::getUserBuyItemMatchStats(); } /** * 获取用户卖出物品撮合统计信息 * * @return array 统计信息 */ public static function getUserSellItemMatchStats(): array { return MexMatchLogic::getUserSellItemMatchStats(); } /** * 检查用户买入物品撮合条件 * * @param int $itemId 商品ID * @return array 检查结果 */ public static function checkUserBuyItemMatchConditions(int $itemId): array { return MexMatchLogic::checkUserBuyItemMatchConditions($itemId); } /** * 检查用户卖出物品撮合条件 * * @param int $itemId 商品ID * @return array 检查结果 */ public static function checkUserSellItemMatchConditions(int $itemId): array { return MexMatchLogic::checkUserSellItemMatchConditions($itemId); } /** * 执行单个用户卖出物品订单的撮合(带事务处理) * * @param \App\Module\Mex\Models\MexOrder $order 用户卖出物品订单 * @return array 撮合结果 */ public static function executeUserSellItemOrderMatchWithTransaction(\App\Module\Mex\Models\MexOrder $order): array { try { return DB::transaction(function () use ($order) { return \App\Module\Mex\Logic\MexMatchLogic::executeUserSellItemOrderMatch($order); }); } catch (\Exception $e) { return [ 'success' => false, 'message' => '用户卖出物品订单撮合失败:' . $e->getMessage(), 'order_id' => $order->id, 'total_amount' => '0.00000', ]; } } /** * 执行单个用户买入物品订单的撮合(带事务处理) * * @param \App\Module\Mex\Models\MexOrder $order 用户买入物品订单 * @param \App\Module\Mex\Models\MexWarehouse $warehouse 仓库信息 * @return array 撮合结果 */ public static function executeUserBuyItemOrderMatchWithTransaction(\App\Module\Mex\Models\MexOrder $order, \App\Module\Mex\Models\MexWarehouse $warehouse): array { try { return DB::transaction(function () use ($order, $warehouse) { return \App\Module\Mex\Logic\MexMatchLogic::executeUserBuyItemOrderMatch($order, $warehouse); }); } catch (\Exception $e) { return [ 'success' => false, 'message' => '用户买入物品订单撮合失败:' . $e->getMessage(), 'order_id' => $order->id, 'total_amount' => '0.00000', ]; } } /** * 获取撮合统计信息(已废弃,请使用getUserBuyItemMatchStats) * * @deprecated 请使用getUserBuyItemMatchStats或getUserSellItemMatchStats * @return array 统计信息 */ public static function getMatchStats(): array { return self::getUserBuyItemMatchStats(); } }