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,55 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\controller\wdsxh\member;
use app\common\controller\Api;
class Cert extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\member\Cert();
}
/**
* Desc 证书模型
* Create on 2024/3/12 9:52
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$where = [];
if(isset($param['name']) && !empty($param['name'])) {
$member_id = (new \app\admin\model\wdsxh\member\Member())
->where('name',$param['name'])
->value('id');
$where['member_id'] = array('eq',$member_id);
}
if(isset($param['number']) && !empty($param['number'])) {
$where['number'] = array('eq',$param['number']);
}
$data = $this->model
->where($where)
->field('id,image')
->select();
if (!$data){
$data = '';
}
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,425 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\controller\wdsxh\member;
use app\common\controller\Api;
/**
* Class JoinConfig
* Desc 入会申请控制器
* Create on 2024/3/7 9:08
* Create by wangyafang
*/
class JoinConfig extends Api
{
protected $noNeedLogin = ['custom_field'];
protected $noNeedRight = ['*'];
/**
* 首页
*
*/
public function custom_field()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$type = $this->request->get('type');
switch ($type) {
case 1:
$this->peroson_field();
break;
case 2:
$this->company_field();
break;
case 3:
$this->organize_field();
break;
}
}
private function peroson_field()
{
$fieldset = array();
$field_file_name = 'person';
$config_file = ADDON_PATH . "wdsxh" . DS . 'config' . DS .$field_file_name.".php";
if (is_file($config_file)) {
$fieldset = include $config_file;
}
if (empty($fieldset)) {
$fieldset = array (
0 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '姓名',
'field' => 'name',
'option' => '请输入你的姓名',
),
1 =>
array (
'show' => '1',
'required' => '1',
'type' => 'image',
'label' => '头像',
'field' => 'avatar',
'option' => '请上传头像',
),
2 =>
array (
'show' => '1',
'required' => '1',
'type' => 'number',
'label' => '手机号',
'field' => 'mobile',
'option' => '请输入你的手机号',
),
3 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '级别',
'field' => 'member_level_id',
'option' => '请选择会员级别',
),
4 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '籍贯',
'field' => 'native_place',
'option' => '请选择籍贯',
),
5 =>
array (
'show' => '1',
'required' => '1',
'type' => 'textarea',
'label' => '介绍',
'field' => 'introduce_content',
'option' => '请输入介绍',
),
6 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '所在地址',
'field' => 'address',
'option' => '请选择所在地址',
),
7 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '行业分类',
'field' => 'industry_category_id',
'option' => '请选择行业分类',
),
);
}
foreach ($fieldset as $k=>$v) {
$fieldset[$k]['value'] = '';
}
$this->success('请求成功',$fieldset);
}
private function company_field()
{
$fieldset = array();
$field_file_name = 'company';
$config_file = ADDON_PATH . "wdsxh" . DS . 'config' . DS .$field_file_name.".php";
if (is_file($config_file)) {
$fieldset = include $config_file;
}
if (empty($fieldset)) {
$fieldset = array (
'person' =>
array (
0 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '姓名',
'field' => 'name',
'option' => '请输入你的姓名',
),
1 =>
array (
'show' => '1',
'required' => '1',
'type' => 'image',
'label' => '头像',
'field' => 'avatar',
'option' => '请上传头像',
),
2 =>
array (
'show' => '1',
'required' => '1',
'type' => 'number',
'label' => '手机号',
'field' => 'mobile',
'option' => '请输入你的手机号',
),
3 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '级别',
'field' => 'member_level_id',
'option' => '请选择会员级别',
),
4 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '籍贯',
'field' => 'native_place',
'option' => '请选择籍贯',
),
5 =>
array (
'show' => '1',
'required' => '1',
'type' => 'textarea',
'label' => '介绍',
'field' => 'introduce_content',
'option' => '请输入介绍',
),
6 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '所在地址',
'field' => 'address',
'option' => '请选择所在地址',
),
7 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '行业分类',
'field' => 'industry_category_id',
'option' => '请选择行业分类',
),
8 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '公司职务',
'field' => 'company_position',
'option' => '请输入公司职务',
),
),
'company' =>
array (
0 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '公司名称',
'field' => 'company_name',
'option' => '请输入公司名称',
),
1 =>
array (
'show' => '1',
'required' => '1',
'type' => 'image',
'label' => '公司Logo',
'field' => 'company_logo',
'option' => '请上传公司Logo',
),
2 =>
array (
'show' => '1',
'required' => '1',
'type' => 'textarea',
'label' => '公司简介',
'field' => 'company_introduction',
'option' => '请输入公司简介',
),
),
);
}
foreach ($fieldset['person'] as $k=>$v) {
$fieldset['person'][$k]['value'] = '';
}
foreach ($fieldset['company'] as $k=>$v) {
$fieldset['company'][$k]['value'] = '';
}
$this->success('请求成功',$fieldset);
}
private function organize_field()
{
$fieldset = array();
$field_file_name = 'organize';
$config_file = ADDON_PATH . "wdsxh" . DS . 'config' . DS .$field_file_name.".php";
if (is_file($config_file)) {
$fieldset = include $config_file;
}
if (empty($fieldset)) {
$fieldset = array (
'person' =>
array (
0 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '姓名',
'field' => 'name',
'option' => '请输入你的姓名',
),
1 =>
array (
'show' => '1',
'required' => '1',
'type' => 'image',
'label' => '头像',
'field' => 'avatar',
'option' => '请上传头像',
),
2 =>
array (
'show' => '1',
'required' => '1',
'type' => 'number',
'label' => '手机号',
'field' => 'mobile',
'option' => '请输入你的手机号',
),
3 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '级别',
'field' => 'member_level_id',
'option' => '请选择会员级别',
),
4 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '籍贯',
'field' => 'native_place',
'option' => '请选择籍贯',
),
5 =>
array (
'show' => '1',
'required' => '1',
'type' => 'textarea',
'label' => '介绍',
'field' => 'introduce_content',
'option' => '请输入介绍',
),
6 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '所在地址',
'field' => 'address',
'option' => '请选择所在地址',
),
7 =>
array (
'show' => '1',
'required' => '1',
'type' => 'select',
'label' => '行业分类',
'field' => 'industry_category_id',
'option' => '请选择行业分类',
),
8 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '团体职务',
'field' => 'organize_position',
'option' => '请输入团体职务',
),
),
'organize' =>
array (
0 =>
array (
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '团体名称',
'field' => 'organize_name',
'option' => '请输入团体名称',
),
1 =>
array (
'show' => '1',
'required' => '1',
'type' => 'image',
'label' => '团体Logo',
'field' => 'organize_logo',
'option' => '请上传团体Logo',
),
2 =>
array (
'show' => '1',
'required' => '1',
'type' => 'textarea',
'label' => '团体简介',
'field' => 'organize_introduction',
'option' => '请输入团体简介',
),
),
);
}
foreach ($fieldset['person'] as $k=>$v) {
$fieldset['person'][$k]['value'] = '';
}
foreach ($fieldset['organize'] as $k=>$v) {
$fieldset['organize'][$k]['value'] = '';
}
$this->success('请求成功',$fieldset);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,418 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class MemberApply
* Desc 入会申请控制器
* Create on 2024/3/7 15:45
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\member;
use addons\wdsxh\library\AlibabaCloudSms;
use addons\wdsxh\library\Wxapp;
use app\admin\model\wdsxh\member\FeesConfig;
use app\admin\model\wdsxh\member\IndustryCategory;
use app\api\model\wdsxh\business\Association;
use app\api\model\wdsxh\member\Level;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class MemberApply extends Api
{
protected $noNeedLogin = ['submit','level_list','industry_category_list'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $configObj = '';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\member\MemberApply();
$this->configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
}
/**
* Desc 入会申请提交
* Create on 2024/3/7 15:56
* Create by wangyafang
*/
public function submit()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$param['data'] = json_decode($_POST['data'],true);
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$param['wechat_id'] = $wechat_id;
$channel = $this->request->header('channel');
$param['channel'] = $channel;
$result = $this->validate($param,'app\api\validate\wdsxh\member\MemberApply.submit');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
$memberApplyObj = $this->model->where('wechat_id',$wechat_id)->find();
if ($memberApplyObj && $memberApplyObj['state'] == '1') {
$this->error('你的入会信息正在审核,不能重复提交');
}
if ($memberApplyObj && $memberApplyObj['state'] == '2') {
$this->error('你已经是会员了,不能再次申请');
}
try {
$custom_data = $this->handle_custom_data($param['type'],$param['data']);
$channel = $this->request->header('channel');
$custom_data['channel'] = $channel;
$custom_data['type'] = $param['type'];
$custom_data['pay_method'] = (new FeesConfig())->where('id',1)->value('pay_method');
if ($memberApplyObj) {
$custom_data['state'] = '1';
$custom_data['child_state'] = '1';
$custom_data['custom_content'] = \app\common\model\wdsxh\member\Member::remove_custom_content_full_image($param['type'],$_POST['data']);
$custom_data['createtime'] = time();
$custom_data['reject'] = '';
$memberApplyObj->save($custom_data);
} else {
$custom_data['wechat_id'] = $wechat_id;
$custom_data['type'] = $param['type'];
$custom_data['custom_content'] = json_encode($this->handleCustomDataAvatarCompanyLogo($param['type'],$param['data']));
$this->model->data($custom_data);
$this->model->allowField(true)->save();
}
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$conf = $this->configObj;
if ($channel == 1) {
//发送入会申请通知
try {
$data = [
'thing2' => [
'value' => $custom_data['name'],
],
'phone_number4' => [
'value' => $custom_data['mobile'],
],
'phrase1' => [
'value' => '待审核',
],
];
$openids = (new UserWechat())->where('set_admin', 1)->column('applet_openid');
if ($openids) {
foreach ($openids as $openid) {
$result = Wxapp::subscribeMessage($conf['applet_initiation_admin'], trim($openid), '/pagesAdmin/examine/index', $data);
if ($result && $result[0]['errcode'] == 0) {
$wechat_id = (new UserWechat())
->where('applet_openid', $openid)
->value('id');
$subscribeObj = Db::name('wdsxh_member_subscribe')->where('wechat_id', $wechat_id)->where('type', 1)->find();
if ($subscribeObj && $subscribeObj['count'] > 0) {
Db::name('wdsxh_member_subscribe')->where('wechat_id', $wechat_id)->where('type', 1)->setDec('count');
}
}
}
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
}
$configObj = $this->configObj;
$phoneNumbers = (new Association())->where('id',1)->value('phone');
if (!empty($configObj['alibaba_cloud_sign_name'])
&& !empty($configObj['alibaba_cloud_access_key_id'])
&& !empty($configObj['alibaba_cloud_access_key_secret'])
&& !empty($configObj['alibaba_initiation_admin_notify'])
&& !empty($phoneNumbers)
) {
$name = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $custom_data['name']);
if (empty($name)) {
$name = '用户';
}
$phone = $custom_data['mobile'];
$userSendSmsRequestParam = [
"phoneNumbers" => $phoneNumbers,
"templateCode" => $configObj['alibaba_initiation_admin_notify'],
"templateParam" => "{'name':'$name','phone':'$phone'}"
];
AlibabaCloudSms::main($userSendSmsRequestParam);
}
$this->success('提交成功');
}
public function handle_custom_data($type,$data)
{
$custom_field = array();
switch ($type) {
case 1:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','address','industry_category_id');
break;
case 2:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','company_name','company_logo','company_introduction','company_position','address','industry_category_id');
break;
case 3:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','organize_name','organize_logo','organize_introduction','organize_position','address','industry_category_id');
break;
}
$result = array();
if ($type == 1) {
foreach ($data as &$v) {
if (in_array($v['field'],$custom_field)) {
$result[$v['field']] = $v['value'];
if ($v['field'] == 'industry_category_id' && !empty($v['value'])) {
$result['industry_category_name'] = (new IndustryCategory())->where('id',$v['value'])->value('name');
}
if ($v['field'] == 'introduce_content' && !empty($v['value'])) {
$v['value'] = wdsxh_xss_filter($v['value']);
}
if ($v['field'] == 'avatar' && empty($v['value'])) {
$result['avatar'] = $v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
if(isset($result['address']) && !empty($result['address'])){
$result['address'] = json_encode($result['address']);
}
} elseif ($type == 2) {
foreach ($data['person'] as &$v) {
if (in_array($v['field'],$custom_field)) {
$result[$v['field']] = $v['value'];
if ($v['field'] == 'industry_category_id' && !empty($v['value'])) {
$result['industry_category_name'] = (new IndustryCategory())->where('id',$v['value'])->value('name');
}
if ($v['field'] == 'address' && !empty($v['value'])) {
$result['address'] = json_encode($v['value']);
}
if ($v['field'] == 'introduce_content' && !empty($v['value'])) {
$v['value'] = wdsxh_xss_filter($v['value']);
}
if ($v['field'] == 'avatar' && empty($v['value'])) {
$result['avatar'] = $v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
foreach ($data['company'] as &$v) {
if (in_array($v['field'],$custom_field)) {
$result[$v['field']] = $v['value'];
}
if ($v['field'] == 'company_introduction' && !empty($v['value'])) {
$v['value'] = wdsxh_xss_filter($v['value']);
}
if ($v['field'] == 'company_logo' && empty($v['value'])) {
$result['company_logo'] = $v['value'] = '/assets/addons/wdsxh/img/company_logo.png';
}
}
} else {
foreach ($data['person'] as &$v) {
if (in_array($v['field'],$custom_field)) {
$result[$v['field']] = $v['value'];
if ($v['field'] == 'industry_category_id' && !empty($v['value'])) {
$result['industry_category_name'] = (new IndustryCategory())->where('id',$v['value'])->value('name');
}
if ($v['field'] == 'address' && !empty($v['value'])) {
$result['address'] = json_encode($v['value']);
}
if ($v['field'] == 'introduce_content' && !empty($v['value'])) {
$v['value'] = wdsxh_xss_filter($v['value']);
}
if ($v['field'] == 'avatar' && empty($v['value'])) {
$result['avatar'] = $v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
foreach ($data['organize'] as &$v) {
if (in_array($v['field'],$custom_field)) {
$result[$v['field']] = $v['value'];
}
if ($v['field'] == 'organize_introduction' && !empty($v['value'])) {
$v['value'] = wdsxh_xss_filter($v['value']);
}
if ($v['field'] == 'organize_logo' && empty($v['value'])) {
$result['organize_logo'] = $v['value'] = '/assets/addons/wdsxh/img/organize_logo.png';
}
}
}
return $result;
}
public function handleCustomDataAvatarCompanyLogo($type,$data)
{
$custom_field = array();
switch ($type) {
case 1:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','address','industry_category_id');
break;
case 2:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','company_name','company_logo','company_introduction','company_position','address','industry_category_id');
break;
case 3:
$custom_field = array('name','avatar','mobile','member_level_id','native_place','introduce_content','organize_name','organize_logo','organize_introduction','organize_position','address','industry_category_id');
break;
}
$result = array();
if ($type == 1) {
foreach ($data as &$v) {
if (in_array($v['field'],$custom_field)) {
if ($v['field'] == 'avatar' && empty($v['value'])) {
$v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
} elseif ($type == 2) {
foreach ($data['person'] as &$v) {
if (in_array($v['field'],$custom_field)) {
if ($v['field'] == 'avatar' && empty($v['value'])) {
$v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
foreach ($data['company'] as &$v) {
if ($v['field'] == 'company_logo' && empty($v['value'])) {
$v['value'] = '/assets/addons/wdsxh/img/company_logo.png';
}
}
} else {
foreach ($data['person'] as &$v) {
if (in_array($v['field'],$custom_field)) {
if ($v['field'] == 'avatar' && empty($v['value'])) {
$v['value'] = '/assets/addons/wdsxh/img/avatar.png';
}
}
}
foreach ($data['organize'] as &$v) {
if ($v['field'] == 'organize_logo' && empty($v['value'])) {
$v['value'] = '/assets/addons/wdsxh/img/organize_logo.png';
}
}
}
return $data;
}
/**
* Desc 会员级别列表
* Create on 2024/3/18 11:26
* Create by wangyafang
*/
public function level_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$list = (new Level())
->where('status','normal')
->field('id,name')
->order('weigh asc,id asc')
->select();
$this->success('请求成功',$list);
}
/**
* Desc 行业分类列表
* Create on 2024/3/19 11:21
* Create by wangyafang
*/
public function industry_category_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$list = (new \app\api\model\wdsxh\member\IndustryCategory())
->where('status','1')
->field('id,name,icon')
->order('weigh desc,id desc')
->select();
$this->success('请求成功',$list);
}
/**
* Desc 入会信息详情
* Create on 2024/3/27 16:29
* Create by wangyafang
*/
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$applyObj = $this->model->where('wechat_id',$wechat_id)->field('type,custom_content')->find();
if (!$applyObj) {
$this->error('入会信息不存在');
}
$custom_content = \app\common\model\wdsxh\member\Member::get_custom_content_full_image($applyObj['type'],$applyObj['custom_content']);
$this->success('请求成功',$custom_content);
}
/**
* Desc 检查手机号是否被使用
* Create on 2024/3/27 16:29
* Create by wangyafang
*/
public function check_mobile_use()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$mobile = $this->request->get('mobile');
if (empty($mobile)) {
$this->error('手机号不能为空');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberApplyId = (new \app\api\model\wdsxh\member\MemberApply())
->where('wechat_id','<>',$wechat_id)
->where('mobile',$mobile)
->value('id');
$use_status = $memberApplyId ? 1 : 2;
$result = array(
'use_status'=>$use_status,
);
$this->success('成功请求',$result);
}
}

View File

@@ -0,0 +1,598 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class MemberApplyExamine
* Desc 入会申请审核会员
* Create on 2025/3/5 14:03
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\member;
use addons\wdsxh\library\Wxapp;
use app\api\model\wdsxh\member\Cert;
use app\admin\model\wdsxh\member\FeesConfig;
use app\api\model\wdsxh\member\IndustryCategory;
use app\api\model\wdsxh\member\Level;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\business\Association;
use app\api\model\wdsxh\member\Pay;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use think\Exception;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
class MemberApplyExamine extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
protected $wechat_id = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\member\MemberApplyExamine();
$userWechatModel = new UserWechat();
$this->wechat_id = $userWechatModel->where('user_id',$this->auth->id)->value('id');
$set_admin = $userWechatModel->where('id',$this->wechat_id)->value('set_admin');
if ($set_admin == 2) {
$this->error('不是管理员,无法操作');
}
}
/**
* Desc 审核列表
* Create on 2025/3/5 14:08
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
if (empty($param['state'])) {
$this->error('参数错误');
}
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
if ($param['state'] == 1) {//待审核
$where['child_state'] = array('in',array('1','4'));
} else {//已审核
$where['child_state'] = array('in',array('2','5','3','6'));
$where[] = ['exp',Db::raw("FIND_IN_SET($this->wechat_id,examine_wechat_id)")];
}
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->with(['level'])
->page($page,$limit)
->order('createtime desc')
->select();
foreach ($data as &$v) {
// 先处理 level 的字段限制
$v->level->visible(['name']);
// 再处理 $v 的字段限制,确保不覆盖 level 的字段
$v->visible(['id', 'name', 'avatar', 'createtime', 'state', 'child_state','examine_time','level']);
if (in_array($v['state'],['4','6'])) {
$v->createtime = date('Y-m-d H:i:s',$v['examine_time']);
}
unset($v['examine_time']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 详情
* Create on 2025/3/5 15:43
* Create by wangyafang
*/
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
if (!$id) {
$this->error('参数错误');
}
try {
$row = $this->model->get($id);
if (!$row) {
$this->error('数据不存在');
}
$custom_content = json_decode($row['custom_content'],true);
switch ($row['type']) {
case 1:
$custom_content = $this->loop_array_get_full_url($custom_content);
break;
case 2:
$custom_content['person'] = $this->loop_array_get_full_url($custom_content['person']);
$custom_content['company'] = $this->loop_array_get_full_url($custom_content['company']);
break;
case 3:
$custom_content['person'] = $this->loop_array_get_full_url($custom_content['person']);
$custom_content['organize'] = $this->loop_array_get_full_url($custom_content['organize']);
break;
}
$data['custom_content'] = $custom_content;
if ($row['state'] == '1' && $row['child_state'] == '4' && !empty($row['pay_voucher'])) {
$data['pay_voucher'] = wdsxh_full_url($row['pay_voucher']);
}
$data['name'] = $row['name'];
$data['avatar'] = $row['avatar'];
$data['level_name'] = (new Level())->where('id',$row['member_level_id'])->value('name');
$data['child_state'] = $row['child_state'];
$data['createtime'] = $row['createtime'];
$data['type'] = $row['type'];
$this->success('请求成功',$data);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
/**
* Desc 遍历数组获取图片,文件,视频全路径
* Create on 2025/3/8 8:15
* Create by wangyafang
*/
private function loop_array_get_full_url($array) {
$industryCategoryModel = new IndustryCategory();
foreach ($array as $k=>&$v) {
if (in_array($v['field'],['name','avatar','member_level_id'])) {
unset($array[$k]);
continue;
}
if (in_array($v['type'],['image','video']) && !empty($v['value'])) {
$v['value'] = \app\common\model\wdsxh\member\Member::get_string_full_url($v['value']);
}
if (in_array($v['type'],['cert']) && !empty($v['value']['image'])) {
$v['value']['image'] = \app\common\model\wdsxh\member\Member::get_string_full_url($v['value']['image']);
}
if (in_array($v['type'],['file']) && !empty($v['value'])) {
foreach ($v['value'] as &$vv) {
$vv['path'] = \app\common\model\wdsxh\member\Member::get_string_full_url($vv['path']);
}
}
if ($v['field'] == 'industry_category_id') {
$v['value'] = $industryCategoryModel->where('id',$v['value'])->value('name');
}
}
$array = array_values($array);
return $array;
}
/**
* 入会审核
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function examine()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$params = $this->request->post();
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
if (empty($params['id'])) {
$this->error('参数错误');
}
$ids = $params['id'];
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
if (!isset($params['state'])) {
$this->error('请选择审核状态');
}
if ($params['state'] == 3 && empty($params['reject'])) {
$this->error('请填写驳回原因');
}
$row = $this->model->get($ids);
if ($params['state'] == '2') {
$this->pass($row,$params);
} else {
$this->reject($row,$params);
}
}
/**
* 线下审核
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function offline_examine()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$params = $this->request->post();
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$ids = $params['id'];
$row = $this->model->get($ids);
$row['custom_content'] = \app\common\model\wdsxh\member\Member::get_custom_data($row);
if (!$row) {
$this->error(__('No Results were found'));
}
if (!isset($params['state'])) {
$this->error('请选择审核状态');
}
if ($params['state'] == 3 && empty($params['reject'])) {
$this->error('请填写驳回原因');
}
$row = $this->model->get($ids);
if ($params['state'] == '2') {
$this->offline_pass($row,$params);
} else {
$this->offline_reject($row,$params);
}
}
/**
* Desc 通过
* Create on 2024/3/7 15:56
* Create by wangyafang
*/
protected function pass($row = '',$params = [])
{
$feesConfigObj = (new FeesConfig())->where('id',1)->find();
$member_data = \app\common\model\wdsxh\member\Member::get_member_data($row);
$memberModel = new Member();
$memberObj = $memberModel->where('wechat_id',$row['wechat_id'])->find();
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$params['examine_role'] = 2;
$params['examine_wechat_id'] = $this->wechat_id;
$params['examine_time'] = time();
if ($feesConfigObj['pay_method'] == 1) {//免费入会
$params['state'] = '2';//已通过
$params['child_state'] = '6';//已通过
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
if ($memberObj) {
$memberObj->expire_time = $member_data['expire_time'];
$memberObj->save();
} else {
$memberModel->data($member_data);
$memberModel->allowField(true)->save();
}
$cert_data = \app\common\model\wdsxh\Cert::get_cert_data($row['type'],$row,$memberModel->id);
if(!empty($cert_data)) {
$certModel = new Cert();
$certModel->saveAll($cert_data);
}
if ($row['channel'] == '1') {
//入会审核成功通知
try {
$data = [
'thing1' => [
'value' => $row['name'],
],
'time3' => [
'value' => date('Y-m-d H:i:s'),
],
'phrase4' => [
'value' => '审核通过',
],
'thing5' => [
'value' => '恭喜成功加入会员',
],
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_audit'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
//入会申请成功通知
$businessAssociationObj = (new Association())->get(1);
try {
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$data = [
'thing3' => [
'value' => mb_substr($businessAssociationObj['name'], 0, 20)
],
'time2' => [
'value' => date('Y-m-d H:i:s'),
],
'thing1' => [
'value' => mb_substr('恭喜您已成功加入' . $businessAssociationObj['name'], 0, 20),
]
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_success'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
} else {
$params['state'] = '4';//待付款
$params['child_state'] = '3';//待付款
$row->allowField(true)->save($params);
if ($row['channel'] == '1') {
//入会审核成功通知
try {
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$data = [
'thing1' => [
'value' => $row['name'],
],
'time3' => [
'value' => date('Y-m-d H:i:s'),
],
'phrase4' => [
'value' => '审核通过',
],
'thing5' => [
'value' => '通过审核,请前往小程序缴纳会费!',
],
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_audit'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
}
$this->success('操作成功');
}
/**
* Desc 驳回
* Create on 2024/3/7 15:56
* Create by wangyafang
*/
protected function reject($row = '',$params = [])
{
$params['examine_role'] = 2;
$params['examine_wechat_id'] = $this->wechat_id;
$params['child_state'] = '2';
$params['examine_time'] = time();
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
if ($row['channel'] == 1) {
//入会审核成功通知
try {
$data = [
'thing1' => [
'value' => $row['name'],
],
'time3' => [
'value' => date('Y-m-d H:i:s'),
],
'phrase4' => [
'value' => '审核未通过',
],
'thing5' => [
'value' => '原因:' . $params['reject'],
],
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_audit'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
$this->success('操作成功');
}
/**
* Desc 线下通过
* Create on 2024/3/21 9:01
* Create by wangyafang
*/
protected function offline_pass($row = '',$params = [])
{
$member_data = \app\common\model\wdsxh\member\Member::get_member_data($row);
$params['state'] = '2';//已通过
$params['child_state'] = '6';//已通过
$params['examine_role'] = 2;
$params['examine_time'] = time();
if (!empty($row['examine_wechat_id']) && ($row['examine_wechat_id'] != $this->wechat_id)) {
$params['examine_wechat_id'] = $row['examine_wechat_id'].','.$this->wechat_id;
} else {
$params['examine_wechat_id'] = $this->wechat_id;
}
$memberModel = new Member();
$memberObj = $memberModel->where('wechat_id',$row['wechat_id'])->find();
if ($memberObj) {
$memberObj->expire_time = $member_data['expire_time'];
$memberObj->save();
$member_id = $memberObj['id'];
} else {
$memberModel->data($member_data);
$memberModel->allowField(true)->save();
$member_id = $memberModel->id;
}
$payModel = new Pay();
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($params);
$pay_data = array(
'member_id'=>$member_id,
'wechat_id'=>$row['wechat_id'],
'order_no'=> wdsxh_create_order(),
'fees'=>(new Level())->where('id',$row['member_level_id'])->value('fees'),
'level_id'=>$row['member_level_id'],
'channel'=>$row['channel'],
'pay_method'=>'3',
'paid'=>'2',
'pay_time'=>time(),
);
$payModel->data($pay_data);
$payModel->allowField(true)->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$cert_data = \app\common\model\wdsxh\Cert::get_cert_data($row['type'],$row,$member_id);
if(!empty($cert_data)) {
$certModel = new Cert();
$certModel->saveAll($cert_data);
}
//入会审核成功通知
try {
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$data = [
'thing1' => [
'value' => $row['name'],
],
'time3' => [
'value' => date('Y-m-d H:i:s'),
],
'phrase4' => [
'value' => '审核通过',
],
'thing5' => [
'value' => '恭喜成功加入会员',
],
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_audit'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
//入会申请成功通知
$businessAssociationObj = (new Association())->get(1);
try {
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$data = [
'thing3' => [
'value' => mb_substr($businessAssociationObj['name'], 0, 20)
],
'time2' => [
'value' => date('Y-m-d H:i:s'),
],
'thing1' => [
'value' => mb_substr('恭喜您已成功加入' . $businessAssociationObj['name'], 0, 20),
]
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_success'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
$this->success('操作成功');
}
/**
* Desc 线下驳回
* Create on 2024/3/21 8:56
* Create by wangyafang
*/
protected function offline_reject($row = '',$params = [])
{
$params['examine_role'] = 2;
$params['examine_wechat_id'] = $this->wechat_id;
$params['child_state'] = '5';
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
if ($row['channel'] == 1) {
//入会审核成功通知
try {
$conf = (new \app\admin\model\wdsxh\Config())->where('id', 1)->find();
$data = [
'thing1' => [
'value' => $row['name'],
],
'time3' => [
'value' => date('Y-m-d H:i:s'),
],
'phrase4' => [
'value' => '审核未通过',
],
'thing5' => [
'value' => '原因:' . $params['reject'],
],
];
$result = Wxapp::subscribeMessage($conf['applet_initiation_audit'], trim(wdsxh_get_openid($row['wechat_id'],1)), '/pages/mine/index', $data);
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
$this->success('操作成功');
}
}

View File

@@ -0,0 +1,173 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Promotion
* Desc 推广人员控制器
* Create on 2024/3/16 13:51
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\member;
use app\admin\model\wdsxh\Config;
use app\api\model\wdsxh\business\Association;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use EasyWeChat\Factory;
class Promotion extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$userWechatModel = new UserWechat();
$memberModel = new \app\api\model\wdsxh\member\Member();
// 确保 auth->id 为整数,防止注入
$userId = (int)$this->auth->id;
// 获取 parent_wechat_id
$parent_wechat_id = $userWechatModel->where('user_id', $userId)->value('id');
if (!$parent_wechat_id) {
// 处理 parent_wechat_id 不存在的情况
$user_data = [];
$member_data = [];
} else {
// 获取所有子微信ID
$all_wechat_id_array = $userWechatModel->where('parent_wechat_id', $parent_wechat_id)->column('id');
if (empty($all_wechat_id_array)) {
$user_data = [];
$member_data = [];
} else {
// 获取已经是会员的微信ID
$member_wechat_id_array = $memberModel->where('wechat_id', 'in', $all_wechat_id_array)->column('wechat_id');
$member_wechat_id_array = $member_wechat_id_array ?: [];
// 计算非会员的微信ID
$user_wechat_id_array = array_diff($all_wechat_id_array, $member_wechat_id_array);
// 查询非会员用户信息
$user_data = $userWechatModel->where('id', 'in', $user_wechat_id_array)->order('id desc')
->field("avatar,REPLACE(mobile,SUBSTR(mobile,4,4),'****') mobile,createtime join_time")
->select();
// 查询会员信息
$member_data = $memberModel
->alias('member')
->where('member.wechat_id', 'in', $member_wechat_id_array)
->field('member.name member_name,member.avatar member_avatar,level.name level_name,member.join_time')
->join('wdsxh_member_level level', 'level.id = member.member_level_id')
->order('member.id desc')
->select();
// 处理头像路径
foreach ($member_data as &$v) {
$v->member_avatar = wdsxh_full_url($v->member_avatar);
}
unset($v); // 释放引用
}
}
$memberObj = $memberModel->where('wechat_id',$parent_wechat_id)->field('id,name,avatar,createtime')->find();
if (!$memberObj) {
$this->error('会员信息不存在');
}
$user = array(
'total'=> count($user_data),
'data'=> $user_data,
);
$member = array(
'total'=> count($member_data),
'data'=> $member_data,
);
$promotion_img = (new Config())->where('id',1)->value('promotion_img');
$channel = $this->request->header('channel');
if ($channel == 1) {//小程序
$save_path = '/uploads/wdsxh/applet_qrcode/'.$memberObj['id'].'/'.$memberObj['createtime'].'.png';
if (is_file(ROOT_PATH."public".$save_path)) {
$applet_qrcode_path = $this->request->domain().$save_path;
} else {
$configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
$path = 'pages/index/index';
$config = [
'app_id' => $configObj['applet_appid'],
'secret' => $configObj['applet_secret'],
'response_type' => 'array',
'log' => [
'level' => 'debug',
],
];
$app = Factory::miniProgram($config);
$response = $app->app_code->getUnlimit($parent_wechat_id, [
'page' => $path,
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$response->saveAs('uploads/wdsxh/applet_qrcode/'.$memberObj['id'], $memberObj['createtime'].'.png');
$applet_qrcode_path = $this->request->domain().$save_path;
} else {
$this->error('小程序二维码生成失败');
}
}
} else {//公众号
$save_path = DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'wdsxh'.DIRECTORY_SEPARATOR.'wananchi_qrcode'.DIRECTORY_SEPARATOR.$memberObj['id'].DIRECTORY_SEPARATOR.$memberObj['createtime'].'promotion.png';
if (is_file(ROOT_PATH."public".$save_path)) {
$applet_qrcode_path = $this->request->domain().$save_path;
} else {
$params['text'] = $this->request->get('text', $this->request->domain().'/web/#/?parent_wechat_id='.$parent_wechat_id, 'trim');
$qrCode = \addons\qrcode\library\Service::qrcode($params);
$qrcodePath = ROOT_PATH . 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'wdsxh'.DIRECTORY_SEPARATOR.'wananchi_qrcode'.DIRECTORY_SEPARATOR.$memberObj['id'].DIRECTORY_SEPARATOR;
if (!is_dir($qrcodePath)) {
wdsxh_mkdirs($qrcodePath);
}
if (is_really_writable($qrcodePath)) {
$filePath = $qrcodePath . $memberObj['createtime'].'promotion.png';
$qrCode->writeFile($filePath);
$save_path = DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'wdsxh'.DIRECTORY_SEPARATOR.'wananchi_qrcode'.DIRECTORY_SEPARATOR.$memberObj['id'].DIRECTORY_SEPARATOR.$memberObj['createtime'].'promotion.png';
$applet_qrcode_path = $this->request->domain().$save_path;
}
}
}
$data = array(
'user'=>$user,
'member'=>$member,
'parent_wechat_id'=>$parent_wechat_id,
'member_name'=>$memberObj['name'],
'member_avatar'=>$memberObj['avatar'],
'promotion_img'=>wdsxh_full_url($promotion_img),
'applet_qrcode_path'=>$applet_qrcode_path,
);
$business_association_name = (new Association())->where('id',1)->value('name');
$data['business_association_name'] = $business_association_name;
$this->success('请求成功',$data);
}
}