初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,73 @@
<?php
namespace app\admin\model\app\exchange;
use think\Model;
class Batch extends Model
{
// 表名
protected $name = 'app_exchange_batch';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'starttime_text',
'endtime_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'),'0' => __('Status 0')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getStarttimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['starttime']) ? $data['starttime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getEndtimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['endtime']) ? $data['endtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setStarttimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setEndtimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
}
@@ -0,0 +1,98 @@
<?php
namespace app\admin\model\app\exchange;
use think\Model;
class Code extends Model
{
// 表名
protected $name = 'app_exchange_code';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'),'0' => __('Status 0'),'2' => __('Status 2')];
}
/**
* 创建分享码
* @param $count 数量
* @param $lenght 长度
* @return void
*/
public function createCode($count,$lenght = 10){
$data = [];
for($i=0;$i<$count;$i++){
$data[] = \fast\Random::alnum($lenght);
}
return $data;
}
/**
* 绑定分享码
* @param $batchId
* @param $count
* @return void
*/
public function build($batchId,$count){
$codeList = $this->createCode($count);
$data = [];
foreach ($codeList as $code){
$data[] = [
'uniacid'=>UNIACID,
'batch_id'=>$batchId,
'code'=>$code,
'status'=>1,
'createtime'=>time()
];
}
self::insertAll($data);
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function batch()
{
return $this->belongsTo('Batch', 'batch_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
@@ -0,0 +1,79 @@
<?php
namespace app\admin\model\app\exchange;
use think\Model;
class Goods extends Model
{
// 表名
protected $name = 'app_exchange_batch_goods';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
/**
* 绑定分享码
* @param $batchId
* @param $count
* @return void
*/
public function bindGoods($batchId,$goodsIds){
$data = [];
self::where([
'uniacid'=>UNIACID,
'batch_id'=>$batchId,
])->delete();
if(!empty($goodsIds)){
foreach ($goodsIds as $id){
$data[] = [
'uniacid'=>UNIACID,
'goods_id'=>$id,
'batch_id'=>$batchId,
'createtime'=>time()
];
}
}
self::insertAll($data);
}
public function batch()
{
return $this->belongsTo('Batch', 'batch_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function course()
{
return $this->belongsTo('app\admin\model\Course', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
@@ -0,0 +1,56 @@
<?php
namespace app\admin\model\app\exchange;
use think\Model;
class UseLog extends Model
{
// 表名
protected $name = 'app_exchange_use_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function batch()
{
return $this->belongsTo('Batch', 'batch_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function course()
{
return $this->belongsTo('app\admin\model\Course', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}