初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
@@ -0,0 +1,74 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\user;
use cores\BaseModel;
use app\common\enum\user\balanceLog\Scene as SceneEnum;
/**
* 用户余额变动明细模型
* Class BalanceLog
* @package app\common\model\user
*/
class BalanceLog extends BaseModel
{
// 定义表名
protected $name = 'user_balance_log';
// 定义主键
protected $pk = 'log_id';
protected $updateTime = false;
/**
* 关联会员记录表
* @return \think\model\relation\BelongsTo
*/
public function user()
{
$module = self::getCalledModule();
return $this->belongsTo("app\\{$module}\\model\\User");
}
/**
* 新增记录
* @param int $scene
* @param array $data
* @param array $describeParam
*/
public static function add(int $scene, array $data, array $describeParam)
{
$model = new static;
$model->save(array_merge([
'scene' => $scene,
'describe' => vsprintf(SceneEnum::data()[$scene]['describe'], $describeParam),
'store_id' => $model::$storeId
], $data));
}
/**
* 新增记录
* @param int $scene
* @param array $data
* @param array $describeParam
*/
public static function addExchange(int $scene, array $data, array $describeParam)
{
$model = new static;
$model->save(array_merge([
'scene' => $scene,
'describe' => vsprintf(SceneEnum::data()[$scene]['describe'], $describeParam),
], $data));
}
}
+102
View File
@@ -0,0 +1,102 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\user;
use cores\BaseModel;
use app\common\library\helper;
/**
* 用户会员等级模型
* Class Grade
* @package app\common\model\user
*/
class Grade extends BaseModel
{
// 定义表名
protected $name = 'user_grade';
// 定义主键
protected $pk = 'grade_id';
/**
* 获取器:升级条件
* @param $json
* @return mixed
*/
public function getUpgradeAttr($json)
{
return helper::jsonDecode($json);
}
/**
* 获取器:等级权益
* @param $json
* @return mixed
*/
public function getEquityAttr($json)
{
return helper::jsonDecode($json);
}
/**
* 修改器:升级条件
* @param $data
* @return mixed
*/
public function setUpgradeAttr($data)
{
// 这里需要转换下, 否则会出现浮点数精度丢失问题
$data['expend_money'] = (string)$data['expend_money'];
return helper::jsonEncode($data);
}
/**
* 修改器:等级权益
* @param $data
* @return mixed
*/
public function setEquityAttr($data)
{
// 这里需要转换下, 否则会出现浮点数精度丢失问题
$data['discount'] = (string)$data['discount'];
return helper::jsonEncode($data);
}
/**
* 会员等级详情
* @param int $gradId
* @param array $with
* @return array|null|static
*/
public static function detail(int $gradId, array $with = [])
{
return static::get($gradId, $with);
}
/**
* 验证等级权重是否存在
* @param int $weight 验证的权重
* @param int $gradeId 自身的等级ID
* @return bool
*/
public static function checkExistByWeight(int $weight, int $gradeId = 0): bool
{
$filter = [];
$gradeId > 0 && $filter[] = ['grade_id', '<>', (int)$gradeId];
return !!(new static)->where('weight', '=', (int)$weight)
->where($filter)
->where('is_delete', '=', 0)
->value('grade_id');
}
}
@@ -0,0 +1,50 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\user;
use cores\BaseModel;
use app\common\enum\user\grade\log\ChangeType as ChangeTypeEnum;
/**
* 用户会员等级变更记录模型
* Class GradeLog
* @package app\common\model\user
*/
class GradeLog extends BaseModel
{
// 定义表名
protected $name = 'user_grade_log';
// 定义主键
protected $pk = 'log_id';
protected $updateTime = false;
/**
* 新增变更记录 (批量)
* @param $data
* @return int
*/
public function records($data)
{
$saveData = [];
foreach ($data as $item) {
$saveData[] = array_merge([
'change_type' => ChangeTypeEnum::ADMIN_USER,
'store_id' => static::$storeId
], $item);
}
return $this->addAll($saveData) !== false;
}
}
@@ -0,0 +1,63 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\user;
use cores\BaseModel;
use think\model\relation\BelongsTo;
/**
* 用户积分变动明细模型
* Class PointsLog
* @package app\common\model\user
*/
class PointsLog extends BaseModel
{
// 定义表名
protected $name = 'user_points_log';
// 定义主键
protected $pk = 'log_id';
protected $updateTime = false;
/**
* 关联会员记录表
* @return BelongsTo
*/
public function user(): BelongsTo
{
$module = self::getCalledModule();
return $this->belongsTo("app\\{$module}\\model\\User");
}
/**
* 新增记录
* @param array $data
*/
public static function add(array $data)
{
$static = new static;
empty($data['store_id']) && $data['store_id'] = $static::$storeId;
$static->save($data);
}
/**
* 新增记录 (批量)
* @param $saveData
* @return bool
*/
public function onBatchAdd($saveData): bool
{
return $this->addAll($saveData) !== false;
}
}