MexMatchService.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace App\Module\Mex\Services;
  3. use App\Module\Mex\Logic\MexMatchLogic;
  4. /**
  5. * 农贸市场撮合服务
  6. *
  7. * 提供撮合相关的对外服务接口
  8. */
  9. class MexMatchService
  10. {
  11. /**
  12. * 执行用户买入物品撮合任务
  13. *
  14. * @param int|null $itemId 指定商品ID,null表示处理所有商品
  15. * @param int $batchSize 批处理大小
  16. * @return array 撮合结果
  17. */
  18. public static function executeUserBuyItemMatch(?int $itemId = null, int $batchSize = 100): array
  19. {
  20. return MexMatchLogic::executeUserBuyItemMatch($itemId, $batchSize);
  21. }
  22. /**
  23. * 执行用户卖出物品撮合任务
  24. *
  25. * @param int|null $itemId 指定商品ID,null表示处理所有商品
  26. * @param int $batchSize 批处理大小
  27. * @return array 撮合结果
  28. */
  29. public static function executeUserSellItemMatch(?int $itemId = null, int $batchSize = 100): array
  30. {
  31. return MexMatchLogic::executeUserSellItemMatch($itemId, $batchSize);
  32. }
  33. /**
  34. * 执行单个商品的用户买入物品撮合
  35. *
  36. * @param int $itemId 商品ID
  37. * @param int $batchSize 批处理大小
  38. * @return array 撮合结果
  39. */
  40. public static function executeUserBuyItemMatchForItem(int $itemId, int $batchSize = 100): array
  41. {
  42. return MexMatchLogic::executeUserBuyItemMatchForItem($itemId, $batchSize);
  43. }
  44. /**
  45. * 执行单个商品的用户卖出物品撮合
  46. *
  47. * @param int $itemId 商品ID
  48. * @param int $batchSize 批处理大小
  49. * @return array 撮合结果
  50. */
  51. public static function executeUserSellItemMatchForItem(int $itemId, int $batchSize = 100): array
  52. {
  53. return MexMatchLogic::executeUserSellItemMatchForItem($itemId, $batchSize);
  54. }
  55. /**
  56. * 获取用户买入物品撮合统计信息
  57. *
  58. * @return array 统计信息
  59. */
  60. public static function getUserBuyItemMatchStats(): array
  61. {
  62. return MexMatchLogic::getUserBuyItemMatchStats();
  63. }
  64. /**
  65. * 获取用户卖出物品撮合统计信息
  66. *
  67. * @return array 统计信息
  68. */
  69. public static function getUserSellItemMatchStats(): array
  70. {
  71. return MexMatchLogic::getUserSellItemMatchStats();
  72. }
  73. /**
  74. * 检查用户买入物品撮合条件
  75. *
  76. * @param int $itemId 商品ID
  77. * @return array 检查结果
  78. */
  79. public static function checkUserBuyItemMatchConditions(int $itemId): array
  80. {
  81. return MexMatchLogic::checkUserBuyItemMatchConditions($itemId);
  82. }
  83. /**
  84. * 检查用户卖出物品撮合条件
  85. *
  86. * @param int $itemId 商品ID
  87. * @return array 检查结果
  88. */
  89. public static function checkUserSellItemMatchConditions(int $itemId): array
  90. {
  91. return MexMatchLogic::checkUserSellItemMatchConditions($itemId);
  92. }
  93. // 保留旧方法以兼容现有代码
  94. /**
  95. * 执行撮合任务(已废弃,请使用executeUserBuyItemMatch)
  96. *
  97. * @deprecated 请使用executeUserBuyItemMatch或executeUserSellItemMatch
  98. * @param int|null $itemId 指定商品ID,null表示处理所有商品
  99. * @param int $batchSize 批处理大小
  100. * @return array 撮合结果
  101. */
  102. public static function executeMatch(?int $itemId = null, int $batchSize = 100): array
  103. {
  104. return self::executeUserBuyItemMatch($itemId, $batchSize);
  105. }
  106. /**
  107. * 执行单个商品的撮合(已废弃,请使用executeUserBuyItemMatchForItem)
  108. *
  109. * @deprecated 请使用executeUserBuyItemMatchForItem或executeUserSellItemMatchForItem
  110. * @param int $itemId 商品ID
  111. * @param int $batchSize 批处理大小
  112. * @return array 撮合结果
  113. */
  114. public static function executeItemMatch(int $itemId, int $batchSize = 100): array
  115. {
  116. return self::executeUserBuyItemMatchForItem($itemId, $batchSize);
  117. }
  118. /**
  119. * 获取撮合统计信息(已废弃,请使用getUserBuyItemMatchStats)
  120. *
  121. * @deprecated 请使用getUserBuyItemMatchStats或getUserSellItemMatchStats
  122. * @return array 统计信息
  123. */
  124. public static function getMatchStats(): array
  125. {
  126. return self::getUserBuyItemMatchStats();
  127. }
  128. /**
  129. * 检查撮合条件(已废弃,请使用checkUserBuyItemMatchConditions)
  130. *
  131. * @deprecated 请使用checkUserBuyItemMatchConditions或checkUserSellItemMatchConditions
  132. * @param int $itemId 商品ID
  133. * @return array 检查结果
  134. */
  135. public static function checkMatchConditions(int $itemId): array
  136. {
  137. return self::checkUserBuyItemMatchConditions($itemId);
  138. }
  139. }