init commit

This commit is contained in:
2026-03-17 09:56:00 +08:00
commit e2c8ae752d
6827 changed files with 1211784 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\controller\wdsxh\institution;
use app\admin\model\wdsxh\institution\InstitutionConfig;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\user\Wechat;
use app\common\controller\Api;
/**
* Class Institution
* Desc 机构控制器
* Create on 2025/3/5 10:30
* Create by wangyafang
*/
class Institution extends Api
{
protected $noNeedLogin = ['index','details','institution_config'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\institution\Institution();
}
/**
* Desc 机构列表
* Create on 2025/3/5 10:32
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
$where['status'] = array('eq',1);
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,name,icon')
->page($page,$limit)
->order('weigh desc,createtime desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 机构详情
* Create on 2025/3/5 10:36
* Create by wangyafang
*/
public function details()
{
$is_status = (new InstitutionConfig())->value('is_status');
if ($is_status == 2) {
if (!$this->auth->isLogin()) {
$this->error('请登录后操作',null,401);
}
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$current_date = date('Y-m-d',time());
$member = (new Member())->where('wechat_id',$wechat_id)->where('expire_time','>=',$current_date)->find();
if (!$member) {
$this->error('成为会员后可查看');
}
}
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
if (!$id) {
$this->error('参数错误');
}
$data = $this->model->where('id',$id)
->field('id,name,images,introduction,icon')
->find();
if ($this->auth->isLogin()) {
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$queryInstitutionMemberObj = (new \app\api\model\wdsxh\institution\Member())->where('institution_id',$id)
->where('wechat_id',$wechat_id)
->find();
if ($queryInstitutionMemberObj) {
$data['apply_state'] = 2;
} else {
$data['apply_state'] = (new \app\api\model\wdsxh\institution\InstitutionMemberApply())
->where('institution_id',$id)
->where('wechat_id',$wechat_id)
->value('state');
}
}
$this->success('请求成功',$data);
}
/**
* Desc 机构配置
* Create on 2025/3/6 10:58
* Create by wangyafang
*/
public function institution_config()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$is_status = (new InstitutionConfig())->where('id',1)->value('is_status');
if ($is_status == 2){
if ($this->auth->isLogin()) {
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$current_date = date('Y-m-d',time());
$member = (new Member())->where('wechat_id',$wechat_id)->where('expire_time','>=',$current_date)->find();
if ($member) {
$is_status = 1;
}
}
}
$this->success('请求成功',['show_status'=>$is_status]);
}
}

View File

@@ -0,0 +1,176 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\controller\wdsxh\institution;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\user\Wechat;
use app\common\controller\Api;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class InstitutionMemberApply extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\institution\InstitutionMemberApply();
}
/**
* Desc 申请
* Create on 2025/8/4 15:48
* Create by wangyafang
*/
public function submit()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $_POST;
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$member = (new Member())->where('wechat_id',$wechat_id)->find();
if (!$member){
$this->error('你还不是会员,请先入会');
}
$current_date = date('Y-m-d',time());
if ($member['expire_time'] <= $current_date){
$this->error('您的会员已到期,请先入会');
}
$channel = $this->request->header('channel');
$param['channel'] = $channel;
$param['wechat_id'] = $wechat_id;
$result = $this->validate($param,'app\api\validate\wdsxh\institution\InstitutionMemberApply.submit');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
if (!(new \app\api\model\wdsxh\institution\Institution())
->get($param['institution_id'])
) {
$this->error('机构不存在');
}
if (!(new \app\api\model\wdsxh\institution\Level())->get($param['level_id'])) {
$this->error('级别不存在不存在');
}
if ((new \app\api\model\wdsxh\institution\Member())
->where('institution_id',$param['institution_id'])
->where('wechat_id',$param['wechat_id'])
->find()
) {
$this->error('已经加入机构');
}
if ($this->model->where('institution_id',$param['institution_id'])
->where('level_id',$param['level_id'])
->where('wechat_id',$param['wechat_id'])
->where('state','1')
->find()
) {
$this->error('已提交申请');
}
$rejectObj = $this->model->where('institution_id',$param['institution_id'])
->where('wechat_id',$param['wechat_id'])
->where('state','3')
->find();
if ($rejectObj) {
try {
$rejectObj->level_id = $param['level_id'];
$rejectObj->introduction = $param['introduction'];
$rejectObj->state = '1';
$rejectObj->reject = '';
$rejectObj->handle_time = '';
$result = $rejectObj->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
} else {
try {
$this->model->data([
'institution_id' => $param['institution_id'],
'wechat_id' => $param['wechat_id'],
'member_id' => $member['id'],
'level_id' => $param['level_id'],
'introduction' => $param['introduction'],
'state' => '1',
]);
$result = $this->model->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('提交成功');
}
/**
* Desc 申请详情
* Create on 2025/8/7 上午10:32
* Create by wangyafang
*/
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$institution_id = $this->request->get('institution_id');
if (empty($institution_id)) {
$this->error('参数错误');
}
$data = null;
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$queryInstitutionMemberObj = (new \app\api\model\wdsxh\institution\Member())->where('institution_id',$institution_id)
->where('wechat_id',$wechat_id)
->find();
if (!empty($queryInstitutionMemberObj)) {
$queryInstitutionMemberObj['level_name'] = (new \app\api\model\wdsxh\institution\Level())
->where('id',$queryInstitutionMemberObj['level_id'])->value('level_name');
$this->success('请求成功',$queryInstitutionMemberObj);
}
$applyData = $this->model
->where('institution_id',$institution_id)
->where('wechat_id',$wechat_id)
->field('introduction,level_id,state,reject')
->find();
if (!empty($applyData)) {
$applyData['level_name'] = (new \app\api\model\wdsxh\institution\Level())
->where('id',$applyData['level_id'])->value('level_name');
$this->success('请求成功',$applyData);
}
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\controller\wdsxh\institution;
use app\common\controller\Api;
class Level extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\institution\Level();
}
/**
* Desc 机构级别列表
* Create on 2025/8/7 8:47
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$institution_id = $this->request->get('institution_id');
if (empty($institution_id)) {
$this->error('参数错误');
}
$data = $this->model
->where('institution_id',$institution_id)
->field('id,level_name')
->order('id asc')
->select();
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class Member
* Desc 成员控制器
* Create on 2025/3/5 10:42
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\institution;
use app\common\controller\Api;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Member extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\institution\Member();
}
/**
* Desc 成员列表
* Create on 2025/3/5 10:44
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
if (empty($param['institution_id'])) {
$this->error('参数错误');
}
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
try {
$where = [];
$where[config('database.prefix').'wdsxh_institution_member.institution_id'] = array('eq',$param['institution_id']);
$memberModel = new \app\api\model\wdsxh\member\Member();
$date = date('Y-m-d',time());
$total = $this->model->where($where)
->alias('member')
->with(['usermember','institution_level'])
->join('wdsxh_member','wdsxh_member.id = '.config('database.prefix').'wdsxh_institution_member.member_id')
->where('wdsxh_member.expire_time','>=',$date)
->count();
$data = $this->model
->alias('member')
->with(['usermember','institution_level'])
->join('wdsxh_member','wdsxh_member.id = '.config('database.prefix').'wdsxh_institution_member.member_id')
->where('wdsxh_member.expire_time','>=',$date)
->where($where)
->page($page,$limit)
->order('createtime asc')
->select();
foreach ($data as &$v) {
$v->usermember->visible(['name','avatar']);
$v['member_level'] = $memberModel->alias('m')->where('m.id',$v['member_id'])
->join('wdsxh_member_level member_level','m.member_level_id = member_level.id')
->value('member_level.name');
$v->institution_level->visible(['level_name']);
$v->hidden(['id','institution_id','level_id','wechat_id','member_id','wechat_id','createtime','updatetime']);
$v->content = $v->introduction;
$v->introduction = wdsxh_cut_str($v->introduction,4000);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
}