1. Definitions:
Data layer: models defines data-related automatic validation, automatic completion, and data access interfaces.
Logic layer: logics defines data-related business logic.
2. Create a logics directory in the common directory to serve as the location for the logic layer of MySQL models, as shown in Figure 1.

3. Create a redis directory inside the common/logics directory to serve as the location for the logic layer of Redis (ActiveRecord) models, as shown in Figure 2.

4. The MySQL model files in the common/models directory are generated by the Gii tool, as shown in Figure 3.

5. The Redis (ActiveRecord) model files in the common/models/redis directory define the model field structure, as shown in Figure 4.

6. The MySQL model files in the common/logics directory handle business logic and inherit from the \common\models\Game data layer, as shown in Figure 5.
api\models
common\logics

7. The Redis (ActiveRecord) model files in the common/logics/redis directory handle business logic and inherit from the \common\models\redis\Game data layer, as shown in Figure 6.
api\models\redis
common\logics\redis
api\models
common\models
Api
Common
common\models\redis\Lock
common\logics\redis\Lock
common\models\redis\Live
common\logics\redis\Live
$api
$common

8. The Redis (native command) model files in the common/logics/redis directory handle business logic. They do not need to inherit from the \common\models\redis\Game data layer; instead, they inherit directly from \yii\redis\ActiveRecord, as shown in Figure 7.

9. The MySQL model files in the api/models directory handle business logic and inherit from the \common\logics\Game logic layer, as shown in Figure 8.
\common\models
\common\logics

10. The Redis (ActiveRecord/native command) model files in the api/models/redis directory handle business logic and inherit from the \common\logics\redis\Game logic layer, as shown in Figure 9.
common\models\redis\Lock
common\logics\redis\Lock
\common\models\redis
\common\logics\redis

