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 @@
<?php

View File

@@ -0,0 +1,6 @@
<?php
//配置文件
return [
'exception_handle' => '\\app\\api\\library\\ExceptionHandle',
];

View File

@@ -0,0 +1,166 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\exception\UploadException;
use app\common\library\Upload;
use app\common\model\Area;
use app\common\model\Version;
use fast\Random;
use think\captcha\Captcha;
use think\Config;
use think\Hook;
/**
* 公共接口
*/
class Common extends Api
{
protected $noNeedLogin = ['init', 'captcha'];
protected $noNeedRight = '*';
public function _initialize()
{
if (isset($_SERVER['HTTP_ORIGIN'])) {
header('Access-Control-Expose-Headers: __token__');//跨域让客户端获取到
}
//跨域检测
check_cors_request();
if (!isset($_COOKIE['PHPSESSID'])) {
Config::set('session.id', $this->request->server("HTTP_SID"));
}
parent::_initialize();
}
/**
* 加载初始化
*
* @param string $version 版本号
* @param string $lng 经度
* @param string $lat 纬度
*/
public function init()
{
if ($version = $this->request->request('version')) {
$lng = $this->request->request('lng');
$lat = $this->request->request('lat');
//配置信息
$upload = Config::get('upload');
//如果非服务端中转模式需要修改为中转
if ($upload['storage'] != 'local' && isset($upload['uploadmode']) && $upload['uploadmode'] != 'server') {
//临时修改上传模式为服务端中转
set_addon_config($upload['storage'], ["uploadmode" => "server"], false);
$upload = \app\common\model\Config::upload();
// 上传信息配置后
Hook::listen("upload_config_init", $upload);
$upload = Config::set('upload', array_merge(Config::get('upload'), $upload));
}
$upload['cdnurl'] = $upload['cdnurl'] ? $upload['cdnurl'] : cdnurl('', true);
$upload['uploadurl'] = preg_match("/^((?:[a-z]+:)?\/\/)(.*)/i", $upload['uploadurl']) ? $upload['uploadurl'] : url($upload['storage'] == 'local' ? '/api/common/upload' : $upload['uploadurl'], '', false, true);
$content = [
'citydata' => Area::getCityFromLngLat($lng, $lat),
'versiondata' => Version::check($version),
'uploaddata' => $upload,
'coverdata' => Config::get("cover"),
];
$this->success('', $content);
} else {
$this->error(__('Invalid parameters'));
}
}
/**
* 上传文件
* @ApiMethod (POST)
* @param File $file 文件流
*/
public function upload()
{
Config::set('default_return_type', 'json');
//必须设定cdnurl为空,否则cdnurl函数计算错误
Config::set('upload.cdnurl', '');
$chunkid = $this->request->post("chunkid");
if ($chunkid) {
if (!Config::get('upload.chunking')) {
$this->error(__('Chunk file disabled'));
}
$action = $this->request->post("action");
$chunkindex = $this->request->post("chunkindex/d");
$chunkcount = $this->request->post("chunkcount/d");
$filename = $this->request->post("filename");
$method = $this->request->method(true);
if ($action == 'merge') {
$attachment = null;
//合并分片文件
try {
$upload = new Upload();
$attachment = $upload->merge($chunkid, $chunkcount, $filename);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
} elseif ($method == 'clean') {
//删除冗余的分片文件
try {
$upload = new Upload();
$upload->clean($chunkid);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
$this->success();
} else {
//上传分片文件
//默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$upload->chunk($chunkid, $chunkindex, $chunkcount);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
$this->success();
}
} else {
$attachment = null;
//默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$attachment = $upload->upload();
} catch (UploadException $e) {
$this->error($e->getMessage());
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
}
}
/**
* 验证码
* @param $id
* @return \think\Response
*/
public function captcha($id = "")
{
\think\Config::set([
'captcha' => array_merge(config('captcha'), [
'fontSize' => 44,
'imageH' => 150,
'imageW' => 350,
])
]);
$captcha = new Captcha((array)Config::get('captcha'));
return $captcha->entry($id);
}
}

View File

@@ -0,0 +1,202 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\Invitation;
use think\Validate;
/**
* 示例接口
*/
class Demo extends Api
{
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
//如果接口已经设置无需登录,那也就无需鉴权了
//
// 无需登录的接口,*表示全部
protected $noNeedLogin = ['test', 'test1', 'apply'];
// 无需鉴权的接口,*表示全部
protected $noNeedRight = ['test2','apply','invitation'];
/**
* 测试方法
*
* @ApiTitle (测试名称)
* @ApiSummary (测试描述信息)
* @ApiMethod (POST)
* @ApiRoute (/api/demo/test/id/{id}/name/{name})
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="integer", required=true, description="会员ID")
* @ApiParams (name="name", type="string", required=true, description="用户名")
* @ApiParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
/**
* 提交邀请
*
* @ApiMethod (POST)
*/
public function apply()
{
$params = request()->post();
$mobile = $this->request->post('mobile');
if ($mobile) {
$exists = \app\common\model\Invitation::where('mobile', $mobile)->find();
if ($exists) {
//$this->error();
$this->success(__('Username already invited'));
}
else{
$dine = $params['dine'];
$attendees = $params['attendees'];
//echo print_r($dine)."<pre>==". print_r($attendees); die;
$feeData = array(
'username'=>$this->request->post('username'),
'company'=>$this->request->post('company'),
'position'=>$this->request->post('position'),
'mobile'=>$this->request->post('mobile'),
'hometown'=>$this->request->post('hometown'),
'gender'=>$this->request->post('gender'),
'is_member'=>$this->request->post('is_member'),
//'pay_member'=>$params['pay_member'],
'dine'=>json_encode($dine, JSON_UNESCAPED_UNICODE),
'attendees'=>json_encode($attendees, JSON_UNESCAPED_UNICODE)
);
$invitation = new Invitation;
try {
$result = $invitation->allowField(true)->save($feeData);
if ($result !== false) {
$this->success();
} else {
$this->error($row->getError());
}
} catch (\think\exception\PDOException $e) {
$this->error($e->getMessage());
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
}
}
public function test()
{
$this->success('返回成功', $this->request->param());
}
/**
* 无需登录的接口
*
*/
public function test1()
{
$this->success('返回成功', ['action' => 'test1']);
}
/**
* 需要登录的接口
*
*/
public function test2()
{
$this->success('返回成功', ['action' => 'test2']);
}
/**
* 需要登录且需要验证有相应组的权限
*
*/
public function test3()
{
$this->success('返回成功', ['action' => 'test3']);
}
public function invitation()
{
$params = request()->post();
/* $username = $this->request->post('username');
$company = $this->request->post('company');
$position = $this->request->post('position');
$hometown = $this->request->post('hometown');
$gender = $this->request->post('gender');
$is_member = $this->request->post('is_member');
$attendees = $this->request->post('attendees');
if (!$username) {
$this->error(__('Invalid parameters'));
}
if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}*/
$mobile = $this->request->post('mobile');
$mobile = '13246777081';
if ($mobile) {
$exists = \app\common\model\Invitation::where('mobile', $mobile)->find();
if ($exists) {
//$this->error();
$this->success(__('Username already invited'));
}
else{
$dine = $this->request->post('dine');
$attendees = $this->request->post('attendees');
$feeData = array(
'username'=>$this->request->post('username'),
'company'=>$this->request->post('company'),
'position'=>$this->request->post('position'),
'mobile'=>$this->request->post('mobile'),
'hometown'=>$this->request->post('hometown'),
'gender'=>$this->request->post('gender'),
'is_member'=>$this->request->post('is_member'),
//'pay_member'=>$params['pay_member'],
'dine'=>json_encode($dine, JSON_UNESCAPED_UNICODE),
'attendees'=>json_encode($attendees, JSON_UNESCAPED_UNICODE)
);
$invitation = new Invitation;
try {
$result = $invitation->allowField(true)->save($feeData);
if ($result !== false) {
$this->success();
} else {
$this->error($row->getError());
}
} catch (\think\exception\PDOException $e) {
$this->error($e->getMessage());
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Ems as Emslib;
use app\common\model\User;
use think\Hook;
/**
* 邮箱验证码接口
*/
class Ems extends Api
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
}
/**
* 发送验证码
*
* @ApiMethod (POST)
* @param string $email 邮箱
* @param string $event 事件名称
*/
public function send()
{
$email = $this->request->post("email");
$event = $this->request->post("event");
$event = $event ? $event : 'register';
$last = Emslib::get($email, $event);
if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁'));
}
$ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) {
$this->error(__('发送频繁'));
}
if ($event) {
$userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
$ret = Emslib::send($email, null, $event);
if ($ret) {
$this->success(__('发送成功'));
} else {
$this->error(__('发送失败'));
}
}
/**
* 检测验证码
*
* @ApiMethod (POST)
* @param string $email 邮箱
* @param string $event 事件名称
* @param string $captcha 验证码
*/
public function check()
{
$email = $this->request->post("email");
$event = $this->request->post("event");
$event = $event ? $event : 'register';
$captcha = $this->request->post("captcha");
if ($event) {
$userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
$ret = Emslib::check($email, $captcha, $event);
if ($ret) {
$this->success(__('成功'));
} else {
$this->error(__('验证码不正确'));
}
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
/**
* 首页接口
*/
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 首页
*
*/
public function index()
{
$this->success('请求成功');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Validate;
/**
* <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
*/
class Invitation extends Api
{
protected $noNeedLogin = ['apply','test'];
protected $noNeedRight = ['apply'];
public function test()
{
$this->success('<27><><EFBFBD>سɹ<D8B3>', $this->request->param());
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Sms as Smslib;
use app\common\model\User;
use think\Hook;
/**
* 手机短信接口
*/
class Sms extends Api
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
/**
* 发送验证码
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $event 事件名称
*/
public function send()
{
$mobile = $this->request->post("mobile");
$event = $this->request->post("event");
$event = $event ? $event : 'register';
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('手机号不正确'));
}
$last = Smslib::get($mobile, $event);
if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁'));
}
$ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) {
$this->error(__('发送频繁'));
}
if ($event) {
$userinfo = User::getByMobile($mobile);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changemobile']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
if (!Hook::get('sms_send')) {
$this->error(__('请在后台插件管理安装短信验证插件'));
}
$ret = Smslib::send($mobile, null, $event);
if ($ret) {
$this->success(__('发送成功'));
} else {
$this->error(__('发送失败,请检查短信配置是否正确'));
}
}
/**
* 检测验证码
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $event 事件名称
* @param string $captcha 验证码
*/
public function check()
{
$mobile = $this->request->post("mobile");
$event = $this->request->post("event");
$event = $event ? $event : 'register';
$captcha = $this->request->post("captcha");
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('手机号不正确'));
}
if ($event) {
$userinfo = User::getByMobile($mobile);
if ($event == 'register' && $userinfo) {
//已被注册
$this->error(__('已被注册'));
} elseif (in_array($event, ['changemobile']) && $userinfo) {
//被占用
$this->error(__('已被占用'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册
$this->error(__('未注册'));
}
}
$ret = Smslib::check($mobile, $captcha, $event);
if ($ret) {
$this->success(__('成功'));
} else {
$this->error(__('验证码不正确'));
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use fast\Random;
/**
* Token接口
*/
class Token extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
/**
* 检测Token是否过期
*
*/
public function check()
{
$token = $this->auth->getToken();
$tokenInfo = \app\common\library\Token::get($token);
$this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
}
/**
* 刷新Token
*
*/
public function refresh()
{
//删除源Token
$token = $this->auth->getToken();
\app\common\library\Token::delete($token);
//创建新Token
$token = Random::uuid();
\app\common\library\Token::set($token, $this->auth->id, 2592000);
$tokenInfo = \app\common\library\Token::get($token);
$this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
}
}

View File

@@ -0,0 +1,348 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use fast\Random;
use think\Config;
use think\Validate;
/**
* 会员接口
*/
class User extends Api
{
protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third'];
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
if (!Config::get('fastadmin.usercenter')) {
$this->error(__('User center already closed'));
}
}
/**
* 会员中心
*/
public function index()
{
$this->success('', ['welcome' => $this->auth->nickname]);
}
/**
* 会员登录
*
* @ApiMethod (POST)
* @param string $account 账号
* @param string $password 密码
*/
public function login()
{
$account = $this->request->post('account');
$password = $this->request->post('password');
if (!$account || !$password) {
$this->error(__('Invalid parameters'));
}
$ret = $this->auth->login($account, $password);
if ($ret) {
$data = ['userinfo' => $this->auth->getUserinfo()];
$this->success(__('Logged in successful'), $data);
} else {
$this->error($this->auth->getError());
}
}
/**
* 手机验证码登录
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $captcha 验证码
*/
public function mobilelogin()
{
$mobile = $this->request->post('mobile');
$captcha = $this->request->post('captcha');
if (!$mobile || !$captcha) {
$this->error(__('Invalid parameters'));
}
if (!Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
$this->error(__('Captcha is incorrect'));
}
$user = \app\common\model\User::getByMobile($mobile);
if ($user) {
if ($user->status != 'normal') {
$this->error(__('Account is locked'));
}
//如果已经有账号则直接登录
$ret = $this->auth->direct($user->id);
} else {
$ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
}
if ($ret) {
Sms::flush($mobile, 'mobilelogin');
$data = ['userinfo' => $this->auth->getUserinfo()];
$this->success(__('Logged in successful'), $data);
} else {
$this->error($this->auth->getError());
}
}
/**
* 注册会员
*
* @ApiMethod (POST)
* @param string $username 用户名
* @param string $password 密码
* @param string $email 邮箱
* @param string $mobile 手机号
* @param string $code 验证码
*/
public function register()
{
$username = $this->request->post('username');
$password = $this->request->post('password');
$email = $this->request->post('email');
$mobile = $this->request->post('mobile');
$code = $this->request->post('code');
if (!$username || !$password) {
$this->error(__('Invalid parameters'));
}
if ($email && !Validate::is($email, "email")) {
$this->error(__('Email is incorrect'));
}
if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
$ret = Sms::check($mobile, $code, 'register');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
}
$ret = $this->auth->register($username, $password, $email, $mobile, []);
if ($ret) {
$data = ['userinfo' => $this->auth->getUserinfo()];
$this->success(__('Sign up successful'), $data);
} else {
$this->error($this->auth->getError());
}
}
/**
* 退出登录
* @ApiMethod (POST)
*/
public function logout()
{
if (!$this->request->isPost()) {
$this->error(__('Invalid parameters'));
}
$this->auth->logout();
$this->success(__('Logout successful'));
}
/**
* 修改会员个人信息
*
* @ApiMethod (POST)
* @param string $avatar 头像地址
* @param string $username 用户名
* @param string $nickname 昵称
* @param string $bio 个人简介
*/
public function profile()
{
$user = $this->auth->getUser();
$username = $this->request->post('username');
$nickname = $this->request->post('nickname');
$bio = $this->request->post('bio');
$avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
if ($username) {
$exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
if ($exists) {
$this->error(__('Username already exists'));
}
$user->username = $username;
}
if ($nickname) {
$exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
if ($exists) {
$this->error(__('Nickname already exists'));
}
$user->nickname = $nickname;
}
$user->bio = $bio;
$user->avatar = $avatar;
$user->save();
$this->success();
}
/**
* 修改邮箱
*
* @ApiMethod (POST)
* @param string $email 邮箱
* @param string $captcha 验证码
*/
public function changeemail()
{
$user = $this->auth->getUser();
$email = $this->request->post('email');
$captcha = $this->request->post('captcha');
if (!$email || !$captcha) {
$this->error(__('Invalid parameters'));
}
if (!Validate::is($email, "email")) {
$this->error(__('Email is incorrect'));
}
if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
$this->error(__('Email already exists'));
}
$result = Ems::check($email, $captcha, 'changeemail');
if (!$result) {
$this->error(__('Captcha is incorrect'));
}
$verification = $user->verification;
$verification->email = 1;
$user->verification = $verification;
$user->email = $email;
$user->save();
Ems::flush($email, 'changeemail');
$this->success();
}
/**
* 修改手机号
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $captcha 验证码
*/
public function changemobile()
{
$user = $this->auth->getUser();
$mobile = $this->request->post('mobile');
$captcha = $this->request->post('captcha');
if (!$mobile || !$captcha) {
$this->error(__('Invalid parameters'));
}
if (!Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
$this->error(__('Mobile already exists'));
}
$result = Sms::check($mobile, $captcha, 'changemobile');
if (!$result) {
$this->error(__('Captcha is incorrect'));
}
$verification = $user->verification;
$verification->mobile = 1;
$user->verification = $verification;
$user->mobile = $mobile;
$user->save();
Sms::flush($mobile, 'changemobile');
$this->success();
}
/**
* 第三方登录
*
* @ApiMethod (POST)
* @param string $platform 平台名称
* @param string $code Code码
*/
public function third()
{
$url = url('user/index');
$platform = $this->request->post("platform");
$code = $this->request->post("code");
$config = get_addon_config('third');
if (!$config || !isset($config[$platform])) {
$this->error(__('Invalid parameters'));
}
$app = new \addons\third\library\Application($config);
//通过code换access_token和绑定会员
$result = $app->{$platform}->getUserInfo(['code' => $code]);
if ($result) {
$loginret = \addons\third\library\Service::connect($platform, $result);
if ($loginret) {
$data = [
'userinfo' => $this->auth->getUserinfo(),
'thirdinfo' => $result
];
$this->success(__('Logged in successful'), $data);
}
}
$this->error(__('Operation failed'), $url);
}
/**
* 重置密码
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $newpassword 新密码
* @param string $captcha 验证码
*/
public function resetpwd()
{
$type = $this->request->post("type", "mobile");
$mobile = $this->request->post("mobile");
$email = $this->request->post("email");
$newpassword = $this->request->post("newpassword");
$captcha = $this->request->post("captcha");
if (!$newpassword || !$captcha) {
$this->error(__('Invalid parameters'));
}
//验证Token
if (!Validate::make()->check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,30}'])) {
$this->error(__('Password must be 6 to 30 characters'));
}
if ($type == 'mobile') {
if (!Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
$user = \app\common\model\User::getByMobile($mobile);
if (!$user) {
$this->error(__('User not found'));
}
$ret = Sms::check($mobile, $captcha, 'resetpwd');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
}
Sms::flush($mobile, 'resetpwd');
} else {
if (!Validate::is($email, "email")) {
$this->error(__('Email is incorrect'));
}
$user = \app\common\model\User::getByEmail($email);
if (!$user) {
$this->error(__('User not found'));
}
$ret = Ems::check($email, $captcha, 'resetpwd');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
}
Ems::flush($email, 'resetpwd');
}
//模拟一次登录
$this->auth->direct($user->id);
$ret = $this->auth->changepwd($newpassword, '', true);
if ($ret) {
$this->success(__('Reset password successful'));
} else {
$this->error($this->auth->getError());
}
}
}

View File

@@ -0,0 +1,163 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\User;
/**
* 验证接口
*/
class Validate extends Api
{
protected $noNeedLogin = '*';
protected $layout = '';
protected $error = null;
public function _initialize()
{
parent::_initialize();
}
/**
* 检测邮箱
*
* @ApiMethod (POST)
* @param string $email 邮箱
* @param string $id 排除会员ID
*/
public function check_email_available()
{
$email = $this->request->post('email');
$id = (int)$this->request->post('id');
$count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
if ($count > 0) {
$this->error(__('邮箱已经被占用'));
}
$this->success();
}
/**
* 检测用户名
*
* @ApiMethod (POST)
* @param string $username 用户名
* @param string $id 排除会员ID
*/
public function check_username_available()
{
$username = $this->request->post('username');
$id = (int)$this->request->post('id');
$count = User::where('username', '=', $username)->where('id', '<>', $id)->count();
if ($count > 0) {
$this->error(__('用户名已经被占用'));
}
$this->success();
}
/**
* 检测昵称
*
* @ApiMethod (POST)
* @param string $nickname 昵称
* @param string $id 排除会员ID
*/
public function check_nickname_available()
{
$nickname = $this->request->post('nickname');
$id = (int)$this->request->post('id');
$count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
if ($count > 0) {
$this->error(__('昵称已经被占用'));
}
$this->success();
}
/**
* 检测手机
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $id 排除会员ID
*/
public function check_mobile_available()
{
$mobile = $this->request->post('mobile');
$id = (int)$this->request->post('id');
$count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
if ($count > 0) {
$this->error(__('该手机号已经占用'));
}
$this->success();
}
/**
* 检测手机
*
* @ApiMethod (POST)
* @param string $mobile 手机号
*/
public function check_mobile_exist()
{
$mobile = $this->request->post('mobile');
$count = User::where('mobile', '=', $mobile)->count();
if (!$count) {
$this->error(__('手机号不存在'));
}
$this->success();
}
/**
* 检测邮箱
*
* @ApiMethod (POST)
* @param string $mobile 邮箱
*/
public function check_email_exist()
{
$email = $this->request->post('email');
$count = User::where('email', '=', $email)->count();
if (!$count) {
$this->error(__('邮箱不存在'));
}
$this->success();
}
/**
* 检测手机验证码
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $captcha 验证码
* @param string $event 事件
*/
public function check_sms_correct()
{
$mobile = $this->request->post('mobile');
$captcha = $this->request->post('captcha');
$event = $this->request->post('event');
if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
$this->error(__('验证码不正确'));
}
$this->success();
}
/**
* 检测邮箱验证码
*
* @ApiMethod (POST)
* @param string $email 邮箱
* @param string $captcha 验证码
* @param string $event 事件
*/
public function check_ems_correct()
{
$email = $this->request->post('email');
$captcha = $this->request->post('captcha');
$event = $this->request->post('event');
if (!\app\common\library\Ems::check($email, $captcha, $event)) {
$this->error(__('验证码不正确'));
}
$this->success();
}
}

View File

@@ -0,0 +1,169 @@
<?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;
use app\api\model\wdsxh\album\AlbumConfig;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class Album extends Api
{
protected $noNeedLogin = ['index','diy_list','album_config'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $AlbumConfigModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\album\Album;
$this->AlbumConfigModel = new \app\api\model\wdsxh\album\AlbumConfig();
}
/**
* Desc 相册配置
* Create on 2024/3/12 10:28
* Create by @小趴菜
*/
public function album_config(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$type = $this->request->get('type');
//会员详情显示权限:1=全部开放,2=部分开放,3=会员专属
$is_status = (new AlbumConfig())->where('id',1)->value('is_status');
if ($type == 1) {//列表
if ($is_status == 1 || $is_status == 2) {
$show_status = 1;//能看
} else {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($memberObj) {
$show_status = 1;
} else {
$show_status = 2;
}
} else {
$show_status = 2;//不能看
}
}
} else {//详情
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
$show_status = ($is_status == '1' || $memberObj) ? 1 : 2;
}
$this->success('请求成功',['show_status'=>$show_status]);
}
/**
* Desc 相册列表
* Create on 2024/3/12 10:13
* Create by @小趴菜
*/
public function index(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$is_status = (new AlbumConfig())->where('id',1)->value('is_status');
if ($is_status == 3) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$this->error('成为会员后可查看');
}
} else {
$this->error('请登录后操作',null,401);
}
}
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
$where['status'] = array('eq','normal');
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,name,release_date,type,files,image')
->page($page,$limit)
->order('release_date desc,weigh desc')
->select();
foreach ($data as $datum) {
$files = explode(',',$datum['files']);
// 如果文件数量超过3个只取前三个文件否则取全部文件
$datum['files'] = implode(',', array_slice($files, 0, 3));
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 相册详情
* Create on 2024/3/12 10:13
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$where = [];
$where['status'] = array('eq','normal');
$where['id'] = array('eq',$param['album_id']);
$data = $this->model
->where($where)
->field('id,name,release_date,type,files,image')
->find();
$this->success('请求成功',$data);
}
/**
* Desc 首页diy
* Create on 2025/8/8 上午10:27
* Create by wangyafang
*/
public function diy_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$limit = $this->request->get('limit');
if (empty($limit)) {
$this->error('参数错误');
}
$where = [];
$where['status'] = array('eq','normal');
$data = $this->model
->where($where)
->field('id,name,release_date,type,files,image')
->page(1,$limit)
->order('release_date desc,weigh desc')
->select();
foreach ($data as $datum) {
$files = explode(',',$datum['files']);
// 如果文件数量超过3个只取前三个文件否则取全部文件
$datum['files'] = implode(',', array_slice($files, 0, 3));
}
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,482 @@
<?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;
use addons\wdsxh\library\Wxapp;
use app\admin\model\wdsxh\business\Association;
use app\api\model\wdsxh\activity\ActivityApply;
use app\api\model\wdsxh\activity\ActivityApplyRecord;
use app\api\model\wdsxh\activity\Order;
use app\api\model\wdsxh\activity\Refund;
use app\api\model\wdsxh\goods\Address;
use app\api\model\wdsxh\jielong\JielongFeedback;
use app\api\model\wdsxh\member\Cert;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\member\MemberApply;
use app\api\model\wdsxh\member\MemberExpireMessage;
use app\api\model\wdsxh\member\Pay;
use app\api\model\wdsxh\member\Promotion;
use app\api\model\wdsxh\member\Visitor;
use app\api\model\wdsxh\questionnaire\Questionnaire;
use app\api\model\wdsxh\questionnaire\Render;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use app\common\library\Token;
use app\common\model\User;
use think\Db;
/**
* Class AppletUserWechat
* Desc 小程序微信用户注册登录
* Create on 2024/3/7 10:03
* Create by wangyafang
*/
class AppletUserWechat extends Api
{
protected $noNeedLogin = ['is_register','get_phone','register','login'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
if (empty($configObj['applet_appid'])) {
$this->error('小程序AppID未配置');
}
if (empty($configObj['applet_secret'])) {
$this->error('小程序AppSecret未配置');
}
}
/**
* Desc 微信小程序是否注册
* Create on 2024/3/7 10:05
* Create by wangyafang
*/
public function is_register()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$code=$this->request->param('code');
if(empty($code)){
$this->error('code参数错误');
}
$data=Wxapp::wxlogin($code);
if(empty($data['openid'])){
$this->error('小程序登录失败',$data);
}
$openid=$data['openid'];
$userWechatObj = (new UserWechat())->where('applet_openid',$openid)->find();
$auth_status = !empty($userWechatObj) ? 1 : 2;
$this->success('请求成功!',['auth_status'=>$auth_status]);
}
/**
* Desc 微信小程序注册
* Create on 2024/3/7 10:06
* Create by wangyafang
*/
public function register()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$code=$this->request->post('code');
$param = $this->request->post();
if(empty($code)){
$this->error('code参数错误');
}
$data=Wxapp::wxlogin($code);
if(empty($data['openid'])){
$this->error('小程序注册失败',$data);
}
$openid=$data['openid'];
//todo 腾讯校验增加开关
$security_text_switch = (new \app\admin\model\wdsxh\Config())->where('id','1')->value('security_text_switch');
if ($security_text_switch == '1' && isset($param['nickname']) && !empty($param['nickname'])) {
$result = Wxapp::checkSecurityText($openid,$param['nickname']);
if ($result != 1) {
if ($result == 2) {
$this->error('文本内容输入不合规,请重新输入');
} else {
$this->error('errcode:'.$result['errcode'].',errmsg:'.$result['errmsg']);
}
}
}
$nickname_avatar_data = $this->get_nickname_avatar();
$avatar = (isset($param['avatar']) && !empty($param['avatar'])) ? $param['avatar'] : $nickname_avatar_data['avatar'];
$param['nickname'] = (isset($param['nickname']) && !empty($param['nickname'])) ? $param['nickname'] : $nickname_avatar_data['nickname'];
$parent_wechat_id = $this->request->post('parent_wechat_id',0);
//todo 后台统一用户同一时间出现3次
$userWechatCheckObj = (new UserWechat())->where('applet_openid',$openid)->find();
if ($userWechatCheckObj) {
$this->error('微信小程序数据错误,删除小程序重新进入,试下');
}
Db::startTrans();
try{
$user=User::create(array(
'group_id'=>1,
'status'=>'normal',
'joinip'=>request()->ip(),
'jointime'=>time(),
'nickname'=>$param['nickname'],
'avatar'=>$avatar,
),true);
$userWechatObj = UserWechat::create(array(
'user_id' =>$user->id,
'applet_openid'=>$openid,
'nickname'=>$param['nickname'],
'avatar'=>$avatar,
'channel'=>1,
'parent_wechat_id'=>$parent_wechat_id,
));
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$member_id = (new Member())->where('wechat_id',$parent_wechat_id)->value('id');
if ($parent_wechat_id && $member_id) {
$promotionModel = new Promotion();
$promotion_data = array(
'wechat_id' => $parent_wechat_id,
'member_id'=>$member_id,
);
$promotionModel->data($promotion_data);
$promotionModel->allowField(true)->save();
}
$this->auth->direct($user->id);
$userObj = $this->auth->getUserinfo();
$userObj['avatar'] = wdsxh_full_url($userObj['avatar']);
$this->success('请求成功',$userObj);
}
/**
* Desc 微信小程序登录
* Create on 2024/3/7 10:06
* Create by wangyafang
*/
public function login()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$code = $this->request->param('code');
if(empty($code)){
$this->error('code参数错误');
}
$data=Wxapp::wxlogin($code);
if(empty($data['openid'])){
$this->error('小程序登录失败',$data);
}
$openid=$data['openid'];
$userWechatObj = (new UserWechat())->where('applet_openid',$openid)->find();
$userObj = User::get($userWechatObj['user_id']);
if (!$userObj) {
$userObj = User::create(array(
'group_id'=>1,
'status'=>'normal',
'joinip'=>request()->ip(),
'jointime'=>time(),
'avatar'=> $userWechatObj['avatar'],
'nickname'=> $userWechatObj['nickname'],
'mobile'=> $userWechatObj['mobile'],
),true);
$userWechatObj->user_id = $userObj->id;
$userWechatObj->save();
}
if (empty($userWechatObj['openid'])) {
$userWechatObj->applet_openid = $openid;
$userWechatObj->save();
}
$this->auth->direct($userObj->id);
$userObj = $this->auth->getUserinfo();
$userObj['avatar'] = wdsxh_full_url($userObj['avatar']);
$this->success('请求成功',$userObj);
}
/**
* Desc 获取微信小程序用户手机号
* Create on 2024/3/7 11:16
* Create by wangyafang
*/
public function get_phone(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$code=$this->request->get('code');
$iv=$this->request->get('iv');
$encryptedData=$this->request->get('encryptedData','','trim');
if(empty($code)){
$this->error('code 参数错误');
}
if(empty($iv)){
$this->error('iv 参数错误');
}
if(empty($encryptedData)){
$this->error('encryptedData 参数错误');
}
$data=Wxapp::phone($code,$iv,$encryptedData);
if (isset($data['phoneNumber'])) {
$userWechatObj = (new UserWechat())->where('mobile',$data['phoneNumber'])->find();
$auth_status = !empty($userWechatObj) ? 1 : 2;
$data['auth_status'] = $auth_status;
} else {
$this->error('获取手机号失败');
}
$this->success('请求成功',$data);
}
private function get_nickname_avatar()
{
$avatar = Association::where('id',1)->value('logo');
if (empty($avatar)) {
$avatar = '/assets/addons/wdsxh/img/avatar.png';
}
$current_user_id = User::order('id','desc')->limit(1)->value('id');
if (!$current_user_id) {
$current_user_id = 1;
} else {
$current_user_id = bcadd($current_user_id, 1);
}
$nickname = '用户'.$current_user_id;
return array(
'avatar'=>$avatar,
'nickname'=>$nickname
);
}
/**
* Desc 绑定手机号
* Create on 2024/10/15 17:14
* Create by wangyafang
*/
public function bind_mobile()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$user_id = $this->auth->id;
$code=$this->request->post('code');
$iv=$this->request->post('iv');
$encryptedData=$this->request->post('encryptedData','','trim');
if(empty($code)){
$this->error('code 参数错误');
}
if(empty($iv)){
$this->error('iv 参数错误');
}
if(empty($encryptedData)){
$this->error('encryptedData 参数错误');
}
$data=Wxapp::phone($code,$iv,$encryptedData);
if (!isset($data['phoneNumber'])) {
$this->error('获取手机号失败');
}
$mobile = $data['phoneNumber'];
$userWechatObj = $appletUserWechatObj = (new UserWechat())->where('user_id',$user_id)->find();
$byMObileQueryUserWechat = (new UserWechat())->where('mobile',$mobile)->find();
if (!empty($byMObileQueryUserWechat) && !empty($userWechatObj) && !empty($byMObileQueryUserWechat['applet_openid']) && ($byMObileQueryUserWechat['applet_openid'] != $userWechatObj['applet_openid'])) {
$this->error('手机号已被其他微信使用');
}
$wananchiWhere['wananchi_openid'] = ['not null', '']; //not null
$wananchiUserWechatObj = (new UserWechat())->where('mobile',$mobile)->where($wananchiWhere)->find();
if ($wananchiUserWechatObj) {//已经在公众号使用一段时间
$wananchiUserObj = (new User())->where('id',$wananchiUserWechatObj['user_id'])->find();
$wananchiData = $wananchiUserWechatObj;
$result = false;
$activityApplyModel = new ActivityApply();
$activityApplyRecordModel = new ActivityApplyRecord();
$activityOrderModel = new Order();
$activityRefundModel = new Refund();
$businessModel = new \app\api\model\wdsxh\business\Business();
$demandModel = new \app\api\model\wdsxh\Demand();
$jielongFeedbackModel = new JielongFeedback();
$mallOrderModel = new \app\admin\model\wdsxh\mall\Order();
$mallUserAddressModel = new Address();
$memberModel = new Member();
$memberApplyModel = new MemberApply();
$memberCertModel = new Cert();
$memberExpireMessageModel = new MemberExpireMessage();
$memberPayModel = new Pay();
$memberPromotionModel = new Promotion();
$memberVisitorModel = new Visitor();
$questionnaireModel = new Questionnaire();
$questionnaireRenderModel = new Render();
$token_user_id = $wananchiUserWechatObj['user_id'];
Db::startTrans();
try{
$result = (new UserWechat())->save([
'wananchi_openid' => $wananchiData['wananchi_openid'],
'member_id' => $wananchiData['member_id'],
],['id' => $appletUserWechatObj['id']]);
$memberModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$activityApplyModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$activityApplyRecordModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$activityOrderModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$activityRefundModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$businessModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$demandModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$jielongFeedbackModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$mallOrderModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$mallUserAddressModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberApplyModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberCertModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberExpireMessageModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberPayModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberPromotionModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$memberVisitorModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$questionnaireModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
$questionnaireRenderModel->save([
'wechat_id' => $appletUserWechatObj['id'],
],['wechat_id' => $wananchiData['id']]);
(new UserWechat())->save([
'parent_wechat_id' => $appletUserWechatObj['id'],
],['parent_wechat_id' => $wananchiData['id']]);
$wananchiUserWechatObj->delete();
$wananchiUserObj->delete();
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$wechat_id = $wananchiData['id'];
$where[] = ['exp',Db::raw("FIND_IN_SET($wechat_id,verifying_wechat_ids)")];
$activityModel = new \app\api\model\wdsxh\activity\Activity();
$activityVerifyingData = $activityModel
->where($where)
->select();
if (!empty($activityVerifyingData)) {
foreach ($activityVerifyingData as $v) {
$verifying_wechat_ids_array = explode(',',$v['verifying_wechat_ids']);
foreach ($verifying_wechat_ids_array as $kk=>&$vv) {
if ($vv == $wechat_id) {
$vv = $appletUserWechatObj['id'];
}
}
$verifying_wechat_ids = implode(',',$verifying_wechat_ids_array);
$v->verifying_wechat_ids = $verifying_wechat_ids;
$v->save();
}
}
if (false === $result) {
$this->error('整合公众号数据失败');
}
Token::clear($token_user_id);
}
$appletUserWechatObj->mobile = $mobile;
$result = $appletUserWechatObj->save();
if (false === $result) {
$this->error('绑定失败');
}
$memberApplyObj = (new MemberApply())
->where('mobile',$mobile)
->where('state','2')
->where('channel',3)
->where('child_state','6')
->where('pay_method','1')
->find();
$memberObj = (new Member())->where('mobile',$mobile)->find();
if ($memberApplyObj && empty($memberApplyObj['wechat_id']) && $memberObj && empty($memberObj['wechat_id'])) {
$memberApplyObj->wechat_id = $userWechatObj->id;
$memberApplyObj->save();
$memberObj->wechat_id = $userWechatObj->id;
$memberObj->save();
$memberPayObj = (new Pay())->where('member_id',$memberObj['id'])->where('paid','2')
->where('channel','3')
->where('pay_method','4')
->where('delivery_state',2)
->order('id desc')
->find();
if ($memberPayObj && empty($memberPayObj['wechat_id'])) {
$memberPayObj->wechat_id = $userWechatObj->id;
$memberPayObj->save();
}
}
$this->success('绑定成功',$data);
}
}

View File

@@ -0,0 +1,124 @@
<?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;
use app\api\model\wdsxh\article\ArticleCat;
use app\common\controller\Api;
class Article extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $ArticleCatModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\article\Article();
$this->ArticleCatModel = new ArticleCat();
}
/**
* Desc 文章分类
* Create on 2024/3/12 11:44
* Create by @小趴菜
*/
public function article_cat(){
$data = $this->ArticleCatModel
->field('id,name')
->where('status','1')
->select();
$this->success('请求成功',$data);
}
/**
* Desc 文章列表
* Create on 2024/3/12 11:48
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
if(isset($param['keywords']) && !empty($param['keywords'])) {
$where['title'] = array('like','%'.$param['keywords'].'%');
}
if(isset($param['cat_id']) && !empty($param['cat_id'])) {
$where['cat_id'] = array('eq',$param['cat_id']);
}
$where['status'] = array('eq',1);
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,title,type,image,createtime,link,read_num')
->page($page,$limit)
->order('createtime desc,weigh desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 文章详情
* Create on 2024/3/12 13:40
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$where = [];
$where['id'] = array('eq',$param['id']);
$data = $this->model
->where($where)
->field('id,title,release,content,read_num,createtime,image,files,filesdata')
->find();
if ($data){
$data->hidden(['filesdata']);
if ($data['release'] == ''){
$data['release'] = (new \app\api\model\wdsxh\business\Association())->where('id',1)->value('name');
}
$data['read_num']+=1;
$data->save();
$data=$data->toArray();
}
$this->success('请求成功',$data);
}
/**
* Desc 更新阅读量
* Create on 2025/8/11 上午8:31
* Create by wangyafang
*/
public function update_read_num()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$id = $this->request->post('id');
if (empty($id)) {
$this->error('参数错误');
}
$articleObj = $this->model->get($id);
if (!$articleObj) {
$this->error('数据不存在');
}
if ($articleObj['type'] == '2') {
$articleObj->read_num = $articleObj->read_num + 1;
$articleObj->save();
}
$this->success('请求成功');
}
}

View File

@@ -0,0 +1,73 @@
<?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;
use app\api\model\wdsxh\PcBusinessAssociation;
use app\common\controller\Api;
class Association extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $pcModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\business\Association();
$this->pcModel = new PcBusinessAssociation();
}
/**
* Desc 商协信息
* Create on 2024/3/12 14:21
* Create by @小趴菜
*/
public function index(){
$data = $this->model->field('id,logo,name,contacts,phone,mailbox,address,wananchi_qr_code,qr_code_jump_link,rules,honor,course,lng,lat')->find();
$this->success('请求成功',$data);
}
/**
* Desc pc商协信息
* Create on 2024/4/9 17:43
* Create by @小趴菜
*/
public function pc_index(){
$data = $this->pcModel->find();
$data['image'] = wdsxh_full_url($data['image']);
$data['background_image'] = wdsxh_full_url($data['background_image']);
$data['association_image'] = wdsxh_full_url($data['association_image']);
$data['member_image'] = wdsxh_full_url($data['member_image']);
$data['activity_image'] = wdsxh_full_url($data['activity_image']);
$data['business_image'] = wdsxh_full_url($data['business_image']);
$data['article_image'] = wdsxh_full_url($data['article_image']);
$data['contact_image'] = wdsxh_full_url($data['contact_image']);
$data['applet_qr_code'] = wdsxh_full_url($data['applet_qr_code']);
$data['album_image'] = wdsxh_full_url($data['album_image']);
$this->success('请求成功',$data);
}
/**
* Desc 公户信息
* Create on 2024/6/26 9:27
* Create by wangyafang
*/
public function public_account_information(){
$data = $this->model->field('bank_account_name,receiving_account,bank_name')->find();
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,92 @@
<?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;
use app\api\model\wdsxh\PcBanner;
use app\common\controller\Api;
class Banner extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $pcModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\Banner();
$this->pcModel = new PcBanner();
}
/**
* Desc 首页轮播图
* Create on 2024/3/25 10:03
* Create by @小趴菜
*/
public function index(){
$where = [];
$where['status'] = array('eq',1);
$data = $this->model
->where($where)
->field('id,title,image,jump_type,content,jump_link')
->order('weigh desc,createtime desc')
->select();
if($data){
$list=collection($data)->toArray();
foreach ($list as &$row){
if($row['jump_type'] == 2){
$row['content']=json_decode($row['content'],true);
}
}
}
$this->success('请求成功', $data);
}
/**
* Desc 轮播图详情
* Create on 2024/3/28 14:56
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$data = $this->model
->where('id',$param['id'])
->field('id,title,content')
->find();
$this->success('请求成功',$data);
}
/**
* Desc pc首页轮播图
* Create on 2024/4/09 16:25
* Create by @小趴菜
*/
public function pc_banner(){
$where = [];
$where['status'] = array('eq',1);
$data = $this->pcModel
->where($where)
->field('id,title,image')
->order('weigh desc,createtime desc')
->select();
$this->success('请求成功', $data);
}
}

View File

@@ -0,0 +1,533 @@
<?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;
use addons\wdsxh\library\Wxapp;
use app\api\model\wdsxh\business\BusinessConfig;
use app\api\model\wdsxh\business\Category;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\user\Wechat;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Business extends Api
{
protected $noNeedLogin = ['business_cat','index','business_config','user_details','diy_list','details'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $BusinessCatModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\business\Business();
$this->BusinessCatModel = new Category();
}
/**
* Desc 商圈分类
* Create on 2024/3/12 15:36
* Create by @小趴菜
*/
public function business_cat(){
$where = [];
$where['status'] = array('eq','normal');
$data = $this->BusinessCatModel
->where($where)
->field('id,name')
->select();
$this->success('请求成功',$data);
}
/**
* Desc 商圈列表
* Create on 2024/3/12 14:49
* Create by @小趴菜
*/
public function index(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$is_status = (new BusinessConfig())->where('id',1)->value('is_status');
if ($is_status == 3) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$this->error('成为会员后可查看');
}
} else {
$this->error('请登录后操作',null,401);
}
}
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
if(isset($param['category_id']) && !empty($param['category_id'])) {
$where['category_id'] = array('eq',$param['category_id']);
}
if(isset($param['title']) && !empty($param['title'])) {
$where['title'] = array('like','%'.$param['title'].'%');
}
$where['status'] = array('eq','normal');
$where['state'] = array('eq',2);
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,title,images,title,content,createtime,page_view,member_id,address,lng,lat')
->page($page,$limit)
->order('createtime desc,weigh desc')
->select();
$businessAssociationModel = new \app\api\model\wdsxh\business\Association();
$is_status = (new BusinessConfig())->where('id',1)->value('is_status');
foreach ($data as $k=>$v){
$images = explode(',',$v['images']);
// 如果文件数量超过3个只取前三个文件否则取全部文件
// $data[$k]['images'] = implode(',', array_slice($images, 0, 3));
if ($v['member_id'] == '-1') {
$businessAssociationObj = $businessAssociationModel
->where('id',1)
->field('name,logo avatar,phone mobile')
->find();
$businessAssociationObj['level_name'] = '平台发布';
$businessAssociationObj['avatar'] = wdsxh_full_url($businessAssociationObj['avatar']);
$data[$k]['member'] = $businessAssociationObj;
} else {
$data[$k]['member'] = (new Member())
->alias('member')
->where('member.id',$v['member_id'])
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field('member.id,member.name,member.avatar,member.mobile,level.name level_name')
->find();
}
if ($is_status == 2) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$data[$k]['member']['mobile'] = '';
}
} else {
$data[$k]['member']['mobile'] = '';
}
}
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 商圈详情
* Create on 2024/3/12 14:03
* Create by @小趴菜
*/
public function details(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$is_status = (new BusinessConfig())->where('id',1)->value('is_status');
if ($is_status == 3) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$this->error('成为会员后可查看');
}
} else {
$this->error('请登录后操作',null,401);
}
}
if ($is_status == 2) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$this->error('成为会员后可查看');
}
} else {
$this->error('请登录后操作',null,401);
}
}
$param = $this->request->param();
$where = [];
$where['id'] = array('eq',$param['id']);
$business = $this->model
->where($where)
->field('id,title,images,content,createtime,page_view,member_id,address,lng,lat')
->find();
if ($business){
$business['page_view']+=1;
$business->save();
}
if ($business['member_id'] == '-1') {
$businessAssociationModel = new \app\api\model\wdsxh\business\Association();
$businessAssociationObj = $businessAssociationModel
->where('id',1)
->field('name,logo avatar,phone mobile')
->find();
$businessAssociationObj['level_name'] = '平台发布';
$businessAssociationObj['avatar'] = wdsxh_full_url($businessAssociationObj['avatar']);
$member = $businessAssociationObj;
} else {
$member = (new Member())
->alias('member')
->where('member.id',$business['member_id'])
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field('member.id,member.name,member.avatar,member.mobile,level.name level_name')
->find();
}
$data = [
'member' => $member,
'business' => $business,
];
$this->success('请求成功',$data);
}
/**
* Desc 商圈发布
* Create on 2024/3/12 17:07
* Create by @小趴菜
*/
public function add(){
$param = $this->request->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('您的会员已到期,请先入会');
}
$openid = wdsxh_get_openid($wechat_id,1);
$channel = $this->request->header('channel');
//todo 腾讯校验增加开关
$security_text_switch = (new \app\admin\model\wdsxh\Config())->where('id','1')->value('security_text_switch');
if ($security_text_switch == '1' && $channel == 1) {
$result = Wxapp::checkSecurityText($openid,$param['title']);
if ($result != 1) {
if ($result == 2) {
$this->error('文本内容输入不合规,请重新输入');
} else {
$this->error('errcode:'.$result['errcode'].',errmsg:'.$result['errmsg']);
}
}
unset($result);
if (!empty($param['content'])) {
$result = Wxapp::checkSecurityText($openid,$param['content']);
if ($result != 1) {
if ($result == 2) {
$this->error('文本内容输入不合规,请重新输入');
} else {
$this->error('errcode:'.$result['errcode'].',errmsg:'.$result['errmsg']);
}
}
}
}
$member_id = (new Member())->where('wechat_id',$wechat_id)->value('id');
$state_config = (new BusinessConfig())->value('is_process');
$param['address'] = isset($param['address']) ? $param['address'] : '';
$param['lat'] = isset($param['lat']) ? $param['lat'] : '';
$param['lng'] = isset($param['lng']) ? $param['lng'] : '';
$param['number'] = wdsxh_create_order();
$param['member_id'] = $member_id;
$param['wechat_id'] = $wechat_id;
$param['createtime'] = time();
if ($state_config == 1){
$param['state'] = 1;
}else{
$param['state'] = 2;
}
$result = false;
Db::startTrans();
try {
$result = $this->model->save($param);
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 2024/3/12 17:58
* Create by @小趴菜
*/
public function edit(){
$param = $this->request->post();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$openid = wdsxh_get_openid($wechat_id,1);
$channel = $this->request->header('channel');
//todo 腾讯校验增加开关
$security_text_switch = (new \app\admin\model\wdsxh\Config())->where('id','1')->value('security_text_switch');
if ($security_text_switch == '1' && $channel == 1) {
$result = Wxapp::checkSecurityText($openid,$param['title']);
if ($result != 1) {
if ($result == 2) {
$this->error('文本内容输入不合规,请重新输入');
} else {
$this->error('errcode:'.$result['errcode'].',errmsg:'.$result['errmsg']);
}
}
unset($result);
if (!empty($param['content'])) {
$result = Wxapp::checkSecurityText($openid,$param['content']);
if ($result != 1) {
if ($result == 2) {
$this->error('文本内容输入不合规,请重新输入');
} else {
$this->error('errcode:'.$result['errcode'].',errmsg:'.$result['errmsg']);
}
}
}
}
$state_config = (new BusinessConfig())->value('is_process');
$param['createtime'] = time();
$param['updatetime'] = time();
if(isset($param['images']) && !empty($param['images'])) {
$param['images'] = remove_wdsxh_full_url($param['images']);
}
if ($state_config == 1){
$param['state'] = 1;
}else{
$param['state'] = 2;
}
$param['reject'] = '';
$param['address'] = isset($param['address']) ? $param['address'] : '';
$param['lat'] = isset($param['lat']) ? $param['lat'] : '';
$param['lng'] = isset($param['lng']) ? $param['lng'] : '';
$result = false;
Db::startTrans();
try {
$result = $this->model->where('id',$param['id'])->update($param);
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 2024/3/13 15:17
* Create by @小趴菜
*/
public function del(){
$param = $this->request->param();
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$result = false;
Db::startTrans();
try {
$result = $this->model
->where('id',$param['id'])
->where('wechat_id',$wechat_id)
->delete();
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 2024/3/13 14:35
* Create by @小趴菜
*/
public function user_details(){
$param = $this->request->param();
$where = [];
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$where['id'] = array('eq',$param['id']);
$where['wechat_id'] = array('eq',$wechat_id);
$business = $this->model
->where($where)
->field('id,title,images,content,category_id,createtime,page_view,member_id,reject,state,address,lng,lat')
->find();
if ($business){
$business['category_name'] = $this->BusinessCatModel->where('id',$business['category_id'])->value('name');
}
$member = (new Member())
->alias('member')
->where('member.id',$business['member_id'])
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field('member.id,member.name,member.avatar,member.mobile,level.name level_name')
->find();
$data = [
'member' => $member,
'business' => $business,
];
$this->success('请求成功',$data);
}
/**
* Desc 我的发布-商圈列表
* Create on 2024/3/13 15:00
* Create by @小趴菜
*/
public function user_index(){
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
if(isset($param['state']) && !empty($param['state'])) {
$where['state'] = array('eq',$param['state']);
}
$where['wechat_id'] = array('eq',$wechat_id);
$where['status'] = array('eq','normal');
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,number,title,images,content,state,reject,page_view,address,lng,lat')
->page($page,$limit)
->order('createtime desc,weigh desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 商圈配置
* Create on 2024/3/18 11:22
* Create by @小趴菜
*/
public function business_config(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$type = $this->request->get('type');
//会员详情显示权限:1=全部开放,2=部分开放,3=会员专属
$member_details = (new BusinessConfig())->where('id',1)->value('is_status');
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($type == 1) {//列表
$show_status = in_array($member_details,array('1','2')) || $memberObj ? 1 : 2;
} else {//详情
$show_status = ($member_details == '1' || $memberObj) ? 1 : 2;
}
$this->success('请求成功',['show_status'=>$show_status]);
}
/**
* Desc 首页diy
* Create on 2025/8/8 上午10:27
* Create by wangyafang
*/
public function diy_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$limit = $this->request->get('limit');
if (empty($limit)) {
$this->error('参数错误');
}
$param = $this->request->get();
$where = [];
if(isset($param['category_id']) && !empty($param['category_id'])) {
$where['category_id'] = array('eq',$param['category_id']);
}
$where['status'] = array('eq','normal');
$where['state'] = array('eq',2);
$data = $this->model
->where($where)
->field('id,title,images,title,content,createtime,page_view,member_id,address,lng,lat')
->page(1,$limit)
->order('createtime desc,weigh desc')
->select();
$businessAssociationModel = new \app\api\model\wdsxh\business\Association();
$is_status = (new BusinessConfig())->where('id',1)->value('is_status');
foreach ($data as $k=>$v){
if ($v['member_id'] == '-1') {
$businessAssociationObj = $businessAssociationModel
->where('id',1)
->field('name,logo avatar,phone mobile')
->find();
$businessAssociationObj['level_name'] = '平台发布';
$businessAssociationObj['avatar'] = wdsxh_full_url($businessAssociationObj['avatar']);
$data[$k]['member'] = $businessAssociationObj;
} else {
$data[$k]['member'] = (new Member())
->alias('member')
->where('member.id',$v['member_id'])
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field('member.id,member.name,member.avatar,member.mobile,level.name level_name')
->find();
}
if ($is_status == 2) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$data[$k]['member']['mobile'] = '';
}
} else {
$data[$k]['member']['mobile'] = '';
}
}
}
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* Class Common
* Desc 公共控制器
* Create on 2023/8/17 11:26
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\common\controller\Api;
use app\common\exception\UploadException;
use app\common\library\Upload;
use think\App;
use think\Config;
use think\Hook;
use think\Lang;
class Common extends Api
{
protected $noNeedLogin = ['upload'];
protected $noNeedRight = '*';
//上传方法
public function upload()
{
// 自定义鉴权判断
// 强烈建议这里判断$file = $this->request->file('file');的后缀和mimetype
// 载入语言包,避免出现英文错误提示
Lang::load(APP_PATH . 'api/lang/zh-cn.php');
// 获取上传配置
$uploadConfig = Config::get("upload");
// 兼容云存储上传
if ($uploadConfig['storage'] != 'local') {
// 这里可以修改允许上传文件的后缀或修改存储的文件路径,例如只允许上传图片
set_addon_config($uploadConfig['storage'], ['savekey' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', 'mimetype' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm,pem,xlsx,xls,doc,docx,pdf'], false);
// 添加允许上传的行为
Hook::add('upload_config_checklogin', function () {
return true;
});
request()->param('isApi', true);
App::invokeMethod(["\\addons\\{$uploadConfig["storage"]}\\controller\\Index", "upload"], ['isApi' => true]);
} else {
// 这里可以修改允许上传文件的后缀或修改存储的文件路径,例如只允许上传图片
//Config::set('upload', array_merge($uploadConfig, ['savekey' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', 'mimetype' => 'jpg,png,bmp,jpeg,gif']));
$attachment = null;
// 默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$attachment = $upload->upload();
$fileInfo = $attachment;//todo 后台和前端上传图片自动压缩到1M以内
if (in_array($fileInfo['mimetype'], ['image/gif', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/png', 'image/webp']) || in_array($fileInfo['imagetype'], ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'webp'])) {
$max_size = 1024*1024;
if($fileInfo['filesize']>$max_size){
$required_memory = $fileInfo['imagewidth'] * $fileInfo['imageheight'];
$new_limit=memory_get_usage() + $required_memory+200000000;
ini_set("memory_limit", $new_limit);
if($fileInfo['mimetype']=='image/jpg'||$fileInfo['mimetype']=='jpg' || $fileInfo['mimetype']=='image/jpeg' || $fileInfo['mimetype']=='jpeg'){
$image = ROOT_PATH . '/public' . $fileInfo['url'];
$src = @imagecreatefromjpeg($image);
$newwidth = $fileInfo['imagewidth']; //宽高可以设置,
$newheight = $fileInfo['imageheight'];
$tmp = imagecreatetruecolor($newwidth,$newheight); //生成新的宽高
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $fileInfo['imagewidth'], $fileInfo['imageheight']); //缩放图像
imagejpeg($tmp, $image, 60); //第三个参数(0~100);越大越清晰,图片大小也高; png格式的为(1~9)
$filesize = filesize($image);
$attachment->filesize = $filesize;
$attachment->save();
}
if($fileInfo['mimetype']=='image/png'||$fileInfo['mimetype']=='png'){
$image = ROOT_PATH . '/public' . $fileInfo['url'];
$src = @imagecreatefrompng($image);
$newwidth = $fileInfo['imagewidth']; //宽高可以设置,
$newheight = $fileInfo['imageheight'];
$newwidth = $newwidth/2;
$newheight = $newheight/2;
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $fileInfo['imagewidth'], $fileInfo['imageheight']);
imagepng($tmp, $image, 2); //这个图片的第三参数(1~9)
$filesize = filesize($image);
$attachment->imagewidth = $newwidth;
$attachment->imageheight = $newheight;
$attachment->filesize = $filesize;
$attachment->save();
}
}
}
} catch (UploadException $e) {
$error = $e->getMessage();
$intercept_result = substr($error,0,15);
if ($intercept_result == 'File is too big') {
$maxsize = strtoupper(config('upload')['maxsize']);
$this->error('文件太大,最大文件大小:'.$maxsize);
} else {
$this->error($e->getMessage());
}
}
$this->success('上传成功', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
}
}
}

View File

@@ -0,0 +1,198 @@
<?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;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class CompanyGoods extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
protected $member_id = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\member\CompanyGoods();
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
if (!$wechat_id) {
$this->error('用户信息不存在');
}
$memberObj = (new Member())->where('wechat_id',$wechat_id)->find();
if (!$memberObj) {
$this->error('会员信息不存在');
}
$current_date = date('Y-m-d',time());
if ($memberObj['expire_time'] < $current_date) {
$this->error('会员已过期,需要缴纳会费');
}
if (!in_array($memberObj['type'],[2,3])) {
$this->error('仅限会员使用');
}
$this->member_id = $memberObj['id'];
}
/**
* 产品列表
*/
public function index()
{
if (!$this->request->isGet()) {
$this->error('请求方式错误');
}
$list = $this->model->where('member_id', $this->member_id)
->field('id,name,images')
->order('createtime desc')
->select();
foreach ($list as &$item) {
$item->hidden(['images']);
}
$this->success('获取成功', $list);
}
/**
* 产品详情
*/
public function detail()
{
if (!$this->request->isGet()) {
$this->error('请求方式错误');
}
$id = $this->request->get('id');
if (!$id) {
$this->error('参数错误');
}
// 检查产品是否属于当前会员
$goods = $this->model->where('id', $id)
->field('id,name,images,content')
->where('member_id', $this->member_id)
->find();
if (!$goods) {
$this->error('产品不存在或无权查看');
}
$data = $goods->toArray();
unset($data['image']);
$this->success('获取成功', $data);
}
/**
* 添加产品
*/
public function add()
{
if (!$this->request->isPost()) {
$this->error('请求方式错误');
}
$params = $this->request->post();
$params['content'] = $_POST['content'] ?? '';
// 验证数据
$validate = new \app\api\validate\wdsxh\CompanyGoods();
if (!$validate->scene('add')->check($params)) {
$this->error($validate->getError());
}
// 添加会员ID
$params['member_id'] = $this->member_id;
// 保存数据
$result = $this->model->save($params);
if ($result) {
$this->success('添加成功');
} else {
$this->error('添加失败');
}
}
/**
* 修改产品
*/
public function edit()
{
if (!$this->request->isPost()) {
$this->error('请求方式错误');
}
$params = $this->request->post();
$params['content'] = $_POST['content'] ?? '';
$id = $this->request->post('id');
if (!$id) {
$this->error('参数错误');
}
// 验证数据
$validate = new \app\api\validate\wdsxh\CompanyGoods();
if (!$validate->scene('edit')->check($params)) {
$this->error($validate->getError());
}
// 检查产品是否属于当前会员
$goods = $this->model->where('id', $id)
->where('member_id', $this->member_id)
->find();
if (!$goods) {
$this->error('产品不存在或无权操作');
}
// 更新数据
$result = $goods->save($params);
if ($result !== false) {
$this->success('修改成功');
} else {
$this->error('修改失败');
}
}
/**
* 删除产品
*/
public function del()
{
if (!$this->request->isPost()) {
$this->error('请求方式错误');
}
$id = $this->request->post('id');
if (!$id) {
$this->error('参数错误');
}
// 检查产品是否属于当前会员
$goods = $this->model->where('id', $id)
->where('member_id', $this->member_id)
->find();
if (!$goods) {
$this->error('产品不存在或无权操作');
}
// 删除数据
$result = $goods->delete();
if ($result) {
$this->success('删除成功');
} else {
$this->error('删除失败');
}
}
}

View File

@@ -0,0 +1,159 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Config
* Desc 系统配置控制器
* Create on 2024/3/16 8:56
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\api\model\wdsxh\member\JoinConfig;
use app\common\controller\Api;
class Config extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $configObj = null;
protected $association = null;
public function _initialize()
{
parent::_initialize();
$this->configObj = (new \app\admin\model\wdsxh\Config())->get(1);
$this->association = (new \app\api\model\wdsxh\business\Association());
}
/**
* Desc 协议
* Create on 2024/3/16 8:59
* Create by wangyafang
*/
public function agreement()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$type = $this->request->get('type');
if ($type == 1) {//用户协议
$data = $this->configObj->user_agreement;
} elseif ($type == 2) {//隐私政策
$data = $this->configObj->privacy_policy;
} else {//入会协议
$data = $this->association->where('id',1)->value('notice');
}
$this->success('请求成功',['content'=>$data]);
}
/**
* Desc 入会类型启用状态
* Create on 2024/3/19 10:59
* Create by wangyafang
*/
public function join_config()
{
$list = (new JoinConfig())->select();
foreach ($list as &$row) {
if (empty($row['name']) && $row['type'] == 1) {
$row['name'] = '个人入会';
$row->save();
}
if (empty($row['name']) && $row['type'] == 2) {
$row['name'] = '企业入会';
$row->save();
}
if (empty($row['name']) && $row['type'] == 3) {
$row['name'] = '团体入会';
$row->save();
}
}
$data = (new JoinConfig())->where('status','normal')->field('type,name')->order('weigh desc,id asc')->select();
$this->success('请求成功',$data);
}
/**
* Desc 系统配置
* Create on 2024/3/26 09:00
* Create by @小趴菜
*/
public function config(){
$list = (new JoinConfig())->select();
foreach ($list as &$row) {
if (empty($row['name']) && $row['type'] == 1) {
$row['name'] = '个人入会';
$row->save();
}
if (empty($row['name']) && $row['type'] == 2) {
$row['name'] = '企业入会';
$row->save();
}
if (empty($row['name']) && $row['type'] == 3) {
$row['name'] = '团体入会';
$row->save();
}
}
$configObj = $this->configObj
->where('id',1)
->field('id,organize,theme_colors,share_title,share_image,
applet_initiation_admin,applet_initiation_audit,applet_initiation_success,
applet_member_expiretime,applet_activity_apply,jielong_img,questionnaire_img,login_img,
applet_record_number,
wananchi_appid,
technical_support_image,jump_type,jump_link,call_mobile,
domain_record_number,public_security_record_number,
delivery_management,
applet_order_shipping_notification,applet_confirm_receipt_notification')
->find();
$data = [
'organize' => $configObj['organize'],
'theme_colors' => $configObj['theme_colors'],
'share_title' => $configObj['share_title'],
'share_image' => wdsxh_full_url($configObj['share_image']),
'applet_record_number'=>$configObj['applet_record_number'],
'subscribe_msg_tpl_ids'=>array(
'applet_initiation_admin'=>empty($configObj['applet_initiation_admin'])?null:trim($configObj['applet_initiation_admin']),
'applet_initiation_audit'=>empty($configObj['applet_initiation_audit'])?null:trim($configObj['applet_initiation_audit']),
'applet_initiation_success'=>empty($configObj['applet_initiation_success'])?null:trim($configObj['applet_initiation_success']),
'applet_member_expiretime'=>empty($configObj['applet_member_expiretime'])?null:trim($configObj['applet_member_expiretime']),
'applet_activity_apply'=>empty($configObj['applet_activity_apply'])?null:trim($configObj['applet_activity_apply']),
'applet_order_shipping_notification'=>empty($configObj['applet_order_shipping_notification'])?null:trim($configObj['applet_order_shipping_notification']),
'applet_confirm_receipt_notification'=>empty($configObj['applet_confirm_receipt_notification'])?null:trim($configObj['applet_confirm_receipt_notification']),
),
'jielong_img' => wdsxh_full_url($configObj['jielong_img']),
'questionnaire_img' => wdsxh_full_url($configObj['questionnaire_img']),
'login_img' => wdsxh_full_url($configObj['login_img']),
'wananchi_appid' => $configObj['wananchi_appid'],
'technical_support_image' => wdsxh_full_url($configObj['technical_support_image']),
'jump_type' => $configObj['jump_type'],
'jump_link' => $configObj['jump_link'],
'call_mobile' => $configObj['call_mobile'],
'domain_record_number' => $configObj['domain_record_number'],
'public_security_record_number' => $configObj['public_security_record_number'],
'delivery_management'=>$configObj['delivery_management'],
'join_config'=>(new JoinConfig())->field('type,name')->order('weigh desc,id asc')->select(),
];
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,65 @@
<?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;
use app\api\model\wdsxh\user\Wechat;
use app\common\controller\Api;
use think\Db;
use Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Demand extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\Demand();
}
/**
* Desc 需求反馈
* Create on 2024/3/13 15:42
* Create by @小趴菜
*/
public function add(){
$param = $this->request->post();
if ($param['title'] == ''){
$this->error('请填写标题');
}
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$param['wechat_id'] = $wechat_id;
$param['createtime'] = time();
$result = false;
Db::startTrans();
try {
$result = $this->model->save($param);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('提交成功');
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Class Diy
* Desc Diy模式
* Create on 2022/5/18 8:49
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\common\controller\Api;
class Diy extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function mode()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$home_mode = '2';
$this->success('请求成功',['home_mode'=>$home_mode]);
}
public function getPage()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$page_id = (int)$this->request->request('page_id');
if (Db("wdsxh_diy_page")->where(['deletetime' => null])->order(['id' => 'desc'])->count() <= 0) {
$this->error('未定义页面');
}
// 页面详情//todo 软删除
$detail = $page_id > 0 ? Db("wdsxh_diy_page")->where(['deletetime' => null])->where('id', $page_id)->find() : Db("wdsxh_diy_page")->where(['deletetime' => null])->where('status', 'home')->find();
if (!$detail) {
$this->error('页面错误');
}
$page_data = json_decode($detail['page_data'],true);
//todo 配置七牛云后,自定义装修,自定义入会图片无法访问
$domain = \think\Config::get('upload.cdnurl');
if (!wdsxh_is_url($domain)) {
$domain = request()->domain();
}
$page_data['domain'] = $domain;
// 页面diy元素
$this->success('请求成功', $page_data);
}
}

View File

@@ -0,0 +1,67 @@
<?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;
use app\common\controller\Api;
class Faq extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\Faq();
}
/**
* Desc 常见问题列表
* Create on 2024/3/13 15:57
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$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,title')
->page($page,$limit)
->order('weigh desc,createtime desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 常见问题详情
* Create on 2024/3/13 16:10
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$where = [];
$where['id'] = array('eq',$param['id']);
$data = $this->model
->where($where)
->field('id,title,reply')
->find();
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,113 @@
<?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;
use app\api\model\wdsxh\Quickmenu;
use app\api\model\wdsxh\Tabbar;
use app\common\controller\Api;
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $tabbarModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new Quickmenu();
$this->tabbarModel = new Tabbar();
}
/**
* Desc 快速导航
* Create on 2024/3/22 16:37
* Create by @小趴菜
*/
public function quickmenu_index(){
$list=$this->model->where('status',1)
->order('weigh desc')
->field('id,name,icon,skip_type,content')
->select();
if($list){
foreach ($list as $row){
$row->icon=wdsxh_full_url($row->icon);
if($row->skip_type == 3){
$row->content=json_decode($row->content,true);
}
}
}
$this->success('请求成功',$list);
}
/**
* Desc 快速导航详情
* Create on 2024/3/28 15:06
* Create by @小趴菜
*/
public function quickmenu_details(){
$param = $this->request->param();
$data = $this->model
->where('id',$param['id'])
->field('id,name,content')
->find();
$this->success('请求成功',$data);
}
/**
* Desc 底部导航
* Create on 2024/3/22 17:04
* Create by @小趴菜
*/
public function tabbar_index(){
$list= $this->tabbarModel->where('status',1)
->order('weigh desc')
->field('id,name,path,icon,selicon,jump_type')
->select();
if($list){
$list=collection($list)->toArray();
foreach ($list as &$row){
if($row['jump_type'] == 1){
$row['path']='';
}
}
}
$this->success('请求成功',$list);
}
/**
* Desc 底部导航详情
* Create on 2025/10/30 10:24
* Create by @小趴菜
*/
public function tabbar_details(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->param();
$data = $this->tabbarModel
->where('id',$param['id'])
->field('path content')
->find();
$this->success('请求成功', $data);
}
}

View File

@@ -0,0 +1,382 @@
<?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;
use app\api\model\wdsxh\jielong\JielongFeedback;
use app\api\model\wdsxh\member\Level;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\user\Wechat;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Jielong extends Api
{
protected $noNeedLogin = ['index','jielong_config'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $feedbackModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\jielong\Jielong();
$this->feedbackModel = new JielongFeedback();
}
/**
* Desc 接龙列表
* Create on 2024/3/14 16:23
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
$where['status'] = array('eq','normal');
$expired_jielong_show = (new \app\admin\model\wdsxh\Config())->value('expired_jielong_show');
$total = $this->model->where($where)->where(function ($query) use($expired_jielong_show){
if ($expired_jielong_show == 2) {
$query->where('expire_time','>=',time());
}
})->count();
$data = $this->model->where($where)
->where(function ($query) use($expired_jielong_show){
if ($expired_jielong_show == 2) {
$query->where('expire_time','>=',time());
}
})
->field('id,name,type,expire_time,page_view,member_id,jielong_auth')
->page($page,$limit)
->order('createtime desc,weigh desc')
->select();
foreach ($data as $row){
$row['expire_time'] = date('Y-m-d h:i',$row['expire_time']);
$row['part_total'] = $this->feedbackModel->where('jielong_id',$row['id'])->count();
if ($row['member_id'] == -1){
$row['mobile'] = (new \app\api\model\wdsxh\business\Association())->where('id',1)->value('phone');
}else{
$row['mobile'] = (new Member())->where('id',$row['member_id'])->value('mobile');
}
}
$this->success('',['total' => $total,'data' => $data]);
}
/**
* Desc 接龙详情
* Create on 2024/3/14 17:41
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$where = [];
$where['id'] = array('eq',$param['id']);
$list = $this->model
->where($where)
->field('id,name,type,content,expire_time,page_view,member_ids,createtime,member_id,jielong_auth')
->find();
if ($list){
if ($list['member_id'] == -1){
$association = (new \app\api\model\wdsxh\business\Association())
->where('id',1)->field('name,logo,phone')->find();
$list['member_name'] = $association['name'];
$list['avatar'] = $association['logo'];
$list['level_name'] = '';
$list['mobile'] = $association['phone'];
}else{
$member = (new Member())->alias('member')
->where('member.id',$list['member_id'])
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field('member.name member_name,member.avatar,member.mobile,level.name level_name')
->find();
$list['member_name'] = $member['member_name'];
$list['avatar'] = $member['avatar'];
$list['level_name'] = $member['level_name'];
$list['mobile'] = $member['mobile'];
}
$list['expire_time'] = date('Y-m-d H:i',$list['expire_time']);
$list['createtime'] = date('Y-m-d H:i',$list['createtime']);
if ($list['type'] == 2){//限定接龙
//根据接龙表存的member_ids来查询会员信息
$member_ids = explode(",", $list['member_ids']);
$memberObj_data = [];
foreach ($member_ids as $datum){
$memberObj = (new Member())
->where('id',$datum)
->field('id,name member_name')->find();
$JielongFeedbackObj = (new JielongFeedback())->where('member_id',$datum)->where('jielong_id',$param['id'])->find();
if ($JielongFeedbackObj){
$memberObj['status'] = 1;
}else{
$memberObj['status'] = 2;
}
$memberObj_data[] = $memberObj;
}
$JielongFeedback_data = (new JielongFeedback())
->where('jielong_id',$param['id'])
->field('id,name member_name')
->select();
foreach ($JielongFeedback_data as $datum){
$datum['status'] = 1;
}
//合并数组
$result = array_merge($memberObj_data, $JielongFeedback_data);
// 创建一个关联数组,用于存储唯一的 member_name
$uniqueArray = [];
foreach ($result as $element) {
$memberName = $element["member_name"];
// 如果这个 member_name 还没有被加入到 $uniqueArray 中,就加入
if (!isset($uniqueArray[$memberName])) {
$uniqueArray[$memberName] = $element;
}
}
// 获取去重后的数组
$member_data = array_values($uniqueArray); // 重新索引数组
}else{
$member_data = (new JielongFeedback())
->where('jielong_id',$param['id'])
->field('id,name member_name')
->select();
foreach ($member_data as $datum){
$datum['status'] = 1;
}
}
$page_view = $list['page_view'] +=1;
(new \app\api\model\wdsxh\jielong\Jielong())->where('id',$param['id'])->update(['page_view' => $page_view]);
}
$data = [
'data' => $list,
'member_data' => $member_data,
];
$this->success('请求成功',$data);
}
/**
* Desc 活动接龙反馈
* Create on 2024/3/15 10:46
* Create by @小趴菜
*/
public function add(){
$param = $this->request->post();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$member_id = (new Member())->where('wechat_id',$wechat_id)->value('id');
//接龙类型 类型:1=自由接龙,2=限定接龙
$jielong_type = $this->model->where('id',$param['jielong_id'])->value('type');
if ($jielong_type == 2){
$member_ids = $this->model->where('id',$param['jielong_id'])->value('member_ids');
$member_ids_array = explode(',',$member_ids);
if (!in_array($param['member_id'],$member_ids_array)) {
$this->error('不是指定人员,无法接龙');
}
if ($param['member_id'] != $member_id){
$this->error('请选择自己的名字进行反馈!');
}
$jielong_feedback = (new JielongFeedback())
->where('member_id',$param['member_id'])
->where('jielong_id',$param['jielong_id'])
->where('wechat_id',$wechat_id)
->find();
if ($jielong_feedback){
$this->error('您已经反馈过啦!');
}
}else{
$jielong_feedback = (new JielongFeedback())
->where('jielong_id',$param['jielong_id'])
->where('wechat_id',$wechat_id)
->find();
if ($jielong_feedback){
$this->error('您已经反馈过啦!');
}
}
$param['wechat_id'] = $wechat_id;
$param['createtime'] = time();
$result = false;
Db::startTrans();
try {
$result = $this->feedbackModel->save($param);
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 2024/3/22 11:26
* Create by @小趴菜
*/
public function feedback_state()
{
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id', $user_id)->value('id');
$where = [];
$where['id'] = array('eq', $param['id']);
$list = $this->model
->where($where)
->field('id,name,type,content,expire_time,page_view,member_ids,createtime,member_id')
->find();
if ($list) {
if ($list['type'] == 2) {//限定接龙
$member_data = (new Member())->where('wechat_id', $wechat_id)->field('id,name member_name')->find();
$JielongFeedbackObj = (new JielongFeedback())->where('member_id', $member_data['id'])->where('jielong_id', $param['id'])->find();
if ($JielongFeedbackObj) {
$member_data['status'] = 1;
} else {
$member_data['status'] = 2;
}
} else {
$member_data = (new Member())->where('wechat_id', $wechat_id)->field('id,name')->find();
if ($member_data){
$member_data['member_name'] = $member_data['name'];
}else{
$member_data = (new Wechat())->where('user_id', $user_id)->field('id,nickname member_name')->find();
$member_data['name'] = $member_data['member_name'];
}
$JielongFeedbackObj = (new JielongFeedback())->where('wechat_id', $wechat_id)->where('jielong_id', $param['id'])->find();
if ($JielongFeedbackObj) {
$member_data['status'] = 1;
} else {
$member_data['status'] = 2;
}
}
}
$this->success('请求成功', $member_data);
}
/**
* Desc 判断是否有资格参加
* Create on 2024/3/22 11:42
* Create by @小趴菜
*/
public function jielong_state()
{
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id', $user_id)->value('id');
$where = [];
$where['id'] = array('eq', $param['id']);
$list = $this->model
->where($where)
->field('id,member_ids,type')
->find();
$current_date = date('Y-m-d',time());
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($list['type'] == 2) {//限定接龙
if ($memberObj){
//根据接龙表存的member_ids来查询会员信息
$member_ids = explode(",", $list['member_ids']);
$member_data = (new Member())->where('wechat_id', $wechat_id)->value('id');
if (in_array($member_data, $member_ids)) {
$member_data = 1;
} else {
$member_data = 2;
}
}else{
$member_data = 2;
}
}else{
if ($memberObj){
$member_data = 1;
}else{
$member_data = 2;
}
}
$this->success('请求成功', ['state' => $member_data]);
}
/**
* Desc 反馈详情
* Create on 2024/4/11 15:44
* Create by @小趴菜
*/
public function feedback_details(){
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new UserWechat())->where('user_id',$user_id)->value('id');
$data = (new JielongFeedback())->where('jielong_id',$param['jielong_id'])
->where('wechat_id',$wechat_id)->field('id,name,member_id,images,content,status,createtime')->find();
if ($data){
$data['createtime'] = date('Y-m-d h:i',$data['createtime']);
if ($data['status'] == 1){
$data['status'] = '参加';
}elseif($data['status'] == 2){
$data['status'] = '不参加';
}elseif ($data['status'] == 3){
$data['status'] = '参加其他';
}
}
$member_data = (new Member())->where('id',$data['member_id'])->field('id,avatar,name,member_level_id')->find();
if ($member_data){
$member_data['member_level'] = (new Level())->where('id',$member_data['member_level_id'])->value('name');
} else {
$member_data = (new UserWechat())->where('id',$wechat_id)->field('id,avatar,nickname name')->find();
}
$data = [
'member_data' => $member_data,
'feedback_data' => $data,
];
$this->success('请求成功',$data);
}
/**
* Desc 接龙配置
* Create on 2025/8/8 10:04
* Create by wangyafang
*/
public function jielong_config()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
if (empty($id)) {
$this->error('参数错误');
}
$jielongObj = $this->model->get($id);
if (!$jielongObj) {
$this->error('接龙数据不存在');
}
$is_status = $jielongObj['jielong_auth'];
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,58 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class PersonCenterDiyPage
* Desc 个人中心自定义控制器
* Create on 2025/3/13 17:20
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\common\controller\Api;
class PersonCenterDiyPage extends Api
{
protected $noNeedLogin = ['details'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\PersonCenterDiyPage();
}
/**
* Desc 详情
* Create on 2025/3/13 17:21
* Create by wangyafang
*/
public function details()
{
$detail = $this->model->where('id',1)->field('page_name,page_data')->find();
$page_data = json_decode($detail['page_data'],true);
//todo 配置七牛云后,自定义装修,自定义入会图片无法访问
$domain = \think\Config::get('upload.cdnurl');
if (!wdsxh_is_url($domain)) {
$domain = request()->domain();
}
$page_data['domain'] = $domain;
$this->success('请求成功', $page_data);
}
}

View File

@@ -0,0 +1,351 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Screen
* Desc 数据大屏
* Create on 2024/7/2 9:55
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\api\model\wdsxh\activity\Activity;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\member\Visitor;
use app\common\controller\Api;
use app\api\model\wdsxh\business\Business;
use app\common\model\User;
class Screen extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
// 获取数据大屏密码启用状态
$config = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
$data_screen_password_switch = $config['data_screen_password_switch'] ?? '2';
// 如果密码验证已关闭,则跳过密码验证
if ($data_screen_password_switch == '2') {
return;
}
// 密码验证已开启,进行密码验证
$password = $this->request->get('password');
if(!$password) {
$this->error('密码不能为空');
}
$data_screen_password = $config['data_screen_password'] ?? '';
if($password != $data_screen_password) {
$this->error('密码错误');
}
}
/**
* Desc 行业会员数量
* Create on 2024/7/2 10:19
* Create by wangyafang
*/
public function member_count()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$current_date = date('Y-m-d',time());
$data = array(
'platform'=>array(
'total_user_count' => User::count(),
'today_user_count' => User::whereTime('jointime', 'today')->count(),
),
'member'=>array(
'total_member_count' => Member::where('expire_time','>=',$current_date)->count(),
'today_member_count' => Member::whereTime('createtime', 'today')->count(),
),
'activity'=>array(
'total_activity_count' => Activity::where('status','normal')->count(),
'today_activity_count' => Activity::where('status','normal')->whereTime('createtime', 'today')->count(),
),
'business'=>array(
'total_business_count' => Business::where('status','normal')->where('state','2')->count(),
'today_business_count' => Business::where('status','normal')->where('state','2')->whereTime('createtime', 'today')->count(),
),
);
$this->success('请求成功',$data);
}
/**
* Desc 会员类型
* Create on 2024/7/2 10:56
* Create by wangyafang
*/
public function member_type()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$current_date = date('Y-m-d',time());
$data = array(
'total_member_count' => Member::where('expire_time','>=',$current_date)->count(),
'person_member_count' => Member::where('expire_time','>=',$current_date)->where('type','1')->count(),
'company_member_count' => Member::where('expire_time','>=',$current_date)->where('type','2')->count(),
'organize_member_count' => Member::where('expire_time','>=',$current_date)->where('type','3')->count(),
);
$this->success('请求成功',$data);
}
/**
* Desc 上月用户访问情况
* Create on 2024/7/2 11:10
* Create by wangyafang
*/
public function last_month_user_data()
{
//todo 展示数据大屏,显示会员头像
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$day_array = array();
$count_array = array();
for ($i = 30; $i >= 1 ; $i--) {
$day_array[] = date("d",strtotime("-$i day"));
$count_array[] = User::whereTime('logintime', 'between',[date("Y-m-d",strtotime("-$i day")).' 00:00:00', date("Y-m-d",strtotime("-$i day")).' 23:59:59'])->count();
}
$data = array(
'day_array' =>$day_array,
'count_array' =>$count_array,
);
$this->success('请求成功',$data);
}
public function last_month_user_data_bak()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$year_month = date('Y-m', strtotime('-1 month'));
$last_month_count = date('t', strtotime('-1 month'));
$day_array = array();
$count_array = array();
for ($i = 1; $i <= $last_month_count ; $i++) {
$day_array[] = $i;
$count_array[] = User::whereTime('logintime', 'between',[$year_month.'-'.$i.' 00:00:00', $year_month.'-'.$i.' 23:59:59'])->count();
}
$data = array(
'day_array' =>$day_array,
'count_array' =>$count_array,
);
$this->success('请求成功',$data);
}
/**
* Desc 商会活动
* Create on 2024/7/2 10:58
* Create by wangyafang
*/
public function activity()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$data = array(
'total_count' => Activity::where('status','normal')->count(),
'apply_count' => Activity::where('status','normal')->where('state','1')->count(),
'progress_count' => Activity::where('status','normal')->where('state','2')->count(),
'end_count' => Activity::where('status','normal')->where('state','3')->count(),
);
$this->success('请求成功',$data);
}
/**
* Desc 会员列表
* Create on 2024/7/2 11:40
* Create by wangyafang
*/
public function member_list()
{
//todo 展示数据大屏,显示会员头像
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$field = 'member.name,member.avatar,member.member_level_name,member.industry_category_name,member.join_time';
$order = "level.weigh asc,member.id asc";
$current_date = date('Y-m-d',time());
$table_name = config('database.prefix').'wdsxh_member.';
$where[$table_name.'status'] = array('eq','normal');
$where['expire_time'] = array('>=',$current_date);
$data = (new Member())
->alias('member')
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field($field)->order($order)
->select();
$data = collection($data)->toArray();
$result = array();
foreach ($data as $v) {
$result[] = array(
0=>$v['avatar'],
1=>$v['name'],
2=>$v['member_level_name'],
3=>$v['industry_category_name'],
4=>$v['join_time'],
);
}
$this->success('请求成功',$result);
}
/**
* Desc 会员行业
* Create on 2024/7/2 11:55
* Create by wangyafang
*/
public function member_industry()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$industryCategoryIdArray = (new \app\api\model\wdsxh\member\IndustryCategory())
->where('status','1')
->column('id');
$data = (new Member())
->field('industry_category_name,count(industry_category_id) count')
->group('industry_category_id')
->order('count desc')
->where('industry_category_id','in',$industryCategoryIdArray)
->select();
$category_array = array();
$count_array = array();
$data = collection($data)->toArray();
foreach ($data as $k=>$v) {
$category_array[] = $v['industry_category_name'];
$count_array[] = $v['count'];
}
$result = array(
'category_array'=>$category_array,
'count_array'=>$count_array,
);
$this->success('请求成功',$result);
}
/**
* Desc 会员本月新增
* Create on 2024/7/2 13:55
* Create by wangyafang
*/
public function member_this_month_new()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$current_date = date('Y-m-d',time());
$data = array(
'person_count'=>Member::where('expire_time','>=',$current_date)->whereTime('createtime', 'month')->where('type','1')->count(),
'company_count'=>Member::where('expire_time','>=',$current_date)->whereTime('createtime', 'month')->where('type','2')->count(),
'organize_count'=>Member::where('expire_time','>=',$current_date)->whereTime('createtime', 'month')->where('type','3')->count(),
);
$this->success('请求成功',$data);
}
/**
* Desc 会员当日访问频率
* Create on 2024/7/2 13:55
* Create by wangyafang
*/
public function member_daily_visit_frequency()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$time_slot = array(
'00:00',
'03:00',
'06:00',
'09:00',
'12:00',
'15:00',
'18:00',
'21:00',
);
$current_time = time();
$time = array();
$person_count = array();
$company_count = array();
$organize_count = array();
$current_date = date('Y-m-d',time());
$where['expire_time'] = array('>=',$current_date);
$person_member_id_array = (new Member())
->where($where)
->where('type','1')
->column('id');
$company_member_id_array = (new Member())
->where($where)
->where('type','2')
->column('id');
$organize_member_id_array = (new Member())
->where($where)
->where('type','3')
->column('id');
foreach ($time_slot as $v) {
$time[] = $v;
$tem = date('Y-m-d',time()).' '.$v.':00';
if ($current_time >= strtotime($tem)) {
switch ($v) {
case '00:00':
$whereTime = [$current_date.' 00:00:00', $current_date.' 00:00:00'];
break;
case '03:00':
$whereTime = [$current_date.' 00:00:01', $current_date.' 03:00:00'];
break;
case '06:00':
$whereTime = [$current_date.' 03:00:01', $current_date.' 06:00:00'];
break;
case '09:00':
$whereTime = [$current_date.' 06:00:01', $current_date.' 09:00:00'];
break;
case '12:00':
$whereTime = [$current_date.' 09:00:01', $current_date.' 12:00:00'];
break;
case '15:00':
$whereTime = [$current_date.' 12:00:01', $current_date.' 15:00:00'];
break;
case '18:00':
$whereTime = [$current_date.' 15:00:01', $current_date.' 18:00:00'];
break;
case '21:00':
$whereTime = [$current_date.' 18:00:01', $current_date.' 23:59:59'];
break;
}
$person_count[] = Visitor::where('member_id','in',$person_member_id_array)->whereTime('createtime', 'between',$whereTime)->count();
$company_count[] = Visitor::where('member_id','in',$company_member_id_array)->whereTime('createtime', 'between',$whereTime)->count();
$organize_count[] = Visitor::where('member_id','in',$organize_member_id_array)->whereTime('createtime', 'between',$whereTime)->count();
}
}
$result = array(
'time'=>$time,
'person_count'=>$person_count,
'company_count'=>$company_count,
'organize_count'=>$organize_count,
);
$this->success('请求成功',$result);
}
}

View File

@@ -0,0 +1,81 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Screen
* Desc 数据大屏
* Create on 2024/7/2 9:55
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\common\controller\Api;
class ScreenValidate extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
}
/**
* Desc 头部信息
* Create on 2024/7/2 10:08
* Create by wangyafang
*/
public function header()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$data = (new \app\api\model\wdsxh\business\Association())->where('id',1)
->field('logo')
->find();
$data['name'] = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('data_screen_title');
$config = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
$data_screen_password_switch = $config['data_screen_password_switch'] ?? '2';
$data['data_screen_password_switch'] = $data_screen_password_switch;
$this->success('请求成功',$data);
}
/**
* Desc 校验开屏密码
* Create on 2025/10/29 下午3:26
* Create by wangyafang
*/
public function checkPassword() {
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$password = $this->request->get('password');
if(!$password) {
$this->error('密码不能为空');
}
$data_screen_password = (new \app\admin\model\wdsxh\Config())
->where('id',1)
->value('data_screen_password');
if($password == $data_screen_password) {
$this->success('校验成功');
} else {
$this->error('校验失败');
}
}
}

View File

@@ -0,0 +1,409 @@
<?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;
use app\admin\model\wdsxh\activity\ActivityConfig;
use app\admin\model\wdsxh\member\AuthConfig;
use app\api\model\wdsxh\activity\Activity;
use app\api\model\wdsxh\goods\Goods;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class Search extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
}
/**
* Desc 搜索数据
* Create on 2025/8/12 下午5:56
* Create by wangyafang
*/
public function search_result()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$keywords = $this->request->get('keywords');
if (!$keywords) {
$this->error('请输入搜索关键词');
}
$limit = $this->request->get('limit');
if (!$limit) {
$this->error('请输入条数');
}
$member_data = array();
$unit_data = array();
$activity_data = $this->search_activity_data($keywords,$limit);
$article_data = $this->search_article_data($keywords,$limit);
$goods_data = $this->search_goods_data($keywords,$limit);
$unit_data = $this->search_unit($keywords,$limit);
$member_details = (new AuthConfig())->where('id',1)->value('member_details');
if ($member_details == 3) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($memberObj) {
$unit_data = $this->search_unit($keywords,$limit);
$member_data = $this->inner_search_member_name($keywords,$limit);
}
}
} else {
$unit_data = $this->search_unit($keywords,$limit);
$member_data = $this->inner_search_member_name($keywords,$limit);
}
$this->success('请求成功',[
'member_data' => $member_data,
'unit_data' => $unit_data,
'activity_data' => $activity_data,
'article_data' => $article_data,
'goods_data' => $goods_data
]);
}
/**
* Desc 搜索活动数据
* Create on 2025/8/13 上午8:50
* Create by wangyafang
*/
private function search_activity_data($keywords,$limit){
$expired_activity_show = (new ActivityConfig())->value('expired_activity_show');
if ($expired_activity_show == 1) {
$where['state'] = array('in',['1','2','3']);
} else {
$where['state'] = array('in',['1','2']);
}
$where['status'] = array('eq','normal');
$where['name'] = array('like','%'.$keywords.'%');
$order = 'weigh desc,id desc';
$total = (new Activity())
->where($where)
->count();
$data = (new Activity())
->where($where)
->limit($limit)
->field('id,name,start_time,address,images,organizing_method,activity_auth')
->order($order)
->select();
foreach ($data as $k=>&$v) {
$v->week = $this->getTimeWeek($v['start_time']);
$v->start_time = date('m/d H:i',$v->start_time);
$images = explode(',',$v->images);
$v->images = $images[0];
}
return array(
'total' => $total,
'data' => $data
);
}
private function getTimeWeek($time, $i = 0) {
$weekarray = array("","", "", "", "", "", "");
$week = $weekarray[date("w",$time)];
return "".$week;
}
/**
* Desc 搜索文章数据
* Create on 2025/8/13 上午8:54
* Create by wangyafang
*/
private function search_article_data($keywords,$limit){
$where['title'] = array('like','%'.$keywords.'%');
$where['status'] = array('eq',1);
$total = (new \app\api\model\wdsxh\article\Article())
->where($where)
->count();
$data = (new \app\api\model\wdsxh\article\Article())
->where($where)
->field('id,title,type,image,createtime,link,read_num')
->limit($limit)
->order('createtime desc,weigh desc')
->select();
return array(
'total' => $total,
'data' => $data
);
}
/**
* Desc 搜索商品数据
* Create on 2025/8/13 上午8:54
* Create by wangyafang
*/
private function search_goods_data($keywords,$limit){
$where['name'] = array('like','%'.$keywords.'%');
$where['status'] = array('eq','normal');
$total = (new Goods())
->where($where)
->count();
$data = (new Goods())
->where($where)
->field('id,name,image,recommend_image,price')
->limit($limit)
->order('weigh desc,createtime desc')
->select();
return array(
'total' => $total,
'data' => $data
);
}
/**
* Desc 搜索会员单位
* Create on 2025/8/15 上午9:19
* Create by wangyafang
*/
private function search_unit($keywords,$limit) {
$current_date = date('Y-m-d',time());
$table_name = config('database.prefix').'wdsxh_member.';
$where[$table_name.'status'] = array('eq','normal');
$where['expire_time'] = array('>=',$current_date);
$where['type'] = array('in',array('2','3'));
$field = 'member.id,member.type,
member.company_name,member.company_logo,member.company_introduction,
member.organize_name,member.organize_logo,member.organize_introduction,
level.name level_name';
$order = "level.weigh asc,member.id asc";
$total = (new \app\api\model\wdsxh\member\Member())
->alias('member')
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'company_name','like','%'.$keywords.'%')
->whereor($table_name.'organize_name','like','%'.$keywords.'%');
})
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->count();;
$data = (new \app\api\model\wdsxh\member\Member())
->alias('member')
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'company_name','like','%'.$keywords.'%')
->whereor($table_name.'organize_name','like','%'.$keywords.'%');
})
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->field($field)->order($order)
->limit($limit)
->select();
foreach ($data as &$v) {
$v['name'] = $v['type'] == '2' ? $v['company_name'] : $v['organize_name'];
$v['logo'] = $v['type'] == '2' ? $v['company_logo'] : $v['organize_logo'];
$introduction = $v['type'] == '2' ? $v['company_introduction'] : $v['organize_introduction'];
$v['introduction'] = strip_tags($introduction);
$v->hidden(['company_name','company_logo','company_introduction','organize_name','organize_logo','organize_introduction']);
}
return array(
'total' => $total,
'data' => $data
);
}
/** 内部调用搜索会员名称
* Desc inner_search_member_name
* Create on 2025/8/15 上午10:01
* Create by wangyafang
*/
private function inner_search_member_name($keywords,$limit)
{
$current_date = date('Y-m-d',time());
$table_name = config('database.prefix').'wdsxh_member.';
$where[$table_name.'status'] = array('eq','normal');
$where['expire_time'] = array('>=',$current_date);
$field = 'member.id,member.name,member.avatar,member.native_place,
member.member_level_id,level.name level_name,member.latitude,member.longitude,
industry_category.name industry_category_name';
$order = "level.weigh asc,member.join_time asc,member.createtime asc";
$total = (new \app\api\model\wdsxh\member\Member())
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'name','like','%'.$keywords.'%');
})
->alias('member')
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->join('wdsxh_member_industry_category industry_category','industry_category.id = member.industry_category_id','left')
->count();
$data = (new \app\api\model\wdsxh\member\Member())
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'name','like','%'.$keywords.'%');
})
->alias('member')
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->join('wdsxh_member_industry_category industry_category','industry_category.id = member.industry_category_id','left')
->field($field)->order($order)
->limit($limit)
->select();
foreach ($data as &$v) {
if (!empty($longitude) && !empty($latitude) && !empty($v['longitude']) && !empty($v['latitude'])){
$distance = wdsxh_distance($latitude,$longitude,$v['latitude'],$v['longitude']);
if ($distance > 0) {
$v['distance'] = $distance;
} else {
$v['distance'] = $distance;
}
} else {
$v['distance'] = '';
}
if (empty($v['industry_category_name'])) {
$v['industry_category_name'] = '';
}
$v->hidden(['member_level_id','latitude','longitude']);
}
return array(
'total' => $total,
'data' => $data
);
}
/**
* Desc 搜索会员名称
* Create on 2025/8/15 9:53
* Create by wangyafang
*/
public function search_member_name()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$member_details = (new AuthConfig())->where('id',1)->value('member_details');
if ($member_details == 3) {
if ($this->auth->isLogin()) {
$current_date = date('Y-m-d',time());
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if (!$memberObj) {
$this->error('成为会员后可查看');
}
} else {
$this->error('请登录后操作',null,401);
}
}
$current_date = date('Y-m-d',time());
$param = $this->request->get();
//经度
$longitude = $this->request->param('longitude','');
//纬度
$latitude = $this->request->param('latitude','');
//模糊查询
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$table_name = config('database.prefix').'wdsxh_member.';
$where[$table_name.'status'] = array('eq','normal');
$where['expire_time'] = array('>=',$current_date);
$field = 'member.id,member.name,member.avatar,member.native_place,
member.member_level_id,level.name level_name,member.latitude,member.longitude,
industry_category.name industry_category_name';
$order = "level.weigh asc,member.join_time asc,member.createtime asc";
$keywords = isset($param['keywords']) && !empty($param['keywords']) ? $param['keywords'] : '';
$total = (new \app\api\model\wdsxh\member\Member())
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'name','like','%'.$keywords.'%');
})
->alias('member')
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->join('wdsxh_member_industry_category industry_category','industry_category.id = member.industry_category_id')
->count();
$data = (new \app\api\model\wdsxh\member\Member())
->where(function ($query) use($keywords){
$table_name = config('database.prefix').'wdsxh_member.';
$query->where($table_name.'name','like','%'.$keywords.'%');
})
->alias('member')
->where($where)
->join('wdsxh_member_level level','level.id = member.member_level_id')
->join('wdsxh_member_industry_category industry_category','industry_category.id = member.industry_category_id')
->field($field)->order($order)
->page($page)->limit($limit)
->select();
foreach ($data as &$v) {
if (!empty($longitude) && !empty($latitude) && !empty($v['longitude']) && !empty($v['latitude'])){
$distance = wdsxh_distance($latitude,$longitude,$v['latitude'],$v['longitude']);
if ($distance > 0) {
$v['distance'] = $distance;
} else {
$v['distance'] = $distance;
}
} else {
$v['distance'] = '';
}
$v->hidden(['member_level_id','latitude','longitude']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
}

View File

@@ -0,0 +1,261 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class UserWechat
* Desc 微信用户控制器
* Create on 2024/3/16 9:14
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\admin\model\wdsxh\mall\Order;
use app\api\model\wdsxh\member\Level;
use app\api\model\wdsxh\message\MemberNotification;
use app\api\model\wdsxh\activity\Activity;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\member\MemberApply;
use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use Exception;
class UserWechat extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\UserWechat();
}
/**
* Desc 个人中心
* Create on 2024/3/16 9:15
* Create by wangyafang
*/
public function center()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = $this->model->where('user_id',$this->auth->id)->value('id');
if (!$wechat_id) {
$this->error('用户信息不存在');
}
$data = $this->model->where('id',$wechat_id)->field("nickname,REPLACE(mobile,SUBSTR(mobile,4,4),'****') mobile,avatar")->find();
$data['apply_member_state'] = $this->query_apply_member_state($wechat_id);
if ($data['apply_member_state']['state'] == '6') {
$data['expire_time'] = (new Member())->where('wechat_id',$wechat_id)->value('expire_time');
} else {
$data['expire_time'] = '';
}
if (in_array($data['apply_member_state']['state'],array('2','5'))) {
$data['reject'] = (new MemberApply())->where('wechat_id',$wechat_id)->value('reject');
} else {
$data['reject'] = '';
}
$mallOrderModel = new Order();
$data['order'] = array(
'unpaid_count'=> $mallOrderModel->where('wechat_id',$wechat_id)->where('state','1')->count(),
'to_be_shipped_count'=> $mallOrderModel->where('wechat_id',$wechat_id)->where('state','2')->count(),
'to_be_received_count'=> $mallOrderModel->where('wechat_id',$wechat_id)->where('state','3')->count(),
'refund_count'=> $mallOrderModel->where('wechat_id',$wechat_id)->where('state','-1')->count(),
);
$data['set_admin'] = $this->model->where('id',$wechat_id)->value('set_admin');
$where_query[] = ['exp',Db::raw("FIND_IN_SET($wechat_id,verifying_wechat_ids)")];
$verifying_wechat_ids_array = (new Activity())
->where($where_query)
->column('id');
$data['is_verifying'] = !empty($verifying_wechat_ids_array) ? 1 : 2;
$memberApplyObj = (new MemberApply())->where('wechat_id',$wechat_id)->order('id desc')->find();
$data['member_level_name'] = $memberApplyObj ? (new Level())->where('id',$memberApplyObj['member_level_id'])->value('name') : '';
if ($data['set_admin'] == 1) {
$data['member_apply_count'] = (new MemberApply())
->where('state','1')
->count();
}
if ($data['apply_member_state']['state'] == '6') {
$member_id = (new Member())->where('wechat_id',$wechat_id)->value('id');
$data['member_notification_count'] = (new MemberNotification())
->where('member_id',$member_id)
->where('is_read',0)
->count();
} else {
$data['member_notification_count'] = 0;
}
$this->success('请求成功',$data);
}
/**
* Desc 入会申请状态
* Create on 2024/3/21 9:48
* Create by wangyafang
*/
public function apply_member_state()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = $this->model->where('user_id',$this->auth->id)->value('id');
if (!$wechat_id) {
$this->error('用户信息不存在');
}
$state = $this->query_apply_member_state($wechat_id);
if ($state['state'] == '-1') {
$reject = '';
} else {
$memberApplyObj = (new MemberApply())->where('wechat_id',$wechat_id)->field('reject')->find();
$reject = $memberApplyObj['reject'];
}
$state['reject'] = $reject;
$this->success('请求成功',['state'=>$state]);
}
public function query_apply_member_state($wechat_id = '')
{
$applyObj = (new MemberApply())->where('wechat_id',$wechat_id)->order('id desc')->find();
if (!$applyObj) {
$data = array(
'state'=>'-1',
'msg'=>'未提交入会申请',
);
return $data;
}
switch ($applyObj['child_state']) {
case '1':
$data = array(
'state'=>'1',
'msg'=>'已提交审核,请等待审核',
);
break;
case '2':
$data = array(
'state'=>'2',
'msg'=>'入会申请被驳回',
);
break;
case '3':
$data = array(
'state'=>'3',
'msg'=>'后台审核通过未缴费,需要缴纳会费',
);
break;
case '4':
$data = array(
'state'=>'4',
'msg'=>'线下缴费审核中',
);
break;
case '5':
$data = array(
'state'=>'5',
'msg'=>'线下缴费被驳回',
);
break;
case '6':
$current_date = date('Y-m-d',time());
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)
->find();
if ($memberObj['expire_time'] < $current_date) {
$data = array(
'state'=>'7',
'msg'=>'会员已过期,需要缴纳会费',
);
} else {
$data = array(
'state'=>'6',
'msg'=>'已经是会员',
);
}
break;
}
return $data;
}
/**
* Desc 更新昵称和头像
* Create on 2024/3/28 14:12
* Create by wangyafang
*/
public function update_nickname_avatar(){
if (!$this->request->isPost()){
$this->error('请求类型错误');
}
$params = $this->request->param();
$model = new \app\admin\model\User();
$user = $model->get($this->auth->id);
if (!$user){
$this->error('用户信息不存在');
}
$wechatObj = (new \app\api\model\wdsxh\UserWechat())->where('user_id',$this->auth->id)->find();
if (!$wechatObj) {
$this->error('微信用户信息不存在');
}
$user['nickname']=empty($params['nickname'])?$user['nickname']:$params['nickname'];
$user['avatar']=empty($params['avatar'])?$user['avatar']:$params['avatar'];
$wechatObj->nickname = $user['nickname'];
$wechatObj->avatar = $user['avatar'];
$result = false;
Db::startTrans();
try {
$result = $user->save();
$wechatObj->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success('更新成功!',$this->auth->getUserinfo());
}
/**
* Desc 获取手机号
* Create on 2025/8/18 上午11:45
* Create by wangyafang
*/
public function get_mobile()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechatObj = (new \app\api\model\wdsxh\UserWechat())->where('user_id',$this->auth->id)->find();
if (!$wechatObj) {
$this->error('微信用户信息不存在');
}
$this->success('请求成功', [
'mobile' => $wechatObj->mobile,
]);
}
}

View File

@@ -0,0 +1,240 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class WananchiUserWechat
* Desc 公众号H5微信用户注册登录
* Create on 2024/3/7 10:08
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use addons\wdsxh\library\Wxofficial\Jssdk;
use app\admin\model\wdsxh\business\Association;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\member\MemberApply;
use app\api\model\wdsxh\member\Promotion;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use app\common\library\Sms;
use app\common\model\User;
use think\Db;
class WananchiUserWechat extends Api
{
protected $noNeedLogin = ['mobile_login','get_wechat_config'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
}
/**
* 手机验证码登录
*
* @ApiMethod (POST)
* @param string $mobile 手机号
* @param string $captcha 验证码
*/
public function mobile_login()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$mobile = $this->request->post('mobile');
$code = $this->request->post('code');
$param = $this->request->post();
$result = $this->validate($param,'app\api\validate\wdsxh\WananchiUserWechat.mobile_login');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
$userWechatObj = UserWechat::getByMobile($mobile);
$wananchi_openid = $this->by_code_get_openid($code);
$parent_wechat_id = $this->request->post('parent_wechat_id',0);
if ($userWechatObj) {
//如果已经有账号则直接登录
$userWechatObj->wananchi_openid = $wananchi_openid;
$userWechatObj->save();
$userObj = User::get($userWechatObj['user_id']);
if (!$userObj) {
$userObj = User::create(array(
'group_id'=>1,
'status'=>'normal',
'joinip'=>request()->ip(),
'jointime'=>time(),
'avatar'=> $userWechatObj['avatar'],
'nickname'=> $userWechatObj['nickname'],
'mobile'=> $userWechatObj['mobile'],
),true);
$userWechatObj->user_id = $userObj->id;
$userWechatObj->save();
}
$register_state = 2;
$ret = $this->auth->direct($userWechatObj['user_id']);
} else {
$nickname_avatar_data = $this->get_nickname_avatar();
Db::startTrans();
try{
$user = User::create(array(
'group_id'=>1,
'status'=>'normal',
'joinip'=>request()->ip(),
'jointime'=>time(),
'nickname'=>$nickname_avatar_data['nickname'],
'avatar'=>$nickname_avatar_data['avatar'],
'mobile'=>$mobile
),true);
$userWechatObj = UserWechat::create(array(
'user_id' =>$user->id,
'wananchi_openid'=>$wananchi_openid,
'nickname'=>$nickname_avatar_data['nickname'],
'avatar'=>$nickname_avatar_data['avatar'],
'mobile'=>$mobile,
'channel'=>2,
'parent_wechat_id'=>$parent_wechat_id,
));
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$ret = $this->auth->direct($user->id);
$register_state = 1;
}
if ($parent_wechat_id) {
$promotionModel = new Promotion();
$member_id = (new Member())->where('wechat_id',$parent_wechat_id)->value('id');
$promotion_data = array(
'wechat_id' => $parent_wechat_id,
'member_id'=>$member_id,
);
$promotionModel->data($promotion_data);
$promotionModel->allowField(true)->save();
}
//todo 导入会员后,会员使用手机号登陆小程序,可以自动绑定会员信息
$memberApplyObj = (new MemberApply())
->where('mobile',$mobile)
->where('state','2')
->where('channel',3)
->where('child_state','6')
->where('pay_method','1')
->find();
$memberObj = (new Member())->where('mobile',$mobile)->find();
if ($memberApplyObj && empty($memberApplyObj['wechat_id']) && $memberObj && empty($memberObj['wechat_id'])) {
$memberApplyObj->wechat_id = $userWechatObj->id;
$memberApplyObj->save();
$memberObj->wechat_id = $userWechatObj->id;
$memberObj->save();
}
if ($ret) {
Sms::flush($mobile, 'mobilelogin');
$userObj = $this->auth->getUserinfo();
$avatar = (new UserWechat())->where('user_id',$userObj['id'])->value('avatar');
$userObj['avatar'] = wdsxh_full_url($avatar);
$userObj['register_state'] = $register_state;
$this->success('请求成功',$userObj);
} else {
$this->error($this->auth->getError());
}
}
/**
* Desc 通过code获取公众号微信用户openid
* Create on 2024/3/7 11:39
* Create by wangyafang
*/
private function by_code_get_openid($code = '')
{
$configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
$wananchi_appid = $configObj['wananchi_appid'];
$wananchi_secret = $configObj['wananchi_secret'];
$token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$wananchi_appid&secret=$wananchi_secret&code={$code}&grant_type=authorization_code";
$token = json_decode(\fast\Http::get($token_url));
if(isset($token->errcode)) {
$this->error('token:'.$token->errcode);
}
$access_token_url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=$wananchi_appid&grant_type=refresh_token&refresh_token=".$token->refresh_token;
//转成对象
$access_token = json_decode(\fast\Http::get($access_token_url));
if(isset($access_token->errcode)) {
$this->error('access_token:'.$access_token->errcode);
}
$openid = $access_token->openid;
return $openid;
}
private function get_nickname_avatar()
{
$avatar = Association::where('id',1)->value('logo');
if (empty($avatar)) {
$avatar = '/assets/addons/wdsxh/img/avatar.png';
}
$current_user_id = User::order('id','desc')->limit(1)->value('id');
if (!$current_user_id) {
$current_user_id = 1;
} else {
$current_user_id = bcadd($current_user_id, 1);
}
$nickname = '用户'.$current_user_id;
return array(
'avatar'=>$avatar,
'nickname'=>$nickname
);
}
/**
* Desc 通过config接口注入权限验证配置
* Create on 2024/6/13 17:53
* Create by wangyafang
*/
public function get_wechat_config()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$url = $this->request->get('url');
$configObj = (new \app\admin\model\wdsxh\Config())->get(1);
$appid = $configObj['wananchi_appid'];
$secret = $configObj['wananchi_secret'];
$jssdk = (new Jssdk($appid,$secret));
$signPackage = $jssdk->GetSignPackage($url);
$data = array(
'appId'=>$appid,
'timestamp'=>isset($signPackage['timestamp']) ? $signPackage['timestamp'] : '',
'nonceStr'=>isset($signPackage['nonceStr']) ? $signPackage['nonceStr'] : '',
'signature'=>isset($signPackage['signature']) ? $signPackage['signature'] : '',
);
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,163 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Willbrand
* Desc 电子会牌控制器
* Create on 2024/4/9 17:06
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use EasyWeChat\Factory;
class Willbrand extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\Willbrand();
}
/**
* Desc 展示电子会牌
* Create on 2024/4/9 17:52
* Create by wangyafang
*/
public function index(){
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$current_date = date('Y-m-d',time());
$memberObj = (new \app\api\model\wdsxh\member\Member())->where('wechat_id',$wechat_id)->find();
if(!$memberObj){
$this->error('会员信息不存在');
}
if($current_date > $memberObj['expire_time']) {
$this->error('会员信息已过期,请重新缴纳会费');
}
$data = $this->model->where('id',1)->value('data');
$data = json_decode($data,true);
$data['bg']['img'] = wdsxh_full_url($data['bg']['img']);
$channel = $this->request->header('channel');
if ($channel == 1) {//小程序
$save_path = '/uploads/wdsxh/willbrand/'.$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($wechat_id, [
'page' => $path,
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$response->saveAs('uploads/wdsxh/willbrand/'.$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'].'.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', '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'].'.png';
$qrCode->writeFile($filePath);
$save_path = DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'wdsxh'.DIRECTORY_SEPARATOR.'wananchi_qrcode'.DIRECTORY_SEPARATOR.$memberObj['id'].DIRECTORY_SEPARATOR.$memberObj['createtime'].'.png';
$applet_qrcode_path = $this->request->domain().$save_path;
}
}
}
$member_level_name = $memberObj['member_level_name'];
$member_name = $memberObj['name'];
if (empty($memberObj['serial_number'])) {
$memberTodayJoinCount = (new Member())
->where('id','neq',$memberObj['id'])
->order('id desc')
->limit(1)
->value('id');
if (!$memberTodayJoinCount) {
$serial_number = str_pad('1', 3, '0', STR_PAD_LEFT);
} else {
$serial_number = str_pad($memberTodayJoinCount + 1, 3, '0', STR_PAD_LEFT);
}
$memberObj['serial_number'] = $serial_number;
$memberObj->save();
}
// 自定义会员编号格式:前后自定义,中间四位数字固定
$custom_prefix = ''; // 前缀,可以自定义
$custom_suffix = ''; // 后缀,可以自定义
$middle_number = str_pad($memberObj['serial_number'], 4, '0', STR_PAD_LEFT); // 中间四位数字
// 从电子会牌设置中获取自定义前缀和后缀
if (isset($data['member_number_settings'])) {
$custom_prefix = isset($data['member_number_settings']['prefix']) ? $data['member_number_settings']['prefix'] : '';
$custom_suffix = isset($data['member_number_settings']['suffix']) ? $data['member_number_settings']['suffix'] : '';
}
// 生成自定义会员编号
$number = $custom_prefix . $middle_number . $custom_suffix;
$result_data = array(
'number'=>$number,
'member_name'=>$member_name,
'join_time'=>date('Y年m月d日',strtotime($memberObj['join_time'])),
'expire_time'=>date('Y年m月d日',strtotime($memberObj['expire_time'])),
'member_level_name'=>$member_level_name,
'applet_qrcode_path'=>$applet_qrcode_path,
'willbrand'=>$data,
'avatar'=>wdsxh_full_url($memberObj['avatar']),
);
if ($memberObj['type'] == '2') {
$result_data['company_name'] = $memberObj['company_name'];
}
if ($memberObj['type'] == '3') {
$result_data['organize_name'] = $memberObj['organize_name'];
}
$this->success('请求成功',$result_data);
}
}

View File

@@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class WxExpress
* Desc 微信小程序发货信息管理服务
* Create on 2025/2/28 15:51
* Create by wangyafang
*/
namespace app\api\controller\wdsxh;
use addons\wdsxh\library\Wxapp;
use app\api\model\wdsxh\activity\Order;
use app\api\model\wdsxh\member\Pay;
use app\common\controller\Api;
class WxExpress extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
}
public function delivery_state(){
// todo 文档定时任务
$delivery_management = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('delivery_management');
if ($delivery_management == 1){
$activityOrderObj = (new Order())->where('paid',2)->where('delivery_state',1)
->where('trade_no','not in','')
->select();
foreach ($activityOrderObj as $item){
$activityObj = (new \app\api\model\wdsxh\activity\Activity())
->where('id',$item['activity_id'])
->find();
$delivery = Wxapp::upload_shipping_info(2,$item['trade_no'],1,3,'','',$activityObj['name'],'',wdsxh_get_openid($item['wechat_id'],1));
Log::record($delivery,'activity_delivery_upload_shipping_info');
}
$memberPayObj = (new Pay())->where('paid',2)->where('delivery_state',1)
->where('trade_no','not in','')
->select();
foreach ($memberPayObj as $item){
$delivery = Wxapp::upload_shipping_info(2,$item['trade_no'],1,3,'','','会费缴纳','',wdsxh_get_openid($item['wechat_id'],1));
Log::record($delivery,'member_pay_delivery_upload_shipping_info');
}
}
$this->success('请求成功');
}
}

View File

@@ -0,0 +1,496 @@
<?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\activity;
use app\admin\model\wdsxh\activity\ActivityConfig;
use app\api\model\wdsxh\activity\Order;
use app\api\model\wdsxh\activity\Refund;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\user\Wechat;
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 Activity
* Desc 活动控制器
* Create on 2024/3/11 16:24
* Create by wangyafang
*/
class Activity extends Api
{
protected $noNeedLogin = ['index','update_activity_state','details','activity_config'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\activity\Activity();
}
/*
* desc: 活动列表
* time: 2024-3-11 16:38
* */
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$where = [];
$expired_activity_show = (new ActivityConfig())->value('expired_activity_show');
if ($expired_activity_show == 1) {
$where['state'] = array('in',['1','2','3']);
} else {
$where['state'] = array('in',['1','2']);
}
$where['status'] = array('eq','normal');
if(isset($param['keywords']) && !empty($param['keywords'])) {
$where['name'] = array('like','%'.$param['keywords'].'%');
}
if(isset($param['state']) && !empty($param['state'])) {
$where['state'] = array('eq',$param['state']);
}
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$count = $this->model->where($where)->count();
$order = 'weigh desc,id desc';
$data = $this->model
->where($where)
->page($page,$limit)
->field('id,name,start_time,address,images,organizing_method,activity_auth')
->order($order)
->select();
foreach ($data as $k=>&$v) {
$v->week = $this->getTimeWeek($v['start_time']);
$v->start_time = date('m/d H:i',$v->start_time);
$images = explode(',',$v->images);
$v->images = $images[0];
}
$this->success('请求成功',['total'=>$count,'data'=>$data]);
}
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
$data = $this->model
->where('id',$id)
->field('id,images,start_time,end_time,name,fees,state activity_state,
contacts,mobile,
organizing_method,url,address,longitude,latitude,content,
is_verifying,refund,
apply_time,
activity_auth,
points_status,points,
apply_field_state,
apply_limit_number,
non_member_registration_status')
->find();
if (!$data) {
$this->error('活动不存在');
}
if ($this->auth->isLogin()) {
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('wechat_id',$wechat_id)
->where('activity_id',$id)
->order('id desc')
->find();
if (!$activityApplyObj) {
$data['pay_state'] = '1';
$data['apply_id'] = '';
$data['reject'] = '';
} else {
$data['pay_state'] = $activityApplyObj['state'];
$data['apply_id'] = $activityApplyObj['id'];
$activityRefundObj = (new Refund())
->where('activity_id',$id)
->where('wechat_id',$wechat_id)
->where('state','3')
->order('id desc')
->find();
$data['reject'] = $activityRefundObj ? $activityRefundObj['reject'] : '';
}
} else {
$data['pay_state'] = '1';
$data['apply_id'] = '';
$data['reject'] = '';
}
if ($data['points_status'] == 2) {
unset($data['points']);
}
$activityApplyModel = new \app\api\model\wdsxh\activity\ActivityApply();
$data['apply_count'] = $activityApplyModel->where('activity_id', $id)->where('state',2)->count();
$apply_list = $activityApplyModel->where('activity_id', $id)
->where('state',2)
->alias('apply')
->order('apply.createtime desc')
->join('wdsxh_member member', 'member.id = apply.member_id')
->field('member.avatar member_avatar')
->limit(10)
->select();
if (!empty($apply_list)) {
foreach ($apply_list as &$v) {
$v->member_avatar = wdsxh_full_url($v->member_avatar);
}
}
$data['apply_list'] = $apply_list;
if ($this->auth->isLogin()) {
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('activity_id', $id)
->where('wechat_id',$wechat_id)
->where('state','2')
->find();
if ($activityApplyObj) {
$apply_status = 1;
} else {
$apply_status = 2;
}
} else {
$apply_status = 2;
}
$data['apply_status'] = $apply_status;
if ($this->auth->isLogin()) {
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('activity_id', $id)
->where('wechat_id',$wechat_id)
->where('state','1')
->find();
if ($activityApplyObj && !empty($activityApplyObj['field_data'])) {
$apply_info_fill_state = 1;
} else {
$apply_info_fill_state = 2;
}
} else {
$apply_info_fill_state = 2;
}
$data['apply_info_fill_state'] = $apply_info_fill_state;
if (!empty($data['apply_limit_number']) && $data['apply_limit_number'] > 0) {
$apply_count = (new \app\api\model\wdsxh\activity\ActivityApply())->where('activity_id', $id)
->where('state',2)
->count();
if ($data['apply_limit_number'] > $apply_count) {
$data['apply_limit_number'] = $data['apply_limit_number'] - $apply_count;
} else {
$data['apply_limit_number'] = 0;
}
}
$this->success('请求成功',$data);
}
public function getTimeWeek($time, $i = 0) {
$weekarray = array("","", "", "", "", "", "");
$week = $weekarray[date("w",$time)];
return "".$week;
}
/*
* desc: 会员活动列表
* time: 2024-3-11 17:38
* */
public function user_index()
{
$page=$this->request->param('page',1);
$limit=$this->request->param('limit',10);
$payState=$this->request->param('pay_state',0);//报名状态
$activityState=$this->request->param('activity_state',0);
try {
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$where=array(
'ActivityApply.wechat_id'=>$wechat_id
);
if(!empty($payState)){
$where['ActivityApply.state'] = $payState;
}
$activityMap = array();
if(!empty($activityState)){
$activityMap['state']=$activityState;
}
$applyModel = new \app\api\model\wdsxh\activity\ActivityApply();
$count = $applyModel->hasWhere('activity',$activityMap)->where($where)->count();
$list = $applyModel->hasWhere('activity',$activityMap)->page($page,$limit)->where($where)->order('id desc')->select();
$activityOrderModel = new Order();
foreach ($list as $k=>&$v) {
$v->pay_state = $v->state;
$activityObj = $this->model->get($v->activity_id);
$orderObj = $activityOrderModel
->where('activity_id',$v->activity_id)
->where('apply_id',$v->id)
->where('wechat_id',$v->wechat_id)
->where('member_id',$v->member_id)
->order('id desc')
->limit(1)
->find();
$v->order_no = $orderObj ? $orderObj['order_no'] : '';
$v->name = $activityObj['name'];
$images = explode(',',$activityObj['images']);
$v->images = $images[0];
$v->week = $this->getTimeWeek($activityObj['start_time']);
$v->start_time = date('m/d H:i',$activityObj['start_time']);
$v->address = $activityObj->address;
$v->fees = $orderObj ? $orderObj['pay_amount'] : '';
$v->organizing_method = $activityObj['organizing_method'];
$v->activity_state = $activityObj['state'];
$v->refund = $activityObj['refund'];
$v->url = $activityObj['url'];
$v->is_verifying = $activityObj['is_verifying'];
$v->verification_method = $activityObj['verification_method'];
$v->hidden(['wechat_id','member_id','createtime','state']);
unset($orderObj);
unset($activityObj);
}
$this->success('请求成功',['total'=>$count,'data'=>$list]);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
/*
* desc: 申请退款
* time: 2024-3-11 16:38
* */
public function apply_refund()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$result = $this->validate($param,'app\api\validate\wdsxh\activity\Refund.apply_refund');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
$activityObj = $this->model->get($param['activity_id']);
if(!$activityObj){
$this->error('活动信息不存在');
}
if ($activityObj['refund'] == 0) {
$this->error('此活动无法退款');
}
if ($activityObj && $activityObj['state'] == '2') {
$this->error('活动进行中,无法退款');
}
if ($activityObj && $activityObj['state'] == '3') {
$this->error('活动已结束,无法退款');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$refundModel = new Refund();
$refundObj = $refundModel->where('activity_id',$param['activity_id'])
->where('apply_id',$param['apply_id'])
->find();
if ($refundObj && $refundObj['wechat_id'] != $wechat_id) {
$this->error('不是此用户下的活动,无法退款');
}
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())->get($param['apply_id']);
$orderObj = (new Order())->where('activity_id',$param['activity_id'])
->where('apply_id',$param['apply_id'])
->where('wechat_id',$wechat_id)
->where('member_id',$activityApplyObj['member_id'])
->where('paid','2')
->order('id desc')
->limit(1)
->find();
if (!$orderObj) {
$this->error('订单支付信息不存在');
}
if($orderObj['pay_amount'] == 0.00){
$this->error('订单0元无法退款');
}
if ($refundObj && $refundObj['state'] == '1') {
$this->error('已申请退款,请勿重复提交');
}
$applyObj = (new \app\api\model\wdsxh\activity\ActivityApply())->get($param['apply_id']);
if ($refundObj) {
Db::startTrans();
try{
$refundObj->state = '1';
$refundObj->reject = '';
$refundObj->save();
$applyObj->state = '3';
$applyObj->save();
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('提交成功');
} else {
Db::startTrans();
try{
$refund_data = array(
'activity_id'=> $param['activity_id'],
'apply_id'=> $param['apply_id'],
'wechat_id' => $activityApplyObj['wechat_id'],
'member_id'=>$activityApplyObj['member_id'],
'order_id'=>$orderObj['id'],
);
$refundModel->data($refund_data);
$refundModel->allowField(true)->save();
$applyObj->state = '3';
$applyObj->save();
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('提交成功');
}
}
/*
* desc: 参会凭证
* time: 2024-3-130 9:46
* */
public function attendance_voucher()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('activity_id');
$activityObj = $this->model
->where('id',$id)
->field('id,name activity_name,
address')
->find();
if (!$activityObj) {
$this->error('活动不存在');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityArray = $activityObj->toArray();
$memberObj = (new Member())->where('wechat_id',$wechat_id)
->field('name member_name,avatar member_avatar,mobile,
type,member_level_name,type,company_name,organize_name')
->find();
if ($memberObj) {
$memberObj->member_avatar = wdsxh_full_url($memberObj->member_avatar);
$memberArray = $memberObj->toArray();
$data = array_merge($activityArray,$memberArray);
} else {
$memberObj = (new UserWechat())->where('id',$wechat_id)
->field('nickname member_name,avatar member_avatar,mobile')
->find();
$memberObj->member_avatar = wdsxh_full_url($memberObj->member_avatar);
$memberObj['member_level_name'] = '普通用户';
$memberObj['company_name'] = '';
$memberObj['organize_name'] = '';
$memberArray = $memberObj->toArray();
$data = array_merge($activityArray,$memberArray);
}
$data['wechat_id'] = $wechat_id;
$this->success('请求成功',$data);
}
/**
* Desc 更新活动状态
* Create on 2025/1/20 15:22
* Create by wangyafang
*/
public function update_activity_state()
{
$now = time();
// 更新为进行中状态
$applyData = $this->model->where('state','1')->where('apply_time','elt',$now)->column('id');
if (!empty($applyData)) {
$this->model->where('id','in',$applyData)->update(['state'=>'2']);
}
// 更新为已结束状态(遍历更新以触发 afterUpdate 事件)
$endList = $this->model
->where('end_time','elt',$now)
->where('state','<>','3')
->select();
if (!empty($endList)) {
foreach ($endList as $activity) {
$activity->state = '3';
$activity->save();
}
}
$this->success('请求成功');
}
/**
* Desc 接龙配置
* Create on 2025/8/8 10:04
* Create by wangyafang
*/
public function activity_config()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
if (empty($id)) {
$this->error('参数错误');
}
$activityObj = $this->model->get($id);
if (!$activityObj) {
$this->error('活动数据不存在');
}
$is_status = $activityObj['activity_auth'];
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,536 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class ActivityApply
* Desc 活动报名控制器
* Create on 2024/3/11 17:57
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\activity;
use addons\wdsxh\library\Wxapp;
use app\api\model\wdsxh\activity\ActivityApplyRecord;
use app\api\model\wdsxh\activity\Order;
use app\api\model\wdsxh\activity\Refund;
use app\api\model\wdsxh\member\Member;
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 ActivityApply extends Api
{
protected $noNeedLogin = ['index','notify'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $configObj = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\activity\ActivityApply();
$this->configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
}
/*
* desc: 活动取消
* time: 2023-3-30 10:20
* */
public function cancel()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$id = $this->request->post('id');
$where = array(
'id'=>$id,
);
$activityApplyObj = $this->model->where($where)->find();
if (!$activityApplyObj) {
$this->error('活动已取消');
}
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->where('id',$activityApplyObj['activity_id'])->find();
if ($activityObj && $activityObj['state'] == '2') {
$this->error('活动进行中,无法取消');
}
if ($activityObj && $activityObj['state'] == '3') {
$this->error('活动已结束,无法取消');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
if ($wechat_id != $activityApplyObj['wechat_id']) {
$this->error('不是本人,无法取消');
}
$result = false;
Db::startTrans();
try {
$result = $activityApplyObj->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($activityApplyObj->getError());
}
$this->success('取消成功');
}
/*
* desc: 活动提交
* time: 2023-3-11 18:00
* */
public function submit()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$fixed_data = array();
if (isset($_POST['data']) && !empty($_POST['data'])) {
$custom_content = $_POST['data'];
$param['data'] = json_decode($custom_content, true);
$fixed_data = $this->handle_custom_data($param['data']);
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$result = $this->validate($param,'app\api\validate\wdsxh\activity\ActivityApply.apply');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->where('id',$param['activity_id'])->find();
$current_date = date('Y-m-d',time());
$memberObj = (new Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($activityObj['non_member_registration_status'] == '2' && !$memberObj) {
$this->error('只有会员才能报名');
}
if (!$activityObj) {
$this->error('活动不存在');
}
if ($activityObj['apply_time'] < time()) {
$this->error('活动报名时间已过,无法报名');
}
if ($activityObj['state'] == '2') {
$this->error('活动进行中,无法报名');
}
if ($activityObj['state'] == '3') {
$this->error('活动已结束,无法报名');
}
$applyObj = $this->model->where(array('wechat_id'=>$wechat_id,'activity_id'=>$param['activity_id']))
->where('state','<>','4')
->order('id desc')->find();
if($applyObj && $applyObj['state'] == '2'){
$this->error('你已报名过了,不能重复报名');
}
if($applyObj && $applyObj['state'] == '3'){
$this->error('你的报名信息正在申请退款处理,暂时无法报名');
}
if (!empty($activityObj['apply_limit_number']) && $activityObj['apply_limit_number'] > 0) {
$apply_count = $this->model->where('activity_id', $param['activity_id'])
->where('state',2)
->count();
if ($apply_count >= $activityObj['apply_limit_number']) {
$this->error('活动报名人数已满,无法报名');
}
}
//is_verifying 活动是否核销:1=是,2=否
//is_sign_in 签到:1=已签到,2=未签到,3=无需签到
$is_sign_in = $activityObj['is_verifying'] == '1' ? '2' : '3';
if ($applyObj && ($applyObj['state'] == 1 || $applyObj['state'] == 4)) {//已提交报名,但未付款
if ($activityObj['apply_field_state'] == 1 && empty($applyObj['field_data'])) {
$this->error('请填写报名信息');
}
$apply_id = $applyObj->id;
} else {//第一次报名
$apply_data = array(
'activity_id'=> $param['activity_id'],
'wechat_id' => $wechat_id,
'member_id'=>$memberObj ? $memberObj->id : 0,
'is_sign_in'=>$is_sign_in,
);
if ($activityObj['apply_field_state'] == 1
&& (!isset($_POST['data']) || empty($_POST['data']))
) {
$this->error('请填写报名信息');
}
if (isset($_POST['data']) && !empty($_POST['data'])) {
$apply_data['field_data'] = $_POST['data'];
}
$apply_data = array_merge($apply_data, $fixed_data);
$apply_data['state'] = $activityObj['fees'] == 0.00 ? 2 : 1;
$this->model->data($apply_data);
$applyObj = $this->model->allowField(true)->save();
$apply_id = $this->model->id;
}
if ($applyObj) {
$orderModel = new Order();
$activityOrderObj = $orderModel
->where(array('wechat_id'=>$wechat_id,'activity_id'=>$param['activity_id']))
->where('paid','1')
->find();
$channel = $this->request->header('channel');
$paid = $activityObj['fees'] == 0.00 ? 2 : 1;
if ($activityOrderObj) {
$activityOrderObj->order_no = wdsxh_create_order();
$activityOrderObj->pay_amount = $activityObj['fees'];
$activityOrderObj->channel = $channel;
$activityOrderObj->paid = $paid;
if ($paid == 2) {
$activityOrderObj->pay_time = time();
$activityOrderObj->complete_time = date('Y-m-d H:i:s',time());
}
$activityOrderObj->save();
} else {
$order_data = array(
'activity_id'=> $param['activity_id'],
'apply_id'=> $apply_id,
'wechat_id' => $wechat_id,
'member_id'=>$memberObj ? $memberObj->id : 0,
'order_no'=> wdsxh_create_order(),
'pay_amount'=>$activityObj['fees'],
'channel'=>$channel,
'paid'=>$paid,
);
if ($paid == 2) {
$order_data['pay_time'] = time();
$order_data['complete_time'] = date('Y-m-d H:i:s',time());
}
$orderModel->data($order_data);
$orderModel->allowField(true)->save();
$activityOrderObj = $orderModel;
}
$applyObj = $this->model->get($apply_id);
$applyObj->is_sign_in = $is_sign_in;
$applyObj->save();
if($paid == 2){//不付钱
$avtivity_apply_record_data = array(
'activity_id'=> $param['activity_id'],
'wechat_id' => $wechat_id,
'member_id'=>$memberObj ? $memberObj->id : 0,
);
$avtivityApplyRecordModel = new ActivityApplyRecord();
$avtivityApplyRecordModel->data($avtivity_apply_record_data);
$avtivityApplyRecordModel->allowField(true)->save();
$this->zero_pay($activityObj , $wechat_id , $channel);
} else{//微信支付
$this->wx_pay($activityOrderObj , $wechat_id , $channel);
}
} else {
$this->error('创建订单失败');
}
}
private function zero_pay($activityObj = [] , $wechat_id = '' ,$channel = 1)
{
$address = $activityObj['organizing_method'] == '1' ? $activityObj['url'] : $activityObj['address'];
if ($channel == 1) {
//活动报名成功通知
try{
$conf=$this->configObj;
$data=[
'thing1'=>[
'value'=>$activityObj['name'],
],
'amount3'=>[
'value'=>$activityObj['fees'],
],
'thing6'=>[
'value'=>$address,
],
'date7'=>[
'value'=>date('Y年m月d日 H:i',$activityObj['start_time']),
],
'phone_number8'=>[
'value'=>$activityObj['mobile'],
]
];
$result = Wxapp::subscribeMessage($conf['applet_activity_apply'],trim(wdsxh_get_openid($wechat_id,$channel)),'/pagesActivity/index/details?id='.$activityObj['id'],$data);
}catch (\think\Exception $e){
$this->error($e->getMessage());
}
} else {//todo公众号逻辑
}
$this->success('报名成功');
}
private function wx_pay($activityOrderObj = [] , $wechat_id = '' ,$channel = 1)
{
if ($channel == 1) {//小程序支付
try{
$openid = wdsxh_get_openid($wechat_id,$channel);
$conf=Wxapp::unify('商会活动报名',$activityOrderObj->order_no,$activityOrderObj->pay_amount,$openid,request()->domain().'/api/wdsxh/activity/activity_apply/notify');
}catch (Exception $e){
$this->error($e->getMessage());
}
$this->success('报名成功',$conf);
} else {//todo 公众号支付
try{
$openid = wdsxh_get_openid($wechat_id,$channel);
$conf=Wxapp::unify_wxofficial('商会活动报名',$activityOrderObj->order_no,$activityOrderObj->pay_amount,$openid,request()->domain().'/api/wdsxh/activity/activity_apply/notify');
}catch (Exception $e){
$this->error($e->getMessage());
}
$this->success('报名成功',$conf);
}
}
/*
* desc: 活动支付回调处理
* time: 2023-3-11 18:00
* */
public function notify()
{
$pay = Wxapp::getPay();
$response = $pay->handlePaidNotify(function($message, $fail){
$orderObj = Order::where('order_no',$message['out_trade_no'])->find();
if (!$orderObj || $orderObj['paid'] == '2') {
return true;
}
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code'] === 'SUCCESS') {
$avtivity_apply_record_data = array(
'activity_id'=> $orderObj['activity_id'],
'wechat_id' => $orderObj['wechat_id'],
'member_id'=>$orderObj['member_id'],
);
$avtivityApplyRecordModel = new ActivityApplyRecord();
Db::startTrans();
try {
$orderObj['pay_time'] = time();
$orderObj['paid'] = '2';
$orderObj->trade_no = $message['transaction_id'];
$orderObj->save();
//处理活动报名
//todo 活动创建后,会员功能对外功能不可用,非会员无法报名 删除where条件
$applyObj = $this->model->where(array('wechat_id'=>$orderObj['wechat_id'],'activity_id'=>$orderObj['activity_id']))
->where('state','1')
->find();
$applyObj->state = '2';
$applyObj->save();
$avtivityApplyRecordModel->data($avtivity_apply_record_data);
$avtivityApplyRecordModel->allowField(true)->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->get($orderObj['activity_id']);
$address = $activityObj['organizing_method'] == '1' ? $activityObj['url'] : mb_substr($activityObj['address'],0,20);
//活动报名成功通知
try{
$conf=$this->configObj;
$data=[
'thing1'=>[
'value'=>mb_substr($activityObj['name'],0,20),
],
'amount3'=>[
'value'=>$orderObj['pay_amount'],
],
'thing6'=>[
'value'=>$address,
],
'date7'=>[
'value'=>date('Y年m月d日 H:i',$activityObj['start_time']),
],
'phone_number8'=>[
'value'=>$activityObj['mobile'],
]
];
$result = Wxapp::subscribeMessage($conf['applet_activity_apply'],trim(wdsxh_get_openid($orderObj['wechat_id'],1)),'/pagesActivity/index/details?id='.$orderObj['activity_id'],$data);
}catch (\think\Exception $e){
$this->error($e->getMessage());
}
}
} else {
return $fail('FAIL');
}
return true;
});
$response->send();
}
/*
* desc: 删除未支付订单
* time: 2023-4-10 11:58
* */
public function del()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$id = $this->request->post('id');
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$where = array(
'id'=>$id,
'wechat_id'=>$wechat_id,
);
$activityApplyObj = $this->model->where($where)->find();
if (!$activityApplyObj) {
$this->error('未支付已取消');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
if ($wechat_id != $activityApplyObj['wechat_id']) {
$this->error('不是本人,无法取消');
}
$activityOrderObj = (new Order())->where('activity_id',$activityApplyObj['activity_id'])
->where('apply_id',$id)
->where('wechat_id',$wechat_id)
->where('paid','1')
->find();
if (!$activityOrderObj) {
$this->error('未支付已取消');
}
$result = false;
Db::startTrans();
try {
$result = $activityApplyObj->delete();
$activityOrderObj->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($activityApplyObj->getError());
}
$this->success('删除成功');
}
/*
* desc: 报名活动详情
* time: 2023-6-29 9:03
* */
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
try {
$id = $this->request->get('id');
$apply_id = $this->request->get('apply_id');
$data = (new \app\api\model\wdsxh\activity\Activity())
->where('id',$id)
->field('id,images,start_time,end_time,name,fees,state activity_state,
contacts,mobile,
organizing_method,url,address,longitude,latitude,content,
refund,
apply_time,
activity_auth,is_verifying,verification_method,points_status,points')
->find();
if (!$data) {
$this->error('活动不存在');
}
if ($data['points_status'] == 2) {
unset($data['points']);
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityObj = (new Order())->where('apply_id',$apply_id)->find();
if (!$activityObj) {
$this->error('活动订单不存在');
}
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('wechat_id',$wechat_id)
->where('id',$activityObj['apply_id'])
->where('activity_id',$id)
->find();
if (!$activityApplyObj) {
$this->error('报名信息不存在');
}
$data['pay_state'] = $activityApplyObj['state'];
$data['apply_id'] = $apply_id;
$activityRefundObj = (new Refund())
->where('apply_id',$activityObj['apply_id'])
->where('activity_id',$id)
->where('wechat_id',$wechat_id)
->where('state','3')
->order('id desc')
->find();
$data['reject'] = $activityRefundObj ? $activityRefundObj['reject'] : '';
$activityApplyModel = new \app\api\model\wdsxh\activity\ActivityApply();
$data['apply_count'] = $activityApplyModel->where('activity_id', $id)->where('state',2)->count();
$apply_list = $activityApplyModel->where('activity_id', $id)
->where('state',2)
->alias('apply')
->order('apply.createtime desc')
->join('wdsxh_user_wechat member', 'member.id = apply.wechat_id')
->field('member.avatar member_avatar')
->limit(10)
->select();
if (!empty($apply_list)) {
foreach ($apply_list as &$v) {
$v->member_avatar = wdsxh_full_url($v->member_avatar);
}
}
$data['apply_list'] = $apply_list;
$applyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('id',$apply_id)
->where('activity_id',$id)
->where('wechat_id',$wechat_id)
->find();
$data['apply_status'] = $applyObj['state'] == 2 ? 1 : 2;
$data['is_sign_in'] = $applyObj['is_sign_in'];
$this->success('请求成功',$data);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
private function handle_custom_data($data)
{
$custom_field = array('name','mobile');
$result = array();
foreach ($data as $v) {
if (in_array($v['field'], $custom_field)) {
$result[$v['field']] = $v['value'];
}
}
return $result;
}
}

View File

@@ -0,0 +1,90 @@
<?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\activity;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class ActivityElectronicCertificate extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\activity\ActivityElectronicCertificate();
}
/**
* Desc 电子证书数据
* Create on 2024/4/9 17:52
* Create by wangyafang
*/
public function index(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$activity_id = $this->request->get('id');
if (empty($activity_id)) {
$this->error('参数错误');
}
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->get($activity_id);
if (!$activityObj) {
$this->error('活动不存在');
}
if ($activityObj['end_time'] > time()) {
$this->error('活动未结束');
}
if ($activityObj['state'] != '3') {
$this->error('活动未结束');
}
$apply_id = $this->request->get('apply_id');
if (empty($apply_id)) {
$this->error('参数错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('id',$apply_id)
->where('wechat_id',$wechat_id)
->where('activity_id',$activity_id)
->find();
if(!$activityApplyObj){
$this->error('报名信息不存在');
}
if ($activityObj['certificate_enabled'] == 1 && !empty($activityObj['certificate_data'])) {
$data = $activityObj['certificate_data'];
} else {
$data = $this->model->where('id',1)->value('data');
}
$data = json_decode($data,true);
$data['bg']['img'] = wdsxh_full_url($data['bg']['img']);
if (!empty($activityApplyObj['name'])) {
$participant = $activityApplyObj['name'];
} else {
$participant = (new UserWechat())->where('id', $activityApplyObj['wechat_id'])->value('nickname');
}
$result_data = array(
'activity_name'=>$activityObj['name'],
'participant'=>$participant,
'time'=>date('Y年m月d日',$activityObj['start_time']),
'data'=>$data,
);
$this->success('请求成功',$result_data);
}
}

View File

@@ -0,0 +1,80 @@
<?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\activity;
use app\common\controller\Api;
/**
* Class JoinConfig
* Desc 入会申请控制器
* Create on 2024/3/7 9:08
* Create by wangyafang
*/
class ActivityFieldset extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* Desc 报名字段
* Create on 2025/8/11 下午5:00
* Create by wangyafang
*/
public function field()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$activity_id = $this->request->get('id');
if (empty($activity_id)) {
$this->error('参数错误');
}
$activityFieldsetObj = (new \app\admin\model\wdsxh\activity\ActivityFieldset())
->where('activity_id',$activity_id)
->find();
if ($activityFieldsetObj) {
$fieldset = json_decode($activityFieldsetObj['json'],true);
} else {
$fieldset = array(
0 =>
array(
'show' => '1',
'required' => '1',
'type' => 'text',
'label' => '姓名',
'field' => 'name',
'option' => '请输入姓名',
),
1 =>
array(
'show' => '1',
'required' => '1',
'type' => 'number',
'label' => '手机号',
'field' => 'mobile',
'option' => '请输入你的手机号',
),
);;
}
foreach ($fieldset as $k=>$v) {
$fieldset[$k]['value'] = '';
}
$this->success('请求成功',$fieldset);
}
}

View File

@@ -0,0 +1,318 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Verifying
* Desc 活动核销
* Create on 2024/3/15 16:27
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\activity;
use addons\wdsxh\library\Encryptor;
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 Verifying extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
}
/**
* Desc 核销活动列表
* Create on 2024/3/14 17:09
* Create by wangyafang
*/
public function activity_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$where[] = ['exp',Db::raw("FIND_IN_SET($wechat_id,verifying_wechat_ids)")];
$activityModel = new \app\api\model\wdsxh\activity\Activity();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$count = $activityModel->where($where)->count();
$data = $activityModel
->where($where)
->page($page,$limit)
->field('id,name,start_time,address,images,organizing_method')
->order('id desc')
->select();
$activityController = new Activity();
foreach ($data as $k=>&$v) {
$v->week = $activityController->getTimeWeek($v['start_time']);
$v->start_time = date('m/d H:i',$v->start_time);
$images = explode(',',$v->images);
$v->images = $images[0];
}
$this->success('请求成功',['total'=>$count,'data'=>$data]);
}
/**
* @notes 扫码核销
* @author wangyafang
* @date 2024/3/15 16:46
*/
public function verifying() {
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$wechat_id = $this->request->post('wechat_id');
$activity_id = $this->request->post('activity_id');
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->get($activity_id);
if (!$activityObj) {
$this->error('活动不存在');
}
if ($activityObj['state'] == '3') {
$this->error('活动已结束,无法核销');
}
if ($activityObj['is_verifying'] == '1') {
$user_id = $this->auth->id;
$admin_wechat_id = (new UserWechat())->where('user_id',$user_id)->value('id');
$verifying_wechat_ids_array = explode(',',$activityObj['verifying_wechat_ids']);
if (!in_array($admin_wechat_id,$verifying_wechat_ids_array)) {
$this->error('不是核销管理员,请在后台活动设置为核销管理员');
}
} else {
$this->error('此活动不用核销');
}
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('wechat_id',$wechat_id)
->where('activity_id',$activity_id)
->where('state','2')
->find();
if (!$activityApplyObj) {
$this->error('没有找到报名信息或者未付款,无法核销');
}
if ($activityApplyObj['is_sign_in'] == '1') {
$this->error('已核销');
}
$activityApplyObj->is_sign_in = '1';
$activityApplyObj->save();
$this->success('核销成功');
}
/**
* @notes 核销会员列表
* @author wangyafang
* @date 2024/3/15 16:57
*/
public function verifying_member_list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$where = [];
$where['apply.activity_id'] = array('eq',$param['activity_id']);
$where['apply.is_sign_in'] = array('eq',$param['is_sign_in']);
$activityApplyModel = new \app\api\model\wdsxh\activity\ActivityApply();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$count = $activityApplyModel->alias('apply')->where($where)->count();
$order = 'apply.id desc';
//todo 活动创建后,会员功能对外功能不可用,非会员无法报名
$data = $activityApplyModel
->alias('apply')
->where($where)
->page($page,$limit)
->field('apply.is_sign_in,wechat.nickname,wechat.avatar')
->join('wdsxh_user_wechat wechat','apply.wechat_id = wechat.id')
->order($order)
->select();
foreach ($data as &$v) {
$v->avatar = wdsxh_full_url($v->avatar);
}
$this->success('请求成功',['total'=>$count,'data'=>$data]);
}
/**
* Desc 自动核销
* Create on 2025/3/8 9:34
* Create by wangyafang
*/
public function self_service_check_in()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$validate_value = $this->request->post('validate_value');
$activity_id = $this->request->post('activity_id');
$from_lng = $this->request->post('lng');
$from_lat = $this->request->post('lat');
if (empty($validate_value)) {
$this->error('validate_value参数不能为空');
}
if (empty($activity_id)) {
$this->error('activity_id参数不能为空');
}
if (empty($from_lng)) {
$this->error('纬度不能为空');
}
if (empty($from_lat)) {
$this->error('经度不能为空');
}
try {
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$activityObj = (new \app\api\model\wdsxh\activity\Activity())->get($activity_id);
if (!$activityObj) {
$this->error('活动不存在');
}
if ($activityObj['state'] == '3') {
$this->error('活动已结束,无法核销');
}
if ($activityObj['is_verifying'] == '2') {
$this->error('此活动不用核销');
}
if ($activityObj['verification_method'] != 1) {
$this->error('核销方式不是自助签到,无法核销');
}
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
->where('wechat_id',$wechat_id)
->where('activity_id',$activity_id)
->where('state','2')
->find();
if (!$activityApplyObj) {
$this->error('没有找到报名信息或者未付款,无法核销');
}
if ($activityApplyObj['is_sign_in'] == '1') {
$this->error('已核销');
}
$token_key = config('token.key');
$encryptor = new Encryptor(substr($token_key,0,16),substr($token_key,16));
if ($encryptor->encrypt($activity_id) != $validate_value) {// 验证失败,返回错误
$this->error('签到失败,请检查签到二维码是否正确');
}
$distance = $this->calculateDistance($from_lat,$from_lng,$activityObj['latitude'],$activityObj['longitude']);
if ($distance > 1000) {
$this->error('请在1000米内核销');
}
$activityApplyObj->is_sign_in = '1';
$activityApplyObj->save();
$this->success('核销成功');
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
/**
* Desc 计算距离
* Create on 2025/3/8 9:55
* Create by wangyafang
*/
private function calculateDistance($lat1, $lon1, $lat2, $lon2) {
$lat1 = floatval($lat1);
$lon1 = floatval($lon1);
$lat2 = floatval($lat2);
$lon2 = floatval($lon2);
// 验证经度和纬度是否在有效范围内
if ($lon1 < -180 || $lon1 > 180) {
$this->error('经度值不在有效范围内');
}
if ($lat1 < -90 || $lat1 > 90) {
$this->error('纬度值不在有效范围内');
}
if ($lon2 < -180 || $lon2 > 180) {
$this->error('经度值不在有效范围内');
}
if ($lat2 < -90 || $lat2 > 90) {
$this->error('纬度值不在有效范围内');
}
// 地球半径(单位:米)
$earthRadius = 6371000;
// 将纬度、经度从度转换为弧度
$latFrom = deg2rad($lat1);
$lonFrom = deg2rad($lon1);
$latTo = deg2rad($lat2);
$lonTo = deg2rad($lon2);
// 计算纬度和经度的差值
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
// 使用 Haversine 公式计算距离
$angle = 2 * asin(sqrt(
pow(sin($latDelta / 2), 2) +
cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)
));
$distance = $angle * $earthRadius;
return $distance;
}
/**
* Desc 获取核销加密数据
* Create on 2025/4/17 9:58
* Create by wangyafang
*/
public function get_decrypt_data()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$validate_value = $this->request->get('validate_value');
if (empty($validate_value)) {
$this->error('validate_value参数不能为空');
}
$token_key = config('token.key');
$encryptor = new Encryptor(substr($token_key,0,16),substr($token_key,16));
$activity_id = $validate_value = $encryptor->decrypt($validate_value);
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$apply_id = (new \app\api\model\wdsxh\activity\ActivityApply())->where('activity_id',$activity_id)->where('wechat_id',$wechat_id)->value('id');
if (!$apply_id) {
$apply_id = '';
}
$this->success('请求成功',array('activity_id'=>$validate_value,'apply_id'=>$apply_id));
}
}

View File

@@ -0,0 +1,436 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class Card
* Desc 名片控制器
* Create on 2025/1/21 16:59
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\corporate;
use app\api\model\wdsxh\corporate\Reliable;
use app\api\model\wdsxh\corporate\Visitor;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use Exception;
class Card extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\corporate\Card();
}
/**
* Desc 名片列表
* Create on 2025/1/21 17:00
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$where = [];
$where['wechat_id'] = array('eq',$wechat_id);
$order = 'is_default asc,id desc';
$data = $this->model
->where($where)
->field('id,image,share_title,is_default,font_color,card_background_image,name,avatar,
company_name,main_business,mobile,company_address,is_hide_avatar,company_position,wechat_id')
->order($order)
->select();
$memberModel = new Member();
$current_date = date('Y-m-d',time());
foreach($data as $v) {
$memberObj = $memberModel->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($memberObj) {
$v->member_level_name = $memberObj->member_level_name;
unset($memberObj);
}
$v->hidden(['wechat_id']);
}
$data = collection($data)->toArray();
$this->success('请求成功',$data);
}
/**
* Desc 添加
* Create on 2025/1/21 17:17
* Create by wangyafang
*/
public function add()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$result = $this->validate($param,'app\api\validate\wdsxh\corporate\Card');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
if (isset($param['mobile']) && !empty($param['mobile'])) {
if (!$param['mobile'] || !\think\Validate::regex($param['mobile'], "^1\d{10}$")) {
$this->error('手机号格式不正确');
}
}
$param['is_default'] = isset($param['is_default']) ? $param['is_default'] : 2;
$param['is_hide_avatar'] = isset($param['is_hide_avatar']) ? $param['is_hide_avatar'] : 2;
$param['is_wechat_number_public'] = isset($param['is_wechat_number_public']) ? $param['is_wechat_number_public'] : 2;
$param['wechat_id'] = $wechat_id;
$count = $this->model->where('wechat_id',$wechat_id)->count();
if ($count == 0) {
$param['is_default'] = 1;
} else {
$default_id = $this->model->where([
'wechat_id'=> $wechat_id,
'is_default'=>1,
])->value('id');
if($param['is_default'] == 1 && $default_id) {
$this->model->where('id',$default_id)->update([
'is_default'=>2,
]);
}
}
if (isset($_POST['company_introduction'])) {
$param['company_introduction'] = $_POST['company_introduction'];
}
if (isset($param['company_introduction']) && !empty($param['company_introduction'])) {
$param['company_introduction'] = wdsxh_xss_filter($param['company_introduction']);
}
$result = false;
Db::startTrans();
try {
$result = $this->model->allowField(true)->save($param);
$card_id = $this->model->id; // 获取刚添加数据的ID
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('提交成功', ['card_id' => $card_id]); // 返回刚添加数据的ID
}
/**
* Desc 编辑
* Create on 2025/1/21 17:18
* Create by wangyafang
*/
public function edit()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$result = $this->validate($param,'app\api\validate\wdsxh\corporate\Card');
if(true !== $result){
// 验证失败 输出错误信息
$this->error($result);
}
if (isset($param['mobile']) && !empty($param['mobile'])) {
if (!$param['mobile'] || !\think\Validate::regex($param['mobile'], "^1\d{10}$")) {
$this->error('手机号格式不正确');
}
}
$row = $this->model->where('id',$param['id'])->where('wechat_id',$wechat_id)->find();
if (!$row) {
$this->error('名片信息不存在');
}
$default_id = $this->model->where([
'wechat_id'=> $wechat_id,
'is_default'=>1,
])->where('id','<>',$param['id'])->value('id');
if($param['is_default'] == 1 && $default_id) {
$this->model->where('id',$default_id)->update([
'is_default'=>2,
]);
}
if (isset($_POST['company_introduction'])) {
$param['company_introduction'] = $_POST['company_introduction'];
}
if (isset($param['company_introduction']) && !empty($param['company_introduction'])) {
$param['company_introduction'] = wdsxh_xss_filter($param['company_introduction']);
}
$param['updatetime'] = time();
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($param);
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/1/21 17:18
* Create by wangyafang
*/
public function details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$data = $this->model
->where('id',$id)
->field('id,name,company_position,company_name,main_business,mobile,company_address,
avatar,company_introduction,
is_hide_avatar,is_wechat_number_public,wechat_number,image,card_background_image,font_color')
->find();
if (!$data) {
$this->error('名片不存在');
}
if ($data['is_hide_avatar'] == '1') {
$data['avatar'] = '';
}
if ($data['is_wechat_number_public'] == '2') {
$data['wechat_number'] = '';
}
$visitorObj = (new Visitor())->where('wechat_id', $wechat_id)->where('card_id', $id)->find();
if ($visitorObj) {
$visitorObj->createtime = time();
$visitorObj->save();
} else {
$visitor_data = array(
'wechat_id' => $wechat_id,
'card_id' => $id,
'createtime' => time(),
);
Visitor::create($visitor_data);
}
$visitor_list = (new Visitor())->where('visitor.card_id', $id)
->alias('visitor')
->order('visitor.createtime desc')
->join('wdsxh_user_wechat wechat', 'wechat.id = visitor.wechat_id')
->field('wechat.avatar')
->limit(23)
->select();
if (!empty($visitor_list)) {
foreach ($visitor_list as &$v) {
$v->avatar = wdsxh_full_url($v->avatar);
}
}
$data['visitor_list'] = $visitor_list;
$data['visitor_count'] = (new Visitor())->where('card_id', $id)->count();
$reliableObj = (new Reliable())->where('card_id', $id)
->where('wechat_id',$wechat_id)
->find();
$data['reliable_status'] = !empty($reliableObj) ? 1 : 2;
$current_date = date('Y-m-d',time());
$memberObj = (new Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
if ($memberObj) {
$data['member_level_name'] = $memberObj->member_level_name;
unset($memberObj);
}
$this->success('请求成功',$data);
}
/**
* Desc 编辑详情
* Create on 2025/1/22 10:58
* Create by wangyafang
*/
public function edit_details()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$data = $this->model
->where('id',$id)
->where('wechat_id', $wechat_id)
->find();
if (empty($data)) {
$this->error('名片不存在');
}
$data->hidden(['wechat_id','company_lat','company_lng','image','createtime','updatetime']);
$this->success('请求成功',$data);
}
/**
* Desc 设置默认
* Create on 2025/1/22 11:41
* Create by wangyafang
*/
public function set_default()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
if (!isset($param['is_default'])) {
$this->error('参数错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$row = $this->model->where('id',$param['id'])->where('wechat_id',$wechat_id)->find();
if (!$row) {
$this->error('名片信息不存在');
}
$default_id = $this->model->where([
'wechat_id'=> $wechat_id,
'is_default'=>1,
])->where('id','<>',$param['id'])->value('id');
if($param['is_default'] == 1 && $default_id) {
$this->model->where('id',$default_id)->update([
'is_default'=>2,
]);
}
$result = false;
Db::startTrans();
try {
$result = $row->allowField(true)->save($param);
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/1/22 11:53
* Create by wangyafang
*/
public function center()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$visitorModel = new Visitor();
$cart_id_array = $this->model->where('wechat_id',$wechat_id)->column('id');
$total_count = $visitorModel
->where('card_id','in',$cart_id_array)
->count();
$today_count = $visitorModel
->where('card_id','in',$cart_id_array)
->whereTime('createtime', 'today')
->count();
$data = array(
'total_count'=>$total_count,
'today_count'=>$today_count,
);
$this->success('请求成功',$data);
}
/**
* Desc 默认名片
* Create on 2025/1/22 14:07
* Create by wangyafang
*/
public function default_card()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$data = $this->model->where('wechat_id',$wechat_id)->where('is_default',1)->field('id,image,share_title')->find();
$this->success('请求成功',$data);
}
/**
* Desc 删除
* Create on 2025/1/23 9:28
* Create by wangyafang
*/
public function del()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$ids = $this->request->post('ids');
if (empty($ids)) {
$this->error('参数错误');
}
$idsArray = explode(',',$ids);
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$result = false;
Db::startTrans();
try {
$result = $this->model->where('id','in',$idsArray)->where('wechat_id',$wechat_id)->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result == false) {
$this->error('删除失败');
}
$this->success('删除成功');
}
}

View File

@@ -0,0 +1,62 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class CardBackground
* Desc 名片背景控制器
* Create on 2025/1/21 16:59
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\corporate;
use app\common\controller\Api;
class CardBackground extends Api
{
protected $noNeedLogin = ['index','font_color'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\corporate\CardBackground();
}
/**
* Desc 背景列表
* Create on 2025/1/21 17:00
* Create by wangyafang
*/
public function index()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$where = [];
$where['status'] = array('eq','normal');
$order = 'weigh desc,id desc';
$data = $this->model
->where($where)
->field('id,image,font_color')
->order($order)
->select();
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,118 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class Reliable
* Desc 名片靠谱控制器
* Create on 2025/1/22 14:33
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\corporate;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use Exception;
class Reliable extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\corporate\Reliable();
}
/**
* Desc 靠谱
* Create on 2025/1/22 14:40
* Create by wangyafang
*/
public function reliable()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$card_id = $this->request->post('card_id');
if (empty($card_id)) {
$this->error('名片ID不能为空');
}
$reliableObj = $this->model->where('wechat_id',$wechat_id)->where('card_id',$card_id)->find();
if($reliableObj) {
$this->error('已点击');
}
$result = false;
Db::startTrans();
try {
$result = $this->model->allowField(true)->save(array(
'card_id'=>$card_id,
'wechat_id'=>$wechat_id,
));
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/1/22 15:05
* Create by wangyafang
*/
public function cancel()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$card_id = $this->request->post('card_id');
if (empty($card_id)) {
$this->error('名片ID不能为空');
}
$reliableObj = $this->model->where('wechat_id',$wechat_id)->where('card_id',$card_id)->find();
if(!$reliableObj) {
$this->error('已取消');
}
$result = false;
Db::startTrans();
try {
$result = $reliableObj->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('取消成功');
}
}

View File

@@ -0,0 +1,223 @@
<?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\goods;
use app\api\model\wdsxh\user\Wechat;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
class Address extends Api
{
protected $noNeedLogin = ['address_province','address_city','address_area'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\goods\Address();
}
/**
* Desc 地址列表
* Create on 2024/3/15 15:25
* Create by @小趴菜
*/
public function index()
{
$param = $this->request->param();
//查询默认地址
if(isset($param['is_default']) && !empty($param['is_default'])) {
$where['is_default'] = array('eq',$param['is_default']);
}
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$where['wechat_id'] = array('eq',$wechat_id);
$data = $this->model
->where($where)
->field('id,name,tel,address,is_default')
->select();
$this->success('请求成功',$data);
}
/**
* Desc 地址列表
* Create on 2024/3/15 15:39
* Create by @小趴菜
*/
public function add(){
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$default_id = $this->model->where([
'wechat_id'=>$wechat_id,
'is_default'=>1,
])->value('id');
if($param['is_default'] == 1 && $default_id) {
Db::name('wdsxh_mall_user_address')->where('id',$default_id)->update([
'is_default'=>0,
]);
}
Db::startTrans();
try{
Db::name('wdsxh_mall_user_address')->insert([
'wechat_id'=>$wechat_id,
'name'=>$param['name'],
'tel' =>$param['tel'],
'address'=>$param['address'],
'is_default'=>$param['is_default'] == true ? 1 : 0,
'createtime'=>time(),
]);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('操作成功');
}
/**
* Desc 修改地址
* Create on 2024/3/15 15:46
* Create by @小趴菜
*/
public function edit(){
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
if($param['is_default'] == true) {
Db::name('wdsxh_mall_user_address')
->where('wechat_id',$wechat_id)
->update([
'is_default'=>0,
]);
}
Db::startTrans();
try{
Db::name('wdsxh_mall_user_address')
->where('id',$param['id'])
->update([
'name'=>$param['name'],
'tel' =>$param['tel'],
'address'=>$param['address'],
'is_default'=>$param['is_default'] == true ? 1 : 0,
'updatetime'=>time(),
]);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('操作成功');
}
/**
* Desc 删除地址
* Create on 2024/3/15 15:54
* Create by @小趴菜
*/
public function del()
{
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
$userAddressObj = $this->model
->where('id',$this->request->param('id'))
->where('wechat_id',$wechat_id)
->find();
$userAddressObj->delete();
$this->success('删除成功');
}
/**
* Desc 修改默认地址
* Create on 2024/3/15 15:56
* Create by @小趴菜
*/
public function set_default()
{
$id = $this->request->param('id');
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
Db::startTrans();
try{
Db::name('wdsxh_mall_user_address')
->where('wechat_id',$wechat_id)
->update([
'is_default'=>0,
]);
Db::name('wdsxh_mall_user_address')
->where('id',$id)
->update([
'is_default'=>1,
]);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('操作成功');
}
//省
public function address_province(){
$total = Db::name('wdsxh_area')
->where('level',1)
->count();
$data = Db::name('wdsxh_area')
->where('level',1)
->field('id,name')
->select();
$this->success('请求成功',['total'=>$total,'data'=>$data]);
}
//市
public function address_city(){
$param = $this->request->param();
$total = Db::name('wdsxh_area')
->where('level',2)
->where('pid',$param['crea_id'])
->count();
$data = Db::name('wdsxh_area')
->where('level',2)
->where('pid',$param['crea_id'])
->field('id,name')
->select();
$this->success('请求成功',['total'=>$total,'data'=>$data]);
}
//区
public function address_area(){
$param = $this->request->param();
$total = Db::name('wdsxh_area')
->where('level',3)
->where('pid',$param['crea_id'])
->count();
$data = Db::name('wdsxh_area')
->where('level',3)
->where('pid',$param['crea_id'])
->field('id,name')
->select();
$this->success('请求成功',['total'=>$total,'data'=>$data]);
}
}

View File

@@ -0,0 +1,156 @@
<?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\goods;
use app\api\model\wdsxh\goods\Banner;
use app\api\model\wdsxh\goods\SingleCategory;
use app\common\controller\Api;
class Goods extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $categoryModel = null;
protected $bannerModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\goods\Goods();
$this->categoryModel = new SingleCategory();
$this->bannerModel = new Banner();
}
/**
* Desc 商品列表
* Create on 2024/3/13 16:23
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
//分类id
if(isset($param['category_id']) && !empty($param['category_id'])) {
$pid = (new SingleCategory())->where('id',$param['category_id'])->value('pid');
if ($pid == 0) {
$childCategoryIdArray = (new SingleCategory())->where('pid',$param['category_id'])->column('id');
array_push($childCategoryIdArray,$param['category_id']);
$where['category_id'] = array('in',$childCategoryIdArray);
} else {
$where['category_id'] = array('eq',$param['category_id']);
}
}
if(isset($param['keywords']) && !empty($param['keywords'])) {
$where['name'] = array('like','%'.$param['keywords'].'%');
}
//是否热销:1=是,0=否
if(isset($param['is_hot']) && !empty($param['is_hot'])) {
$where['is_hot'] = array('eq',$param['is_hot']);
}
$where['status'] = array('eq','normal');
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,name,image,recommend_image,price')
->page($page,$limit)
->order('weigh desc,createtime desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 商品详情
* Create on 2024/3/13 16:43
* Create by @小趴菜
*/
public function details(){
$param = $this->request->param();
$where = [];
$where['id'] = array('eq',$param['id']);
$data = $this->model
->where($where)
->field('id,name,slider_images,price,ot_price,param_json,content,image')
->find();
$this->success('请求成功',$data);
}
/**
* Desc 商品分类
* Create on 2024/3/13 17:32
* Create by @小趴菜
*/
public function category_index(){
$where = [];
$where['status'] = array('eq',1);
$where['pid'] = array('eq',0);
$data = $this->categoryModel
->where($where)
->field('id,name,image')
->order('weigh desc,createtime desc')
->select();
foreach ($data as &$v) {
$v['child'] = $this->categoryModel
->where('pid',$v['id'])
->where('status',1)
->field('id,name,image')
->order('weigh desc,createtime desc')
->select();
}
$this->success('请求成功',$data);
}
/**
* Desc 商城轮播图
* Create on 2024/3/13 17:58
* Create by @小趴菜
*/
public function banner_index(){
$where = [];
$where['status'] = array('eq',1);
$data = $this->bannerModel
->where($where)
->field('id,title,image,jump_type,content,jump_link')
->order('weigh desc,createtime desc')
->select();
if($data){
$list=collection($data)->toArray();
foreach ($list as &$row){
$row['image']=wdsxh_full_url($row['image']);
if($row['jump_type'] == 2){
$row['content']=json_decode($row['content'],true);
}
}
}
$this->success('请求成功', $data);
}
/**
* Desc 商城轮播图详情
* Create on 2024/4/2 11:42
* Create by @小趴菜
*/
public function banner_details(){
$param = $this->request->param();
$data = $this->bannerModel
->where('id',$param['id'])
->field('id,title,content')
->find();
$this->success('请求成功', $data);
}
}

View File

@@ -0,0 +1,688 @@
<?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\goods;
use addons\wdsxh\library\Wxapp;
use app\admin\model\wdsxh\mall\Logistics;
use app\api\model\wdsxh\goods\FreightRules;
use app\api\model\wdsxh\goods\Refund;
use app\api\model\wdsxh\mall\Cart;
use app\api\model\wdsxh\mall\OrderItem;
use app\api\model\wdsxh\user\Wechat;
use app\common\controller\Api;
use think\Db;
use Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\Log;
class Order extends Api
{
protected $noNeedLogin = ['postage','payResult'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $rulesModel = null;
protected $refundModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\goods\Order();
$this->rulesModel = new FreightRules();
$this->refundModel = new Refund();
}
/**
* Desc 创建订单
* Create on 2024/3/14 08:38
* Create by @小趴菜
*/
public function create(){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$buy_now = isset($param['buy_now']) ? $param['buy_now'] : 1;
//查询用户id
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$param['wechat_id'] = $wechat_id;//用户id
$delivery_method = isset($param['delivery_method']) ? $param['delivery_method'] : 1;
if ($delivery_method == 1 && empty($param['address_id'])) {
$this->error('请选择地址');
}
if (isset($param['address_id']) && !empty($param['address_id'])) {
//查询用户收货地址
$address = (new \app\api\model\wdsxh\goods\Address())->where('id',$param['address_id'])->find();
$param['real_name'] = $address['name'];//用户名称
$param['user_phone'] = $address['tel'];//手机号
$param['user_address'] = $address['address'];//详细地址
}
if ($buy_now == 1) {
$goods_price = (new \app\api\model\wdsxh\goods\Goods())->where('id',$param['goods_id'])->value('price');
if ($param['delivery_method'] == 1) {
//查询商品价格
$pay_price_number = bcmul($goods_price,$param['number'],2);
//计算邮费
$postage = $this->rulesModel
->where('min','<=',$pay_price_number)
->where('max','>=',$pay_price_number)
->value('price');
//如果不在配送范围之内,邮费将会返回0
if (!$postage){
$postage = 0;
}
} else {
$postage = 0;
}
$param['number'] = isset($param['number']) ? $param['number'] : 1;
$param['goods_price'] = $goods_price;
$param['pay_postage'] = $postage;//支付邮费
$param['pay_price'] = bcmul($goods_price,$param['number'],2) + $postage;//实际支付金额
$param['total_price'] = $param['pay_price'];//订单总价
$param['order_no'] = wdsxh_create_order();//订单号
$param['refund_status'] = 1;
$param['paid'] = 1;
$param['createtime'] = time();
$param['delivery_method'] = $delivery_method;
$result = false;
Db::startTrans();
try {
$result = $this->model->allowField(true)->save($param);
$order_id = $this->model->id; // 获取刚添加数据的ID
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('提交成功', ['order_id' => $order_id]); // 返回刚添加数据的ID
} else {//购物车
$goods_id_array = explode(',',$param['goods_id']);
$cartModel = new Cart();
$cartList = $cartModel->where('goods_id','in',$goods_id_array)
->where('wechat_id',$wechat_id)
->select();
if (empty($cartList)) {
$this->error('购物车数据不存在');
}
if (count($goods_id_array) != count($cartList)) {
$this->error('购物车数量不对');
}
$all_goods_total_price = 0;//排除运费,商品总价格
$order_item_data = array();
foreach ($cartList as $v) {
$goodsObj = (new \app\api\model\wdsxh\goods\Goods())->where('id',$v['goods_id'])->find();
$pay_price = bcmul($goodsObj['price'],$v['goods_num'],2);
$all_goods_total_price = $all_goods_total_price + $pay_price;
$order_item_data[] = array(
'goods_id'=>$v['goods_id'],
'goods_num'=>$v['goods_num'],
'goods_name'=>$goodsObj['name'],
'goods_image'=>$goodsObj['image'],
'goods_price'=>$goodsObj['price'],
'pay_price'=>$pay_price,
);
}
if ($param['delivery_method'] == 1) {
//计算邮费
$postage = $this->rulesModel
->where('min','<=',$all_goods_total_price)
->where('max','>=',$all_goods_total_price)
->value('price');
//如果不在配送范围之内,邮费将会返回0
if (!$postage){
$postage = 0;
}
} else {
$postage = 0;
}
$param['number'] = $cartModel->where('goods_id','in',$goods_id_array)
->where('wechat_id',$wechat_id)
->sum('goods_num');
$param['goods_price'] = $all_goods_total_price;
$param['pay_postage'] = $postage;//支付邮费
$param['pay_price'] = $all_goods_total_price + $postage;//实际支付金额
$param['total_price'] = $param['pay_price'];//订单总价
$param['order_no'] = wdsxh_create_order();//订单号
$param['refund_status'] = 1;
$param['paid'] = 1;
$param['createtime'] = time();
$param['delivery_method'] = $delivery_method;
$result = false;
Db::startTrans();
try {
$result = $this->model->allowField(true)->save($param);
$order_id = $this->model->id; // 获取刚添加数据的ID
// 使用 array_map 给每个元素追加 order_id
$order_item_data = array_map(function($item) use ($order_id) {
$item['order_id'] = $order_id;
return $item;
}, $order_item_data);
(new OrderItem())->saveAll($order_item_data);
$cartModel->where('goods_id','in',$goods_id_array)
->where('wechat_id',$wechat_id)->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('提交成功', ['order_id' => $order_id]); // 返回刚添加数据的ID
}
}
/**
* Desc 订单列表
* Create on 2024/3/13 16:23
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$user_id = $this->auth->id;
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
//状态:1=待付款,2=待发货,3=待收货,5=支付失败,4=已完成,6=已取消,-1=退款中,-2=已退款
if(isset($param['state']) && !empty($param['state'])) {
$where['state'] = array('eq',$param['state']);
}
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$where['refund_status'] = array('eq',1);
$where['wechat_id'] = array('eq',$wechat_id);
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,order_no,state,pay_price,number,trade_no,buy_now,
delivery_method')
->page($page,$limit)
->order('createtime desc')
->select();
$orderItemModel = new OrderItem();
foreach ($data as $row){
if ($row['buy_now'] == '1') {
$goods = $this->model
->alias('mall_order')
->join('wdsxh_mall_goods goods','goods.id = mall_order.goods_id')
->where('mall_order.wechat_id',$wechat_id)
->where('mall_order.id',$row['id'])
->field('goods.id,goods.image,goods.name')
->select();
} else {
$goods = $orderItemModel
->alias('order_item')
->join('wdsxh_mall_goods goods','goods.id = order_item.goods_id')
->where('order_item.order_id',$row['id'])
->field('goods.id,goods.image,goods.name')
->select();
foreach ($goods as &$vv) {
$vv->image = wdsxh_full_url($vv->image);
}
}
$row->goods = $goods;
$row->hidden(['buy_now']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 计算邮费
* Create on 2024/3/15 13:55
* Create by @小趴菜
*/
public function postage(){
$param = $this->request->param();
$where_query = array();
if (isset($param['address_id']) && !empty($param['address_id'])) {
$address_id = $param['address_id'];
$address = (new \app\api\model\wdsxh\goods\Address())->where('id',$address_id)->value('address');
// 正则表达式匹配省、直辖市、自治区、特别行政区
preg_match('/^(.*?(省|自治区|市|香港|澳门))/u', $address, $matches);
if (!empty($matches)) {
$province = $matches[0]; // 截取到的省、直辖市、自治区、特别行政区
$where_query[] = ['exp',Db::raw("FIND_IN_SET('$province',open_area)")];
}
}
$postage = $this->rulesModel
->where('min','<=',$param['pay_price'])
->where('max','>=',$param['pay_price'])
->where($where_query)
->value('price');
if (!$postage){
$postage = 0;
}
$this->success('请求成功',['price' =>$postage]);
}
/**
* Desc 订单详情
* Create on 2024/3/15 14:22
* Create by @小趴菜
*/
public function details(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$order_no = $this->request->get('order_no');
$id = $this->request->get('id');
if (!$order_no && !$id) {
$this->error('参数错误');
}
if ($id) {
$where['id'] = array('eq',$id);
}
if ($order_no) {
$where['order_no'] = array('eq',$order_no);
}
$row = $this->model
->where($where)
->field('id,order_no,real_name,user_phone,
user_address,total_price,
pay_postage,state,refund_status,
number,
trade_no,
buy_now,
delivery_method,pick_up_code')
->find();
if (!$row) {
$this->error('订单不存在');
}
$orderItemModel = new OrderItem();
if ($row['buy_now'] == '1') {
$goods = $this->model
->alias('mall_order')
->join('wdsxh_mall_goods goods','goods.id = mall_order.goods_id')
->where('mall_order.id',$row['id'])
->field('goods.image,goods.name,mall_order.goods_price,number goods_num')
->select();
} else {
$goods = $orderItemModel
->alias('order_item')
->join('wdsxh_mall_goods goods','goods.id = order_item.goods_id')
->where('order_item.order_id',$row['id'])
->field('goods.image,goods.name,order_item.goods_price,goods_num')
->select();
foreach ($goods as &$vv) {
$vv->image = wdsxh_full_url($vv->image);
}
}
$row->goods = $goods;
unset($row['buy_now']);
$row['refund_reason'] = (new Refund())->where('order_id',$row['id'])->value('refund_reason');
if ($row['delivery_method'] == 1) {
unset($row['pick_up_code']);
} else {
unset($row['real_name']);
unset($row['real_name']);
unset($row['real_name']);
if (!in_array($row['state'],['2','3','4'])) {
unset($row['pick_up_code']);
}
}
$this->success('请求成功',$row);
}
/**
* Desc 订单预支付
* Create on 2024/3/15 16:23
* Create by @小趴菜
*/
public function prepare_pay()
{
$channel = $this->request->header('channel');
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$openid = wdsxh_get_openid($wechat_id,$channel);
$orderObj = $this->model
->where('id',$param['order_id'])
->field('order_no,pay_price')
->find();
if (!$orderObj) {
$this->error('订单不存在');
}
$order_no = wdsxh_create_order();
$orderObj->order_no = $order_no;
$orderObj->save();
try{
//微信小程序支付
if ($channel == 1){
$data=\addons\wdsxh\library\Wxapp::unify('商城商品购买',$orderObj->order_no,$orderObj->pay_price,$openid,request()->domain().'/api/wdsxh/goods/order/payresult');
} else {
$data=\addons\wdsxh\library\Wxapp::unify_wxofficial('商城商品购买',$orderObj->order_no,$orderObj->pay_price,$openid,request()->domain().'/api/wdsxh/goods/order/payresult');
}
}catch (\think\Exception $e){
$this->error($e->getMessage());
}
$this->success('success',$data);
}
/**
* Desc 订单支付回调
* Create on 2024/3/15 17:40
* Create by @小趴菜
*/
public function payResult(){
$pay=Wxapp::getPay();
$response = $pay->handlePaidNotify(function($message, $fail){
Log::record($message['out_trade_no'],'logeuas');
$order =$this->model->where('order_no',$message['out_trade_no'])->find();
if (!$order || $order->state == '2') {
return true;
}
if ($order['delivery_method'] == 2) {
// 生成唯一的6位随机数字
do {
$pickUpCode = mt_rand(100000, 999999); // 生成6位随机数
$exists = $this->model->where('pick_up_code', $pickUpCode)->count(); // 检查数据库中是否已存在该pick_up_code
} while ($exists > 0); // 如果该pick_up_code已经存在重新生成
$order->pick_up_code = $pickUpCode;
}
Db::startTrans();
try {
$order->pay_time = time();
$order->state = '2';
$order->paid = '2';
$order->trade_no = $message['transaction_id'];
$order->save();
Db::commit();
} catch (\think\Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
return true;
});
$response->send();
}
/**
* Desc 确认收货
* Create on 2024/3/15 17:48
* Create by @小趴菜
*/
public function sing(){
$param = $this->request->param();
Db::startTrans();
try{
$this->model->allowField(true)
->where('id',$param['id'])
->update([
'state' => 4,
'complete_time'=>time(),
]);
(new Logistics())->allowField(true)
->where('order_id',$param['id'])
->update([
'receive_time' => time(),
]);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('确认收货成功');
}
/**
* Desc 申请退款
* Create on 2024/3/18 11:59
* Create by @小趴菜
*/
public function refund(){
$param = $this->request->param();
$user_id = $this->auth->id;
//查询用户wechat_id
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$refundObj = (new Refund())->where('order_id',$param['order_id'])->where('wechat_id',$wechat_id)->find();
if ($refundObj){
$this->error('你已提交退款申请,请勿重复提交,请等待管理员同意退款申请');
}
$orderModel = (new \app\api\model\wdsxh\goods\Order())->where('id', $param['order_id'])->find();
$refund_reason = '退款原因:' . $param['refund_reason'] . ',' . '退款详情:' . $param['refund_content'];
if ($orderModel['state'] == '2') {
$refundSn=wdsxh_create_order();
$res=\addons\wdsxh\library\Wxapp::payRefund($orderModel['order_no'],$refundSn,$orderModel['pay_price'],array('refund_desc'=>'退款'));
if($res && $res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){
Db::startTrans();
try {
(new \app\api\model\wdsxh\goods\Order())
->where('id', $param['order_id'])
->update([
'state' =>'-2',
'refund_status' => '5',
'complete_time'=>time(),
]);
$result = (new \app\admin\model\wdsxh\mall\Refund())->insert([
'order_id' => $orderModel['id'],//订单id
'refund_price' => $orderModel['pay_price'],//退款金额
'refund_reason' => $refund_reason,//退款用户说明
'state' => $orderModel['state'],//退款前状态
'wechat_id' => $wechat_id,//用户id
'createtime' => time(),//创建时间
'refund_time' => time(),//退款时间
]);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(false === $result){
$this->error($this->model->getError());
}
$this->success('退款成功');
}else{
$this->error('退款失败,错误信息:'.$res['err_code_des']);
}
}
$result = false;
Db::startTrans();
try {
(new \app\api\model\wdsxh\goods\Order())
->where('id', $param['order_id'])
->update([
'state' =>'-1',
'refund_status' => '2',
]);
$result = (new \app\admin\model\wdsxh\mall\Refund())->insert([
'order_id' => $orderModel['id'],//订单id
'refund_price' => $orderModel['pay_price'],//退款金额
'refund_reason' => $refund_reason,//退款用户说明
'state' => $orderModel['state'],//退款前状态
'wechat_id' => $wechat_id,//用户id
'createtime' => time(),//创建时间
'refund_time' => time(),//退款时间
]);
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 2024/3/18 15:46
* Create by @小趴菜
*/
public function receipt(){
$param = $this->request->param();
Db::startTrans();
try{
(new \app\admin\model\wdsxh\mall\Refund())->allowField(true)
->where('order_id',$param['order_id'])
->update([
'refund_express_no' =>$param['refund_express_no'],//快递单号
'add_express_no_time' => time(),//添加单号时间
]);
(new \app\api\model\wdsxh\goods\Order())->allowField(true)
->where('id', $param['order_id'])
->update([
'refund_status' => '4',
]);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('请求成功');
}
/**
* Desc 退款列表
* Create on 2024/3/13 16:23
* Create by @小趴菜
*/
public function refund_index(){
$param = $this->request->param();
$user_id = $this->auth->id;
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
//退款状态:1=未退款,2=申请中,3=待退货,4=退款中,5=已退款'
if(isset($param['refund_status']) && !empty($param['refund_status'])) {
$where['order.refund_status'] = array('not in',1);
$where['order.refund_status'] = array('eq',$param['refund_status']);
}
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$where['order.wechat_id'] = array('eq',$wechat_id);
$total =(new Refund())
->alias('refund')
->join('wdsxh_mall_order order','order.id = refund.order_id')
->where($where)->count();
$data = (new Refund())
->alias('refund')
->join('wdsxh_mall_order order','order.id = refund.order_id')
->where($where)
->field('order.id,order.order_no,order.goods_id,order.refund_status,order.pay_price,order.number,
buy_now')
->page($page,$limit)
->order('order.createtime desc')
->select();
$orderItemModel = new OrderItem();
foreach ($data as $row){
if ($row['buy_now'] == '1') {
$goods = $this->model
->alias('mall_order')
->join('wdsxh_mall_goods goods','goods.id = mall_order.goods_id')
->where('mall_order.wechat_id',$wechat_id)
->where('mall_order.id',$row['id'])
->field('goods.id,goods.image,goods.name')
->select();
} else {
$goods = $orderItemModel
->alias('order_item')
->join('wdsxh_mall_goods goods','goods.id = order_item.goods_id')
->where('order_item.order_id',$row['id'])
->field('goods.id,goods.image,goods.name')
->select();
foreach ($goods as &$vv) {
$vv->image = wdsxh_full_url($vv->image);
}
}
$row->goods = $goods;
$row->hidden(['buy_now']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 取消退款
* Create on 2024/3/20 15:50
* Create by @小趴菜
*/
public function cancel_refund(){
$param = $this->request->post();
$row = $this->refundModel->where('order_id',$param['id'])->find();
Db::startTrans();
try{
$params['refund_status'] = 1;
$params['state'] = $row['state'];
(new \app\admin\model\wdsxh\mall\Order())->allowField(true)->where('id',$row['order_id'])->update($params);
$row->delete();
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('取消成功');
}
/**
* Desc 取消订单
* Create on 2024/4/10 14:19
* Create by @小趴菜
*/
public function del_order(){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$orderObj = $this->model->where('wechat_id',$wechat_id)->where('id',$param['order_id'])->find();
if (!$orderObj) {
$this->error('订单不存在');
}
if ($orderObj['state'] != '1') {
$this->error('订单不是待付款,无法删除');
}
Db::startTrans();
try{
$orderObj->delete();
(new OrderItem())->allowField(true)->where('order_id',$param['order_id'])->delete();
// 提交事务
Db::commit();
} catch (ValidateException|PDOException|\think\Exception $e) {
// 回滚事务
Db::rollback();
$this->error($e->getMessage());
}
$this->success('取消成功');
}
}

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());
}
}
}

View File

@@ -0,0 +1,241 @@
<?php
/**
* Class Cart
* Desc 购物车
* Create on 2022/10/11 11:33
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\mall;
use app\api\model\wdsxh\goods\Goods;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Cart extends Api
{
protected $noNeedLogin = [''];
// 无需鉴权的接口,*表示全部
protected $noNeedRight = ['*'];
protected $model = '';
protected $wechat_id = '';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\mall\Cart();
$this->wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
}
//加入购物车
//param:token goods_id
public function add()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$user_id = $this->auth->id;
$goods_id = $this->request->post('goods_id');
if (!$goods_id) {
$this->error('参数错误');
}
$number = $this->request->post('number');
if (!$number) {
$this->error('参数错误');
}
if (!filter_var($number, FILTER_VALIDATE_INT)) {
$this->error('数量格式不正确');
}
if ($number <= 0) {
$this->error('数量不能小于0');
}
//判断商品是否已下架
$goodsObj = (new Goods())->where('id',$goods_id)->field('status,name,image,price')->find();
if (!$goodsObj) {
$this->error('商品不存在');
}
if ($goodsObj['status'] == 'hidden') {
$this->error('商品已下架');
}
//判断用户是否已加入购物车
$cartWhere['wechat_id'] = array('eq',$this->wechat_id);
$cartWhere['goods_id'] = array('eq',$goods_id);
$cartObj = $this->model->where($cartWhere)->find();
if ($cartObj) {
$goods_num = $handle_data['goods_num'] = $cartObj['goods_num'] + $number;
} else {
$goods_num = $handle_data['goods_num'] = $number;
}
$handle_data['user_id'] = $user_id;
$handle_data['wechat_id'] = $this->wechat_id;
$handle_data['goods_id'] = $goods_id;
$handle_data['buy_now'] = 2;
$handle_data['goods_name'] = $goodsObj['name'];
$handle_data['goods_image'] = $goodsObj['image'];
$handle_data['goods_price'] = $goodsObj['price'];
try {
if (!$cartObj) {
$this->model->allowField(true)->save($handle_data);
} else {
$cartObj->save(['goods_num'=>$goods_num]);
}
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$goods_id = $this->model->where('wechat_id',$this->wechat_id)
->group('goods_id')
->column('goods_id');
$number = count($goods_id);
$this->success('加入购物车成功',array('number'=>$number));
}
//购物车列表
//param:token
public function list()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$cartWhere['wechat_id'] = array('eq',$this->wechat_id);
$cartWhere['buy_now'] = array('eq','2');
$data = $this->model
->where($cartWhere)
->order('createtime desc,id desc')
->field('goods_id id,goods_num number,
goods_name,goods_image,goods_price')
->select();
$goodsModel = new Goods();
foreach ($data as &$v) {
$goodsObj = $goodsModel->where('id',$v['id'])
->where('status','normal')
->find();
if ($goodsObj) {
$v->goods_status = 1;
$v->name = $goodsObj['name'];
$v->image = $goodsObj['image'];
$v->price = $goodsObj['price'];
unset($goodsObj);
unset($v['goods_name']);
unset($v['goods_image']);
unset($v['goods_price']);
} else {
$v->goods_status = 2;
$v->name = $v['goods_name'];
$v->image = $v['goods_image'];
$v->price = $v['goods_price'];
unset($v['goods_name']);
unset($v['goods_image']);
unset($v['goods_price']);
}
}
$this->success('请求成功',$data);
}
//清除购物车
//param:token ids列表id
public function del()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$goods_id = $this->request->post('goods_id');
if (!$goods_id) {
$this->error('参数错误');
}
$goods_id_array = explode(',',$goods_id);
$delete_count = $this->model
->where('wechat_id',$this->wechat_id)
->where('goods_id', 'in', $goods_id_array)
->count();
if (count($goods_id_array) != $delete_count) {
$this->error('数量错误');
}
$count = 0;
try {
$count = $this->model
->where('wechat_id',$this->wechat_id)
->where('goods_id', 'in', $goods_id_array)
->delete();
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error('删除失败');
}
}
/**
* Desc 更新商品数量
* Create on 2025/4/14 14:17
* Create by wangyafang
*/
public function update_goods_number()
{
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$goods_id = $this->request->post('goods_id');
if (!$goods_id) {
$this->error('参数错误');
}
$number = $this->request->post('number');
if (!$number) {
$this->error('参数错误');
}
if (!filter_var($number, FILTER_VALIDATE_INT)) {
$this->error('数量格式不正确');
}
if ($number <= 0) {
$this->error('数量不能小于0');
}
$cartWhere['wechat_id'] = array('eq',$this->wechat_id);
$cartWhere['goods_id'] = array('eq',$goods_id);
$cartObj = $this->model->where($cartWhere)->find();
if (!$cartObj) {
$this->error('没有查到购物车数据');
}
$cartObj->goods_num = $number;
$cartObj->save();
$this->success('操作成功');
}
/**
* Desc 购物车商品数量
* Create on 2025/4/15 10:14
* Create by wangyafang
*/
public function cart_goods_number()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$goods_id = $this->model->where('wechat_id',$this->wechat_id)
->group('goods_id')
->column('goods_id');
$number = count($goods_id);
if (!$number) {
$number = 0;
}
$this->success('请求成功',array('number'=>$number));
}
}

View File

@@ -0,0 +1,90 @@
<?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\mall;
use addons\wdsxh\library\Wxapp;
use app\common\controller\Api;
class ConfirmReceiptMessage extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\mall\ConfirmReceiptMessage();
}
/**
* Desc 发送确认收货消息提醒 5天未确认收货发送消息提醒
* Create on 2025/8/15 下午1:40
* Create by wangyafang
*/
public function send_confirm_receipt_message()
{
$orderModel = new \app\api\model\wdsxh\goods\Order();
$order_id_array = $orderModel->alias('order')
->join('wdsxh_mall_order_logistics logistics', 'logistics.order_id = order.id')
->where('order.state', '3')
->where('order.paid', '2')
->where('order.delivery_method', 1)
->where('logistics.send_time', '<', time() - 86400 * 5)
->where('order.id','not in', $this->model
->column('order_id'))
->column('order.id');
if (!empty($order_id_array)) {
$conf = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
foreach (array_slice($order_id_array, 0, 10) as $v) {
$this->message($v,$conf['applet_confirm_receipt_notification'],$orderModel);
}
}
echo 'success:'.date('Y-m-d H:i:s',time());
}
private function message($order_id,$applet_confirm_receipt_notification,$orderModel) {
$orderObj = $orderModel
->where('id', $order_id)
->find();
//确认收货通知
$data = [
'character_string2' => [
'value' => $orderObj['order_no'],//订单号
],
'amount3' => [
'value' => $orderObj['pay_price'].'元',//付款金额
],
'thing5' => [
'value' => '您好,需要去小程序确认收货',//备注
]
];
$openid = trim(wdsxh_get_openid($orderObj['wechat_id'],'1'));
$result = Wxapp::subscribeMessage($applet_confirm_receipt_notification,$openid, '/pagesMall/order/details?order_id='.$order_id, $data);
$send_time = date('Y-m-d',time());
$message_data = array(
'wechat_id'=>$orderObj['wechat_id'],
'send_time'=>$send_time,
'errcode'=>$result[0]['errcode'],
'errmsg'=>$result[0]['errcode'] == 0 ? '' : $result[0]['errmsg'],
'order_id'=>$order_id,
);
$this->model->save($message_data);
}
}

View File

@@ -0,0 +1,58 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class SelfPickup
* Desc 自提点控制器
* Create on 2025/4/15 14:37
* Create by wangyafang
*/
namespace app\api\controller\wdsxh\mall;
use app\api\model\wdsxh\business\Association;
use app\common\controller\Api;
class SelfPickup extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\SelfPickup();
}
/**
* Desc 自提点配置
* Create on 2025/4/15 14:38
* Create by wangyafang
*/
public function config()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$data = $this->model->get(1);
if ($data) {
$data->hidden(['id']);
}
$data['mobile'] = (new Association())->value('phone');
$this->success('请求成功',$data);
}
}

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);
}
}

View File

@@ -0,0 +1,101 @@
<?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\message;
use app\admin\model\wdsxh\message\MessageNotification;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class MemberNotification extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
protected $member_id = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\message\MemberNotification();
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
if (!$wechat_id) {
$this->error('用户信息不存在');
}
$memberObj = (new Member())->where('wechat_id',$wechat_id)->find();
if (!$memberObj) {
$this->member_id = '-1';
} else {
$this->member_id = $memberObj['id'];
}
}
/**
* Desc 消息通知列表
* Create on 2025/11/17 下午2:57
* 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['member_id'] = array('eq',$this->member_id);
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,createtime,is_read,notification_id')
->page($page,$limit)
->order('is_read asc,createtime desc,id desc')
->select();
foreach ($data as $key => $value) {
$value->hidden(['notification_id']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 详情
* Create on 2025/11/17 下午2:59
* Create by wangyafang
*/
public function detail()
{
if (!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$id = isset($param['id']) ? $param['id'] : '';
if (!$id) {
$this->error('参数错误');
}
$where = [];
$where['member_id'] = array('eq', $this->member_id);
$where['id'] = array('eq', $id);
$data = $this->model
->where($where)
->field('createtime,is_read,notification_id')
->find();
if (!$data) {
$this->error('消息不存在');
}
if ($data['is_read'] == '0') {
$this->model->where('id', $id)->update(['is_read' => '1']);
}
$data['content'] = (new MessageNotification())->where('id',$data['notification_id'])->value('content');
$data->hidden(['is_read','notification_id']);
$this->success('请求成功', $data);
}
}

View File

@@ -0,0 +1,74 @@
<?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\points;
use app\common\controller\Api;
class Goods extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\points\Goods();
}
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','normal');
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,name,image,points')
->page($page,$limit)
->order('weigh desc,createtime desc,id desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 详情
* Create on 2025/11/13 上午8:55
* Create by wangyafang
*/
public function detail(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$id = isset($param['id']) ? $param['id'] : '';
if(!$id){
$this->error('参数错误');
}
$where = [];
$where['status'] = array('eq','normal');
$where['id'] = array('eq',$id);
$data = $this->model
->where($where)
->field('id,name,image,slider_images,points,content')
->find();
if(!$data){
$this->error('商品不存在或已下架');
}
$this->success('请求成功',$data);
}
}

View File

@@ -0,0 +1,64 @@
<?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\points;
use app\admin\model\wdsxh\points\PointsConfig;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class MyPoints extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $wechat_id = null;
public function _initialize()
{
parent::_initialize();
$this->wechat_id = (new UserWechat())->where('user_id', $this->auth->id)->value('id');
}
/**
* Desc 我的积分
* Create on 2025/11/14
* Create by Claude Code
*/
public function index()
{
if (!$this->request->isGet()) {
$this->error('请求类型错误');
}
try {
$userWechat = (new UserWechat())->where('id', $this->wechat_id)->find();
if (!$userWechat) {
$this->error('用户信息不存在');
}
// 获取用户积分
$points = $userWechat['points'] ?? 0;
$data = [
'my_points' => $points,
'points_description' => (new PointsConfig())->where('id', 1)->value('points_description') ?? '',
];
$this->success('请求成功', $data);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
}
}

View File

@@ -0,0 +1,180 @@
<?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\points;
use app\admin\model\wdsxh\points\Logistics;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
class Order 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\points\Order();
$this->wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
}
/**
* Desc 提交结算
* Create on 2025/11/13 上午10:08
* Create by wangyafang
*/
public function submitSettlement()
{
if (!$this->request->isPost()) {
$this->error('请求类型错误');
}
$data = $this->request->post();
try {
$validate = new \app\api\validate\wdsxh\points\Order();
if (!$validate->scene('submitSettlement')->check($data)) {
$this->error($validate->getError());
}
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
try {
$user_points = (new UserWechat())->where('id',$this->wechat_id)->value('points');
$data['points'] = (new \app\api\model\wdsxh\points\Goods())->where('id',$data['goods_id'])->value('points');
$data['total_points'] = bcmul($data['points'],$data['number']);
if ($data['total_points'] > $user_points) {
$this->error('积分不足,无法结算');
}
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$data['wechat_id'] = $this->wechat_id;
try {
$result = (new \app\api\model\wdsxh\points\Order())->submitSettlement($data);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$this->success('兑换成功', $result);
}
/**
* Desc 兑换订单列表
* Create on 2025/11/13 上午11:52
* 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['wechat_id'] = array('eq',$this->wechat_id);
if (isset($param['state']) && $param['state'] !== '') {
$where['state'] = array('eq',$param['state']);
}
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('id,order_no,number,goods_id,state,points')
->page($page,$limit)
->order('id desc')
->select();
foreach ($data as $k=>&$v){
$v->hidden(['goods_id','points']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 订单详情
* Create on 2025/11/13 下午1:59
* Create by wangyafang
*/
public function detail()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id','');
if(!$id) {
$this->error('参数错误');
}
try {
$where = [];
$where['id'] = array('eq',$id);
$where['wechat_id'] = array('eq',$this->wechat_id);
$fields = 'id,order_no,number,goods_id,state,real_name,user_phone,user_address,redemption_time,total_points,points';
$data = $this->model
->where($where)
->field($fields)
->find();
if(!$data) {
$this->error('订单不存在');
}
if ($data->state == '3' || $data->state == '4') {
$logistics = $this->model->logistics($data->id);
$data->logistics = $logistics;
}
$data->hidden(['goods_id','points']);
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$this->success('请求成功',$data);
}
/**
* Desc 确认收货
* Create on 2025/11/13 下午2:18
* Create by wangyafang
*/
public function confirmReceipt(){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$id = $this->request->post('id','');
if(!$id) {
$this->error('参数错误');
}
$where = [];
$where['id'] = array('eq',$id);
$where['wechat_id'] = array('eq',$this->wechat_id);
$where['state'] = array('eq','3');//待收货状态
$order = $this->model->where($where)->find();
if(!$order) {
$this->error('订单不存在或状态异常');
}
$logisticsObj = (new Logistics())->where('order_id',$id)->find();
try {
$order->state = '4';//已完成
$order->complete_time = time();
$order->save();
$logisticsObj->receive_time = time();
$logisticsObj->save();
} catch (ValidateException|PDOException|Exception $e) {
$this->error($e->getMessage());
}
$this->success('确认收货成功');
}
}

View File

@@ -0,0 +1,59 @@
<?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\points;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
class UserWechatPointsLog extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $model = null;
protected $wechat_id = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\common\model\wdsxh\points\UserWechatPointsLog();
$this->wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
}
/**
* Desc 积分明细
* Create on 2025/11/13 下午5:57
* 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['wechat_id'] = array('eq',$this->wechat_id);
if (isset($param['change']) && $param['change'] !== '') {
$where['change'] = array('eq',$param['change']);
}
$total = $this->model->where($where)->count();
$data = $this->model
->where($where)
->field('change,createtime,points,memo')
->page($page,$limit)
->order('id desc')
->select();
$this->success('请求成功',['total' => $total,'data' => $data]);
}
}

View File

@@ -0,0 +1,43 @@
<?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\questionnaire;
use app\common\controller\Api;
class Category extends Api
{
protected $noNeedLogin = ['index'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $topicModel = null;
protected $renderModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\api\model\wdsxh\questionnaire\Category();
}
/**
* 查看分类列表
*/
public function index()
{
$list = $this->model
->where('status', '1')
->order('weigh', 'asc')
->order('id', 'asc')
->field('id,name')
->select();
$this->success('', $list);
}
}

View File

@@ -0,0 +1,276 @@
<?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\questionnaire;
use app\api\model\wdsxh\member\Level;
use app\api\model\wdsxh\member\Member;
use app\api\model\wdsxh\questionnaire\Questionnaire;
use app\api\model\wdsxh\questionnaire\Render;
use app\api\model\wdsxh\questionnaire\Topic;
use app\api\model\wdsxh\user\Wechat;
use app\api\model\wdsxh\UserWechat;
use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use Exception;
class Index extends Api
{
protected $noNeedLogin = ['index'];
protected $noNeedRight = ['*'];
protected $model = null;
protected $topicModel = null;
protected $renderModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new Questionnaire();
$this->topicModel = new Topic();
$this->renderModel = new Render();
}
/**
* Desc 问卷调查列表
* Create on 2024/3/19 16:29
* Create by @小趴菜
*/
public function index(){
$param = $this->request->param();
$page = isset($param['page']) ? $param['page'] : '';
$limit = isset($param['limit']) ? $param['limit'] : 10;
$where = [];
$where['status'] = array('eq','normal');
$expired_questionnaire_show = (new \app\admin\model\wdsxh\Config())->value('expired_questionnaire_show');
$total = $this->model->where($where)->where(function ($query) use($expired_questionnaire_show){
if ($expired_questionnaire_show == 2) {
$query->where('end_time','>=',time());
}
})->count();
if (isset($param['questionnaire_category_id']) && $param['questionnaire_category_id'] != '') {
$where['questionnaire_category_id'] = array('eq',$param['questionnaire_category_id']);
}
$data = $this->model->where($where)
->where(function ($query) use($expired_questionnaire_show){
if ($expired_questionnaire_show == 2) {
$query->where('end_time','>=',time());
}
})
->field('id,title,end_time,end_time,page_view,member_id,questionnaire_category_id')
->page($page,$limit)
->order('weigh desc,createtime desc')
->select();
$categoryModel = new \app\api\model\wdsxh\questionnaire\Category();
foreach ($data as &$datum){
if ($datum['member_id'] == -1) {//平台发布
$datum['mobile'] = (new \app\api\model\wdsxh\business\Association())
->where('id',1)->value('phone');
}else{
$datum['mobile'] = (new Member())->where('id',$datum['member_id'])->value('mobile');
}
$datum['end_time'] = date('Y-m-d h:i',$datum['end_time']);
$datum['part_total'] = $this->renderModel->where('questionnaire_id',$datum['id'])->count();
if (!$this->auth->isLogin()) {
$datum['state'] = 2;
} else {
$user_id = $this->auth->id;
$wechat_id = (new UserWechat())->where('user_id',$user_id)->value('id');
$renderModel = (new Render())->where('wechat_id',$wechat_id)->where('questionnaire_id',$datum['id'])->find();
if ($renderModel){
$datum['state'] = 1;
}else{
$datum['state'] = 2;
}
}
if (!empty($datum['questionnaire_category_id'])) {
$datum['category_name'] = $categoryModel->where('id',$datum['questionnaire_category_id'])->value('name');
} else {
$datum['category_name'] = '';
}
$datum->hidden(['questionnaire_category_id']);
}
$this->success('请求成功',['total' => $total,'data' => $data]);
}
/**
* Desc 问卷调查详情
* Create on 2024/3/20 08:53
* Create by @小趴菜
*/
public function details(){
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$param = $this->request->get();
$data = (new Questionnaire())
->where('id',$param['id'])
->field('id,title,end_time,end_time,member_id,page_view,content,createtime,non_member_answer_sheet_status')
->find();
$data['end_time'] = date('Y-m-d h:i',$data['end_time']);
$data['createtime'] = date('Y-m-d h:i',$data['createtime']);
if ($data['member_id'] == -1){//平台发布
$association = (new \app\api\model\wdsxh\business\Association())
->where('id',1)->field('name,logo,phone')->find();
$data['member_name'] = $association['name'];
$data['avatar'] = $association['logo'];
$data['level_name'] = '';
$data['mobile'] = $association['phone'];
}else{
$memberObj = (new Member())->where('id',$data['member_id'])->field('id,name,avatar,member_level_id,mobile')->find();
$memberObj['avatar'] = wdsxh_full_url($memberObj['avatar']);
$data['member_name'] = $memberObj['name'];
$data['avatar'] = $memberObj['avatar'];
$data['level_name'] = (new Level())->where('id',$memberObj['member_level_id'])->value('name');
$data['mobile'] = $memberObj['mobile'];
}
unset($data['member_id']);
$topic = $this->topicModel->where('questionnaire_id',$data['id'])->field('id,topic,type,content,message,is_explain,explain_message,must')
->order('weigh asc')
->select();
$page_view = $data['page_view']+=1;
(new Questionnaire())->where('id',$param['id'])->update(['page_view' => $page_view]);
if ($data['non_member_answer_sheet_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) {
$data['non_member_answer_sheet_status'] = 1;
}
}
}
$data= [
'data' => $data,
'topic' => $topic,
];
$this->success('请求成功',$data);
}
/**
* Desc 问卷调查提交
* Create on 2024/3/20 08:53
* Create by @小趴菜
*/
public function add_topic(){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$param = $this->request->post();
$user_id = $this->auth->id;
$wechat_id = (new Wechat())->where('user_id',$user_id)->value('id');
$current_date = date('Y-m-d',time());
$memberObj = (new Member())->where('wechat_id',$wechat_id)
->where('expire_time','>=',$current_date)
->find();
$questionnaireObj = $this->model->get($param['questionnaire_id']);
if (!$questionnaireObj) {
$this->error('问卷不存在');
}
if ($questionnaireObj['non_member_answer_sheet_status'] == '2' && !$memberObj) {
$this->error('只有会员才能填写');
}
$topicModel = (new Render())->where('wechat_id',$wechat_id)->where('questionnaire_id',$param['questionnaire_id'])->find();
if ($topicModel){
$this->error('你已提交过此问卷,请勿重复提交');
}
$param['wechat_id'] = $wechat_id;
$param['content_render'] = $param['content'];
unset($param['content']);
$param['createtime'] = time();
$result = false;
Db::startTrans();
try {
$result = (new Render())->insert($param);
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 2024/4/11 17:11
* Create by @小趴菜
*/
public function render_details(){
$param = $this->request->param();
$user_id = $this->auth->id;
$wechat_id = (new UserWechat())->where('user_id',$user_id)->value('id');
$renderModel = (new Render())->where('wechat_id',$wechat_id)->where('questionnaire_id',$param['questionnaire_id'])->find();
$data = html_entity_decode($renderModel->content_render);
$formData = json_decode($data, true);
foreach ($formData as $k=>$v){
$formData[$k]['status'] = 1;
if ($v['type'] == 'images'){
if ($v['content']){
if (strpos($v['content'], ',') !== false) {
$img = explode(',', $v['content']);
} else {
$img = array($v['content']);
}
$images = [];
foreach ($img as $item){
$images[] = wdsxh_full_url($item);
}
$formData[$k]['content'] = $images;
}
}
}
$this->success('请求成功',$formData);
}
/**
* Desc 答卷状态
* Create on 2025/8/7 上午11:15
* Create by wangyafang
*/
public function answer_sheet_status()
{
if(!$this->request->isGet()) {
$this->error('请求类型错误');
}
$id = $this->request->get('id');
if (empty($id)) {
$this->error('参数错误');
}
$non_member_answer_sheet_status = $this->model->where('id',$id)->value('non_member_answer_sheet_status');
if ($non_member_answer_sheet_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) {
$non_member_answer_sheet_status = 1;
}
}
}
$this->success('请求成功',array(
'status'=>$non_member_answer_sheet_status,
));
}
}

View File

@@ -0,0 +1,102 @@
<?php
return [
'Keep login' => '保持会话',
'Username' => '用户名',
'User id' => '会员ID',
'Nickname' => '昵称',
'Password' => '密码',
'Sign up' => '注 册',
'Sign in' => '登 录',
'Sign out' => '退 出',
'Guest' => '游客',
'Welcome' => '%s你好',
'Add' => '添加',
'Edit' => '编辑',
'Delete' => '删除',
'Move' => '移动',
'Name' => '名称',
'Status' => '状态',
'Weigh' => '权重',
'Operate' => '操作',
'Warning' => '温馨提示',
'Default' => '默认',
'Article' => '文章',
'Page' => '单页',
'OK' => '确定',
'Cancel' => '取消',
'Loading' => '加载中',
'More' => '更多',
'Normal' => '正常',
'Hidden' => '隐藏',
'Submit' => '提交',
'Reset' => '重置',
'Execute' => '执行',
'Close' => '关闭',
'Search' => '搜索',
'Refresh' => '刷新',
'First' => '首页',
'Previous' => '上一页',
'Next' => '下一页',
'Last' => '末页',
'None' => '无',
'Home' => '主页',
'Online' => '在线',
'Logout' => '退出',
'Profile' => '个人资料',
'Index' => '首页',
'Hot' => '热门',
'Recommend' => '推荐',
'Dashboard' => '控制台',
'Code' => '编号',
'Message' => '内容',
'Line' => '行号',
'File' => '文件',
'Menu' => '菜单',
'Type' => '类型',
'Title' => '标题',
'Content' => '内容',
'Append' => '追加',
'Memo' => '备注',
'Parent' => '父级',
'Params' => '参数',
'Permission' => '权限',
'Advance search' => '高级搜索',
'Check all' => '选中全部',
'Expand all' => '展开全部',
'Begin time' => '开始时间',
'End time' => '结束时间',
'Create time' => '创建时间',
'Flag' => '标志',
'Please login first' => '请登录后操作',
'Uploaded successful' => '上传成功',
'You can upload up to %d file%s' => '你最多还可以上传%d个文件',
'You can choose up to %d file%s' => '你最多还可以选择%d个文件',
'Chunk file write error' => '分片写入失败',
'Chunk file info error' => '分片文件错误',
'Chunk file merge error' => '分片合并错误',
'Chunk file disabled' => '未开启分片上传功能',
'Cancel upload' => '取消上传',
'Upload canceled' => '上传已取消',
'No file upload or server upload limit exceeded' => '未上传文件或超出服务器上传限制',
'Uploaded file format is limited' => '上传文件格式受限制',
'Uploaded file is not a valid image' => '上传文件不是有效的图片文件',
'Are you sure you want to cancel this upload?' => '确定取消上传?',
'Remove file' => '移除文件',
'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件',
'You can\'t upload files of this type' => '不允许上传的文件类型',
'Server responded with %s code' => '服务端响应(Code:%s)',
'File is too big (%sMiB), Max filesize: %sMiB.' => '当前上传(%sM),最大允许上传文件大小:%sM',
'Redirect now' => '立即跳转',
'Operation completed' => '操作成功!',
'Operation failed' => '操作失败!',
'Unknown data format' => '未知的数据格式!',
'Network error' => '网络错误!',
'Advanced search' => '高级搜索',
'Invalid parameters' => '未知参数',
'No results were found' => '记录未找到',
'Parameter %s can not be empty' => '参数%s不能为空',
'You have no permission' => '你没有权限访问',
'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
];

View File

@@ -0,0 +1,3 @@
<?php
return [];

View File

@@ -0,0 +1,39 @@
<?php
return [
'User center' => '会员中心',
'Register' => '注册',
'Login' => '登录',
'Sign up successful' => '注册成功',
'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符',
'Mobile is incorrect' => '手机格式不正确',
'Username already exist' => '用户名已经存在',
'Nickname already exist' => '昵称已经存在',
'Email already exist' => '邮箱已经存在',
'Mobile already exist' => '手机号已经存在',
'Username is incorrect' => '用户名不正确',
'Email is incorrect' => '邮箱不正确',
'Account is locked' => '账户已经被锁定',
'Password is incorrect' => '密码不正确',
'Account is incorrect' => '账户不正确',
'Account not exist' => '账户不存在',
'Account can not be empty' => '账户不能为空',
'Username or password is incorrect' => '用户名或密码不正确',
'You are not logged in' => '你当前还未登录',
'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
'Profile' => '个人资料',
'Verify email' => '邮箱验证',
'Change password' => '修改密码',
'Captcha is incorrect' => '验证码不正确',
'Logged in successful' => '登录成功',
'Logout successful' => '退出成功',
'Operation failed' => '操作失败',
'Invalid parameters' => '参数不正确',
'Change password failure' => '修改密码失败',
'Change password successful' => '修改密码成功',
'Reset password successful' => '重置密码成功',
];

View File

@@ -0,0 +1,37 @@
<?php
namespace app\api\library;
use Exception;
use think\exception\Handle;
/**
* 自定义API模块的错误显示
*/
class ExceptionHandle extends Handle
{
public function render(Exception $e)
{
// 在生产环境下返回code信息
if (!\think\Config::get('app_debug')) {
$statuscode = $code = 500;
$msg = 'An error occurred';
// 验证异常
if ($e instanceof \think\exception\ValidateException) {
$code = 0;
$statuscode = 200;
$msg = $e->getError();
}
// Http异常
if ($e instanceof \think\exception\HttpException) {
$statuscode = $code = $e->getStatusCode();
}
return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
}
//其它此交由系统处理
return parent::render($e);
}
}

View File

@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Banner
* Desc 轮播管理
* Create on 2024/3/25 09:59
* Create by @小趴菜
*/
namespace app\api\model\wdsxh;
class Banner extends Base
{
// 表名
protected $name = 'wdsxh_banner';
}

View File

@@ -0,0 +1,65 @@
<?php
namespace app\api\model\wdsxh;
use think\Model;
/**
* Class Base
* Desc 基础Model
* Create on 2024/3/11 11:53
* Create by wangyafang
*/
class Base extends Model
{
protected function getImageAttr($value)
{
return wdsxh_full_url($value);
}
protected function getAvatarAttr($value)
{
return wdsxh_full_url($value);
}
protected function getImagesAttr($value)
{
$array = explode(',',$value);
foreach ($array as $k=>$v) {
$array[$k] = wdsxh_full_url($v);
}
return implode(',',$array);
}
protected function getFilesAttr($value)
{
$array = explode(',',$value);
foreach ($array as $k=>$v) {
$array[$k] = wdsxh_full_url($v);
}
return implode(',',$array);
}
protected function setImagesAttr($value)
{
$value = remove_wdsxh_full_url($value);
return $value;
}
protected function setImageAttr($value)
{
$value = remove_wdsxh_full_url($value);
return $value;
}
protected function setBackgroundImageAttr($value)
{
$value = remove_wdsxh_full_url($value);
return $value;
}
}

View File

@@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Demand
* Desc 需求反馈
* Create on 2024/3/13 15:33
* Create by @小趴菜
*/
namespace app\api\model\wdsxh;
use think\Model;
use traits\model\SoftDelete;
class Demand extends Model
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_demand';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Faq
* Desc 常见问题
* Create on 2024/3/13 15:56
* Create by @小趴菜
*/
namespace app\api\model\wdsxh;
use think\Model;
class Faq extends Model
{
// 表名
protected $name = 'wdsxh_faq';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class PcBanner
* Desc pc轮播管理
* Create on 2024/4/09 16:27
* Create by @小趴菜
*/
namespace app\api\model\wdsxh;
class PcBanner extends Base
{
// 表名
protected $name = 'wdsxh_pc_banner';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class PcBusinessAssociation
* Desc pc商协信息
* Create on 2024/4/09 17:44
* Create by @小趴菜
*/
namespace app\api\model\wdsxh;
use think\Model;
class PcBusinessAssociation extends Model
{
// 表名
protected $name = 'wdsxh_pc_business_association';
}

View File

@@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh;
/**
* Class Quickmenu
* Desc 快速导航
* Create on 2024/3/22 13:32
* Create by @小趴菜
*/
class Quickmenu extends Base
{
// 表名
protected $name = 'wdsxh_quickmenu';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh;
/**
* Class Tabbar
* Desc 底部导航
* Create on 2024/3/22 16:59
* Create by @小趴菜
*/
class Tabbar extends Base
{
// 表名
protected $name = 'wdsxh_tabbar';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
protected function getIconAttr($value)
{
return wdsxh_full_url($value);
}
protected function getSeliconAttr($value)
{
return wdsxh_full_url($value);
}
}

View File

@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh;
/**
* Class UserWechat
* Desc 微信表模型
* Create on 2024/3/7 10:11
* Create by wangyafang
*/
class UserWechat extends Base
{
// 表名
protected $name = 'wdsxh_user_wechat';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
protected $type = [
'join_time' => 'timestamp:Y-m-d',
];
}

View File

@@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh\activity;
use app\api\model\wdsxh\Base;
use app\common\model\wdsxh\points\UserWechatPointsLog;
/**
* Class Activity
* Desc 活动模型
* Create on 2024/3/11 16:29
* Create by wangyafang
*/
class Activity extends Base
{
// 表名
protected $name = 'wdsxh_activity';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
protected static function init()
{
self::afterUpdate(function ($row) {
// 仅当活动状态变更为"已结束"且开启积分功能时才发放积分
if ($row['points_status'] == 1) {
// 获取所有已审核通过的报名用户
$activityApplyList = (new ActivityApply())
->where('activity_id', $row['id'])
->where('state', '2')
->select();
if (empty($activityApplyList)) {
return;
}
// 遍历所有报名用户,为每个用户发放积分
foreach ($activityApplyList as $activityApplyObj) {
// 检查是否已经发放过积分,避免重复插入
$existLog = UserWechatPointsLog::where('activity_id', $row['id'])
->where('wechat_id', $activityApplyObj['wechat_id'])
->where('source', 1)
->where('memo', '参加活动')
->find();
// 如果未发放过,则发放积分
if (!$existLog) {
UserWechatPointsLog::activity(1, $activityApplyObj, $row, '参加活动');
}
}
}
});
}
}

View File

@@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class ActivityApply
* Desc 活动报名模型
* Create on 2024/3/11 17:58
* Create by wangyafang
*/
namespace app\api\model\wdsxh\activity;
use think\Model;
class ActivityApply extends Model
{
// 表名
protected $name = 'wdsxh_activity_apply';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
public function activity()
{
return $this->belongsTo('app\api\model\wdsxh\activity\Activity', 'activity_id', 'id', [])->setEagerlyType(0);
}
}

View File

@@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh\activity;
use think\Model;
/**
* Class ActivityApplyRecord
* Desc 活动报名记录Model
* Create on 2024/4/1 14:04
* Create by wangyafang
*/
class ActivityApplyRecord extends Model
{
// 表名
protected $name = 'wdsxh_activity_apply_record';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Order
* Desc 活动订单表
* Create on 2024/3/12 10:48
* Create by wangyafang
*/
namespace app\api\model\wdsxh\activity;
use think\Model;
class Order extends Model
{
// 表名
protected $name = 'wdsxh_activity_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Refund
* Desc 活动退款模型
* Create on 2024/3/12 17:22
* Create by wangyafang
*/
namespace app\api\model\wdsxh\activity;
use think\Model;
class Refund extends Model
{
// 表名
protected $name = 'wdsxh_activity_refund';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,48 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Album
* Desc 相册管理
* Create on 2024/3/12 10:10
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\album;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Album extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_album';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected function getReleaseDateAttr($value)
{
$new_date = str_replace("-", "/", $value);
return $new_date;
}
}

View File

@@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class AlbumConfig
* Desc 相册设置
* Create on 2024/3/12 10:38
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\album;
use app\api\model\wdsxh\Base;
class AlbumConfig extends Base
{
// 表名
protected $name = 'wdsxh_album_config';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = true;
protected $updateTime = false;
}

View File

@@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Article
* Desc 文章管理
* Create on 2024/3/12 10:10
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\article;
use think\Model;
class Article extends Model
{
// 表名
protected $name = 'wdsxh_article';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = true;
protected $updateTime = false;
protected $deleteTime = false;
protected function getCreatetimeAttr($value)
{
$new_date = date("Y-m-d H:i", $value);
return $new_date;
}
protected function getImageAttr($value)
{
return wdsxh_full_url($value);
}
protected function getFilesAttr($value, $data)
{
$return_data = [];
if (empty($value)) {
return $return_data;
} else {
$filesdataArray = json_decode($data['filesdata'], true);
$array = explode(',',$value);
foreach ($array as $k=>$v) {
// 获取文件扩展名
$path_parts = pathinfo($v);
$extension = isset($path_parts['extension']) ? '.' . $path_parts['extension'] : '';
// 拼接文件名和扩展名
$fullName = $filesdataArray[$k]['name'] . $extension;
$return_data[$k] = array(
'name'=>$fullName,
'file'=>wdsxh_full_url($v),
);
}
return $return_data;
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class ArticleCat
* Desc 文章分类
* Create on 2024/3/12 11:36
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\article;
use app\api\model\wdsxh\Base;
class ArticleCat extends Base
{
// 表名
protected $name = 'wdsxh_article_cat';
}

View File

@@ -0,0 +1,48 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Association
* Desc 商协管理
* Create on 2024/3/12 14:21
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\business;
use think\Model;
class Association extends Model
{
// 表名
protected $name = 'wdsxh_business_association';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = true;
protected $updateTime = false;
protected function getLogoAttr($value)
{
return wdsxh_full_url($value);
}
protected function getWananchiQrCodeAttr($value)
{
return wdsxh_full_url($value);
}
}

View File

@@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Business
* Desc 商圈管理
* Create on 2024/3/12 14:43
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\business;
use app\admin\model\wdsxh\points\PointsConfig;
use app\api\model\wdsxh\Base;
use app\common\model\wdsxh\points\UserWechatPointsLog;
use traits\model\SoftDelete;
class Business extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_business';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected static function init()
{
self::afterInsert(function ($row) {
$is_process = (new BusinessConfig())->where('id',1)->value('is_process');
$add_points = (new PointsConfig())->where('id',1)->value('public_business_get_points');
if($is_process==2 && $add_points>0){
UserWechatPointsLog::addPoints(1,'需求发布',$row['wechat_id'],$add_points,3);
}
});
}
}

View File

@@ -0,0 +1,27 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Business
* Desc 商圈配置';
* Create on 2024/3/12 16:58
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\business;
use think\Model;
class BusinessConfig extends Model
{
// 表名
protected $name = 'wdsxh_business_config';
}

View File

@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Category
* Desc 商圈分类管理
* Create on 2024/3/12 14:43
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\business;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Category extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_business_category';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
}

View File

@@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class Card
* Desc 名片Model
* Create on 2025/1/21 16:57
* Create by wangyafang
*/
namespace app\api\model\wdsxh\corporate;
use app\api\model\wdsxh\Base;
use app\api\model\wdsxh\business\Association;
class Card extends Base
{
// 表名
protected $name = 'wdsxh_corporate_card';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'association'
];
public function getAssociationAttr($value)
{
$result = (new Association())->where('id',1)->field('name,logo')->find();
return $result;
}
protected function getCardBackgroundImageAttr($value)
{
return wdsxh_full_url($value);
}
protected function setCardBackgroundImageAttr($value)
{
$value = remove_wdsxh_full_url($value);
return $value;
}
}

View File

@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class CardBackground
* Desc 名片背景Model
* Create on 2025/1/21 16:57
* Create by wangyafang
*/
namespace app\api\model\wdsxh\corporate;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class CardBackground extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_corporate_card_background';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Reliable
* Desc 名片靠谱模型
* Create on 2025/1/22 14:22
* Create by wangyafang
*/
namespace app\api\model\wdsxh\corporate;
use think\Model;
class Reliable extends Model
{
// 表名
protected $name = 'wdsxh_corporate_card_reliable';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Visitor
* Desc 名片访客模型
* Create on 2025/1/22 8:57
* Create by wangyafang
*/
namespace app\api\model\wdsxh\corporate;
use think\Model;
class Visitor extends Model
{
// 表名
protected $name = 'wdsxh_corporate_card_visitor';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Address
* Desc 收货地址
* Create on 2024/3/15 15:25
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
class Address extends Base
{
// 表名
protected $name = 'wdsxh_mall_user_address';
}

View File

@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Banner
* Desc 商城轮播图
* Create on 2024/3/13 16:20
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Banner extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_mall_banner';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = true;
protected $updateTime = false;
protected $deleteTime = 'deletetime';
}

View File

@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class FreightRules
* Desc 商城运费规则
* Create on 2024/3/15 14:06
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class FreightRules extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_mall_freight_rules';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
}

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
// +----------------------------------------------------------------------
/**
* Class Goods
* Desc 商城商品
* Create on 2024/3/13 16:20
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Goods extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_mall_goods';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = true;
protected $updateTime = false;
protected $deleteTime = 'deletetime';
protected function getRecommendImageAttr($value){
return wdsxh_full_url($value);
}
protected function getSliderImagesAttr($value)
{
$array = explode(',',$value);
foreach ($array as $k=>$v) {
$array[$k] = wdsxh_full_url($v);
}
return implode(',',$array);
}
}

View File

@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Order
* Desc 订单管理
* Create on 2024/3/13 16:20
* Create by @小趴菜
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Order extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_mall_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = 'deletetime';
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
/**
* Class Refund
* Desc 退款管理
* Create on 2024/3/13 16:20
* Create by 订单退款
*/
namespace app\api\model\wdsxh\goods;
use app\api\model\wdsxh\Base;
class Refund extends Base
{
// 表名
protected $name = 'wdsxh_mall_order_refund';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
}

Some files were not shown because too many files have changed in this diff Show More