GridHelperTrait.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. namespace App\Module\Farm\AdminControllers\Helper;
  3. use App\Module\Farm\Enums\BUFF_TYPE;
  4. use App\Module\Farm\Enums\DISASTER_TYPE;
  5. use App\Module\Farm\Enums\GROWTH_STAGE;
  6. use App\Module\Farm\Enums\LAND_STATUS;
  7. use App\Module\Farm\Enums\LAND_TYPE;
  8. use App\Module\Farm\Enums\SEED_TYPE;
  9. use App\Module\Farm\Enums\UPGRADE_TYPE;
  10. use Dcat\Admin\Grid;
  11. use Dcat\Admin\Grid\Column;
  12. /**
  13. * 列表页辅助特性
  14. *
  15. * 提供农场模块后台控制器的列表页构建功能的具体实现
  16. */
  17. trait GridHelperTrait
  18. {
  19. /**
  20. * 添加神灵加持类型列
  21. *
  22. * @param string $field 字段名
  23. * @param string $label 标签名
  24. * @return Column
  25. */
  26. public function columnBuffType(string $field = 'buff_type', string $label = '加持类型'): Column
  27. {
  28. return $this->grid->column($field, $label)->display(function ($value) {
  29. return BUFF_TYPE::getName($value);
  30. });
  31. }
  32. /**
  33. * 添加灾害类型列
  34. *
  35. * @param string $field 字段名
  36. * @param string $label 标签名
  37. * @return Column
  38. */
  39. public function columnDisasterType(string $field = 'disaster_type', string $label = '灾害类型'): Column
  40. {
  41. return $this->grid->column($field, $label)->display(function ($value) {
  42. return DISASTER_TYPE::getName($value);
  43. });
  44. }
  45. /**
  46. * 添加土地状态列
  47. *
  48. * @param string $field 字段名
  49. * @param string $label 标签名
  50. * @return Column
  51. */
  52. public function columnLandStatus(string $field = 'status', string $label = '土地状态'): Column
  53. {
  54. return $this->grid->column($field, $label)->display(function ($value) {
  55. return LAND_STATUS::getName($value);
  56. })->label([
  57. LAND_STATUS::IDLE->value => 'default',
  58. LAND_STATUS::PLANTING->value => 'primary',
  59. LAND_STATUS::DISASTER->value => 'warning',
  60. LAND_STATUS::HARVESTABLE->value => 'success',
  61. LAND_STATUS::WITHERED->value => 'danger',
  62. ]);
  63. }
  64. /**
  65. * 添加土地类型列
  66. *
  67. * @param string $field 字段名
  68. * @param string $label 标签名
  69. * @return Column
  70. */
  71. public function columnLandType(string $field = 'land_type', string $label = '土地类型'): Column
  72. {
  73. return $this->grid->column($field, $label)->display(function ($value) {
  74. return LAND_TYPE::getName($value);
  75. })->label([
  76. LAND_TYPE::NORMAL->value => 'default',
  77. LAND_TYPE::RED->value => 'danger',
  78. LAND_TYPE::BLACK->value => 'dark',
  79. LAND_TYPE::GOLD->value => 'warning',
  80. LAND_TYPE::BLUE->value => 'info',
  81. LAND_TYPE::PURPLE->value => 'primary',
  82. ]);
  83. }
  84. /**
  85. * 添加产出详情列
  86. *
  87. * 展示该土地类型的作物种类概率和产量
  88. *
  89. * @param string $field 字段名
  90. * @param string $label 标签名
  91. * @return Column
  92. */
  93. public function columnOutputDetails(string $field = 'output_details', string $label = '产出详情'): Column
  94. {
  95. return $this->grid->column($field, $label)->display(function () {
  96. // 获取当前土地类型
  97. $landType = $this;
  98. $html = '<div class="output-details">';
  99. $html .= '<div class="mb-2"><strong>' . htmlspecialchars($landType->name) . ' (产量加成:' . ($landType->output_bonus * 100) . '%)</strong></div>';
  100. // 1. 显示神秘种子的产出概率和产量
  101. $html .= self::renderMysterySeeLOutputs($landType);
  102. // 2. 显示普通种子的产出
  103. $html .= self::renderNormalSeeLOutputs($landType);
  104. $html .= '</div>';
  105. return $html;
  106. })->width(500);
  107. }
  108. /**
  109. * 渲染神秘种子的产出详情
  110. *
  111. * 使用服务层逻辑计算神秘种子在该土地类型上的产出概率和产量
  112. *
  113. * @param \App\Module\Farm\Models\FarmLandType $landType
  114. * @return string
  115. */
  116. private static function renderMysterySeeLOutputs($landType): string
  117. {
  118. // 获取神秘种子
  119. $mysterySeeds = \App\Module\Farm\Models\FarmSeed::where('type', \App\Module\Farm\Enums\SEED_TYPE::MYSTERIOUS->value)->get();
  120. if ($mysterySeeds->isEmpty()) {
  121. return '';
  122. }
  123. $html = '<div class="mb-3">';
  124. $html .= '<h6 class="text-info">神秘种子产出概率</h6>';
  125. foreach ($mysterySeeds as $seed) {
  126. try {
  127. // 使用服务层逻辑计算概率
  128. $mysteryLogic = new \App\Module\Farm\Logics\MysterySeeLLogic();
  129. $adjustedOutputs = $mysteryLogic->calculateAdjustedProbabilities($seed->id, $landType->id);
  130. $html .= '<div class="mb-2">';
  131. $html .= '<strong>' . htmlspecialchars($seed->name) . ':</strong>';
  132. $html .= '<div class="table-responsive">';
  133. $html .= '<table class="table table-sm table-bordered">';
  134. $html .= '<thead><tr><th>产出物品</th><th>概率</th><th>正常产量</th><th>灾害产量</th><th>应用土地加成后(正常)</th><th>应用土地加成后(灾害)</th></tr></thead>';
  135. $html .= '<tbody>';
  136. foreach ($adjustedOutputs as $output) {
  137. // 跳过概率为0的产出
  138. if ($output['adjusted_probability'] <= 0) {
  139. continue;
  140. }
  141. $itemName = self::getItemName($output['item_id']);
  142. $probability = number_format($output['adjusted_probability'], 2) . '%';
  143. // 正常产量范围
  144. $normalMin = $output['min_amount'];
  145. $normalMax = $output['max_amount'];
  146. // 灾害产量范围 - 现在从服务层获取正确的数据
  147. $disasterMin = $output['disaster_min_amount'] ?? $output['min_amount'];
  148. $disasterMax = $output['disaster_max_amount'] ?? $output['max_amount'];
  149. // 应用土地加成后的产量
  150. $normalBonusMin = (int)($normalMin * (1 + $landType->output_bonus));
  151. $normalBonusMax = (int)($normalMax * (1 + $landType->output_bonus));
  152. $disasterBonusMin = (int)($disasterMin * (1 + $landType->output_bonus));
  153. $disasterBonusMax = (int)($disasterMax * (1 + $landType->output_bonus));
  154. $html .= '<tr>';
  155. $html .= '<td>' . htmlspecialchars($itemName) . '</td>';
  156. $html .= '<td><span class="badge badge-info">' . $probability . '</span></td>';
  157. $html .= '<td>' . $normalMin . '-' . $normalMax . '</td>';
  158. $html .= '<td class="text-warning">' . $disasterMin . '-' . $disasterMax . '</td>';
  159. $html .= '<td class="text-success"><strong>' . $normalBonusMin . '-' . $normalBonusMax . '</strong></td>';
  160. $html .= '<td class="text-danger"><strong>' . $disasterBonusMin . '-' . $disasterBonusMax . '</strong></td>';
  161. $html .= '</tr>';
  162. }
  163. $html .= '</tbody></table>';
  164. $html .= '</div>';
  165. $html .= '</div>';
  166. } catch (\Exception $e) {
  167. $html .= '<div class="text-danger">计算神秘种子概率失败:' . htmlspecialchars($e->getMessage()) . '</div>';
  168. }
  169. }
  170. $html .= '</div>';
  171. return $html;
  172. }
  173. /**
  174. * 渲染普通种子的产出详情
  175. *
  176. * @param \App\Module\Farm\Models\FarmLandType $landType
  177. * @return string
  178. */
  179. private static function renderNormalSeeLOutputs($landType): string
  180. {
  181. // 获取普通种子的产出配置
  182. $normalOutputs = \App\Module\Farm\Models\FarmSeedOutput::with(['seed', 'item'])
  183. ->whereHas('seed', function($query) {
  184. $query->where('type', '!=', \App\Module\Farm\Enums\SEED_TYPE::MYSTERIOUS->value);
  185. })
  186. ->where('is_default', true)
  187. ->get();
  188. if ($normalOutputs->isEmpty()) {
  189. return '';
  190. }
  191. $html = '<div class="mb-3">';
  192. $html .= '<h6 class="text-success">普通种子产出</h6>';
  193. $html .= '<div class="table-responsive">';
  194. $html .= '<table class="table table-sm table-bordered">';
  195. $html .= '<thead><tr><th>种子</th><th>产出物品</th><th>正常产量</th><th>灾害产量</th><th>应用土地加成后(正常)</th><th>应用土地加成后(灾害)</th></tr></thead>';
  196. $html .= '<tbody>';
  197. foreach ($normalOutputs as $output) {
  198. $seedName = $output->seed->name ?? "种子{$output->seed_id}";
  199. $itemName = $output->item->name ?? "物品{$output->item_id}";
  200. // 正常产量范围
  201. $normalMin = $output->min_amount;
  202. $normalMax = $output->max_amount;
  203. // 灾害产量范围
  204. $disasterMin = $output->disaster_min_amount ?? $output->min_amount;
  205. $disasterMax = $output->disaster_max_amount ?? $output->max_amount;
  206. // 应用土地加成后的产量
  207. $normalBonusMin = (int)($normalMin * (1 + $landType->output_bonus));
  208. $normalBonusMax = (int)($normalMax * (1 + $landType->output_bonus));
  209. $disasterBonusMin = (int)($disasterMin * (1 + $landType->output_bonus));
  210. $disasterBonusMax = (int)($disasterMax * (1 + $landType->output_bonus));
  211. $html .= '<tr>';
  212. $html .= '<td>' . htmlspecialchars($seedName) . '</td>';
  213. $html .= '<td>' . htmlspecialchars($itemName) . '</td>';
  214. $html .= '<td>' . $normalMin . '-' . $normalMax . '</td>';
  215. $html .= '<td class="text-warning">' . $disasterMin . '-' . $disasterMax . '</td>';
  216. $html .= '<td class="text-success"><strong>' . $normalBonusMin . '-' . $normalBonusMax . '</strong></td>';
  217. $html .= '<td class="text-danger"><strong>' . $disasterBonusMin . '-' . $disasterBonusMax . '</strong></td>';
  218. $html .= '</tr>';
  219. }
  220. $html .= '</tbody></table>';
  221. $html .= '</div>';
  222. $html .= '</div>';
  223. return $html;
  224. }
  225. /**
  226. * 获取物品名称
  227. *
  228. * @param int $itemId
  229. * @return string
  230. */
  231. private static function getItemName(int $itemId): string
  232. {
  233. try {
  234. $item = \App\Module\GameItems\Models\Item::find($itemId);
  235. return $item ? $item->name : "物品{$itemId}";
  236. } catch (\Exception $e) {
  237. return "物品{$itemId}";
  238. }
  239. }
  240. /**
  241. * 添加种子类型列
  242. *
  243. * @param string $field 字段名
  244. * @param string $label 标签名
  245. * @return Column
  246. */
  247. public function columnSeedType(string $field = 'type', string $label = '种子类型'): Column
  248. {
  249. return $this->grid->column($field, $label)->display(function ($value) {
  250. return SEED_TYPE::getName($value);
  251. })->label([
  252. SEED_TYPE::NORMAL->value => 'default',
  253. SEED_TYPE::MYSTERIOUS->value => 'primary',
  254. SEED_TYPE::GIANT->value => 'success',
  255. ]);
  256. }
  257. /**
  258. * 添加升级类型列
  259. *
  260. * @param string $field 字段名
  261. * @param string $label 标签名
  262. * @return Column
  263. */
  264. public function columnUpgradeType(string $field = 'upgrade_type', string $label = '升级类型'): Column
  265. {
  266. return $this->grid->column($field, $label)->display(function ($value) {
  267. return UPGRADE_TYPE::getName($value);
  268. })->label([
  269. UPGRADE_TYPE::LAND->value => 'primary',
  270. UPGRADE_TYPE::HOUSE->value => 'success',
  271. ]);
  272. }
  273. /**
  274. * 添加灾害情况列
  275. *
  276. * @param string $field 字段名
  277. * @param string $label 标签名
  278. * @return Column
  279. */
  280. public function columnDisasters(string $field = 'disasters', string $label = '灾害情况'): Column
  281. {
  282. return $this->grid->column($field, $label)->display(function ($value) {
  283. if (empty($value)) {
  284. return '无灾害';
  285. }
  286. $disasters = json_decode($value, true);
  287. if (empty($disasters)) {
  288. return '无灾害';
  289. }
  290. $result = [];
  291. foreach ($disasters as $type => $time) {
  292. $disasterName = DISASTER_TYPE::getName((int)$type);
  293. $result[] = $disasterName;
  294. }
  295. return implode('<br>', $result);
  296. });
  297. }
  298. /**
  299. * 添加是否施肥列
  300. *
  301. * @param string $field 字段名
  302. * @param string $label 标签名
  303. * @return Column
  304. */
  305. public function columnFertilized(string $field = 'fertilized', string $label = '已施肥'): Column
  306. {
  307. return $this->grid->column($field, $label)->bool();
  308. }
  309. /**
  310. * 添加产量加成列
  311. *
  312. * @param string $field 字段名
  313. * @param string $label 标签名
  314. * @return Column
  315. */
  316. public function columnOutputBonus(string $field = 'output_bonus', string $label = '产量加成'): Column
  317. {
  318. return $this->grid->column($field, $label)->display(function ($value) {
  319. return ($value * 100) . '%';
  320. });
  321. }
  322. /**
  323. * 添加灾害抵抗列
  324. *
  325. * @param string $field 字段名
  326. * @param string $label 标签名
  327. * @return Column
  328. */
  329. public function columnDisasterResistance(string $field = 'disaster_resistance', string $label = '灾害抵抗'): Column
  330. {
  331. return $this->grid->column($field, $label)->display(function ($value) {
  332. return ($value * 100) . '%';
  333. });
  334. }
  335. /**
  336. * 添加是否特殊土地列
  337. *
  338. * @param string $field 字段名
  339. * @param string $label 标签名
  340. * @return Column
  341. */
  342. public function columnIsSpecial(string $field = 'is_special', string $label = '特殊土地'): Column
  343. {
  344. return $this->grid->column($field, $label)->bool();
  345. }
  346. /**
  347. * 添加种子列
  348. *
  349. * @param string $field 字段名
  350. * @param string $label 标签名
  351. * @param bool $showType 是否显示种子类型
  352. * @return Column
  353. */
  354. public function columnSeed(string $field = 'seed_id', string $label = '种子', bool $showType = true): Column
  355. {
  356. return $this->grid->column($field, $label)->display(function ($value) use ($showType) {
  357. if (empty($value)) {
  358. return '-';
  359. }
  360. // 尝试获取种子名称
  361. $seed = \App\Module\Farm\Models\FarmSeed::find($value);
  362. if ($seed) {
  363. $html = "<span class='badge badge-primary'>{$seed->name}</span>";
  364. if ($showType) {
  365. $typeName = \App\Module\Farm\Enums\SEED_TYPE::getName($seed->type);
  366. $html .= " <span class='badge badge-info'>{$typeName}</span>";
  367. }
  368. // 如果有关联的物品ID,尝试获取物品名称
  369. if ($seed->item_id) {
  370. try {
  371. $item = \App\Module\GameItems\Models\Item::find($seed->item_id);
  372. if ($item) {
  373. $html .= "<br><small>物品: {$item->name} (ID: {$item->id})</small>";
  374. }
  375. } catch (\Exception $e) {
  376. // 忽略异常,只是不显示物品信息
  377. }
  378. }
  379. return $html;
  380. }
  381. return $value;
  382. });
  383. }
  384. /**
  385. * 添加物品列
  386. *
  387. * @param string $field 字段名
  388. * @param string $label 标签名
  389. * @param bool $showType 是否显示物品类型
  390. * @return Column
  391. */
  392. public function columnItem(string $field = 'item_id', string $label = '物品', bool $showType = true): Column
  393. {
  394. return $this->grid->column($field, $label)->display(function ($value) use ($showType) {
  395. if (empty($value)) {
  396. return '-';
  397. }
  398. // 尝试获取物品名称
  399. try {
  400. $item = \App\Module\GameItems\Models\Item::find($value);
  401. if ($item) {
  402. $html = "<span class='badge badge-success'>{$item->name}</span>";
  403. if ($showType && isset($item->type)) {
  404. try {
  405. $typeName = \App\Module\GameItems\Enums\ITEM_TYPE::getName($item->type);
  406. $html .= " <span class='badge badge-info'>{$typeName}</span>";
  407. } catch (\Exception $e) {
  408. // 忽略异常,只是不显示类型信息
  409. }
  410. }
  411. return $html;
  412. }
  413. } catch (\Exception $e) {
  414. // 忽略异常,只是不显示物品信息
  415. }
  416. return $value;
  417. });
  418. }
  419. /**
  420. * 添加模型Cast JSON列
  421. *
  422. * @param string $field 字段名
  423. * @param string $label 标签名
  424. * @return Column
  425. */
  426. public function columnModelCatsJson(string $field, string $label): Column
  427. {
  428. return $this->grid->column($field, $label)->display(function ($value) {
  429. if (empty($value)) {
  430. return '-';
  431. }
  432. if (is_string($value)) {
  433. $value = json_decode($value, true);
  434. } elseif (is_object($value)) {
  435. $value = (array)$value;
  436. }
  437. if (!is_array($value)) {
  438. return '-';
  439. }
  440. $html = '<div class="table-responsive"><table class="table table-sm table-bordered">';
  441. $html .= '<thead><tr><th>属性</th><th>值</th></tr></thead>';
  442. $html .= '<tbody>';
  443. foreach ($value as $key => $val) {
  444. if (is_array($val) || is_object($val)) {
  445. $val = json_encode($val, JSON_UNESCAPED_UNICODE);
  446. }
  447. $html .= "<tr><td>{$key}</td><td>{$val}</td></tr>";
  448. }
  449. $html .= '</tbody></table></div>';
  450. return $html;
  451. });
  452. }
  453. /**
  454. * 添加消耗组详情列
  455. *
  456. * 展示消耗组的名称和详细内容
  457. *
  458. * @param string $field 字段名
  459. * @param string $label 标签名
  460. * @return Column
  461. */
  462. public function columnConsumeGroupDetails(string $field = 'materials', string $label = '消耗组详情'): Column
  463. {
  464. return $this->grid->column($field, $label)->display(function ($materialsGroupId) {
  465. if (!$materialsGroupId) {
  466. return '<span class="text-muted">使用 materials 字段</span>';
  467. }
  468. $consumeGroup = \App\Module\Game\Models\GameConsumeGroup::with('consumeItems')->find($materialsGroupId);
  469. if (!$consumeGroup) {
  470. return '<span class="text-danger">未知消耗组 (ID: ' . $materialsGroupId . ')</span>';
  471. }
  472. $html = '<div class="consume-group-details">';
  473. $html .= '<div class="mb-2"><strong>' . htmlspecialchars($consumeGroup->name) . ' (' . htmlspecialchars($consumeGroup->code) . ')</strong></div>';
  474. if ($consumeGroup->consumeItems->isEmpty()) {
  475. $html .= '<div class="text-muted">暂无消耗项</div>';
  476. } else {
  477. $html .= '<div class="table-responsive">';
  478. $html .= '<table class="table table-sm table-bordered">';
  479. $html .= '<thead><tr><th>消耗类型</th><th>目标</th><th>数量</th></tr></thead>';
  480. $html .= '<tbody>';
  481. foreach ($consumeGroup->consumeItems as $item) {
  482. $typeName = \App\Module\Game\Enums\CONSUME_TYPE::getName($item->consume_type);
  483. $targetName = $item->getTargetName();
  484. $html .= '<tr>';
  485. $html .= '<td><span class="badge badge-info">' . htmlspecialchars($typeName) . '</span></td>';
  486. $html .= '<td>' . htmlspecialchars($targetName) . '</td>';
  487. $html .= '<td class="text-success"><strong>' . number_format($item->quantity) . '</strong></td>';
  488. $html .= '</tr>';
  489. }
  490. $html .= '</tbody></table>';
  491. $html .= '</div>';
  492. }
  493. $html .= '</div>';
  494. return $html;
  495. })->width(300);
  496. }
  497. /**
  498. * 添加条件组详情列
  499. *
  500. * 展示条件组的名称和详细内容
  501. *
  502. * @param string $field 字段名
  503. * @param string $label 标签名
  504. * @return Column
  505. */
  506. public function columnConditionGroupDetails(string $field = 'conditions', string $label = '条件组详情'): Column
  507. {
  508. return $this->grid->column($field, $label)->display(function ($conditionsGroupId) {
  509. if (!$conditionsGroupId) {
  510. return '<span class="text-muted">使用 conditions 字段</span>';
  511. }
  512. $conditionGroup = \App\Module\Game\Models\GameConditionGroup::with('conditionItems')->find($conditionsGroupId);
  513. if (!$conditionGroup) {
  514. return '<span class="text-danger">未知条件组 (ID: ' . $conditionsGroupId . ')</span>';
  515. }
  516. $html = '<div class="condition-group-details">';
  517. $html .= '<div class="mb-2"><strong>' . htmlspecialchars($conditionGroup->name) . ' (' . htmlspecialchars($conditionGroup->code) . ')</strong></div>';
  518. if ($conditionGroup->conditionItems->isEmpty()) {
  519. $html .= '<div class="text-muted">暂无条件项</div>';
  520. } else {
  521. $html .= '<div class="table-responsive">';
  522. $html .= '<table class="table table-sm table-bordered">';
  523. $html .= '<thead><tr><th>条件类型</th><th>目标</th><th>操作符</th><th>要求值</th></tr></thead>';
  524. $html .= '<tbody>';
  525. foreach ($conditionGroup->conditionItems as $item) {
  526. $typeName = \App\Module\Game\Enums\CONDITION_TYPE::getName($item->condition_type);
  527. $targetName = \App\Module\Game\Services\ConditionTypeDescriptor::getTargetNameFromModel($item);
  528. $operatorName = self::getOperatorName($item->operator);
  529. $html .= '<tr>';
  530. $html .= '<td><span class="badge badge-primary">' . htmlspecialchars($typeName) . '</span></td>';
  531. $html .= '<td>' . htmlspecialchars($targetName) . '</td>';
  532. $html .= '<td><span class="badge badge-secondary">' . htmlspecialchars($operatorName) . '</span></td>';
  533. $html .= '<td class="text-success"><strong>' . number_format($item->value) . '</strong></td>';
  534. $html .= '</tr>';
  535. }
  536. $html .= '</tbody></table>';
  537. $html .= '</div>';
  538. }
  539. $html .= '</div>';
  540. return $html;
  541. })->width(300);
  542. }
  543. /**
  544. * 获取操作符名称
  545. *
  546. * @param int $operator
  547. * @return string
  548. */
  549. private static function getOperatorName(int $operator): string
  550. {
  551. $operators = [
  552. 1 => '等于',
  553. 2 => '不等于',
  554. 3 => '小于',
  555. 4 => '大于等于',
  556. 5 => '小于等于',
  557. 6 => '大于',
  558. ];
  559. return $operators[$operator] ?? "未知操作符({$operator})";
  560. }
  561. }