优化页面和模型

This commit is contained in:
2026-03-30 18:33:24 +08:00
parent 2686c54781
commit 1cd5c3142d
33 changed files with 817 additions and 215 deletions

View File

@@ -47,6 +47,6 @@ class MallAddress extends Model
public function playxUserAsset(): \think\model\relation\BelongsTo
{
return $this->belongsTo(\app\common\model\MallPlayxUserAsset::class, 'playx_user_asset_id', 'id');
return $this->belongsTo(\app\common\model\MallUserAsset::class, 'playx_user_asset_id', 'id');
}
}

View File

@@ -7,14 +7,15 @@ namespace app\common\model;
use support\think\Model;
/**
* PlayX 领取记录(幂等)
* 领取记录(幂等)
*/
class MallPlayxClaimLog extends Model
class MallClaimLog extends Model
{
protected string $name = 'mall_playx_claim_log';
protected string $name = 'mall_claim_log';
protected array $type = [
'claimed_amount' => 'integer',
'create_time' => 'integer',
];
}

View File

@@ -7,11 +7,11 @@ namespace app\common\model;
use support\think\Model;
/**
* PlayX 每日推送数据
* 每日推送数据
*/
class MallPlayxDailyPush extends Model
class MallDailyPush extends Model
{
protected string $name = 'mall_playx_daily_push';
protected string $name = 'mall_daily_push';
protected array $type = [
'yesterday_win_loss_net' => 'float',
@@ -21,3 +21,4 @@ class MallPlayxDailyPush extends Model
'create_time' => 'integer',
];
}

View File

@@ -7,7 +7,7 @@ namespace app\common\model;
use support\think\Model;
/**
* PlayX 统一订单
* 统一订单
*
* @property int $id
* @property string $user_id
@@ -29,9 +29,9 @@ use support\think\Model;
* @property string $receiver_phone
* @property string|null $receiver_address
*/
class MallPlayxOrder extends Model
class MallOrder extends Model
{
protected string $name = 'mall_playx_order';
protected string $name = 'mall_order';
protected bool $autoWriteTimestamp = true;
@@ -51,12 +51,12 @@ class MallPlayxOrder extends Model
public const GRANT_FAILED_FINAL = 'FAILED_FINAL';
protected array $type = [
'create_time' => 'integer',
'update_time' => 'integer',
'points_cost' => 'integer',
'amount' => 'float',
'multiplier' => 'integer',
'retry_count' => 'integer',
'create_time' => 'integer',
'update_time' => 'integer',
'points_cost' => 'integer',
'amount' => 'float',
'multiplier' => 'integer',
'retry_count' => 'integer',
];
public function mallItem(): \think\model\relation\BelongsTo
@@ -64,3 +64,4 @@ class MallPlayxOrder extends Model
return $this->belongsTo(MallItem::class, 'mall_item_id', 'id');
}
}

View File

@@ -21,6 +21,6 @@ class MallPintsOrder extends Model
public function playxUserAsset(): \think\model\relation\BelongsTo
{
return $this->belongsTo(\app\common\model\MallPlayxUserAsset::class, 'playx_user_asset_id', 'id');
return $this->belongsTo(\app\common\model\MallUserAsset::class, 'playx_user_asset_id', 'id');
}
}

View File

@@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
namespace app\common\model;
use support\think\Model;
/**
* PlayX 会话缓存
*/
class MallPlayxSession extends Model
{
protected string $name = 'mall_playx_session';
protected bool $autoWriteTimestamp = true;
protected array $type = [
// 这里需要显式声明 create_time / update_time 为 integer
// 否则 ThinkORM 可能把 bigint 时间戳当成字符串,导致写入时出现 now 字符串问题。
'create_time' => 'integer',
'update_time' => 'integer',
'expire_time' => 'integer',
];
}

View File

@@ -21,7 +21,7 @@ class MallRedemptionOrder extends Model
public function playxUserAsset(): \think\model\relation\BelongsTo
{
return $this->belongsTo(\app\common\model\MallPlayxUserAsset::class, 'playx_user_asset_id', 'id');
return $this->belongsTo(\app\common\model\MallUserAsset::class, 'playx_user_asset_id', 'id');
}
public function mallItem(): \think\model\relation\BelongsTo

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace app\common\model;
use support\think\Model;
/**
* 会话缓存
*/
class MallSession extends Model
{
protected string $name = 'mall_session';
protected bool $autoWriteTimestamp = true;
protected array $type = [
'create_time' => 'integer',
'update_time' => 'integer',
'expire_time' => 'integer',
];
}

View File

@@ -8,22 +8,22 @@ use ba\Random;
use support\think\Model;
/**
* PlayX 用户资产(积分商城用户主表,含登录账号字段)
* 用户资产(积分商城用户主表,含登录账号字段)
*/
class MallPlayxUserAsset extends Model
class MallUserAsset extends Model
{
protected string $name = 'mall_playx_user_asset';
protected string $name = 'mall_user_asset';
protected bool $autoWriteTimestamp = true;
protected array $type = [
'create_time' => 'integer',
'update_time' => 'integer',
'locked_points' => 'integer',
'available_points' => 'integer',
'today_limit' => 'integer',
'today_claimed' => 'integer',
'admin_id' => 'integer',
'create_time' => 'integer',
'update_time' => 'integer',
'locked_points' => 'integer',
'available_points' => 'integer',
'today_limit' => 'integer',
'today_claimed' => 'integer',
'admin_id' => 'integer',
];
/**
@@ -46,24 +46,24 @@ class MallPlayxUserAsset extends Model
$now = time();
$temporaryPlayxId = 'tmp_' . bin2hex(random_bytes(16));
$created = self::create([
'playx_user_id' => $temporaryPlayxId,
'username' => $username,
'phone' => $phone,
'password' => $pwd,
'admin_id' => 0,
'locked_points' => 0,
'available_points' => 0,
'today_limit' => 0,
'today_claimed' => 0,
'today_limit_date' => null,
'create_time' => $now,
'update_time' => $now,
'playx_user_id' => $temporaryPlayxId,
'username' => $username,
'phone' => $phone,
'password' => $pwd,
'admin_id' => 0,
'locked_points' => 0,
'available_points' => 0,
'today_limit' => 0,
'today_claimed' => 0,
'today_limit_date' => null,
'create_time' => $now,
'update_time' => $now,
]);
if (!$created) {
throw new \RuntimeException('Failed to create mall_playx_user_asset');
throw new \RuntimeException('Failed to create mall_user_asset');
}
$id = intval($created->getKey());
$id = $created->getKey();
$finalPlayxId = 'mall_' . $id;
if (self::where('playx_user_id', $finalPlayxId)->where('id', '<>', $id)->find()) {
$finalPlayxId = 'mall_' . $id . '_' . bin2hex(random_bytes(4));
@@ -77,7 +77,7 @@ class MallPlayxUserAsset extends Model
private static function allocateUniquePhone(): ?string
{
for ($i = 0; $i < 8; $i++) {
$candidate = '13' . str_pad(strval(mt_rand(0, 999999999)), 9, '0', STR_PAD_LEFT);
$candidate = '13' . str_pad(mt_rand(0, 999999999), 9, '0', STR_PAD_LEFT);
if (!self::where('phone', $candidate)->find()) {
return $candidate;
}
@@ -86,3 +86,4 @@ class MallPlayxUserAsset extends Model
return null;
}
}