pull/1/head
wanghousheng 12 months ago
parent 5cdc641d1c
commit 47943138c4
  1. 3
      app/api/model/Article.php
  2. 52
      app/common/model/invite/InviteConfig.php
  3. 56
      app/common/model/invite/InviteLog.php
  4. 35
      app/store/controller/Invite.php

@ -88,8 +88,7 @@ class Article extends ArticleModel
$filter[] = ['title', 'like', "%$title%"];
}
// 获取列表数据
$list = $this->withoutField(['content'])
->where($filter)
$list = $this->where($filter)
->where('status', '=', 1)
->where('is_delete', '=', 0)
->order(['sort' => 'asc', 'create_time' => 'desc'])

@ -0,0 +1,52 @@
<?php
namespace app\common\model\invite;
use cores\BaseModel;
class InviteConfig extends BaseModel
{
// 定义表名
protected $name = 'invite_config';
// 定义主键
protected $pk = 'id';
/**
* @notes:编辑
* @param $data
* @return bool
* @author: wanghousheng
*/
public function edit($data): bool
{
if ($this->where(['store_id' => self::$storeId])->exists()) {
return $this->save($data) !== false;
}
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* @notes:新增
* @param $data
* @return bool
* @author: wanghousheng
*/
public function add($data): bool
{
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* 详情
* @param array $where
* @return static|array|null
*/
public static function detail(array $where = [])
{
return self::get($where);
}
}

@ -0,0 +1,56 @@
<?php
declare (strict_types=1);
namespace app\common\model\invite;
use app\common\model\User;
use cores\BaseModel;
use think\model\relation\HasOne;
/**
* 邀请记录表
*
* This class represents the invite log entity.
* It extends the BaseModel class.
*/
class InviteLog extends BaseModel
{
// 定义表名
protected $name = 'invite_log';
// 定义主键
protected $pk = 'invite_id';
public function user(): HasOne
{
return $this->hasOne(User::class, 'user_id', 'user_id');
}
public function invitee(): HasOne
{
return $this->hasOne(User::class, 'user_id', 'invitee_user_id');
}
/**
* @notes:新增
* @param $data
* @return bool
* @author: wanghousheng
*/
public function add($data): bool
{
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* 详情
* @param array $where
* @return static|array|null
*/
public static function detail(array $where)
{
return self::get($where);
}
}

@ -0,0 +1,35 @@
<?php
namespace app\store\controller;
use app\common\model\invite\InviteConfig;
use think\response\Json;
class Invite extends Controller
{
/**获取配置
* @notes:
* @return Json
* @author: wanghousheng
*/
public function getConfig(): Json
{
$info = InviteConfig::detail();
return $this->renderSuccess(compact('info'));
}
public function editConfig()
{
$id =
$info = InviteConfig::detail();
$data = $this->postForm();
if (!$data) {
return $this->renderError('缺少必要参数');
}
$model = ServerCategory::detail($categoryId);
if ($model->edit($data)) {
return $this->renderSuccess('编辑成功');
}
return $this->renderError($model->getError() ?: '编辑失败');
}
}
Loading…
Cancel
Save