重构DiceLotteryConfig为DiceLotteryPoolConfig

This commit is contained in:
2026-03-10 17:56:14 +08:00
parent 1a748745cb
commit 54aa0bd34f
22 changed files with 160 additions and 160 deletions

View File

@@ -4,9 +4,9 @@
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\dice\logic\lottery_config;
namespace app\dice\logic\lottery_pool_config;
use app\dice\model\lottery_config\DiceLotteryConfig;
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
use plugin\saiadmin\basic\think\BaseLogic;
use plugin\saiadmin\exception\ApiException;
use plugin\saiadmin\utils\Helper;
@@ -15,7 +15,7 @@ use support\think\Cache;
/**
* 色子奖池配置逻辑层
*/
class DiceLotteryConfigLogic extends BaseLogic
class DiceLotteryPoolConfigLogic extends BaseLogic
{
/** Redis 当前彩金池type=0 实例key无则按 type=0 创建 */
private const REDIS_KEY_CURRENT_POOL = 'api:game:lottery_pool:default';
@@ -27,7 +27,7 @@ class DiceLotteryConfigLogic extends BaseLogic
*/
public function __construct()
{
$this->model = new DiceLotteryConfig();
$this->model = new DiceLotteryPoolConfig();
}
/**
@@ -41,13 +41,13 @@ class DiceLotteryConfigLogic extends BaseLogic
if ($cached && is_string($cached)) {
$data = json_decode($cached, true);
if (is_array($data)) {
$config = DiceLotteryConfig::find($data['id'] ?? 0);
$config = DiceLotteryPoolConfig::find($data['id'] ?? 0);
$ev = $config && isset($config->ev) ? (float) $config->ev : (float) ($data['profit_amount'] ?? 0);
$data['profit_amount'] = $ev;
return $data;
}
}
$config = DiceLotteryConfig::where('type', 0)->find();
$config = DiceLotteryPoolConfig::where('type', 0)->find();
if (!$config) {
throw new ApiException('未找到 type=0 的奖池配置,请先创建');
}
@@ -77,7 +77,7 @@ class DiceLotteryConfigLogic extends BaseLogic
{
$pool = $this->getCurrentPool();
$id = (int) $pool['id'];
$config = DiceLotteryConfig::find($id);
$config = DiceLotteryPoolConfig::find($id);
if (!$config) {
throw new ApiException('奖池配置不存在');
}
@@ -95,9 +95,9 @@ class DiceLotteryConfigLogic extends BaseLogic
if (empty($update)) {
return;
}
DiceLotteryConfig::where('id', $id)->update($update);
DiceLotteryPoolConfig::where('id', $id)->update($update);
$pool = array_merge($pool, $update);
$refreshed = DiceLotteryConfig::find($id);
$refreshed = DiceLotteryPoolConfig::find($id);
$pool['profit_amount'] = $refreshed && isset($refreshed->ev) ? (float) $refreshed->ev : (float) ($pool['profit_amount'] ?? 0);
Cache::set(self::REDIS_KEY_CURRENT_POOL, json_encode($pool), self::EXPIRE);
}