初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
<?php
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
/**
* 产码模型
* Class User
* @package app\common\model
*/
class Code extends BaseModel
{
protected $name = 'code';
// 定义主键
protected $pk = 'code_id';
/**
* 支付码详情
* @param $where
* @param array $with
* @return static|null
* @throws \think\exception\DbException
*/
public static function detail($where, $with = [])
{
!is_array($where) && $where = ['code_id' => (int)$where];
return static::get($where, $with);
}
/**
* 关联父级用户
* @return \think\model\relation\BelongsTo
*/
public function shop()
{
return $this->belongsTo('Shop');
}
/**
* 关联父级用户
* @return \think\model\relation\BelongsTo
*/
public function user()
{
return $this->belongsTo('app\common\model\store\User','store_user_id','store_user_id');
}
/**
* 获取全部
* @return mixed
*/
public static function getAll()
{
$model = new static;
return $model->order(['shop_id' => 'asc'])->select();
}
/**
* 获取产码数量
* @param array $filter
* @return int|string
*/
public function getCodeTotal($filter=[])
{
return $this->field('code_id')
->where($filter)
->group('code_id')
->count();
}
}