This commit is contained in:
全栈小学生 2025-01-17 19:44:10 +08:00
parent 9f058e2702
commit 2e643290e4
99 changed files with 7742 additions and 764 deletions

View File

@ -10,6 +10,7 @@ use think\db\exception\ModelNotFoundException;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\exception\RouteNotFoundException;
use think\exception\ValidateException;
use think\facade\Log;
use think\Response;
@ -92,6 +93,9 @@ class ExceptionHandle extends Handle
if (strpos($e->getMessage(), 'open_basedir') !== false) {
return fail('OPEN_BASEDIR_ERROR');
}
if (strpos($e->getMessage(), 'Allowed memory size of') !== false) {
return fail('PHP_SCRIPT_RUNNING_OUT_OF_MEMORY');
}
if ($e instanceof DbException) {
return fail(get_lang('DATA_GET_FAIL').':'.$e->getMessage(), [
'file' => $e->getFile(),
@ -108,7 +112,9 @@ class ExceptionHandle extends Handle
return fail($e->getMessage(), [], $e->getCode() ?: 400);
}else if($e instanceof ServerException){
return fail($e->getMessage(), http_code:$e->getCode());
}else {
} else if ($e instanceof RouteNotFoundException) {
return fail('当前访问路由未定义或不匹配 路由地址:' . request()->baseUrl());
} else {
return fail($e->getMessage(), $massageData);
}
}

View File

@ -268,4 +268,41 @@ class Diy extends BaseAdminController
$id = ( new DiyService() )->copy($params);
return success('ADD_SUCCESS', [ 'id' => $id ]);
}
/**
* 获取自定义主题配色
* @return Response
*/
public function getDiyTheme()
{
return success(( new DiyService() )->getDiyTheme());
}
/**
* 添加主题配色
* @return Response
*/
public function setDiyTheme()
{
$data = $this->request->params([
[ 'id', '' ],
[ 'key', '' ],
[ 'mode', '' ],
[ 'color_mark', '' ],
[ 'color_name', '' ],
[ 'diy_value', '' ],
[ 'value', '' ],
]);
( new DiyService() )->setDiyTheme($data);
return success('ADD_SUCCESS');
}
/**
* 设置主题配色
* @return Response
*/
public function getDefaultThemeColor()
{
return success(( new DiyService() )->getDefaultThemeColor());
}
}

View File

@ -0,0 +1,370 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\diy;
use app\service\admin\diy_form\DiyFormConfig;
use app\service\admin\diy_form\DiyFormRecordsService;
use app\service\admin\diy_form\DiyFormService;
use core\base\BaseAdminController;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* 万能表单控制器
* Class DiyForm
* @package app\adminapi\controller\diy
*/
class DiyForm extends BaseAdminController
{
/**
* @notes 获取万能表单分页列表
* @return Response
*/
public function pages()
{
$data = $this->request->params([
[ "title", "" ],
[ "type", "" ],
[ 'addon', '' ]
]);
return success(( new DiyFormService() )->getPage($data));
}
/**
* @notes 获取万能表单列表
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lists()
{
$data = $this->request->params([
[ "title", "" ],
[ 'status', 0 ],
[ "type", "" ],
[ 'addon', '' ]
]);
return success(( new DiyFormService() )->getList($data));
}
/**
* 万能表单详情
* @param int $id
* @return Response
*/
public function info(int $id)
{
return success(( new DiyFormService() )->getInfo($id));
}
/**
* 添加万能表单
* @return Response
*/
public function add()
{
$data = $this->request->params([
[ "title", "" ],
[ "page_title", "" ],
[ "type", "" ],
[ "value", [] ],
[ 'template', '' ],
]);
$this->validate($data, 'app\validate\diy\DiyForm.add');
$id = ( new DiyFormService() )->add($data);
return success('ADD_SUCCESS', [ 'id' => $id ]);
}
/**
* 万能表单编辑
* @param $id
* @return Response
*/
public function edit($id)
{
$data = $this->request->params([
[ "title", "" ],
[ "page_title", "" ],
[ "value", [] ],
[ 'template', '' ],
]);
$this->validate($data, 'app\validate\diy\DiyForm.edit');
( new DiyFormService() )->edit($id, $data);
return success('MODIFY_SUCCESS');
}
/**
* 万能表单删除
* @return Response
*/
public function del()
{
$params = $this->request->params([
[ 'form_ids', [] ]
]);
( new DiyFormService() )->del($params[ 'form_ids' ]);
return success('DELETE_SUCCESS');
}
/**
* 获取万能表单初始化数据
* @return Response
* @throws DbException
*/
public function getInit()
{
$params = $this->request->params([
[ 'form_id', "" ],
[ "type", "" ],
[ "title", "" ],
]);
$diy_service = new DiyFormService();
return success($diy_service->getInit($params));
}
/**
* 获取万能表单模板
* @return Response
*/
public function getTemplate()
{
$params = $this->request->params([
[ 'type', '' ],
[ 'template_key', '' ],
]);
$diy_service = new DiyFormService();
return success($diy_service->getTemplate($params));
}
/**
* 修改页面分享内容
* @return Response
*/
public function modifyShare()
{
$data = $this->request->params([
[ "form_id", "" ],
[ "share", "" ],
]);
( new DiyFormService() )->modifyShare($data);
return success('MODIFY_SUCCESS');
}
/**
* 获取模板页面(存在的应用插件列表)
* @return Response
*/
public function getApps()
{
return success(( new DiyFormService() )->getApps());
}
/**
* 复制模版 todo 靠后
* @return Response
*/
public function copy()
{
$params = $this->request->params([
[ 'form_id', '' ],
]);
$form_id = ( new DiyFormService() )->copy($params);
return success('ADD_SUCCESS', [ 'form_id' => $form_id ]);
}
/**
* 获取模板页面(存在的应用插件列表)
* @return Response
*/
public function getFormType()
{
return success(( new DiyFormService() )->getFormType());
}
/**
* 修改状态
* @return \think\Response
*/
public function modifyStatus()
{
$data = $this->request->params([
[ 'form_id', '' ],
[ 'status', 1 ],
]);
( new DiyFormService() )->modifyStatus($data);
return success('SUCCESS');
}
/**
* 获取使用记录
* @return Response
*/
public function getRecordPages()
{
$data = $this->request->params([
[ "form_id", 0 ],
[ "keyword", "" ],
[ "create_time", "" ],
]);
return success(( new DiyFormService() )->getRecordPages($data));
}
/**
* 获取使用记录详情
* @param int $record_id
* @return Response
*/
public function getRecordInfo(int $record_id)
{
return success(( new DiyFormService() )->getRecordInfo($record_id));
}
/**
* 使用记录删除
* @return Response
*/
public function delRecord()
{
$data = $this->request->params([
[ "form_id", 0 ],
[ 'record_id', 0 ],
]);
( new DiyFormService() )->delRecord($data);
return success('DELETE_SUCCESS');
}
/**
* 获取万能表单字段记录
* @return Response
*/
public function getFieldsList()
{
$data = $this->request->params([
[ "form_id", 0 ],
[ 'order', '' ],
[ 'sort', '' ]
]);
return success(( new DiyFormService() )->getFieldsList($data));
}
/**
* 获取表单填写配置
* @param $form_id int 所属万能表单id
* @return Response
*/
public function getWriteConfig($form_id)
{
return success(( new DiyFormConfig() )->getWriteConfig($form_id));
}
/**
* 编辑表单填写配置
* @return Response
*/
public function editWriteConfig()
{
$data = $this->request->params([
[ 'id', 0 ],
[ 'form_id', 0 ], // 所属万能表单id
[ 'write_way', '' ], // 填写方式no_limit不限制scan仅限微信扫一扫url仅限链接进入
[ 'join_member_type', '' ], // 参与会员all_member所有会员参与selected_member_level指定会员等级selected_member_label指定会员标签
[ 'level_ids', [] ], // 会员等级id集合
[ 'label_ids', [] ], // 会员标签id集合
[ 'member_write_type', '' ], // 每人可填写次数no_limit不限制diy自定义
[ 'member_write_rule', [] ], // 每人可填写次数自定义规则
[ 'form_write_type', '' ], // 表单可填写数量no_limit不限制diy自定义
[ 'form_write_rule', [] ], // 表单可填写总数自定义规则
[ 'time_limit_type', '' ], // 填写时间限制类型no_limit不限制 specify_time指定开始结束时间open_day_time设置每日开启时间
[ 'time_limit_rule', [] ], // 填写时间限制规则
[ 'is_allow_update_content', 0 ], // 是否允许修改自己填写的内容01
[ 'write_instruction', '' ], // 表单填写须知
]);
( new DiyFormConfig() )->editWriteConfig($data);
return success('EDIT_SUCCESS');
}
/**
* 获取表单提交成功 也配置
* @param $form_id int 所属万能表单id
* @return Response
*/
public function getSubmitConfig($form_id)
{
return success(( new DiyFormConfig() )->getSubmitConfig($form_id));
}
/**
* 编辑表单提交成功页配置
* @return Response
*/
public function editSubmitConfig()
{
$data = $this->request->params([
[ 'id', 0 ],
[ 'form_id', 0 ], // 所属万能表单id
[ 'submit_after_action', '' ], // 填表人提交后操作text文字信息voucher核销凭证
[ 'tips_type', '' ], // 提示内容类型default默认提示diy自定义提示
[ 'tips_text', '' ], // 自定义提示内容
[ 'time_limit_type', [] ], // 核销凭证有效期限制类型no_limit不限制specify_time指定固定开始结束时间submission_time按提交时间设置有效期
[ 'time_limit_rule', '' ], // 核销凭证时间限制规则json格式 todo 结构待定
[ 'voucher_content_rule', [] ], // 核销凭证内容json格式 todo 结构待定
[ 'success_after_action', '' ], // 填写成功后续操作
]);
( new DiyFormConfig() )->editSubmitConfig($data);
return success('EDIT_SUCCESS');
}
// todo 查询表单详情
/**
* 获取万能表单填表人统计列表
* @return Response
*/
public function memberStatPages()
{
$data = $this->request->params([
[ "form_id", 0 ],
[ "keyword", '' ],
]);
return success(( new DiyFormRecordsService() )->getPage($data));
}
/**
* 获取万能表单字段统计列表
* @return Response
*/
public function fieldStatList()
{
$data = $this->request->params([
[ "form_id", 0 ],
]);
return success(( new DiyFormRecordsService() )->getFieldStatList($data));
}
/**
* 获取万能表单微信小程序二维码
* @return Response
*/
public function getQrcode()
{
$data = $this->request->params([
[ "form_id", '' ],
]);
return success(( new DiyFormService() )->getQrcode($data[ 'form_id' ]));
}
}

View File

@ -82,6 +82,19 @@ class CashOut extends BaseAdminController
return success();
}
/**
* 备注转账信息
* @param $id
* @return Response
*/
public function remark($id)
{
$data = $this->request->params([
['remark', ''],
]);
(new MemberCashOutService())->remark($id, $data);
return success();
}
/**
* 状态
* @return Response
@ -98,4 +111,13 @@ class CashOut extends BaseAdminController
{
return success((new MemberCashOutService())->stat());
}
/**
* 校验数组是否
* @return void
*/
public function checkTransferStatus($id){
(new MemberCashOutService())->checkTransferStatus($id);
return success();
}
}

View File

@ -26,15 +26,15 @@ class Site extends BaseAdminController
public function lists()
{
$data = $this->request->params([
['keywords', ''],
['status', ""],
['group_id', 0],
['create_time', []],
['expire_time', []],
['app', ''],
['site_domain', '']
[ 'keywords', '' ],
[ 'status', "" ],
[ 'group_id', 0 ],
[ 'create_time', [] ],
[ 'expire_time', [] ],
[ 'app', '' ],
[ 'site_domain', '' ]
]);
return success((new SiteService())->getPage($data));
return success(( new SiteService() )->getPage($data));
}
/**
@ -44,7 +44,7 @@ class Site extends BaseAdminController
*/
public function info(int $id)
{
return success((new SiteService())->getInfo($id));
return success(( new SiteService() )->getInfo($id));
}
/**
@ -55,19 +55,19 @@ class Site extends BaseAdminController
public function add()
{
$data = $this->request->params([
['site_name', ''],
['uid', 0],
['username', ''],
['real_name', ''],
['password', ''],
['group_id', 0],
['expire_time', 0],
['site_domain', ''],
[ 'site_name', '' ],
[ 'uid', 0 ],
[ 'username', '' ],
[ 'real_name', '' ],
[ 'password', '' ],
[ 'group_id', 0 ],
[ 'expire_time', 0 ],
[ 'site_domain', '' ],
]);
$this->validate($data, 'app\validate\site\Site.add');
if (empty($data['uid'])) $this->validate($data, 'app\validate\sys\User.add');
$site_id = (new SiteService())->add($data);
return success('ADD_SUCCESS', ['site_id' => $site_id]);
if (empty($data[ 'uid' ])) $this->validate($data, 'app\validate\sys\User.add');
$site_id = ( new SiteService() )->add($data);
return success('ADD_SUCCESS', [ 'site_id' => $site_id ]);
}
/**
@ -85,7 +85,7 @@ class Site extends BaseAdminController
*/
public function menu()
{
return success((new AuthSiteService())->getMenuList(1, 1, 'all', 0));
return success(( new AuthSiteService() )->getMenuList(1, 1, 'all', 0));
}
/**
@ -94,9 +94,9 @@ class Site extends BaseAdminController
public function closeSite($id)
{
$data = $this->request->params([
['status', SiteDict::CLOSE],
[ 'status', SiteDict::CLOSE ],
]);
(new SiteService())->edit($id, $data);
( new SiteService() )->edit($id, $data);
return success();
}
@ -106,17 +106,17 @@ class Site extends BaseAdminController
public function edit($id)
{
$data = $this->request->params([
['site_name', ''],
['uid', 0],
['username', ''],
['real_name', ''],
['password', ''],
['group_id',0],
['expire_time', 0],
['site_domain', ''],
[ 'site_name', '' ],
[ 'uid', 0 ],
[ 'username', '' ],
[ 'real_name', '' ],
[ 'password', '' ],
[ 'group_id', 0 ],
[ 'expire_time', 0 ],
[ 'site_domain', '' ],
]);
$this->validate(array_merge($data, ['site_id' => $id]), 'app\validate\site\Site.edit');
(new SiteService())->edit($id, $data);
$this->validate(array_merge($data, [ 'site_id' => $id ]), 'app\validate\site\Site.edit');
( new SiteService() )->edit($id, $data);
return success('MODIFY_SUCCESS');
}
@ -125,8 +125,9 @@ class Site extends BaseAdminController
* @param $id
* @return Response
*/
public function del($id) {
(new SiteService())->del($id);
public function del($id)
{
( new SiteService() )->del($id);
return success('DELETE_SUCCESS');
}
@ -136,9 +137,9 @@ class Site extends BaseAdminController
public function openSite($id)
{
$data = $this->request->params([
['status', SiteDict::ON],
[ 'status', SiteDict::ON ],
]);
(new SiteService())->edit($id, $data);
( new SiteService() )->edit($id, $data);
return success();
}
@ -151,12 +152,19 @@ class Site extends BaseAdminController
* 获取站点拥有的应用
* @return Response
*/
public function addons() {
public function addons()
{
$data = $this->request->params([
['title', ''],
[ 'title', '' ],
]);
$data = (new SiteService())->getSiteAddons($data);
$data = ( new SiteService() )->getSiteAddons($data);
return success(data:$data);
}
public function showApp()
{
return success(( new SiteService() )->getShowAppTools());
}
}

View File

@ -84,6 +84,15 @@ Route::group('diy', function() {
// 复制模版
Route::post('copy', 'diy.Diy/copy');
// 获取自定义主题配色
Route::get('theme', 'diy.Diy/getDiyTheme');
// 设置主题配色
Route::post('theme', 'diy.Diy/setDiyTheme');
// 获取默认主题配色
Route::get('theme/color', 'diy.Diy/getDefaultThemeColor');
/***************************************************** 配置相关 *****************************************************/
// 底部导航列表
@ -95,6 +104,76 @@ Route::group('diy', function() {
// 设置底部导航
Route::post('bottom', 'diy.Config/setBottomConfig');
/***************************************************** 万能表单管理 ****************************************************/
// 万能表单分页列表
Route::get('form', 'diy.DiyForm/pages');
// 万能表单列表
Route::get('form/list', 'diy.DiyForm/lists');
// 万能表单类型
Route::get('form/type', 'diy.DiyForm/getFormType');
// 添加万能表单
Route::post('form', 'diy.DiyForm/add');
// 编辑万能表单
Route::put('form/:id', 'diy.DiyForm/edit');
// 万能表单详情
Route::get('form/:id', 'diy.DiyForm/info');
// 删除万能表单
Route::put('form/delete', 'diy.DiyForm/del');
// 获取万能表单微信小程序二维码
Route::get('form/qrcode', 'diy.DiyForm/getQrcode');
// 页面初始化数据
Route::get('form/init', 'diy.DiyForm/getInit');
// 获取页面模板
Route::get('form/template', 'diy.DiyForm/getTemplate');
// 获取万能表单填写配置
Route::get('form/write/:form_id', 'diy.DiyForm/getWriteConfig');
// 编辑万能表单填写配置
Route::put('form/write', 'diy.DiyForm/editWriteConfig');
// 获取万能表单填写配置
Route::get('form/submit/:form_id', 'diy.DiyForm/getSubmitConfig');
// 编辑万能表单填写配置
Route::put('form/submit', 'diy.DiyForm/editSubmitConfig');
// 编辑万能表单分享内容
Route::put('form/share', 'diy.DiyForm/modifyShare');
// 复制模版
Route::post('form/copy', 'diy.DiyForm/copy');
// 修改万能表单状态
Route::put('form/status', 'diy.DiyForm/modifyStatus');
//获取填写记录列表
Route::get('form/records', 'diy.DiyForm/getRecordPages');
//获取填写记录详情
Route::get('form/records/:record_id', 'diy.DiyForm/getRecordInfo');
//删除填写记录
Route::put('form/records/delete', 'diy.DiyForm/delRecord');
//获取万能表单字段记录
Route::get('form/fields/list', 'diy.DiyForm/getFieldsList');
//获取填表人统计列表
Route::get('form/records/member/stat', 'diy.DiyForm/memberStatPages');
//获取字段统计列表
Route::get('form/records/field/stat', 'diy.DiyForm/fieldStatList');
})->middleware([
AdminCheckToken::class,

View File

@ -120,6 +120,10 @@ Route::group('member', function() {
Route::get('cash_out/:id', 'member.CashOut/info');
//会员提现审核
Route::put('cash_out/audit/:id/:action', 'member.CashOut/audit');
//会员提现备注
Route::put('cash_out/remark/:id', 'member.CashOut/remark');
//校验会员提现转账状态
Route::put('cash_out/check/:id', 'member.CashOut/checkTransferStatus');
//转账方式
Route::get('cash_out/transfertype', 'member.CashOut/getTransferType');
//转账方式

View File

@ -87,6 +87,8 @@ Route::group('site', function () {
Route::get('account/type', 'site.SiteAccount/accountType');
// 获取店铺包含的插件
Route::get('addons', 'site.Site/addons');
// 获取应用列表
Route::get('showapp', 'site.Site/showApp');
})->middleware([
AdminCheckToken::class,
AdminCheckRole::class,

View File

@ -18,17 +18,19 @@ use think\Response;
class DiyForm extends BaseApiController
{
/**
* 系统表单详情
* @param int $id
* 万能表单详情
* @return Response
*/
public function info(int $id)
public function info()
{
return success(( new DiyFormService() )->getInfo($id));
$data = $this->request->params([
[ 'form_id', '' ],
]);
return success(( new DiyFormService() )->getInfo($data[ 'form_id' ]));
}
/**
* 添加使用记录
* 提交填表记录
* @return Response
*/
public function addRecord()
@ -38,6 +40,30 @@ class DiyForm extends BaseApiController
[ 'value', [] ],
[ 'relate_id', '' ],
]);
return success(( new DiyFormService())->addRecord($data));
return success('SUCCESS', ( new DiyFormService() )->addRecord($data));
}
/**
* 获取表单填写结果信息
* @return Response
*/
public function getResult()
{
$data = $this->request->params([
[ 'record_id', '' ],
]);
return success('SUCCESS', ( new DiyFormService() )->getResult($data));
}
/**
* 获取表单填写记录
* @return Response
*/
public function getRecord()
{
$data = $this->request->params([
[ 'record_id', '' ],
]);
return success('SUCCESS', ( new DiyFormService() )->getFormRecordInfo($data));
}
}

View File

@ -84,10 +84,13 @@ class Login extends BaseController
{
$data = $this->request->params([
[ 'mobile', '' ],
[ 'nickname', '' ],
[ 'headimg', '' ],
[ 'mobile', '' ]
]);
//校验登录注册配置
( new ConfigService() )->checkLoginConfig(MemberLoginTypeDict::MOBILE);
return success(( new LoginService() )->mobile($data[ 'mobile' ]));
return success(( new LoginService() )->mobile($data));
}
/**

View File

@ -57,7 +57,8 @@ class CashOutAccount extends BaseApiController
['account_type', ''],
['bank_name', ''],
['realname', ''],
['account_no', '']
['account_no', ''],
['transfer_payment_code', '']
]);
$this->validate($data, 'app\validate\member\CashOutAccount.addOrEdit');
$id = (new MemberCashOutAccountService())->add($data);
@ -74,7 +75,8 @@ class CashOutAccount extends BaseApiController
['account_type', ''],
['bank_name', ''],
['realname', ''],
['account_no', '']
['account_no', ''],
['transfer_payment_code', '']
]);
$this->validate($data, 'app\validate\member\CashOutAccount.addOrEdit');
(new MemberCashOutAccountService())->edit($account_id, $data);

View File

@ -24,16 +24,18 @@ class Member extends BaseApiController
* 会员信息
* @return Response
*/
public function info(){
return success((new MemberService())->getInfo());
public function info()
{
return success(( new MemberService() )->getInfo());
}
/**
* 会员中心
* @return Response
*/
public function center(){
return success((new MemberService())->center());
public function center()
{
return success(( new MemberService() )->center());
}
/**
@ -41,14 +43,15 @@ class Member extends BaseApiController
* @param $field
* @return Response
*/
public function modify($field){
public function modify($field)
{
$data = $this->request->params([
['value', ''],
['field', $field],
[ 'value', '' ],
[ 'field', $field ],
]);
$data[$field] = $data['value'];
$data[ $field ] = $data[ 'value' ];
$this->validate($data, 'app\validate\member\Member.modify');
(new MemberService())->modify($field, $data['value']);
( new MemberService() )->modify($field, $data[ 'value' ]);
return success('MODIFY_SUCCESS');
}
@ -56,11 +59,12 @@ class Member extends BaseApiController
* 编辑会员
* @return Response
*/
public function edit(){
public function edit()
{
$data = $this->request->params([
['data', []],
[ 'data', [] ],
]);
(new MemberService())->edit($data['data']);
( new MemberService() )->edit($data[ 'data' ]);
return success('MODIFY_SUCCESS');
}
@ -68,32 +72,47 @@ class Member extends BaseApiController
* 绑定手机号
* @return Response
*/
public function mobile(){
public function mobile()
{
$data = $this->request->params([
['mobile', ''],
['mobile_code', ''],
[ 'mobile', '' ],
[ 'mobile_code', '' ],
]);
return success((new AuthService())->bindMobile($data['mobile'], $data['mobile_code']));
return success(( new AuthService() )->bindMobile($data[ 'mobile' ], $data[ 'mobile_code' ]));
}
/**
* 会员日志
* @return Response
*/
public function log(){
public function log()
{
$data = $this->request->params([
['route', ''],
['params', ''],
['pre_route', '']
[ 'route', '' ],
[ 'params', '' ],
[ 'pre_route', '' ]
]);
(new MemberLogService())->log($data);
( new MemberLogService() )->log($data);
return success();
}
/**
* 获取会员码
*/
public function qrcode(){
return success((new MemberService())->getQrcode());
public function qrcode()
{
return success(( new MemberService() )->getQrcode());
}
/**
* 获取手机号
* @return Response
*/
public function getMobile()
{
$data = $this->request->params([
[ 'mobile_code', '' ],
]);
return success(( new AuthService() )->getMobile($data[ 'mobile_code' ]));
}
}

View File

@ -72,7 +72,8 @@ class MemberCashOut extends BaseApiController
[ 'apply_money', 0 ],
[ 'account_type', MemberAccountTypeDict::MONEY ],
[ 'transfer_type', '' ],
[ 'account_id', 0 ]
[ 'account_id', 0 ],
[ 'transfer_payee', []] ,//收款方信息
]);
$this->validate($data, 'app\validate\member\CashOut.apply');
return success(data:( new MemberCashOutService() )->apply($data));

View File

@ -12,6 +12,7 @@
namespace app\api\controller\sys;
use app\service\api\diy\DiyConfigService;
use app\service\api\diy\DiyService;
use app\service\api\member\MemberConfigService;
use app\service\api\member\MemberLevelService;
use app\service\api\member\MemberService;
@ -87,6 +88,7 @@ class Config extends BaseApiController
$res[ 'site_info' ] = ( new SiteService() )->getSiteCache();
$res[ 'member_level' ] = ( new MemberLevelService() )->getList();
$res[ 'login_config' ] = ( new MemberConfigService() )->getLoginConfig($data[ 'url' ]);
$res[ 'theme_list' ] = ( new DiyService() )->getDiyTheme();
( new MemberService() )->initMemberData();

View File

@ -32,6 +32,18 @@ class Upload extends BaseApiController
return success($upload_service->image($data['file']));
}
/**
* 视频上传
* @return Response
*/
public function video(){
$data = $this->request->params([
['file', 'file'],
]);
$upload_service = new UploadService();
return success($upload_service->video($data['file']));
}
/**
* 远程图片拉取
* @return Response

View File

@ -26,9 +26,15 @@ class Weapp extends BaseApiController
*/
public function login()
{
$data = $this->request->params([ [ 'code', '' ] ]);
$data = $this->request->params([
[ 'code', '' ],
[ 'nickname', '' ],
[ 'headimg', '' ],
[ 'mobile', '' ],
[ 'mobile_code', '' ]
]);
$weapp_auth_service = new WeappAuthService();
return success($weapp_auth_service->login($data[ 'code' ]));
return success($weapp_auth_service->login($data));
}
/**

View File

@ -28,20 +28,26 @@ Route::group('diy', function() {
Route::get('share', 'diy.Diy/share');
// 万能表单详情
Route::get('form', 'diy.DiyForm/info');
})->middleware(ApiLog::class)
->middleware(ApiCheckToken::class, false);
/**
* 自定义页面
* 自定义表单
*/
Route::group('diy', function() {
// 系统表单详情
Route::get('form/:id', 'diy.DiyForm/info');
//添加使用记录
Route::post('form/records', 'diy.DiyForm/addRecord');
// 提交填表记录
Route::post('form/record', 'diy.DiyForm/addRecord');
// 获取表单填写结果信息
Route::get('form/result', 'diy.DiyForm/getResult');
// 获取填表记录
Route::get('form/record', 'diy.DiyForm/getRecord');
})->middleware(ApiLog::class)
->middleware(ApiCheckToken::class,true);
->middleware(ApiCheckToken::class, true);

View File

@ -18,16 +18,27 @@ use think\facade\Route;
/**
* 会员个人信息管理
*/
Route::group('file', function () {
Route::group('file', function() {
/***************************************************** 会员管理 ****************************************************/
//上传图片
Route::post('image', 'upload.Upload/image');
//上传视频
Route::post('video', 'upload.Upload/video');
//拉取图片
Route::post('image/fetch', 'upload.Upload/imageFetch');
})->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);
/**
* 会员个人信息管理
*/
Route::group('file', function() {
//base64图片
Route::post('image/base64', 'upload.Upload/imageBase64');
})->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);
->middleware(ApiLog::class);

View File

@ -116,6 +116,9 @@ Route::group('member', function () {
//会员日志
Route::post('log', 'member.Member/log');
// 获取手机号
Route::put('getMobile', 'member.Member/getMobile');
/***************************************************** 会员等级 **************************************************/
Route::get('level', 'member.Level/lists');
})->middleware(ApiChannel::class)

View File

@ -978,3 +978,43 @@ function is_special_character($str)
return false;
}
}
/**
* 时间格式转换
* @param $time
* @return string
*/
function get_last_time($time = null)
{
$text = '';
$time = $time === null || $time > time() ? time() : intval($time);
$t = time() - $time; //时间差 (秒)
$y = date('Y', $time) - date('Y', time());//是否跨年
switch ($t) {
case 0:
$text = '刚刚';
break;
case $t < 60:
$text = $t . '秒前'; // 一分钟内
break;
case $t < 60 * 60:
$text = floor($t / 60) . '分钟前'; //一小时内
break;
case $t < 60 * 60 * 24:
$text = floor($t / ( 60 * 60 )) . '小时前'; // 一天内
break;
case $t < 60 * 60 * 24 * 3:
$text = floor($time / ( 60 * 60 * 24 )) == 1 ? '昨天' . date('H:i', $time) : '前天' . date('H:i', $time); //昨天和前天
break;
case $t < 60 * 60 * 24 * 30:
$text = date('m-d H:i', $time); //一个月内
break;
case $t < 60 * 60 * 24 * 365 && $y == 0:
$text = date('m-d', $time); //一年内
break;
default:
$text = date('Y-m-d', $time); //一年以前
break;
}
return $text;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\diy_form;
/**
* 万能表单提交页配置项
*/
class ConfigDict
{
//填表人提交后操作
const TEXT = 'text'; // 文字
const VOUCHER = 'voucher'; // 核销凭证
//提示内容类型
const DEFAULT = 'default'; // 默认提示
const DIY = 'diy'; // 自定义提示
// 核销凭证有效期限制类型 / 填写时间限制类型
const NO_LIMIT = 'no_limit'; // 不限制
const SPECIFY_TIME = 'specify_time'; // 指定固定开始结束时间
const VALIDITY_TIME = 'validity_time'; // 按提交时间设置有效期
// 填写方式
const WRITE_WAY_NO_LIMIT = 'no_limit'; // 不限制
const WRITE_WAY_SCAN = 'scan'; // 仅限微信扫一扫
const WRITE_WAY_URL = 'url'; // 仅限链接进入
// 参与会员
const ALL_MEMBER = 'all_member';// 所有会员参与
const SELECTED_MEMBER_LEVEL = 'selected_member_level'; // 指定会员等级
const SELECTED_MEMBER_LABEL = 'selected_member_label'; // 指定会员标签
// 填写次数限制
const WRITE_NUM_NO_LIMIT = 'no_limit'; // 不限制
const WRITE_NUM_DIY = 'diy'; // 自定义
// 是否允许修改自己填写的内容
const NO = 0; // 否
const YES = 1; // 是
}

View File

@ -0,0 +1,785 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\diy_form;
use core\dict\DictLoader;
/**
* 页面模板
*/
class TemplateDict
{
/**
* 获取万能表单模版
* @param array $params
* @return array|null
*/
public static function getTemplate($params = [])
{
$other_template_data = ( new DictLoader("DiyFormTemplate") )->load([]);
$template = self::template();
$data = array_merge($other_template_data, $template);
if (!empty($params) && !empty($params[ 'type' ])) {
if (!empty($params[ 'template_key' ])) {
return $data[ $params[ 'type' ] ][ $params[ 'template_key' ] ] ?? [];
}
return $data[ $params[ 'type' ] ] ?? [];
}
return $data;
}
public static function template()
{
$data = [
"DIY_FORM" => [
'active_sign_up' => [ // 页面标识
"title" => "活动报名", // 页面名称
'cover' => '', // 页面封面图
'preview' => '', // 页面预览图
'desc' => '适用于活动宣传,收集报名信息,快速统计报名总人数', // 页面描述
'containField' => '共8个字段包含8个字段姓名、手机号、身份证号、邮箱、日期、报名职位、特长优点、入职时长', // 包含字段
// 页面数据源
"data" => [
"global" => [
"title" => "活动报名",
"completeLayout" => "style-1",
"completeAlign" => "left",
"borderControl" => true,
"pageStartBgColor" => "rgba(255, 255, 255, 1)",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"bgUrl" => "",
"bgHeightScale" => 100,
"imgWidth" => "",
"imgHeight" => "",
"topStatusBar" => [
"isShow" => true,
"bgColor" => "#ffffff",
"rollBgColor" => "#ffffff",
"style" => "style-1",
"styleName" => "风格1",
"textColor" => "#333333",
"rollTextColor" => "#333333",
"textAlign" => "center",
"inputPlaceholder" => "请输入搜索关键词",
"imgUrl" => "",
"link" => [
"name" => ""
]
],
"bottomTabBarSwitch" => true,
"popWindow" => [
"imgUrl" => "",
"imgWidth" => "",
"imgHeight" => "",
"count" => -1,
"show" => 0,
"link" => [
"name" => ""
]
],
"template" => [
"textColor" => "#303133",
"pageStartBgColor" => "",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 0,
"bottom" => 0,
"both" => 0
],
"isHidden" => false
]
],
"value" => [
[
"path" => "edit-image-ads",
"uses" => 0,
"componentType" => "diy",
"id" => "36vpa1zz5mw0",
"componentName" => "ImageAds",
"componentTitle" => "图片广告",
"ignore" => [
"componentBgUrl"
],
"imageHeight" => 150,
"isSameScreen" => false,
"list" => [
[
"link" => [
"name" => ""
],
"imageUrl" => "static/resource/images/diy_form/diy_form_active_sign_up_banner.png",
"imgWidth" => 750,
"imgHeight" => 300,
"id" => "4wk5whtbi0m0",
"width" => 375,
"height" => 150
]
],
"textColor" => "#303133",
"pageStartBgColor" => "",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 0,
"bottom" => 0,
"both" => 0
],
"isHidden" => false,
"pageStyle" => "padding-top:2rpx;padding-bottom:0rpx;padding-right:0rpx;padding-left:0rpx;"
],
[
"path" => "edit-form-input",
"uses" => 0,
"position" => "",
"componentType" => "diy_form",
"id" => "46wkksoz5ew0",
"componentName" => "FormInput",
"componentTitle" => "单行文本",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "姓名",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => true,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => "",
"value" => ""
],
"placeholder" => "请输入姓名",
"fontSize" => 14,
"fontWeight" => "bold",
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 15,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:30rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-mobile",
"uses" => 1,
"componentType" => "diy_form",
"id" => "6tsdwql8ds00",
"componentName" => "FormMobile",
"componentTitle" => "手机号",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "手机号",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => false,
"unique" => true,
"autofill" => false,
"privacyProtection" => true,
"default" => "",
"value" => ""
],
"placeholder" => "请输入手机号",
"fontSize" => 14,
"fontWeight" => "bold",
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-identity",
"uses" => 1,
"componentType" => "diy_form",
"id" => "4hy63cm1lj80",
"componentName" => "FormIdentity",
"componentTitle" => "身份证号",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "身份证号",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => false,
"unique" => true,
"autofill" => false,
"privacyProtection" => false,
"default" => "",
"value" => ""
],
"placeholder" => "请输入身份证号",
"fontSize" => 14,
"fontWeight" => "bold",
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-email",
"uses" => 0,
"componentType" => "diy_form",
"id" => "13f2w3r9h9vg",
"componentName" => "FormEmail",
"componentTitle" => "邮箱",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "邮箱",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => false,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => "",
"value" => ""
],
"placeholder" => "请输入邮箱",
"fontSize" => 14,
"fontWeight" => "bold",
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-date",
"uses" => 0,
"componentType" => "diy_form",
"id" => "7dc7gd9hh400",
"componentName" => "FormDate",
"componentTitle" => "日期",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "日期",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => true,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => [
"date" => "2025-01-11",
"timestamp" => 1736564405.243
],
"value" => [
"date" => "2025-01-11 11=>02",
"timestamp" => 1736564520
]
],
"placeholder" => "请选择日期",
"fontSize" => 14,
"fontWeight" => "bold",
"dateFormat" => "YYYY-MM-DD HH:mm",
"dateWay" => "current",
"defaultControl" => true,
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-radio",
"uses" => 0,
"componentType" => "diy_form",
"id" => "3z2yq22p9xc0",
"componentName" => "FormRadio",
"componentTitle" => "单选项",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "报名职位",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => true,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => [],
"value" => []
],
"fontSize" => 14,
"fontWeight" => "bold",
"style" => "style-2",
"options" => [
[
"id" => "fzjmiaochnsd",
"text" => "前台"
],
[
"id" => "mabstfflrdpj",
"text" => "收银"
],
[
"id" => "1ogre1qndmrk",
"text" => "后厨"
],
[
"id" => "1mv5qku9wihs",
"text" => "财务"
],
[
"id" => "qfdjp035qsw",
"text" => "经理"
]
],
"logicalRule" => [
[
"triggerOptionId" => "",
"execEvent" => [
[
"id" => "",
"componentName" => "",
"componentTitle" => ""
]
]
]
],
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-textarea",
"uses" => 0,
"componentType" => "diy_form",
"id" => "39m5zel59cw0",
"componentName" => "FormTextarea",
"componentTitle" => "多行文本",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "特长优点",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => false,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => "",
"value" => ""
],
"placeholder" => "请输入特长优点",
"fontSize" => 14,
"fontWeight" => "bold",
"rowCount" => 4,
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-date-scope",
"uses" => 0,
"convert" => [],
"componentType" => "diy_form",
"id" => "mj9fl99x02o",
"componentName" => "FormDateScope",
"componentTitle" => "日期范围",
"ignore" => [
"componentBgUrl"
],
"field" => [
"name" => "入职时长",
"remark" => [
"text" => "",
"color" => "#999999",
"fontSize" => 14
],
"required" => false,
"unique" => false,
"autofill" => false,
"privacyProtection" => false,
"default" => [
"start" => [
"date" => "2025-01-11",
"timestamp" => 1736585705
],
"end" => [
"date" => "2025-01-18",
"timestamp" => 1737190505
]
],
"value" => [
"start" => [
"date" => "2025/01/11",
"timestamp" => 1736524800
],
"end" => [
"date" => "2025/01/11",
"timestamp" => 1736524800
]
]
],
"fontSize" => 14,
"fontWeight" => "bold",
"dateFormat" => "YYYY/MM/DD",
"start" => [
"placeholder" => "请选择起始日期",
"dateWay" => "diy",
"defaultControl" => true
],
"end" => [
"placeholder" => "请选择结束日期",
"dateWay" => "diy",
"defaultControl" => true
],
"textColor" => "#303133",
"pageStartBgColor" => "#FFFFFF",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 0,
"bottomElementRounded" => 0,
"margin" => [
"top" => 5,
"bottom" => 10,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "background-color:#FFFFFF;padding-top:10rpx;padding-bottom:20rpx;padding-right:34rpx;padding-left:34rpx;"
],
[
"path" => "edit-form-submit",
"uses" => 1,
"position" => "bottom_fixed",
"componentType" => "diy_form",
"id" => "38b02iygfzc0",
"componentName" => "FormSubmit",
"componentTitle" => "表单提交",
"ignore" => [
"componentBgUrl"
],
"btnPosition" => "follow_content",
"submitBtn" => [
"text" => "提交",
"color" => "#ffffff",
"bgColor" => "#409EFF"
],
"resetBtn" => [
"control" => true,
"text" => "重置",
"color" => "",
"bgColor" => ""
],
"textColor" => "#303133",
"pageStartBgColor" => "",
"pageEndBgColor" => "",
"pageGradientAngle" => "to bottom",
"componentBgUrl" => "",
"componentBgAlpha" => 2,
"componentStartBgColor" => "",
"componentEndBgColor" => "",
"componentGradientAngle" => "to bottom",
"topRounded" => 0,
"bottomRounded" => 0,
"elementBgColor" => "",
"topElementRounded" => 50,
"bottomElementRounded" => 50,
"margin" => [
"top" => 5,
"bottom" => 5,
"both" => 25
],
"isHidden" => false,
"pageStyle" => "padding-top:10rpx;padding-bottom:10rpx;padding-right:20rpx;padding-left:20rpx;"
]
]
]
],
],
// todo 靠后完善
// 'SIGN_REGISTRATION' => [
// 'active_sign_up' => [ // 页面标识
// "title" => "活动报名", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '适用于活动宣传,收集报名信息,快速统计报名总人数', // 页面描述
// 'containField' => '共2个字段包含2个字段姓名、手机号', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// 'attendance_clock_in' => [ // 页面标识
// "title" => "考勤打卡", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '无需额外设备,员工直接使用微信扫码完成考勤打卡,管理员可随时查看考勤汇总数据,导出后进行工作考核', // 页面描述
// 'containField' => '包含5个字段打卡类型、姓名、手机号、定位、备注', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// 'meeting_sign_up' => [ // 页面标识
// "title" => "会议报名", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '填表人报名后获取核销凭证,活动现场出示,主办方可核销', // 页面描述
// 'containField' => '包含4个字段姓名、手机号、公司名称、职务', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// 'service_reservation' => [ // 页面标识
// "title" => "服务预约", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '扫码填写预约报名信息,管理者可及时查看预约情况', // 页面描述
// 'containField' => '共5个字段包含5个字段姓名、联系方式、预约日期、预约时间、备注', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// 'person_registration' => [ // 页面标识
// "title" => "人员信息登记", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '适用于员工、学生、居民和访客等各类人员的信息收集场景', // 页面描述
// 'containField' => '包含8个字段姓名、手机号、性别、身份证号、出生日期、民族、籍贯、家庭地址', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// ],
// 'LEAVE_MESSAGE_SUGGESTION' => [
// 'feedback_collection' => [ // 页面标识
// "title" => "反馈意见收集", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '反馈人扫码即可随时随地进行留言建议,管理人可以审核内容,在线回复', // 页面描述
// 'containField' => '共5个字段包含5个字段您要反馈哪方面的问题、详细描述、相关图片、反馈人、手机号', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// 'Satisfaction_level_questionnaire' => [ // 页面标识
// "title" => "满意度调查问卷", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '通过满意度调研表单制作一个满意度调研二维码,所有人扫码即可填写,代替原有纸质方式;所有的评价都将汇总在管理后台,可以统一导出进行统计,了解整体的服务质量', // 页面描述
// 'containField' => '包含12个字段1. 商场温度舒适度、2. 电梯及扶梯是否运行正常、3. 商场地面、墙面及天花板清洁、4. 卫生间地面、台盆及镜面清洁、5. 卫生间客用品是否缺失、6. 卫生间有无异味、7. 保洁员工仪容仪表及工作态度、8. 安保员工仪容仪表及工作态度、9. 车场停车费扫码付费便捷度、姓名、联系方式、图文描述', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// ],
// 'WRITE_OFF_VOUCHER' => [
// 'gift_receive_reservation' => [ // 页面标识
// "title" => "礼品领取预约", // 页面名称
// 'cover' => '', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '客户线上填写信息并选择礼品,完成后获取二维码凭证。在现场,出示该凭证领取礼品,工作人员扫描凭证进行核销', // 页面描述
// 'containField' => '包含3个字段姓名、手机、礼品选择', // 包含字段
// // 页面数据源
// "data" => [
// "global" => [],
// "value" => []
// ]
// ],
// ],
];
return $data;
}
}

View File

@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\diy_form;
use core\dict\DictLoader;
/**
* 万能表单类型
*/
class TypeDict
{
/**
* 获取万能表单类型
* @param array $params
* @return array|null
*/
public static function getType($params = [])
{
$system_pages = [
//自定义表单
'DIY_FORM' => [
'title' => get_lang('dict_diy_form.type_diy_form'),
'preview' => 'static/resource/images/diy_form/diy_from_preview.jpg', // 预览图
'sort' => 10001,
'addon' => ''
],
//签到报名登记 todo 靠后完善
// 'SIGN_REGISTRATION' => [
// 'title' => get_lang('dict_diy_form.type_sign_registration'),
// 'preview' => 'static/resource/images/diy_form/diy_from_preview.png',
// 'sort' => 10002,
// 'addon' => ''
// ],
//留言建议 todo 靠后完善
// 'LEAVE_MESSAGE_SUGGESTION' => [
// 'title' => get_lang('dict_diy_form.type_leave_message_suggestion'),
// 'preview' => 'static/resource/images/diy_form/diy_from_preview.png',
// 'sort' => 10003,
// 'addon' => ''
// ],
//核销凭证 todo 靠后完善
// 'WRITE_OFF_VOUCHER' => [
// 'title' => get_lang('dict_diy_form.type_write_off_voucher'),
// 'preview' => 'static/resource/images/diy_form/diy_from_preview.png',
// 'sort' => 10004,
// 'addon' => ''
// ],
];
$data = ( new DictLoader("DiyFormType") )->load($system_pages);
if (!empty($params) && !empty($params[ 'type' ])) {
return $data[ $params[ 'type' ] ];
}
return $data;
}
}

View File

@ -20,6 +20,7 @@ class MemberCashOutDict
{
public const WAIT_AUDIT = 1;//待审核
public const WAIT_TRANSFER = 2;//待转账
public const TRANSFER_ING = 4;//转账中
public const TRANSFERED = 3;//已转账
public const REFUSE = -1;//已拒绝
public const CANCEL = -2;//已取消
@ -33,6 +34,7 @@ class MemberCashOutDict
return [
self::WAIT_AUDIT => get_lang('dict_member_cash_out.status_wait_audit'),//待审核
self::WAIT_TRANSFER => get_lang('dict_member_cash_out.status_wait_transfer'),//待转账
self::TRANSFER_ING => get_lang('dict_member_cash_out.status_transfer_ing'),//转账中
self::TRANSFERED => get_lang('dict_member_cash_out.status_transfered'),//已转账
self::REFUSE => get_lang('dict_member_cash_out.status_refuse'),//已拒绝
self::CANCEL => get_lang('dict_member_cash_out.status_cancel'),//已取消

View File

@ -6,7 +6,7 @@ return [
'menu_short_name' => '首页',
'parent_key' => '',
'menu_type' => '1',
'icon' => 'element Monitor',
'icon' => 'iconfont iconshouye2',
'api_url' => '',
'router_path' => 'index',
'view_path' => 'index/index',
@ -37,7 +37,7 @@ return [
'menu_short_name' => '配置',
'parent_key' => '',
'menu_type' => '0',
'icon' => 'element Setting',
'icon' => 'iconfont iconshezhi11',
'api_url' => '',
'router_path' => '',
'view_path' => '',
@ -51,7 +51,7 @@ return [
'menu_key' => 'website_setting',
'menu_short_name' => '网站设置',
'menu_type' => '0',
'icon' => 'iconfont iconwangzhan1',
'icon' => 'iconfont iconwangzhanshezhi',
'api_url' => '',
'router_path' => '',
'view_path' => '',
@ -65,7 +65,7 @@ return [
'menu_key' => 'base_setting',
'menu_short_name' => '基础设置',
'menu_type' => '1',
'icon' => 'element Basketball',
'icon' => 'iconfont iconjichushezhi1',
'api_url' => 'sys/config/website',
'router_path' => 'setting/website/system',
'view_path' => 'setting/system',
@ -95,7 +95,7 @@ return [
'menu_key' => 'setting_copyright',
'menu_short_name' => '版权设置',
'menu_type' => '1',
'icon' => 'iconfont iconbanquan1',
'icon' => 'iconfont iconbanquanshezhi',
'api_url' => 'sys/config/copyright',
'router_path' => 'setting/website/copyright',
'view_path' => 'setting/copyright',
@ -127,7 +127,7 @@ return [
'menu_key' => 'auth',
'menu_short_name' => '权限设置',
'menu_type' => '0',
'icon' => 'iconfont iconquanxianguanli',
'icon' => 'iconfont iconquanxianshezhi',
'api_url' => '',
'router_path' => '',
'view_path' => '',
@ -141,7 +141,7 @@ return [
'menu_key' => 'auth_list',
'menu_short_name' => '管理员',
'menu_type' => '1',
'icon' => 'element Lock',
'icon' => 'iconfont iconguanliyuan',
'api_url' => 'site/user',
'router_path' => 'setting/auth/user',
'view_path' => 'auth/user',
@ -255,7 +255,7 @@ return [
'menu_key' => 'auth_role',
'menu_short_name' => '管理员角色',
'menu_type' => '1',
'icon' => 'iconfont iconhuiyuanliebiao',
'icon' => 'iconfont iconguanliyuanjiaose',
'api_url' => 'sys/role',
'router_path' => 'setting/auth/role',
'view_path' => 'auth/role',
@ -313,7 +313,7 @@ return [
'menu_key' => 'auth_log',
'menu_short_name' => '操作日志',
'menu_type' => '1',
'icon' => 'element Document',
'icon' => 'iconfont iconcaozuorizhi',
'api_url' => 'sys/log',
'router_path' => 'setting/auth/log',
'view_path' => 'auth/log',
@ -329,7 +329,7 @@ return [
'menu_key' => 'setting_storage',
'menu_short_name' => '存储设置',
'menu_type' => '1',
'icon' => 'element FolderChecked',
'icon' => 'iconfont iconcunchushezhi',
'api_url' => 'sys/storage',
'router_path' => 'setting/storage',
'view_path' => 'setting/storage',
@ -373,7 +373,7 @@ return [
'menu_key' => 'setting_login',
'menu_short_name' => '登录设置',
'menu_type' => '1',
'icon' => 'iconfont iconzhuceshezhi',
'icon' => 'iconfont icondenglushezhi',
'api_url' => 'sys/config/login',
'router_path' => 'setting/adminlogin',
'view_path' => 'setting/adminlogin',
@ -403,7 +403,7 @@ return [
'menu_key' => 'wx_oplatform',
'menu_short_name' => '微信开放平台',
'menu_type' => '0',
'icon' => 'iconfont iconweixin',
'icon' => 'iconfont iconweixinkaifangpingtai',
'api_url' => '',
'router_path' => '',
'view_path' => '',
@ -417,7 +417,7 @@ return [
'menu_key' => 'setting_oplatform',
'menu_short_name' => '开放平台配置',
'menu_type' => '1',
'icon' => 'iconfont iconweixin',
'icon' => 'iconfont iconkaifangpingtaipeizhi',
'api_url' => 'wxoplatform/config',
'router_path' => 'setting/oplatform',
'view_path' => 'wxoplatform/setting',
@ -447,7 +447,7 @@ return [
'menu_key' => 'oplatform_weapp_version',
'menu_short_name' => '小程序同步',
'menu_type' => '1',
'icon' => 'iconfont iconweixin',
'icon' => 'iconfont iconxiaochengxutongbu',
'api_url' => 'wxoplatform/weapp/commit',
'router_path' => 'wxoplatform/weapp_version',
'view_path' => 'wxoplatform/weapp_version',
@ -479,7 +479,7 @@ return [
'menu_key' => 'attachment',
'menu_short_name' => '素材管理',
'menu_type' => '1',
'icon' => 'element Files',
'icon' => 'iconfont iconsucaiguanli1',
'api_url' => 'sys/attachment',
'router_path' => 'setting/attachment',
'view_path' => 'tools/attachment',
@ -579,7 +579,7 @@ return [
'menu_key' => 'map_setting',
'menu_short_name' => '地图设置',
'menu_type' => '1',
'icon' => 'element Message',
'icon' => 'iconfont iconditu2',
'api_url' => 'sys/config/map',
'router_path' => 'setting/map',
'view_path' => 'setting/map',
@ -609,7 +609,7 @@ return [
'menu_key' => 'layout_setting',
'menu_short_name' => '布局设置',
'menu_type' => '1',
'icon' => 'element Message',
'icon' => 'iconfont iconbujushezhi',
'api_url' => 'sys/config/layout',
'router_path' => 'setting/layout',
'view_path' => 'setting/layout',
@ -642,7 +642,7 @@ return [
'menu_short_name' => '站点',
'parent_key' => '',
'menu_type' => '0',
'icon' => 'element Memo',
'icon' => 'iconfont iconzhandianguanli',
'api_url' => '',
'router_path' => '',
'view_path' => '',
@ -656,7 +656,7 @@ return [
'menu_key' => 'site_list',
'menu_short_name' => '站点列表',
'menu_type' => '1',
'icon' => 'element OfficeBuilding',
'icon' => 'iconfont iconzhandianliebiao',
'api_url' => 'site/site',
'router_path' => 'site/list',
'view_path' => 'site/list',
@ -770,7 +770,7 @@ return [
'menu_key' => 'site_group',
'menu_short_name' => '站点套餐',
'menu_type' => '1',
'icon' => 'element PriceTag',
'icon' => 'iconfont iconzhandiantaocan',
'api_url' => 'site/group',
'router_path' => 'site/group',
'view_path' => 'site/group',
@ -846,7 +846,7 @@ return [
'menu_key' => 'site_user_list',
'menu_short_name' => '用户',
'menu_type' => '1',
'icon' => 'iconfont iconhuiyuanzhongxin',
'icon' => 'iconfont iconyonghu1',
'api_url' => 'user/user',
'router_path' => 'site/user',
'view_path' => 'site/user',
@ -961,7 +961,7 @@ return [
'menu_short_name' => '应用',
'parent_key' => '',
'menu_type' => '1',
'icon' => 'element ShoppingBag',
'icon' => 'iconfont iconyingyong2',
'api_url' => 'addon/local',
'router_path' => 'app_manage/app_store',
'view_path' => 'index/store',
@ -1061,7 +1061,7 @@ return [
'menu_key' => 'app_manage_tool',
'menu_short_name' => '开发',
'menu_type' => '1',
'icon' => 'iconfont iconchajian1',
'icon' => 'iconfont icona-kaifa1',
'api_url' => '',
'router_path' => 'app_manage/tools',
'view_path' => 'index/tools',
@ -1090,7 +1090,7 @@ return [
'menu_key' => 'addon_develop',
'menu_short_name' => '插件开发',
'menu_type' => '1',
'icon' => 'iconfont iconchajiankaifa',
'icon' => 'iconfont iconchajiankaifa1',
'api_url' => '',
'router_path' => 'tools/addon',
'view_path' => 'tools/addon/index',
@ -1134,7 +1134,7 @@ return [
'menu_key' => 'code',
'menu_short_name' => '代码生成',
'menu_type' => '1',
'icon' => 'iconfont icondaimashengcheng',
'icon' => 'iconfont icondaimashengcheng1',
'api_url' => 'generator/generator',
'router_path' => 'tools/code',
'view_path' => 'tools/code/index',
@ -1264,7 +1264,7 @@ return [
'menu_key' => 'sys_dict_dict_dict_list',
'menu_short_name' => '数据字典',
'menu_type' => '1',
'icon' => 'iconfont iconwenzhangguanli1',
'icon' => 'iconfont iconshujuzidian',
'api_url' => 'dict/post/post',
'router_path' => 'tools/list',
'view_path' => 'dict/list',
@ -1322,7 +1322,7 @@ return [
'menu_key' => 'tools_check_environment',
'menu_short_name' => '环境检测',
'menu_type' => '1',
'icon' => 'iconfont iconhuanjingjiance',
'icon' => 'iconfont iconhuanjingjiance1',
'api_url' => '',
'router_path' => 'tools/detection',
'view_path' => 'tools/detection',
@ -1336,7 +1336,7 @@ return [
'menu_key' => 'platform_menu',
'menu_short_name' => '平台菜单',
'menu_type' => '1',
'icon' => '',
'icon' => 'iconfont iconpingtaicaidan',
'api_url' => 'sys/menu',
'router_path' => 'tools/admin_menu',
'view_path' => 'auth/menu',
@ -1408,7 +1408,7 @@ return [
'menu_key' => 'site_menu',
'menu_short_name' => '站点菜单',
'menu_type' => '1',
'icon' => '',
'icon' => 'iconfont iconzhandiancaidan',
'api_url' => 'sys/menu',
'router_path' => 'tools/site_menu',
'view_path' => 'auth/site_menu',
@ -1480,7 +1480,7 @@ return [
'menu_key' => 'tools_schedule',
'menu_short_name' => '计划任务',
'menu_type' => '1',
'icon' => 'iconfont iconjihuarenwu',
'icon' => 'iconfont iconjihuarenwu1',
'api_url' => 'sys/schedule/list',
'router_path' => 'tools/schedule',
'view_path' => 'tools/schedule',
@ -1566,7 +1566,7 @@ return [
'menu_key' => 'app_auth',
'menu_short_name' => '授权信息',
'menu_type' => '1',
'icon' => 'iconfont iconshouquanxinxi2',
'icon' => 'iconfont iconshouquanxinxi',
'api_url' => '',
'router_path' => 'tools/authorize',
'view_path' => 'app/authorize',
@ -1610,7 +1610,7 @@ return [
'menu_key' => 'developer_token',
'menu_short_name' => '开发者key',
'menu_type' => '1',
'icon' => 'iconfont iconshouquanxinxi2',
'icon' => 'iconfont iconkaifazhekey',
'api_url' => 'sys/config/developer_token',
'router_path' => 'tools/developer_token',
'view_path' => 'setting/developer_token',

View File

@ -289,6 +289,48 @@ return [
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '主题风格',
'menu_key' => 'diy_theme_style',
'menu_short_name' => '主题风格',
'menu_type' => '1',
'icon' => 'element Files',
'api_url' => '',
'router_path' => 'diy/theme_style',
'view_path' => 'diy/theme_style',
'methods' => 'get',
'sort' => '92',
'status' => '1',
'is_show' => '1'
],
[
'menu_name' => '数据列表',
'menu_key' => 'diy_form_record_list',
'menu_short_name' => '数据列表',
'menu_type' => '1',
'icon' => '',
'api_url' => 'diy_form/records',
'router_path' => 'diy_form/records',
'view_path' => 'diy_form/records',
'methods' => 'get',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '保存',
'menu_key' => 'diy_form_update',
'menu_short_name' => '保存',
'menu_type' => '2',
'icon' => '',
'api_url' => 'diy_form',
'router_path' => '',
'view_path' => '',
'methods' => 'post',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
],
],
[
@ -2161,6 +2203,122 @@ return [
],
],
],
[
'menu_name' => '小票打印',
'menu_key' => 'printer_management',
'menu_short_name' => '小票打印',
'menu_type' => '1',
'icon' => 'element FolderChecked',
'api_url' => 'printer',
'router_path' => 'printer/list',
'view_path' => 'printer/list',
'methods' => 'get',
'sort' => '30',
'status' => '1',
'is_show' => '1',
'children' => [
[
'menu_name' => '删除打印机',
'menu_key' => 'delete_printer',
'menu_short_name' => '删除打印机',
'menu_type' => '2',
'icon' => '',
'api_url' => 'printer/<id>',
'router_path' => '',
'view_path' => '',
'methods' => 'delete',
'sort' => '100',
'status' => '1',
'is_show' => '1',
]
]
],
[
'menu_name' => '添加打印机',
'menu_key' => 'printer_add',
'menu_short_name' => '添加打印机',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer',
'router_path' => 'printer/add',
'view_path' => 'printer/edit',
'methods' => 'post',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '编辑打印机',
'menu_key' => 'printer_edit',
'menu_short_name' => '添加打印机',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/<id>',
'router_path' => 'printer/edit',
'view_path' => 'printer/edit',
'methods' => 'put',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '小票打印模板',
'menu_key' => 'printer_template_management',
'menu_short_name' => '小票打印模板',
'menu_type' => '1',
'icon' => 'element FolderChecked',
'api_url' => 'printer/template',
'router_path' => 'printer/template/list',
'view_path' => 'printer/template_list',
'methods' => 'get',
'sort' => '96',
'status' => '1',
'is_show' => '0',
'children' => [
[
'menu_name' => '删除打印模板',
'menu_key' => 'delete_printer_template',
'menu_short_name' => '删除打印模板',
'menu_type' => '2',
'icon' => '',
'api_url' => 'printer/template/<id>',
'router_path' => '',
'view_path' => '',
'methods' => 'delete',
'sort' => '100',
'status' => '1',
'is_show' => '1',
]
]
],
[
'menu_name' => '添加打印模板',
'menu_key' => 'printer_template_add',
'menu_short_name' => '添加打印模板',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/template',
'router_path' => 'printer/template/add',
'view_path' => 'printer/template_edit',
'methods' => 'post',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '编辑打印模板',
'menu_key' => 'printer_template_edit',
'menu_short_name' => '编辑打印模板',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/template/<id>',
'router_path' => 'printer/template/edit',
'view_path' => 'printer/template_edit',
'methods' => 'put',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '系统工具',
'menu_key' => 'setting_tool',
@ -2171,7 +2329,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '30',
'sort' => '20',
'status' => '1',
'is_show' => '1',
'children' => [
@ -2337,122 +2495,6 @@ return [
]
]
],
[
'menu_name' => '小票打印',
'menu_key' => 'printer_management',
'menu_short_name' => '小票打印',
'menu_type' => '1',
'icon' => 'element FolderChecked',
'api_url' => 'printer',
'router_path' => 'printer/list',
'view_path' => 'printer/list',
'methods' => 'get',
'sort' => '97',
'status' => '1',
'is_show' => '1',
'children' => [
[
'menu_name' => '删除打印机',
'menu_key' => 'delete_printer',
'menu_short_name' => '删除打印机',
'menu_type' => '2',
'icon' => '',
'api_url' => 'printer/<id>',
'router_path' => '',
'view_path' => '',
'methods' => 'delete',
'sort' => '100',
'status' => '1',
'is_show' => '1',
]
]
],
[
'menu_name' => '添加打印机',
'menu_key' => 'printer_add',
'menu_short_name' => '添加打印机',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer',
'router_path' => 'printer/add',
'view_path' => 'printer/edit',
'methods' => 'post',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '编辑打印机',
'menu_key' => 'printer_edit',
'menu_short_name' => '添加打印机',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/<id>',
'router_path' => 'printer/edit',
'view_path' => 'printer/edit',
'methods' => 'put',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '小票打印模板',
'menu_key' => 'printer_template_management',
'menu_short_name' => '小票打印模板',
'menu_type' => '1',
'icon' => 'element FolderChecked',
'api_url' => 'printer/template',
'router_path' => 'printer/template/list',
'view_path' => 'printer/template_list',
'methods' => 'get',
'sort' => '96',
'status' => '1',
'is_show' => '0',
'children' => [
[
'menu_name' => '删除打印模板',
'menu_key' => 'delete_printer_template',
'menu_short_name' => '删除打印模板',
'menu_type' => '2',
'icon' => '',
'api_url' => 'printer/template/<id>',
'router_path' => '',
'view_path' => '',
'methods' => 'delete',
'sort' => '100',
'status' => '1',
'is_show' => '1',
]
]
],
[
'menu_name' => '添加打印模板',
'menu_key' => 'printer_template_add',
'menu_short_name' => '添加打印模板',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/template',
'router_path' => 'printer/template/add',
'view_path' => 'printer/template_edit',
'methods' => 'post',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '编辑打印模板',
'menu_key' => 'printer_template_edit',
'menu_short_name' => '编辑打印模板',
'menu_type' => '1',
'icon' => '',
'api_url' => 'printer/template/<id>',
'router_path' => 'printer/template/edit',
'view_path' => 'printer/template_edit',
'methods' => 'put',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
]
],
@ -2487,6 +2529,20 @@ return [
'status' => '1',
'is_show' => '0',
],
[
'menu_name' => '表单装修',
'menu_key' => 'form_page_decorate',
'menu_short_name' => '表单装修',
'menu_type' => '1',
'icon' => '',
'api_url' => '', // diy/diy/<id>
'router_path' => 'decorate/form/edit',
'view_path' => 'diy_form/edit',
'methods' => 'put',
'sort' => '0',
'status' => '1',
'is_show' => '0',
],
],
],
[
@ -2519,5 +2575,54 @@ return [
'is_show' => '0',
],
],
],
[
'menu_name' => '万能表单',
'menu_key' => 'diy_form',
'menu_short_name' => '万能表单',
'menu_type' => '0',
'icon' => 'element Files',
'api_url' => '',
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '0',
'status' => '1',
'is_show' => '1',
'menu_attr' => 'diy_form',
'children' => [
[
'menu_name' => '表单列表',
'menu_key' => 'diy_form_list',
'menu_short_name' => '表单列表',
'menu_type' => '1',
'icon' => 'element Files',
'api_url' => 'diy_form',
'router_path' => 'diy_form/list',
'view_path' => 'diy_form/list',
'methods' => 'get',
'sort' => '0',
'status' => '1',
'is_show' => '1',
'menu_attr' => 'diy_form',
'children' => [
[
'menu_name' => '分享设置',
'menu_key' => 'save_diy_form_share',
'menu_short_name' => '分享设置',
'menu_type' => '2',
'icon' => '',
'api_url' => 'diy_form/share',
'router_path' => '',
'view_path' => '',
'methods' => 'put',
'sort' => '100',
'status' => '1',
'is_show' => '1',
'menu_attr' => 'diy_form',
],
],
],
]
]
];

View File

@ -33,13 +33,19 @@ class PayChannelDict
// }
// }
foreach ($channel as $k => $v) {
$list[$k] = [
$temp_pay_type = $pay_type;
$list[ $k ] = [
'name' => $v,
'key' => $k,
'pay_type' => $pay_type
];
// PC端暂不支持 帮付
if ($k == ChannelDict::PC) {
unset($temp_pay_type[ PayDict::FRIENDSPAY ]);
$list[ $k ][ 'pay_type' ] = $temp_pay_type;
}
}
return $list;
}
}
}

View File

@ -14,14 +14,17 @@ namespace app\dict\pay;
class TransferDict
{
public const WECHAT = 'wechatpay';//微信支付
public const WECHAT = 'wechatpay';//微信零钱
public const ALIPAY = 'alipay';//支付宝支付
public const ALIPAY = 'alipay';//支付宝支付 (默认收款码)
public const OFFLINE = 'offline';//线下转账
public const BANK = 'bank';//银行卡转账
public const WECHAT_CODE = 'wechat_code';//微信收款码(线下转账)
//转账状态
public const SUCCESS = 'success';//转账成功
@ -43,7 +46,7 @@ class TransferDict
}
/**
* 支付类型
* 转账类型
* @return array
*/
public static function getTransferType(array $types = [], $is_all = true)
@ -64,6 +67,11 @@ class TransferDict
'key' => self::BANK,
'is_online' => false
],//银行卡
self::WECHAT_CODE => [
'name' => get_lang('dict_transfer.type_wechat_code'),
'key' => self::WECHAT_CODE,
'is_online' => false
],//微信收款码(线下转账)
];
if ($is_all) {
$list[self::OFFLINE] = [

View File

@ -25,6 +25,18 @@ return [
'class' => 'app\job\schedule\SiteExpireClose',
'function' => ''
],
[
'key' => 'transfer_check_finish',
'name' => '检验在线转账是否处理完毕',
'desc' => '',
'time' => [
'type' => 'min',
'min' => 5
],
'class' => 'app\job\transfer\schedule\CheckFinish',
'function' => ''
],
// [
// 'key' => 'site_stat',
// 'name' => '站点统计',

View File

@ -43,7 +43,6 @@ class WxOplatform
25 => '开放平台账号管理',
30 => '小程序基本信息管理',
31 => '小程序认证名称检测',
36 => '微信卡路里管理',
37 => '附近的小程序管理',
40 => '小程序插件管理',
45 => '微信物流服务',

View File

@ -92,11 +92,23 @@ $system_event = [
'ExportDataType' => [
//会员导出
'app\listener\member_export\MemberExportTypeListener',
//表单填写明细导出
'app\listener\diy_form_export\DiyFormRecordsExportTypeListener',
//表单填表人统计导出
'app\listener\diy_form_export\DiyFormRecordsMemberExportTypeListener',
//表单字段统计导出
// 'app\listener\diy_form_export\DiyFormRecordsFieldsExportTypeListener',
],
//导出数据源
'ExportData' => [
//会员导出
'app\listener\member_export\MemberExportDataListener',
//表单填写明细导出
'app\listener\diy_form_export\DiyFormRecordsExportDataListener',
//表单填表人统计导出
'app\listener\diy_form_export\DiyFormRecordsMemberExportDataListener',
//表单字段统计导出
// 'app\listener\diy_form_export\DiyFormRecordsFieldsExportDataListener',
],
//统计执行
'StatExecute' => [],
@ -108,7 +120,10 @@ $system_event = [
'GetPosterData' => [ 'app\listener\system\Poster' ],
// 小程序授权变更事件
'WeappAuthChangeAfter' => [ 'app\listener\system\WeappAuthChangeAfter' ]
'WeappAuthChangeAfter' => [ 'app\listener\system\WeappAuthChangeAfter' ],
'ShowApp' => [
'app\listener\system\ShowAppListener'
]
],
'subscribe' => [
],

View File

@ -67,6 +67,124 @@ CREATE TABLE `applet_version` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小程序版本表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `diy_form`;
CREATE TABLE `diy_form` (
`form_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '表单id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`page_title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单名称(用于后台展示)',
`title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单名称(用于前台展示)',
`type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单类型',
`status` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '状态0关闭1开启',
`template` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板名称',
`value` LONGTEXT DEFAULT NULL COMMENT '表单数据json格式包含展示组件',
`addon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '所属插件标识',
`share` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '分享内容',
`write_num` INT(11) NOT NULL DEFAULT 0 COMMENT '表单填写总数量',
`remark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '备注说明',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`form_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单表';
DROP TABLE IF EXISTS `diy_form_fields`;
CREATE TABLE `diy_form_fields` (
`field_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '字段id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`field_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段唯一标识',
`field_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段类型',
`field_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段名称',
`field_remark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段说明',
`field_default` TEXT DEFAULT NULL COMMENT '字段默认值',
`write_num` INT(11) NOT NULL DEFAULT 0 COMMENT '字段填写总数量',
`field_required` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否必填 0:否 1:是',
`field_hidden` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否隐藏 0:否 1:是',
`field_unique` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段内容防重复 0:否 1:是',
`privacy_protection` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '隐私保护 0:关闭 1:开启',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`field_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单字段表';
DROP TABLE IF EXISTS `diy_form_records`;
CREATE TABLE `diy_form_records` (
`record_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '表单填写记录id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`value` LONGTEXT DEFAULT NULL COMMENT '填写的表单数据',
`member_id` INT(11) NOT NULL DEFAULT 0 COMMENT '填写人会员id',
`relate_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联业务id',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
PRIMARY KEY (`record_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写记录表';
DROP TABLE IF EXISTS `diy_form_records_fields`;
CREATE TABLE `diy_form_records_fields` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`form_field_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联表单字段id',
`record_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联表单填写记录id',
`member_id` INT(11) NOT NULL DEFAULT 0 COMMENT '填写会员id',
`field_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段唯一标识',
`field_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段类型',
`field_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段名称',
`field_value` LONGTEXT NOT NULL COMMENT '字段值,根据类型展示对应效果',
`field_required` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否必填 0:否 1:是',
`field_hidden` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否隐藏 0:否 1:是',
`field_unique` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段内容防重复 0:否 1:是',
`privacy_protection` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '隐私保护 0:关闭 1:开启',
`update_num` INT(11) NOT NULL DEFAULT 0 COMMENT '字段修改次数',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写字段表';
DROP TABLE IF EXISTS `diy_form_submit_config`;
CREATE TABLE `diy_form_submit_config` (
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`submit_after_action` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '填表人提交后操作text文字信息voucher核销凭证',
`tips_type` VARCHAR(255) NOT NULL COMMENT '提示内容类型default默认提示diy自定义提示',
`tips_text` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '自定义提示内容',
`time_limit_type` VARCHAR(255) NOT NULL DEFAULT '0' COMMENT '核销凭证有效期限制类型no_limit不限制specify_time指定固定开始结束时间submission_time按提交时间设置有效期',
`time_limit_rule` TEXT DEFAULT NULL COMMENT '核销凭证时间限制规则json格式',
`voucher_content_rule` TEXT DEFAULT NULL COMMENT '核销凭证内容json格式',
`success_after_action` TEXT DEFAULT NULL COMMENT '填写成功后续操作',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单提交页配置表';
DROP TABLE IF EXISTS `diy_form_write_config`;
CREATE TABLE `diy_form_write_config` (
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`write_way` VARCHAR(255) NOT NULL COMMENT '填写方式no_limit不限制scan仅限微信扫一扫url仅限链接进入',
`join_member_type` VARCHAR(255) NOT NULL DEFAULT 'all_member' COMMENT '参与会员all_member所有会员参与selected_member_level指定会员等级selected_member_label指定会员标签',
`level_ids` TEXT DEFAULT NULL COMMENT '会员等级id集合',
`label_ids` TEXT DEFAULT NULL COMMENT '会员标签id集合',
`member_write_type` VARCHAR(255) NOT NULL COMMENT '每人可填写次数no_limit不限制diy自定义',
`member_write_rule` TEXT NOT NULL COMMENT '每人可填写次数自定义规则',
`form_write_type` VARCHAR(255) NOT NULL COMMENT '表单可填写数量no_limit不限制diy自定义',
`form_write_rule` TEXT NOT NULL COMMENT '表单可填写总数自定义规则',
`time_limit_type` VARCHAR(255) NOT NULL DEFAULT '0' COMMENT '填写时间限制类型no_limit不限制 specify_time指定开始结束时间open_day_time设置每日开启时间',
`time_limit_rule` TEXT NOT NULL COMMENT '填写时间限制规则',
`is_allow_update_content` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '是否允许修改自己填写的内容01',
`write_instruction` TEXT DEFAULT NULL COMMENT '表单填写须知',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写配置表';
DROP TABLE IF EXISTS `diy_page`;
CREATE TABLE `diy_page` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@ -102,6 +220,24 @@ CREATE TABLE `diy_route` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '自定义路由' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `diy_theme`;
CREATE TABLE `diy_theme` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '标题',
`type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '插件类型appaddon',
`addon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '所属应用app系统shop商城、o2o上门服务',
`color_mark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '颜色标识',
`color_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '颜色名称',
`mode` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模式default默认【跟随系统】diy自定义配色',
`value` TEXT DEFAULT NULL COMMENT '配色',
`diy_value` TEXT DEFAULT NULL COMMENT '自定义配色',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='自定义主题配色表';
DROP TABLE IF EXISTS `generate_column`;
CREATE TABLE `generate_column` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
@ -282,6 +418,8 @@ CREATE TABLE `member_cash_out` (
`transfer_mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`transfer_bank` varchar(255) NOT NULL DEFAULT '' COMMENT '银行名称',
`transfer_account` varchar(255) NOT NULL DEFAULT '' COMMENT '收款账号',
`transfer_payee` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '转账收款方(json),主要用于对接在线的打款方式',
`transfer_payment_code` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '收款码图片',
`transfer_fail_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '失败原因',
`transfer_status` varchar(20) NOT NULL DEFAULT '' COMMENT '转账状态',
`transfer_time` int(11) NOT NULL DEFAULT 0 COMMENT '转账时间',
@ -313,6 +451,7 @@ CREATE TABLE `member_cash_out_account` (
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
`account_no` varchar(255) NOT NULL DEFAULT '' COMMENT '提现账户',
`transfer_payment_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '收款码',
PRIMARY KEY (`account_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员提现账户' ROW_FORMAT = Dynamic;
@ -446,15 +585,18 @@ CREATE TABLE `pay_transfer` (
`transfer_account` varchar(255) NOT NULL DEFAULT '' COMMENT '收款账号',
`transfer_voucher` varchar(255) NOT NULL DEFAULT '' COMMENT '凭证',
`transfer_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '凭证说明',
`transfer_fail_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '失败原因',
`transfer_payment_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '收款码图片',
`transfer_fail_reason` varchar(2000) NOT NULL DEFAULT '' COMMENT '失败原因',
`transfer_status` varchar(20) NOT NULL DEFAULT '' COMMENT '转账状态',
`money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '转账金额',
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '申请时间',
`transfer_time` int(11) NOT NULL DEFAULT 0 COMMENT '转账时间',
`update_time` int(11) NOT NULL DEFAULT 0,
`openid` varchar(50) NOT NULL DEFAULT '',
`remark` varchar(255) NOT NULL,
`remark` varchar(255) NOT NULL DEFAULT '',
`batch_id` varchar(500) NOT NULL DEFAULT '' COMMENT '转账批次id',
`transfer_payee` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '在线转账数据(json)',
`out_batch_no` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '扩展数据,主要用于记录接收到线上打款的业务数据编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '转账表' ROW_FORMAT = Dynamic;
@ -1052,7 +1194,7 @@ INSERT INTO `site`(site_id, site_name, group_id, keywords, app_type, logo, `desc
UPDATE `site` SET site_id = 0 WHERE site_id = 1;
INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
-- INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1', '1', '0');

View File

@ -22,7 +22,7 @@ class ExportJob extends BaseJob
public function doJob($site_id, $type, $where, $page)
{
//获取导出数据列
$data_column = (new CoreExportService())->getExportDataColumn($type);
$data_column = (new CoreExportService())->getExportDataColumn($site_id, $type, $where);
//获取导出数据源
$data = (new CoreExportService())->getExportData($site_id, $type, $where, $page);
(new CoreExportService())->export($site_id, $type, $data_column, $data);

View File

@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\job\transfer\schedule;
use app\dict\pay\TransferDict;
use app\model\pay\Transfer;
use app\service\core\pay\CoreTransferService;
use core\base\BaseJob;
use think\facade\Log;
/**
* 定时校验转账是否完毕(每分钟一次)
*/
class CheckFinish extends BaseJob
{
public function doJob()
{
$condition = [
'transfer_status' => TransferDict::DEALING,
'transfer_type' => TransferDict::WECHAT
];
$list = (new Transfer())->where($condition)->select();
$core_transfer_service = new CoreTransferService();
foreach($list as $item){
$core_transfer_service->check($item['site_id'], $item->toArray());
}
return true;
}
}

View File

@ -57,6 +57,7 @@ return [
'ADDON_KEY_IS_EXIST' => '已存在相同插件标识的应用',
'ADDON_IS_INSTALLED_NOT_ALLOW_DEL' => '已安装的插件不允许删除',
'ADDON_ZIP_ERROR' => '插件压缩失败',
'PHP_SCRIPT_RUNNING_OUT_OF_MEMORY' => 'PHP脚本运行内存不足, 具体操作方法<a style="text-decoration: underline;" href="https://www.kancloud.cn/niushop/niushop_v6/3248604" target="blank">点击查看相关手册</a>',
//登录注册重置账号....
'LOGIN_SUCCESS' => '登录成功',
@ -180,12 +181,18 @@ return [
'MEMBER_CASHOUT_TRANSFER' => '会员提现转账',
'CASH_OUT_ACCOUNT_NOT_EXIST' => '提现账户不存在',
'CASH_OUT_ACCOUNT_NOT_FOUND_VALUE' => '转账到微信零钱缺少参数',
//DIY
'PAGE_NOT_EXIST' => '页面不存在',
'APP_COLOR_NOT_EXIST' => '系统配色不存在',
//系统表单
'DIY_FORM_NOT_EXIT' => '表单不存在',
//万能表单
'DIY_FORM_NOT_EXIST' => '表单不存在',
'DIY_FORM_NOT_OPEN' => '该表单已关闭',
'DIY_FORM_EXCEEDING_LIMIT' => '已达提交次数上限',
'ON_STATUS_PROHIBIT_DELETE' => '启用状态下禁止删除',
'DIY_FORM_TYPE_NOT_EXIST' => '表单类型不存在',
//渠道相关 占用 4******
//微信
@ -214,6 +221,7 @@ return [
//支付相关(todo 注意:7段不共享)
'ALIPAY_TRANSACTION_NO_NOT_EXIST' => '无效的支付交易号',
'PAYMENT_METHOD_NOT_SUPPORT' => '您选择到支付方式不受业务支持',
'WECHAT_TRANSFER_CONFIG_NOT_EXIST' => '微信零钱打款设置未配置完善',
'PAYMENT_LOCK' => '支付中,请稍后再试',
'PAY_SUCCESS' => '当前支付已完成',
'PAY_IS_REMOVE' => '当前支付已取消',
@ -298,7 +306,10 @@ return [
'SIGN_AWARD' => '签到奖励',
'GET_AWARD' => '恭喜您获得以下奖励',
'WILL_GET_AWARD' => '您将获得以下奖励',
'SIGN_PERIOD_GREATER_THAN' => '签到周期必须大于0天',
'SIGN_PERIOD_CANNOT_EMPTY' => '签到周期不能为空',
'SIGN_PERIOD_BETWEEN_2_365_DAYS' => '签到周期为2-365天',
'CONTINUE_SIGN_BETWEEN_2_365_DAYS' => '连签天数为2-365天',
'CONTINUE_SIGN_CANNOT_GREATER_THAN_SIGN_PERIOD' => '连签天数不能大于签到周期',
//导出相关
'EXPORT_SUCCESS' => '导出成功',

View File

@ -198,10 +198,11 @@ return [
],
//转账相关
'dict_transfer' => [
'type_wechat' => '微信',
'type_wechat' => '微信零钱',
'type_ali' => '支付宝',
'type_bank' => '银行卡',
'type_offline' => '线下转账',
'type_wechat_code' => '微信',//微信线下打款
'status_wait' => '待转账',
'status_dealing' => '处理中',
@ -261,6 +262,9 @@ return [
'dict_diy_form' => [
'component_type_form' => '表单组件',
'type_diy_form' => '自定义表单',
'type_sign_registration' => '签到报名登记',
'type_leave_message_suggestion' => '留言建议',
'type_write_off_voucher' => '核销凭证',
],
//短信相关
'dict_sms' => [
@ -282,6 +286,7 @@ return [
//状态
'status_wait_audit' => '待审核',
'status_wait_transfer' => '待转账',
'status_transfer_ing' => '转账中',
'status_transfered' => '已转账',
'status_refuse' => '已拒绝',
'status_cancel' => '已取消'

View File

@ -0,0 +1,76 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\diy_form_export;
use app\model\diy_form\DiyFormFields;
use app\model\diy_form\DiyFormRecords;
/**
* 表单填写记录导出数据源查询
* Class DiyFormRecordsExportDataListener
* @package app\listener\diy_form_export
*/
class DiyFormRecordsExportDataListener
{
public function handle($param)
{
$data = [];
if ($param['type'] == 'diy_form_records') {
$model = new DiyFormRecords();
$member_where = [];
if (!empty($param[ 'where' ][ 'keyword' ])) {
$member_where[] = [ 'member_no|nickname|username|mobile', 'like', '%' . $param[ 'where' ][ 'keyword' ] . '%' ];
}
$field = 'record_id, form_id, member_id, relate_id, create_time';
$order = "create_time desc";
$search_model = $model->where([
[ 'diy_form_records.site_id', '=', $param[ 'site_id' ] ],
[ 'form_id', '=', $param[ 'where' ] [ 'form_id' ] ]
])->field($field)->withSearch([ 'create_time' ], $param[ 'where' ])
->withJoin([
'member' => function($query) use ($member_where) {
$query->where($member_where);
}
])->with([
// 关联填写字段列表
'recordsFieldList' => function($query) {
$query->field('id, form_id, form_field_id, record_id, member_id, field_key, field_type, field_name, field_value, update_num, update_time')->append([ 'render_value' ]);
},
'form'
])
->order($order);
if ($param['page']['page'] > 0 && $param['page']['limit'] > 0) {
$data = $search_model->page($param['page']['page'], $param['page']['limit'])->select()->toArray();
} else {
$data = $search_model->select()->toArray();
}
$field_key_list = ( new DiyFormFields() )->where([
[ 'form_id', '=', $param['where']['form_id'] ],
[ 'site_id', '=', $param['site_id'] ]
])->column('field_key');
foreach ($data as $key => $value) {
$data[$key]['page_title'] = $value[ 'form' ]['page_title'] ?? '';
$data[$key]['type_name'] = $value[ 'form' ]['type_name'] ?? '';
$data[$key]['nickname'] = $value[ 'member' ]['nickname'] ?? '';
$data[$key]['mobile'] = $value[ 'member' ]['mobile']."\t" ?? '';
$list_key = array_column($value[ 'recordsFieldList' ], null, 'field_key');
foreach ($field_key_list as $field_key) {
$data[$key][$field_key] = !empty($list_key[$field_key]) ? $list_key[$field_key]['render_value']."\t" : '';
}
}
}
return $data;
}
}

View File

@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\diy_form_export;
use app\model\diy_form\DiyFormFields;
/**
* 表单填写记录导出数据类型查询
* Class DiyFormRecordsExportTypeListener
* @package app\listener\diy_form_export
*/
class DiyFormRecordsExportTypeListener
{
public function handle($param)
{
$column = [
'record_id' => [ 'name' => '记录编号' ],
'create_time' => [ 'name' => '填表时间' ],
'page_title' => [ 'name' => '表单名称' ],
'type_name' => [ 'name' => '表单类型' ],
'form_id' => [ 'name' => '表单编号' ],
'nickname' => [ 'name' => '填表人名称' ],
'mobile' => [ 'name' => '填表人手机号' ],
];
if (!empty($param['where']['form_id'])) {
$field_list = ( new DiyFormFields() )->where([
[ 'form_id', '=', $param['where']['form_id'] ],
[ 'site_id', '=', $param['site_id'] ]
])->field('field_key,field_name')->select()->toArray();
foreach ($field_list as $key => $value) {
$column[$value['field_key']] = [ 'name' => $value['field_name'] ];
}
}
return [
'diy_form_records' => [
'name' => '表单填写明细',
'column' => $column,
]
];
}
}

View File

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\diy_form_export;
use app\model\diy_form\DiyFormRecords;
/**
* 表单填表人统计导出数据源查询
* Class DiyFormRecordsMemberExportDataListener
* @package app\listener\diy_form_export
*/
class DiyFormRecordsMemberExportDataListener
{
public function handle($param)
{
$data = [];
if ($param['type'] == 'diy_form_records_member') {
$model = new DiyFormRecords();
$field = 'form_id, diy_form_records.member_id, count(*) as write_count';
$order = "create_time desc";
$search_model = $model->where([ [ 'diy_form_records.site_id', '=', $param[ 'site_id' ] ] ])->withSearch([ 'form_id' ], $param[ 'where' ])
->withJoin(['member' => function ($query) use ($param) {
$query->where([ [ 'nickname|mobile', 'like', "%" . $param[ 'where' ]['keyword'] . "%" ] ]);
}])->field($field)->group('diy_form_records.member_id')->order($order);
if ($param['page']['page'] > 0 && $param['page']['limit'] > 0) {
$data = $search_model->page($param['page']['page'], $param['page']['limit'])->select()->toArray();
} else {
$data = $search_model->select()->toArray();
}
foreach ($data as $key => $value) {
$data[$key]['nickname'] = $value[ 'member' ]['nickname'] ?? '';
}
}
return $data;
}
}

View File

@ -0,0 +1,34 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\diy_form_export;
/**
* 表单填表人统计导出数据类型查询
* Class DiyFormRecordsExportTypeListener
* @package app\listener\diy_form_export
*/
class DiyFormRecordsMemberExportTypeListener
{
public function handle($param)
{
return [
'diy_form_records_member' => [
'name' => '填表人统计列表',
'column' => [
'nickname' => [ 'name' => '填表人名称' ],
'write_count' => [ 'name' => '总计' ]
]
]
];
}
}

View File

@ -13,24 +13,24 @@ class Sms
public function handle(array $data)
{
$site_id = $data['site_id'];
$template = $data['template'];//模板
$vars = $data['vars'];//模板变量
$key = $data['key'];
$to = $data['to'];//发送对象主题
$mobile = $to['mobile'] ?? '';
$site_id = $data[ 'site_id' ];
$template = $data[ 'template' ];//模板
$vars = $data[ 'vars' ];//模板变量
$key = $data[ 'key' ];
$to = $data[ 'to' ];//发送对象主题
$mobile = $to[ 'mobile' ] ?? '';
//完全信任消息的设置, 不再依赖support_type
if ($template['is_sms']) {
$sms_id = $template['sms_id'];//发送模板id
$content = $template['sms']['content'];
$member_id = $to['member_id'] ?? 0;
$uid = $to['uid'] ?? 0;
if ($template[ 'is_sms' ]) {
$sms_id = $template[ 'sms_id' ];//发送模板id
$content = $template[ 'sms' ][ 'content' ];
$member_id = $to[ 'member_id' ] ?? 0;
$uid = $to[ 'uid' ] ?? 0;
if (!$mobile) {
//会员的
if ($member_id > 0) {//查询openid
$info = (new CoreMemberService())->getInfoByMemberId($site_id, $member_id);
$mobile = $info['mobile'] ?? '';
$nickname = $info['nickname'] ?? '';
$info = ( new CoreMemberService() )->getInfoByMemberId($site_id, $member_id);
$mobile = $info[ 'mobile' ] ?? '';
$nickname = $info[ 'nickname' ] ?? '';
}
}
@ -50,17 +50,17 @@ class Sms
'result' => ''
);
$core_sms_service->send($site_id, $mobile, $vars, $key, $sms_id, $content);
(new CoreNoticeLogService())->add($site_id, $log_data);
} catch ( NoticeException $e ) {
$log_data['result'] = $e->getMessage();
(new CoreNoticeLogService())->add($site_id, $log_data);
( new CoreNoticeLogService() )->add($site_id, $log_data);
} catch (NoticeException $e) {
$log_data[ 'result' ] = $e->getMessage();
( new CoreNoticeLogService() )->add($site_id, $log_data);
//这儿决定要不要抛出
if (!$template['async']) {
if (!$template[ 'async' ]) {
throw new NoticeException($e->getMessage());
}
}
} else {
if (!$template['async']) {
if (!$template[ 'async' ]) {
throw new NoticeException('NOTICE_NOT_OPEN_SMS');
}
}

View File

@ -488,6 +488,19 @@ class AddSiteAfterListener
'storage_type' => 'local', // 图片上传类型 local本地 aliyun 阿里云oss qiniu 七牛 ....
'cate_id' => $category_id, // 素材分类id
'create_time' => time()
],
[
'site_id' => $site_id,
'name' => time() . $site_id . $category_id . 'nav_sow_community.png', // 附件名称
'real_name' => '种草社区', // 原始文件名
'path' => 'static/resource/images/attachment/nav_sow_community.png', // 完整地址
'url' => 'static/resource/images/attachment/nav_sow_community.png', // 网络地址
'dir' => 'static/resource/images/attachment', // 附件路径
'att_size' => '24576', // 附件大小
'att_type' => 'image', // 附件类型image,video
'storage_type' => 'local', // 图片上传类型 local本地 aliyun 阿里云oss qiniu 七牛 ....
'cate_id' => $category_id, // 素材分类id
'create_time' => time()
]
];
$exist_attachment_list = $attachment_model->where([
@ -509,23 +522,21 @@ class AddSiteAfterListener
$attachment_model->insertAll($attachment_list);
}
$poster_model = new Poster();
$poster_count = $poster_model->where([
$poster = new CorePosterService();
// 存在则删除
$poster->del([
[ 'site_id', '=', $site_id ],
[ 'type', '=', 'friendspay' ]
])->count();
if ($poster_count == 0) {
// 创建默认找朋友帮忙付海报
$poster = new CorePosterService();
$template = $poster->getTemplateList('', 'friendspay')[ 0 ];
$poster->add($site_id, '', [
'name' => $template[ 'name' ],
'type' => $template[ 'type' ],
'value' => $template[ 'data' ],
'status' => 1,
'is_default' => 1
]);
}
]);
// 创建默认找朋友帮忙付海报
$template = $poster->getTemplateList('', 'friendspay')[ 0 ];
$poster->add($site_id, '', [
'name' => $template[ 'name' ],
'type' => $template[ 'type' ],
'value' => $template[ 'data' ],
'status' => 1,
'is_default' => 1
]);
return true;
}

View File

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\system;
/**
* 查询应用列表
* Class ShowAppListener
* @package app\listener\system
*/
class ShowAppListener
{
public function handle()
{
// 应用app、addon 待定
// 营销promotion
// 工具tool
return [
// 应用
'app' => [
],
// 工具
'tool' => [
[
'title' => '万能表单',
'desc' => '适用于各种应用场景,满足多样化的业务需求',
'icon' => 'static/resource/images/diy_form/icon.png',
'key' => 'diy_form',
'url' => '/diy_form/list',
],
// [
// 'title' => '万能a表单',
// 'desc' => '万能a表单',
// 'icon' => 'static/resource/images/diy_form/icon.png',
// 'key' => 'diy_faorm',
// 'url' => '/diy_faorm/list',
// ]
],
// 营销
'promotion' => [
]
];
}
}

View File

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy;
use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use core\base\BaseModel;
/**
* 自定义主题配色表
* Class DiyTheme
* @package app\model\diy
*/
class DiyTheme extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_theme';
// 设置json类型字段
protected $json = [ 'value', 'diy_value' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
}

View File

@ -0,0 +1,196 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use app\dict\diy_form\TypeDict;
use app\model\addon\Addon;
use core\base\BaseModel;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
/**
* 自定义万能表单模型
* Class DiyForm
* @package app\model\diy
*/
class DiyForm extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
/**
* 数据表主键
* @var string
*/
protected $pk = 'form_id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form';
// 设置json类型字段
protected $json = [ 'value', 'share' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 状态字段转化
* @param $value
* @param $data
* @return mixed
*/
public function getTypeNameAttr($value, $data)
{
if (!empty($data[ 'type' ])) {
return TypeDict::getType([ 'key' => [ $data[ 'type' ] ] ])[ $data[ 'type' ] ][ 'title' ] ?? '';
}
return '';
}
/**
* 状态字段转化:所属插件名称
* @param $value
* @param $data
* @return array
*/
public function getAddonNameAttr($value, $data)
{
if (empty($data[ 'addon' ])) {
return [];
}
return ( new Addon() )->where([ [ 'key', '=', $data[ 'addon' ] ] ])->column('title');
}
/**
* 状态字段转化
* @param $value
* @param $data
* @return mixed
*/
public function getShareAttr($value, $data)
{
if (empty($data[ 'share' ])) {
$data[ 'share' ] = [
'wechat' => [
'title' => $data[ 'title' ],
'desc' => '',
'url' => ''
],
'weapp' => [
'title' => $data[ 'title' ],
'url' => ''
]
];
}
return $data[ 'share' ] ?? '';
}
/**
* 搜索器:表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
/**
* 搜索器:表单名称
* @param $query
* @param $value
* @param $data
*/
public function searchTitleAttr($query, $value, $data)
{
if ($value != '') {
$query->where("title|page_title", 'like', '%' . $this->handelSpecialCharacter($value) . '%');
}
}
/**
* 搜索器:表单类型
* @param $query
* @param $value
* @param $data
*/
public function searchTypeAttr($query, $value, $data)
{
if ($value) {
$query->where("type", $value);
}
}
/**
* 搜索器:所属插件标识
* @param $query
* @param $value
* @param $data
*/
public function searchAddonAttr($query, $value, $data)
{
if ($value) {
$query->where("addon", $value);
}
}
/**
* 搜索器:状态
* @param $query
* @param $value
* @param $data
*/
public function searchStatusAttr($query, $value, $data)
{
if ($value !== '') {
$query->where("status", $value);
}
}
/**
*
* @return HasOne
*/
public function writeConfig()
{
return $this->hasOne(DiyFormWriteConfig::class, 'form_id', 'form_id');
}
/**
*
* @return HasOne
*/
public function submitConfig()
{
return $this->hasOne(DiyFormSubmitConfig::class, 'form_id', 'form_id');
}
/**
*
* @return hasMany
*/
public function formField()
{
return $this->hasMany(DiyFormFields::class, 'form_id', 'form_id');
}
}

View File

@ -0,0 +1,159 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use core\base\BaseModel;
/**
* 自定义万能表单字段模型
* Class DiyFormFields
* @package app\model\diy
*/
class DiyFormFields extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
/**
* 数据表主键
* @var string
*/
protected $pk = 'field_id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form_fields';
/**
* 搜索器:字段id
* @param $query
* @param $value
* @param $data
*/
public function searchFieldIdAttr($query, $value, $data)
{
if ($value) {
$query->where("field_id", $value);
}
}
/**
* 搜索器:表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
/**
* 搜索器:字段唯一标识
* @param $query
* @param $value
* @param $data
*/
public function searchFieldKeyAttr($query, $value, $data)
{
if ($value) {
$query->where("field_key", $value);
}
}
/**
* 搜索器:字段类型
* @param $query
* @param $value
* @param $data
*/
public function searchFieldTypeAttr($query, $value, $data)
{
if ($value) {
$query->where("field_type", $value);
}
}
/**
* 搜索器:字段名称
* @param $query
* @param $value
* @param $data
*/
public function searchFieldNameAttr($query, $value, $data)
{
if ($value) {
$query->where("field_name", 'like', '%' . $value . '%');
}
}
/**
* 搜索器:字段是否必填 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldRequiredAttr($query, $value, $data)
{
if ($value) {
$query->where("field_required", $value);
}
}
/**
* 搜索器:字段是否隐藏 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldHiddenAttr($query, $value, $data)
{
if ($value) {
$query->where("field_hidden", $value);
}
}
/**
* 搜索器:字段内容防重复 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldUniqueAttr($query, $value, $data)
{
if ($value) {
$query->where("field_unique", $value);
}
}
/**
* 搜索器:隐私保护 0:关闭 1:开启
* @param $query
* @param $value
* @param $data
*/
public function searchPrivacyProtectionAttr($query, $value, $data)
{
if ($value) {
$query->where("privacy_protection", $value);
}
}
}

View File

@ -0,0 +1,144 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use app\model\member\Member;
use core\base\BaseModel;
use think\model\relation\HasOne;
use think\db\Query;
/**
* 自定义万能表单填写记录模型
* Class DiyFormRecords
* @package app\model\diy
*/
class DiyFormRecords extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
/**
* 数据表主键
* @var string
*/
protected $pk = 'record_id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form_records';
// 设置json类型字段
protected $json = [ 'value' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 搜索器:记录id
* @param $query
* @param $value
* @param $data
*/
public function searchRecordIdAttr($query, $value, $data)
{
if ($value) {
$query->where("record_id", $value);
}
}
/**
* 搜索器:关联表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
/**
* 搜索器:创建时间
* @param $query
* @param $value
* @param $data
*/
public function searchCreateTimeAttr(Query $query, $value, $data)
{
$start_time = empty($value[ 0 ]) ? 0 : strtotime($value[ 0 ]);
$end_time = empty($value[ 1 ]) ? 0 : strtotime($value[ 1 ]);
if ($start_time > 0 && $end_time > 0) {
$query->whereBetweenTime('diy_form_records.create_time', $start_time, $end_time);
} else if ($start_time > 0 && $end_time == 0) {
$query->where([ [ 'diy_form_records.create_time', '>=', $start_time ] ]);
} else if ($start_time == 0 && $end_time > 0) {
$query->where([ [ 'diy_form_records.create_time', '<=', $end_time ] ]);
}
}
/**
* 会员关联
* @return HasOne
*/
public function member()
{
return $this->hasOne(Member::class, 'member_id', 'member_id')->joinType('left')
->withField('member_id,member_no, username, mobile, nickname, headimg');
}
/**
* 关联表单字段列表
* @return \think\model\relation\HasMany
*/
public function formFieldList()
{
return $this->hasMany(DiyFormFields::class, 'form_id', 'form_id');
}
/**
* 关联填写字段列表
* @return \think\model\relation\HasMany
*/
public function recordsFieldList()
{
return $this->hasMany(DiyFormRecordsFields::class, 'record_id', 'record_id');
}
/**
* 关联表单提交页配置
* @return HasOne
*/
public function submitConfig()
{
return $this->hasOne(DiyFormSubmitConfig::class, 'form_id', 'form_id')->joinType('left')
->withField('id,form_id,submit_after_action,tips_type,tips_text,success_after_action');
}
/**
* 表单关联
* @return HasOne
*/
public function form()
{
return $this->hasOne(DiyForm::class, 'form_id', 'form_id')->joinType('left')
->withField('form_id,page_title,type')->append([ 'type_name' ]);
}
}

View File

@ -0,0 +1,218 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use app\dict\diy_form\ComponentDict;
use core\base\BaseModel;
/**
* 自定义万能表单填写字段模型
* Class DiyFormRecordsFields
* @package app\model\diy_form
*/
class DiyFormRecordsFields extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form_records_fields';
/**
* 状态字段转化
* @param $value
* @param $data
* @return mixed
*/
public function getRenderValueAttr($value, $data)
{
if (!empty($data[ 'field_value' ])) {
$component = ComponentDict::getComponent([
'component_name' => $data[ 'field_type' ]
]);
$render_value = $data[ 'field_value' ]; // 默认渲染值
if (isset($component[ 'render' ])) {
$render = $component[ 'render' ];
if ($render instanceof \Closure) {
$render_value = $render($data[ 'field_value' ]);
}
}
return $render_value;
}
return '';
}
/**
* 状态字段转化
* @param $value
* @param $data
* @return mixed
*/
public function getHandleFieldValueAttr($value, $data)
{
if (!empty($data[ 'field_value' ])) {
$component = ComponentDict::getComponent([
'component_name' => $data[ 'field_type' ]
]);
$render_value = $data[ 'field_value' ]; // 默认渲染值
if (isset($component[ 'convert' ])) {
$render = $component[ 'convert' ];
if ($render instanceof \Closure) {
$render_value = $render($data[ 'field_value' ]);
}
}
return $render_value;
}
return '';
}
/**
* 状态字段转化
* @param $value
* @param $data
* @return mixed
*/
public function getDetailComponentAttr($value, $data)
{
if (!empty($data[ 'field_key' ])) {
$detail_component = '';
$component = ComponentDict::getComponent([ 'component_name' => $data[ 'field_type' ] ]);
if (!empty($component)) {
$detail_component = $component[ 'value' ][ 'field' ][ 'detailComponent' ] ?? '';
}
if (empty($detail_component)) {
$detail_component = '/src/app/views/diy_form/components/detail-form-render.vue';
}
return $detail_component;
}
return '';
}
/**
* 搜索器:表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
/**
* 搜索器:字段唯一标识
* @param $query
* @param $value
* @param $data
*/
public function searchFieldKeyAttr($query, $value, $data)
{
if ($value) {
$query->where("field_key", $value);
}
}
/**
* 搜索器:字段类型
* @param $query
* @param $value
* @param $data
*/
public function searchFieldTypeAttr($query, $value, $data)
{
if ($value) {
$query->where("field_type", $value);
}
}
/**
* 搜索器:字段名称
* @param $query
* @param $value
* @param $data
*/
public function searchFieldNameAttr($query, $value, $data)
{
if ($value) {
$query->where("field_name", 'like', '%' . $value . '%');
}
}
/**
* 搜索器:字段是否必填 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldRequiredAttr($query, $value, $data)
{
if ($value) {
$query->where("field_required", $value);
}
}
/**
* 搜索器:字段是否隐藏 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldHiddenAttr($query, $value, $data)
{
if ($value) {
$query->where("field_hidden", $value);
}
}
/**
* 搜索器:字段内容防重复 0: 1:
* @param $query
* @param $value
* @param $data
*/
public function searchFieldUniqueAttr($query, $value, $data)
{
if ($value) {
$query->where("field_unique", $value);
}
}
/**
* 搜索器:隐私保护 0:关闭 1:开启
* @param $query
* @param $value
* @param $data
*/
public function searchPrivacyProtectionAttr($query, $value, $data)
{
if ($value) {
$query->where("privacy_protection", $value);
}
}
}

View File

@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use core\base\BaseModel;
/**
* 万能表单提交页配置模型
* Class DiyFormSubmitConfig
* @package app\model\diy_form
*/
class DiyFormSubmitConfig extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
// 设置json类型字段
protected $json = [ 'time_limit_rule', 'voucher_content_rule', 'success_after_action' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form_submit_config';
/**
* 搜索器:表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
}

View File

@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\diy_form;
use core\base\BaseModel;
/**
* 万能表单填写配置模型
* Class DiyFormWriteConfig
* @package app\model\diy_form
*/
class DiyFormWriteConfig extends BaseModel
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
// 设置json类型字段
protected $json = [ 'level_ids', 'label_ids', 'member_write_rule', 'form_write_rule', 'time_limit_rule' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'diy_form_write_config';
/**
* 搜索器:表单id
* @param $query
* @param $value
* @param $data
*/
public function searchFormIdAttr($query, $value, $data)
{
if ($value) {
$query->where("form_id", $value);
}
}
}

View File

@ -268,4 +268,5 @@ class Member extends BaseModel
{
return $this->hasOne(MemberLevel::class, 'level_id', 'member_level')->bind([ 'member_level_name' => 'level_name' ]);
}
}

View File

@ -40,6 +40,12 @@ class MemberCashOut extends BaseModel
'transfer_time' => 'timestamp',
];
// 设置json类型字段
protected $json = [ 'transfer_payee' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 会员信息
* @return HasOne

View File

@ -41,6 +41,12 @@ class Transfer extends BaseModel
'finish_time' => 'timestamp',
];
// 设置json类型字段
protected $json = [ 'transfer_payee' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 状态字段转化
* @param $value

View File

@ -16,9 +16,13 @@ use app\dict\diy\LinkDict;
use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use app\dict\sys\FileDict;
use app\model\addon\Addon;
use app\model\diy\Diy;
use app\model\diy\DiyTheme;
use app\service\admin\sys\SystemService;
use app\service\core\diy\CoreDiyConfigService;
use app\service\core\diy\CoreDiyService;
use app\service\core\site\CoreSiteService;
use core\base\BaseAdminService;
use core\exception\AdminException;
use Exception;
@ -26,6 +30,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Log;
/**
* 自定义页面服务层
@ -809,4 +814,111 @@ class DiyService extends BaseAdminService
return $res->id;
}
/**
* 获取自定义主题配色
* @return array
*/
public function getDiyTheme()
{
$site_addon = ( new CoreSiteService() )->getSiteCache($this->site_id);
$theme_data = ( new DiyTheme() )->where([['site_id', '=', $this->site_id], ['type', '=', 'app']])->column('id,color_mark,color_name,diy_value,value,title,mode','addon');
$defaultColor = ( new CoreDiyService() )->getDefaultColor();
$app_theme['app'] = [
'id' => $theme_data['app']['id'] ?? '',
'icon' => '',
'addon_title' => '系统',
'mode' => 'diy',
'title' => $theme_data['app']['title'] ?? '系统主色调',
'color_mark' => $theme_data['app']['color_mark'] ?? $defaultColor['name'],
'color_name' => $theme_data['app']['color_name'] ?? $defaultColor['title'],
'value' => $theme_data['app']['value'] ?? $defaultColor['theme'],
'diy_value' => $theme_data['app']['diy_value'] ?? '',
];
$data = [];
foreach ($site_addon[ 'apps' ] as $value){
$default_theme_data = array_values(array_filter(event('ThemeColor', [ 'key' => $value['key']])))[0] ?? [];
$data[$value['key']]['id'] = $theme_data[$value['key']]['id'] ?? '';
$data[$value['key']]['icon'] = $value['icon'] ?? '';
$data[$value['key']]['mode'] = $theme_data[$value['key']]['mode'] ?? 'diy';
$data[$value['key']]['addon_title'] = $value['title'] ?? '';
$data[$value['key']]['title'] = $theme_data[$value['key']]['title'] ?? $value['title'].'主色调';
$data[$value['key']]['color_mark'] = $theme_data[$value['key']]['color_mark'] ?? ($default_theme_data ? $default_theme_data[ 'name' ] : $defaultColor['name']);
$data[$value['key']]['color_name'] = $theme_data[$value['key']]['color_name'] ?? ($default_theme_data ? $default_theme_data[ 'title' ] : $defaultColor['title']);
$data[$value['key']]['value'] = $theme_data[$value['key']]['value'] ?? ($default_theme_data ? $default_theme_data[ 'theme' ] : $defaultColor['theme']);
$data[$value['key']]['diy_value'] = $theme_data[$value['key']]['diy_value'] ?? '';
}
if (count($site_addon[ 'apps' ]) > 1) {
$data = array_merge($app_theme,$data);
}
return $data;
}
/**
* 设置主题配色
* @param array $data
* @return bool
*/
public function setDiyTheme($data)
{
$diy_theme_model = new (new DiyTheme());
$addon_data = (new addon())->where([['support_app', '=', $data['key']]])->select()->toArray();
$addon_save_data = [];
if (!empty($addon_data)){
foreach ($addon_data as $value){
$addon_save_data[] = [
'site_id' => $this->site_id,
'type' => 'addon',
'addon' => $value['key'],
'color_mark' => $data['color_mark'],
'color_name' => $data['color_name'],
'mode' => $data['mode'],
'value' => $data['value'],
'diy_value' => $data['diy_value'],
'update_time' => time(),
];
}
}
try {
Db::startTrans();
if(!empty($data['id'])){
$data['update_time'] = time();
unset($data['key']);
$diy_theme_model->where([['id', '=', $data['id']], ['site_id', '=', $this->site_id]])->update($data);
if (!empty($addon_save_data)){
foreach ($addon_save_data as $value){
$diy_theme_model->where([['addon', '=', $value['addon']], ['site_id', '=', $this->site_id]])->update($value);
}
}
}else{
$data['site_id'] = $this->site_id;
$data['type'] = 'app';
$data['addon'] = $data['key'];
$data['crete_time'] = time();
unset($data['id'],$data['key']);
array_unshift($addon_save_data, $data);
foreach ($addon_save_data as $value){
unset($value['update_time']);
$diy_theme_model->create($value);
}
}
Db::commit();
return true;
} catch (Exception $e) {
Db::rollback();
throw new AdminException($e->getMessage());
}
}
/**
* 获取默认主题配色
* @return array
*/
public function getDefaultThemeColor()
{
return ( new CoreDiyService() )->getDefaultThemeColor();
}
}

View File

@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\diy_form;
use app\service\core\diy_form\CoreDiyFormConfigService;
use core\base\BaseAdminService;
/**
* 万能表单配置服务层
* Class DiyFormService
* @package app\service\admin\diy
*/
class DiyFormConfig extends BaseAdminService
{
public function __construct()
{
parent::__construct();
}
/**
* 编辑填写配置
* @param $data
* @return bool
*/
public function editWriteConfig($data)
{
$data[ 'site_id' ] = $this->site_id;
return ( new CoreDiyFormConfigService() )->editWriteConfig($data);
}
/**
* 获取表单填写配置
* @param $form_id
* @return mixed
*/
public function getWriteConfig($form_id)
{
$data = [
'site_id' => $this->site_id,
'form_id' => $form_id
];
return ( new CoreDiyFormConfigService() )->getWriteConfig($data);
}
/**
* 编辑提交配置
* @param array $data
* @return mixed
*/
public function editSubmitConfig($data)
{
$data[ 'site_id' ] = $this->site_id;
return ( new CoreDiyFormConfigService() )->editSubmitConfig($data);
}
/**
* 获取表单提交成功页配置
* @param $form_id
* @return mixed
*/
public function getSubmitConfig($form_id)
{
$data = [
'site_id' => $this->site_id,
'form_id' => $form_id
];
return ( new CoreDiyFormConfigService() )->getSubmitConfig($data);
}
}

View File

@ -0,0 +1,139 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\diy_form;
use app\model\diy_form\DiyFormRecords;
use app\model\diy_form\DiyFormRecordsFields;
use core\base\BaseAdminService;
/**
* 万能表单填写记录服务层
* Class DiyFormRecordsService
* @package app\service\admin\diy
*/
class DiyFormRecordsService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new DiyFormRecords();
}
/**
* 获取万能表单填表人统计列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$field = 'form_id, diy_form_records.member_id, count(*) as write_count';
$search_model = $this->model->where([ [ 'diy_form_records.site_id', '=', $this->site_id ] ])->withSearch([ 'form_id' ], $where)
->withJoin([ 'member' => function($query) use ($where) {
$query->where([ [ 'nickname|mobile', 'like', "%" . $where[ 'keyword' ] . "%" ] ]);
} ])->field($field)->group('diy_form_records.member_id');
return $this->pageQuery($search_model);
}
/**
* 获取万能表单字段统计列表
* @param array $where
* @return array
*/
public function getFieldStatList(array $where = [])
{
$field_list = ( new DiyFormService() )->getFieldsList($where, 'field_id, field_key, field_type, field_name');
$simple_field_list = array_filter($field_list, function($v) { return !in_array($v[ 'field_type' ], [ 'FormRadio', 'FormCheckbox', 'FormDateScope', 'FormTimeScope', 'FormImage' ]); });
$json_field_list = array_filter($field_list, function($v) { return in_array($v[ 'field_type' ], [ 'FormRadio', 'FormCheckbox', 'FormDateScope', 'FormTimeScope' ]); });
$records_field_model = new DiyFormRecordsFields();
foreach ($simple_field_list as $k => &$v) {
$value_list = $records_field_model->field('form_id, field_key, field_type, field_value, count(*) as write_count')->where([
[ 'site_id', '=', $this->site_id ],
[ 'field_key', '=', $v[ 'field_key' ] ],
[ 'field_type', '=', $v[ 'field_type' ] ]
])->withSearch([ 'form_id' ], $where)->group('field_value')->append([ 'render_value' ])->select()->toArray();
$total_count = $records_field_model->where([
[ 'site_id', '=', $this->site_id ],
[ 'field_key', '=', $v[ 'field_key' ] ],
[ 'field_type', '=', $v[ 'field_type' ] ]
])->withSearch([ 'form_id' ], $where)->count();
if ($total_count > 0) {
$total_percent = 100;
foreach ($value_list as $k1 => &$v1) {
if ($k1 == count($value_list) - 1) {
$item_percent = $total_percent;
} else {
$item_percent = round($v1['write_count'] / $total_count * 100, 2);
}
$v1['write_percent'] = floatval($item_percent);
$total_percent = bcsub($total_percent, $item_percent, 2);
}
}
$v[ 'value_list' ] = $value_list;
}
foreach ($json_field_list as $k => &$v) {
$field_list = $records_field_model->field('form_id, field_key, field_type, field_value')->where([
[ 'site_id', '=', $this->site_id ],
[ 'field_key', '=', $v[ 'field_key' ] ],
[ 'field_type', '=', $v[ 'field_type' ] ]
])->withSearch([ 'form_id' ], $where)->append([ 'render_value' ])->select()->toArray();
$total_count = 0;
$value_list = [];
foreach ($field_list as $k1 => &$v1) {
if ($v1[ 'field_type' ] != 'FormCheckbox') {
$key = $v1[ 'field_key' ] . '_' . $v1[ 'render_value' ];
if (isset($value_list[ $key ])) {
$value_list[ $key ][ 'write_count' ] = $value_list[ $key ][ 'write_count' ] + 1;
$total_count++;
} else {
// 如果不存在则初始化为1
$value_list[ $key ] = $v1;
$value_list[ $key ][ 'write_count' ] = 1;
$total_count++;
}
} else {
$value_arr = explode(',', $v1[ 'render_value' ]);
foreach ($value_arr as $k2 => $v2) {
$key = $v1[ 'field_key' ] . '_' . $v2;
if (isset($value_list[ $key ])) {
$value_list[ $key ][ 'write_count' ] = $value_list[ $key ][ 'write_count' ] + 1;
$total_count++;
} else {
$value_list[ $key ] = $v1;
$value_list[ $key ][ 'render_value' ] = $v2;
$value_list[ $key ][ 'write_count' ] = 1;
$total_count++;
}
}
}
}
if ($total_count > 0) {
$value_list = array_values($value_list);
$total_percent = 100;
foreach ($value_list as $k1 => &$v1) {
if ($k1 == count($value_list) - 1) {
$item_percent = $total_percent;
} else {
$item_percent = round($v1['write_count'] / $total_count * 100, 2);
}
$v1['write_percent'] = floatval($item_percent);
$total_percent = bcsub($total_percent, $item_percent, 2);
}
}
$v[ 'value_list' ] = $value_list;
}
return array_merge($simple_field_list, $json_field_list);
}
}

View File

@ -0,0 +1,636 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\diy_form;
use app\dict\diy_form\ComponentDict as DiyFormComponentDict;
use app\dict\diy\PagesDict;
use app\dict\diy_form\TemplateDict;
use app\dict\diy_form\TypeDict;
use app\model\diy_form\DiyForm;
use app\model\diy_form\DiyFormFields;
use app\model\diy_form\DiyFormRecords;
use app\model\diy_form\DiyFormRecordsFields;
use app\model\diy_form\DiyFormSubmitConfig;
use app\model\diy_form\DiyFormWriteConfig;
use app\service\admin\diy\DiyService;
use app\service\admin\sys\SystemService;
use app\service\core\diy_form\CoreDiyFormConfigService;
use app\service\core\diy_form\CoreDiyFormRecordsService;
use core\base\BaseAdminService;
use core\exception\AdminException;
use core\exception\CommonException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Log;
/**
* 万能表单服务层
* Class DiyFormService
* @package app\service\admin\diy
*/
class DiyFormService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new DiyForm();
}
/**
* 获取万能表单分页列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'form_id, page_title, title, type, status, addon, share, write_num, remark, update_time';
$order = "form_id desc";
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type", 'addon' ], $where)->field($field)->order($order)->append([ 'type_name', 'addon_name' ]);
return $this->pageQuery($search_model);
}
/**
* 获取万能表单列表
* @param array $where
* @param string $field
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function getList(array $where = [], $field = 'form_id, page_title, title, type, status, addon, share, write_num, remark, update_time')
{
$order = "form_id desc";
return $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type", 'addon', 'status' ], $where)->field($field)->order($order)->append([ 'type_name', 'addon_name' ])->select()->toArray();
}
/**
* 获取万能表单信息
* @param int $form_id
* @param string $field
* @return mixed
*/
public function getInfo(int $form_id, $field = 'form_id, page_title, title, type, status, value, addon, share, write_num,template')
{
return $this->model->field($field)->where([ [ 'form_id', '=', $form_id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
}
/**
* 获取万能表单数量
* @param array $where
* @return mixed
*/
public function getCount(array $where = [])
{
return $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'type' ], $where)->count();
}
/**
* 添加万能表单
* @param array $data
* @return mixed
*/
public function add(array $data)
{
Db::startTrans();
try {
if (empty($data[ 'site_id' ])) {
$data[ 'site_id' ] = $this->site_id;
}
$data[ 'status' ] = 1; // 默认为开启状态
$data[ 'create_time' ] = time();
$data[ 'update_time' ] = time();
$data[ 'addon' ] = TypeDict::getType([ 'type' => $data[ 'type' ] ])[ 'addon' ] ?? '';
$res = $this->model->create($data);
$diy_form_fields = [];
if (!empty($data[ 'value' ])) {
$value = json_decode($data[ 'value' ], true);
foreach ($value[ 'value' ] as $component) {
// 过滤非表单组件和表单提交按钮组件
if ($component[ 'componentType' ] != 'diy_form' || $component[ 'componentName' ] == 'FormSubmit') {
continue;
}
if (isset($component[ 'field' ][ 'default' ]) && is_array($component[ 'field' ][ 'default' ])) {
$component[ 'field' ][ 'default' ] = json_encode($component[ 'field' ][ 'default' ]);
}
$diy_form_fields[] = [
'site_id' => $this->site_id,
'form_id' => $res->form_id, // 所属万能表单id
'field_key' => $component[ 'id' ], // 字段唯一标识
'field_type' => $component[ 'componentName' ], // 字段类型
'field_name' => $component[ 'field' ][ 'name' ] ?? '', // 字段名称
'field_remark' => $component[ 'field' ][ 'remark' ][ 'text' ] ?? '', // 字段说明
'field_default' => $component[ 'field' ][ 'default' ] ?? '', // 字段默认值
'field_required' => $component[ 'field' ][ 'required' ], // 字段是否必填 0:否 1:是
'field_hidden' => $component[ 'isHidden' ], // 字段是否隐藏 0:否 1:是
'field_unique' => $component[ 'field' ][ 'unique' ], // 字段内容防重复 0:否 1:是
'privacy_protection' => $component[ 'field' ][ 'privacyProtection' ], // 隐私保护 0:关闭 1:开启
'create_time' => time(),
'update_time' => time()
];
}
}
$form_fields_model = new DiyFormFields();
$form_fields_model->insertAll($diy_form_fields);
// 初始化表单填写配置
( new CoreDiyFormConfigService() )->addWriteConfig([ 'site_id' => $this->site_id, 'form_id' => $res->form_id ]);
// 初始化表单提交成功页配置
( new CoreDiyFormConfigService() )->addSubmitConfig([ 'site_id' => $this->site_id, 'form_id' => $res->form_id ]);
Db::commit();
return $res->id;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
/**
* 编辑万能表单
* @param int $form_id
* @param array $data
* @return bool
*/
public function edit(int $form_id, array $data)
{
Db::startTrans();
try {
$data[ 'update_time' ] = time();
if (empty($data[ 'site_id' ])) {
$data[ 'site_id' ] = $this->site_id;
}
// 更新万能表单
$this->model->where([ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'form_id', '=', $form_id ] ])->update($data);
// 更新万能表单字段信息
$form_fields_model = new DiyFormFields();
if (!empty($data[ 'value' ])) {
$value = json_decode($data[ 'value' ], true);
if (!empty($value[ 'value' ])) {
$form_fields_add = $form_fields_update = $form_fields_delete_ids = [];
$form_component = []; // 存储表单组件集合
$form_fields_list = $form_fields_model->where([ [ 'site_id', '=', $this->site_id ], [ 'form_id', '=', $form_id ] ])->column('field_id', 'field_key');
foreach ($value[ 'value' ] as $component) {
// 过滤非表单组件和表单提交按钮组件
if ($component[ 'componentType' ] != 'diy_form' || $component[ 'componentName' ] == 'FormSubmit') {
continue;
}
if (isset($component[ 'field' ][ 'default' ]) && is_array($component[ 'field' ][ 'default' ])) {
$component[ 'field' ][ 'default' ] = json_encode($component[ 'field' ][ 'default' ]);
}
$form_component[] = $component;
if (isset($form_fields_list[ $component[ 'id' ] ])) {
$form_fields_update = [
'field_id' => $form_fields_list[ $component[ 'id' ] ],
'field_name' => $component[ 'field' ][ 'name' ] ?? '', // 字段名称
'field_remark' => $component[ 'field' ][ 'remark' ][ 'text' ] ?? '', // 字段说明
'field_default' => $component[ 'field' ][ 'default' ] ?? '', // 字段默认值
'field_required' => $component[ 'field' ][ 'required' ], // 字段是否必填 0:否 1:是
'field_hidden' => $component[ 'isHidden' ], // 字段是否隐藏 0:否 1:是
'field_unique' => $component[ 'field' ][ 'unique' ], // 字段内容防重复 0:否 1:是
'privacy_protection' => $component[ 'field' ][ 'privacyProtection' ], // 隐私保护 0:关闭 1:开启
'update_time' => time()
];
// 更新万能表单字段
$form_fields_model->where([
[ 'site_id', '=', $this->site_id ],
[ 'field_id', '=', $form_fields_list[ $component[ 'id' ] ] ]
])->update($form_fields_update);
} else {
$form_fields_add[] = [
'site_id' => $this->site_id,
'form_id' => $form_id,
'field_key' => $component[ 'id' ], // 字段唯一标识
'field_type' => $component[ 'componentName' ], // 字段类型
'field_name' => $component[ 'field' ][ 'name' ] ?? '', // 字段名称
'field_remark' => $component[ 'field' ][ 'remark' ][ 'text' ] ?? '', // 字段说明
'field_default' => $component[ 'field' ][ 'default' ] ?? '', // 字段默认值
'field_required' => $component[ 'field' ][ 'required' ], // 字段是否必填 0:否 1:是
'field_hidden' => $component[ 'isHidden' ], // 字段是否隐藏 0:否 1:是
'field_unique' => $component[ 'field' ][ 'unique' ], // 字段内容防重复 0:否 1:是
'privacy_protection' => $component[ 'field' ][ 'privacyProtection' ], // 隐私保护 0:关闭 1:开启
'create_time' => time(),
'update_time' => time()
];
}
}
$field_key_list = array_column($form_component, 'id');
$form_fields_delete_ids = array_diff(array_keys($form_fields_list), $field_key_list);
// 添加万能表单字段
if (!empty($form_fields_add)) {
$form_fields_model->insertAll($form_fields_add);
}
// 删除万能表单字段
if (!empty($form_fields_delete_ids)) {
$form_fields_model->where([ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'form_id', '=', $form_id ], [ 'field_key', 'in', $form_fields_delete_ids ] ])->delete();
}
} else {
// 未找到表单组件,则全部清空
$form_fields_model->where([ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'form_id', '=', $form_id ] ])->delete();
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
/**
* 删除万能表单
* @param array $form_ids
* @return bool
*/
public function del(array $form_ids)
{
$where = [
[ 'site_id', '=', $this->site_id ],
[ 'form_id', 'in', $form_ids ]
];
$status_count = $this->model->where($where)->where([ [ 'status', '=', 1 ] ])->count();
if ($status_count > 0) throw new AdminException('ON_STATUS_PROHIBIT_DELETE');
$form_fields_model = new DiyFormFields();
$form_records_model = new DiyFormRecords();
$form_records_fields_model = new DiyFormRecordsFields();
$form_submit_config_model = new DiyFormSubmitConfig();
$form_write_config_model = new DiyFormWriteConfig();
Db::startTrans();
try {
//删除万能表单表
$this->model->where($where)->delete();
//删除万能表单字段表
$form_fields_model->where($where)->delete();
//删除万能表单填写记录
$form_records_model->where($where)->delete();
//删除万能表单填写字段
$form_records_fields_model->where($where)->delete();
//删除万能表单提交页配置
$form_submit_config_model->where($where)->delete();
//删除万能表单填写配置
$form_write_config_model->where($where)->delete();
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
/**
* 页面加载初始化
* @param array $params
* @return array
* @throws DbException
*/
public function getInit(array $params = [])
{
$time = time();
$data = [];
if (!empty($params[ 'form_id' ])) {
$data = $this->getInfo($params[ 'form_id' ]);
}
if (!empty($data)) {
$current_type = TypeDict::getType([ 'type' => $data[ 'type' ] ]);
$type_name = $current_type[ 'title' ];
$data[ 'type_name' ] = $type_name;
} else {
if (!isset($params[ 'type' ]) || empty($params[ 'type' ])) throw new AdminException('DIY_FORM_TYPE_NOT_EXIST');
$type = $params[ 'type' ];
// 新页面赋值
$page_title = $params[ 'title' ] ? : '表单页面' . $time; // 页面标题(用于前台展示)
$current_type = TypeDict::getType([ 'type' => $params[ 'type' ] ]);
$type_name = $current_type[ 'title' ];
$title = $type_name;
$value = '';
$data = [
'page_title' => $page_title, // 页面名称(用于后台展示)
'title' => $title, // 页面标题(用于前台展示)
'type' => $type,
'type_name' => $type_name,
'value' => $value,
];
}
$data[ 'component' ] = $this->getComponentList($data[ 'type' ]);
$data[ 'domain_url' ] = ( new SystemService() )->getUrl();
return $data;
}
/**
* 修改分享内容
* @param $data
* @return bool
*/
public function modifyShare($data)
{
$this->model->where([ [ 'site_id', '=', $this->site_id ], [ 'form_id', '=', $data[ 'form_id' ] ] ])->update([ 'share' => $data[ 'share' ] ]);
return true;
}
/**
* 获取组件列表(表单组件+自定义装修的组件)
* @param string $type 支持表单类型
* @return array
*/
public function getComponentList(string $type = '')
{
$componentType = function(&$component_list, $type) {
if (!empty($component_list)) {
foreach ($component_list as $k => &$value) {
if (!empty($value[ 'list' ])) {
foreach ($value[ 'list' ] as $ck => &$v) {
$v[ 'componentType' ] = $type;
}
}
}
}
};
$form_component_list = DiyFormComponentDict::getComponent();
foreach ($form_component_list as $k => $v) {
// 查询组件支持的表单类型
$sort_arr = [];
foreach ($v[ 'list' ] as $ck => $cv) {
$support = $cv[ 'support' ] ?? [];
if (!( count($support) == 0 || in_array($type, $support) )) {
unset($form_component_list[ $k ][ 'list' ][ $ck ]);
continue;
}
$sort_arr [] = $cv[ 'sort' ];
unset($form_component_list[ $k ][ 'list' ][ $ck ][ 'sort' ], $form_component_list[ $k ][ 'list' ][ $ck ][ 'support' ]);
}
array_multisort($sort_arr, SORT_ASC, $form_component_list[ $k ][ 'list' ]); //排序,根据 sort 排序
}
$componentType($form_component_list, 'diy_form');
$diy_service = new DiyService();
$diy_component_list = $diy_service->getComponentList();
$componentType($diy_component_list, 'diy');
$data = array_merge($form_component_list, $diy_component_list);
return $data;
}
/**
* 获取万能表单模板数据
* @param $type
* @param $name
* @return array
*/
public function getPageData($type, $name)
{
$pages = PagesDict::getPages([ 'type' => $type ]);
return $pages[ $name ] ?? [];
}
/**
* 复制万能表单
* @param array $param
* @return mixed
*/
public function copy($param)
{
$info = $this->model
->withoutfield('create_time,update_time')
->with([
'writeConfig' => function($query) {
$query->withoutfield('id,create_time,update_time');
},
'submitConfig' => function($query) {
$query->withoutfield('id,create_time,update_time');
},
'formField' => function($query) {
$query->withoutfield('field_id,create_time,update_time');
} ])
->where([ [ 'form_id', '=', $param[ 'form_id' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
if (empty($info)) throw new AdminException('DIY_FORM_NOT_EXIST');
unset($info[ 'form_id' ]);
$info[ 'page_title' ] = $info[ 'page_title' ] . '_副本';
$info[ 'status' ] = 0;
$info[ 'share' ] = '';
$info[ 'write_num' ] = 0;
$info[ 'create_time' ] = time();
$info[ 'update_time' ] = time();
Db::startTrans();
try {
$res = $this->model->create($info);
$form_id = $res->form_id;
if (!empty($info[ 'formField' ])) {
$form_field_list = array_map(function($item) use ($form_id) {
$item[ 'form_id' ] = $form_id;
$item[ 'write_num' ] = 0;
$item[ 'create_time' ] = time();
$item[ 'update_time' ] = time();
return $item;
}, $info[ 'formField' ]);
( new DiyFormFields() )->saveALl($form_field_list);
unset($info[ 'formField' ]);
}
if (!empty($info[ 'writeConfig' ])) {
$info[ 'writeConfig' ][ 'form_id' ] = $form_id;
( new CoreDiyFormConfigService() )->addWriteConfig($info[ 'writeConfig' ]);
}
if (!empty($info[ 'submitConfig' ])) {
$info[ 'submitConfig' ][ 'form_id' ] = $form_id;
( new CoreDiyFormConfigService() )->addSubmitConfig($info[ 'submitConfig' ]);
}
Db::commit();
return $form_id;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
/**
* 获取页面模板
* @param array $params
* @return array
*/
public function getTemplate($params = [])
{
$page_template = TemplateDict::getTemplate($params);
return $page_template;
}
/**
* 获取万能表单类型
* @return array|null
*/
public function getFormType()
{
$type_list = TypeDict::getType();
return $type_list;
}
/**
* 修改状态
* @param $data
* @return Bool
*/
public function modifyStatus($data)
{
return $this->model->where([
[ 'form_id', '=', $data[ 'form_id' ] ],
[ 'site_id', '=', $this->site_id ]
])->update([ 'status' => $data[ 'status' ] ]);
}
/**
* 获取使用记录
* @param array $data
* @return array|null
*/
public function getRecordPages($data)
{
$data[ 'site_id' ] = $this->site_id;
return ( new CoreDiyFormRecordsService() )->getPage($data);
}
/**
* 获取使用记录
* @param int $record_id
* @return array|null
*/
public function getRecordInfo(int $record_id)
{
$data[ 'site_id' ] = $this->site_id;
$data[ 'record_id' ] = $record_id;
return ( new CoreDiyFormRecordsService() )->getInfo($data);
}
/**
* 删除填写记录
* @param $params
* @return bool
*/
public function delRecord($params)
{
Db::startTrans();
try {
// 减少填写数量
$this->model->where([ [ 'form_id', '=', $params[ 'form_id' ] ] ])->dec('write_num', 1)->update();
$form_records_model = new DiyFormRecords();
$form_records_model->where([
[ 'site_id', '=', $this->site_id ],
[ 'record_id', '=', $params[ 'record_id' ] ]
])->delete();
$form_records_fields_model = new DiyFormRecordsFields();
// 删除万能表单填写字段
$form_records_fields_model->where([
[ 'site_id', '=', $this->site_id ],
[ 'record_id', '=', $params[ 'record_id' ] ]
])->delete();
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
/**
* 获取万能表单字段列表
* @param array $where
* @param string $field
* @param string $order
* @return mixed
*/
public function getFieldsList($where = [], $field = 'field_id, form_id, field_key, field_type, field_name, field_remark, write_num, field_required, field_hidden, field_unique, privacy_protection, create_time, update_time')
{
$order = "update_time desc";
if (!empty($where[ 'order' ])) {
$order = $where[ 'order' ] . ' ' . $where[ 'sort' ];
}
return ( new DiyFormFields() )->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'form_id' ], $where)->field($field)->order($order)->select()->toArray();
}
/**
* 获取万能表单微信小程序二维码
* @param $form_id
* @return array
*/
public function getQrcode($form_id)
{
if (empty($form_id)) {
throw new AdminException('缺少参考form_id');
}
$page = 'app/pages/index/diy_form';
$data = [
[
'key' => 'form_id',
'value' => $form_id
],
];
$dir = 'upload/' . $this->site_id . '/diy_form_qrcode';
$path = '';
try {
$path = qrcode('', $page, $data, $this->site_id, $dir, 'weapp');
} catch (\Exception $e) {
Log::write('万能表单微信小程序二维码生成error' . $e->getMessage() . $e->getFile() . $e->getLine());
}
return [
'path' => $path
];
}
}

View File

@ -97,7 +97,8 @@ class InstallSystemService extends BaseAdminService
'methods' => $value[ 'methods' ] ?? '',
'sort' => $value[ 'sort' ] ?? '',
'status' => 1,
'is_show' => $value[ 'is_show' ] ?? 1
'is_show' => $value[ 'is_show' ] ?? 1,
'menu_attr' => $value['menu_attr'] ?? ''
];
$refer = $value;
if (isset($refer[ 'children' ])) {

View File

@ -35,11 +35,11 @@ class MemberCashOutService extends BaseAdminService
public function getPage(array $where = [])
{
$field = 'id,member_cash_out.site_id,cash_out_no,member_cash_out.member_id,account_type,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_status,transfer_time,apply_money,rate,service_money,member_cash_out.money,audit_time,member_cash_out.status,remark,member_cash_out.create_time,refuse_reason,transfer_no';
$field = 'id,member_cash_out.site_id,cash_out_no,member_cash_out.member_id,account_type,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_status,transfer_time,apply_money,rate,service_money,member_cash_out.money,audit_time,member_cash_out.status,remark,member_cash_out.create_time,refuse_reason,transfer_no, transfer_payment_code';
$member_where = [];
if(!empty($where['keywords']))
{
$member_where = [['member.member_no|member.nickname|member.mobile', '=', $where['keywords']]];
$member_where = [['member.member_no|member.nickname|member.mobile|member.username', '=', $where['keywords']]];
}
$search_model = $this->model->where([['member_cash_out.site_id', '=', $this->site_id]])
->withSearch(['member_id','status', 'join_create_time' => 'create_time', 'audit_time', 'transfer_time', 'transfer_type', 'cash_out_no'],$where)->with(['transfer'])
@ -55,7 +55,7 @@ class MemberCashOutService extends BaseAdminService
*/
public function getInfo(int $id)
{
$field = 'id,site_id,cash_out_no,member_id,account_type,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_status,transfer_time,apply_money,rate,service_money,money,audit_time,status,remark,create_time,refuse_reason,transfer_no';
$field = 'id,site_id,cash_out_no,member_id,account_type,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_status,transfer_time,apply_money,rate,service_money,money,audit_time,status,remark,create_time,refuse_reason,transfer_no, transfer_payment_code';
return $this->model->where([['id', '=', $id], ['site_id', '=', $this->site_id]])->with(['memberInfo', 'transfer'])->field($field)->append(['status_name', 'transfer_status_name', 'transfer_type_name', 'account_type_name'])->findOrEmpty()->toArray();
}
@ -82,6 +82,16 @@ class MemberCashOutService extends BaseAdminService
return $core_member_cash_out_service->transfer($this->site_id, $id, $data);
}
/**
* 备注
* @param int $id
* @param array $data
* @return true
*/
public function remark(int $id, array $data){
$core_member_cash_out_service = new CoreMemberCashOutService();
return $core_member_cash_out_service->remark($this->site_id, $id, $data);
}
/**
* 统计数据
* @return array
@ -98,4 +108,14 @@ class MemberCashOutService extends BaseAdminService
return $stat;
}
/**
* 检测实际的转账状态
* @param int $id
* @return true
*/
public function checkTransferStatus(int $id){
$core_member_cash_out_service = new CoreMemberCashOutService();
return $core_member_cash_out_service->checkTransferStatus($this->site_id, $id);
}
}

View File

@ -15,7 +15,7 @@ use app\model\member\MemberSign;
use app\service\core\member\CoreMemberService;
use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService;
use core\exception\CommonException;
use core\exception\AdminException;
/**
* 会员签到服务层
@ -84,7 +84,14 @@ class MemberSignService extends BaseAdminService
*/
public function setSign(array $value)
{
if ($value[ 'sign_period' ] <= 0) throw new CommonException('SIGN_PERIOD_GREATER_THAN');
if (empty($value[ 'sign_period' ])) throw new AdminException('SIGN_PERIOD_CANNOT_EMPTY');
if ($value[ 'sign_period' ] < 2 || $value[ 'sign_period' ] > 365) throw new AdminException('SIGN_PERIOD_BETWEEN_2_365_DAYS');
if (!empty($value[ 'continue_award' ])) {
foreach ($value[ 'continue_award' ] as $v) {
if ($v[ 'continue_sign' ] < 2 || $v[ 'continue_sign' ] > 365) throw new AdminException('CONTINUE_SIGN_BETWEEN_2_365_DAYS');
if ($v[ 'continue_sign' ] > $value[ 'sign_period' ]) throw new AdminException('CONTINUE_SIGN_CANNOT_GREATER_THAN_SIGN_PERIOD');
}
}
$data = [
'is_use' => $value[ 'is_use' ], //是否开启
'sign_period' => $value[ 'sign_period' ], // 签到周期

View File

@ -199,7 +199,9 @@ class PayChannelService extends BaseAdminService
'pay_explain_switch' => $data[ 'pay_explain_switch' ] ?? 1,// 帮付说明开关, 1开启0关闭
'pay_explain_title' => $data[ 'pay_explain_title' ] ?? get_lang('dict_pay_config.pay_explain_title'),// 帮付说明标题
'pay_explain_content' => $data[ 'pay_explain_content' ] ?? get_lang('dict_pay_config.pay_explain_content'),// 帮付说明内容
'pay_info_switch' => $data[ 'pay_info_switch' ] ?? 1// 订单信息, 1开启0关闭
'pay_info_switch' => $data[ 'pay_info_switch' ] ?? 1,// 订单信息, 1开启0关闭
'pay_wechat_share_image' => $data[ 'pay_wechat_share_image' ] ?? '/static/resource/images/pay/pay_wechat_share_image.png',// 默认分享图片(公众号)
'pay_weapp_share_image' => $data[ 'pay_weapp_share_image' ] ?? '/static/resource/images/pay/pay_weapp_share_image.png'// 默认分享图片(小程序)
];
break;
default:

View File

@ -88,7 +88,7 @@ class SiteService extends BaseAdminService
if (!empty($info)) {
$site_addons = ( new CoreSiteService() )->getAddonKeysBySiteId($site_id);
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ] ])->field('key,title,desc,icon,type')->select()->toArray();
$info['uid'] = ( new SysUserRole() )->where([ [ 'site_id', '=', $site_id ], [ 'is_admin', '=', 1 ] ])->value('uid');
$info[ 'uid' ] = ( new SysUserRole() )->where([ [ 'site_id', '=', $site_id ], [ 'is_admin', '=', 1 ] ])->value('uid');
}
return $info;
}
@ -190,9 +190,9 @@ class SiteService extends BaseAdminService
$data[ 'status' ] = strtotime($data[ 'expire_time' ]) > time() ? SiteDict::ON : SiteDict::EXPIRE;
}
if (isset($data['uid'])){
if (isset($data[ 'uid' ])) {
if ($data[ 'uid' ] > 0) {
( new UserRoleService() )->editAdmin($site_id,$data['uid']);
( new UserRoleService() )->editAdmin($site_id, $data[ 'uid' ]);
} else {
//添加用户
$data_user = [
@ -205,7 +205,7 @@ class SiteService extends BaseAdminService
'is_admin' => 1
];
$data[ 'uid' ] = ( new UserService() )->add($data_user);
( new UserRoleService() )->editAdmin($site_id,$data['uid']);
( new UserRoleService() )->editAdmin($site_id, $data[ 'uid' ]);
}
}
@ -392,4 +392,61 @@ class SiteService extends BaseAdminService
$site_addon = ( new CoreSiteService() )->getAddonKeysBySiteId($this->site_id);
return $site_addon;
}
/**
* 查询应用列表todo 完善
* @return array
*/
public function getShowAppTools()
{
$list = [
'addon' => [
'title' => '运营工具',
'list' => []
],
'tool' => [
'title' => '系统工具',
'list' => []
],
// 'promotion' => [
// 'title' => '营销活动',
// 'list' => []
// ]
];
$apps = event('ShowApp');
$keys = [];
foreach ($apps as $v) {
foreach ($v as $ck => $cv) {
if (!empty($cv)) {
foreach ($cv as $addon_k => $addon_v) {
if (in_array($addon_v[ 'key' ], $keys)) {
continue;
}
$list[ $ck ][ 'list' ][] = $addon_v;
$keys[] = $addon_v[ 'key' ];
}
}
}
}
$site_addons = $this->getSiteAddons([]);
if (!empty($site_addons)) {
foreach ($site_addons as $k => $v) {
if (!in_array($v[ 'key' ], $keys)) {
$list[ 'addon' ][ 'list' ][] = [
'title' => $v[ 'title' ],
'desc' => $v[ 'desc' ],
'icon' => $v[ 'icon' ],
'key' => $v[ 'key' ]
];
}
}
}
return $list;
}
}

View File

@ -87,7 +87,9 @@ class AreaService extends BaseAdminService
while ($area['level'] > 1) {
$area = $this->model->where([ ['id', '=', $area['pid'] ] ])->field('id,level,pid,name')->findOrEmpty();
$tree[ $level[ $area['level'] ] ] = $area->toArray();
if (!$area->isEmpty()) {
$tree[ $level[ $area[ 'level' ] ] ] = $area->toArray();
}
}
}
return $tree;

View File

@ -269,7 +269,9 @@ class UpgradeService extends BaseAdminService
// 覆盖文件
if (is_dir($code_dir . $version_no)) {
dir_copy($code_dir . $version_no, $to_dir);
// 忽略环境变量文件
$exclude_files = ['.env.development', '.env.production', '.env', '.env.dev', '.env.product'];
dir_copy($code_dir . $version_no, $to_dir, exclude_files:$exclude_files);
if ($addon != AddonDict::FRAMEWORK_KEY) {
(new CoreAddonInstallService($addon))->installDir();
}
@ -367,7 +369,8 @@ class UpgradeService extends BaseAdminService
*/
public function handleUniapp() {
$code_dir = $this->upgrade_dir .$this->upgrade_task['key'] . DIRECTORY_SEPARATOR . 'download' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR;
dir_copy($code_dir . 'uni-app', $this->root_path . 'uni-app');
$exclude_files = ['.env.development', '.env.production', 'manifest.json'];
dir_copy($code_dir . 'uni-app', $this->root_path . 'uni-app', exclude_files:$exclude_files);
$addon_list = (new CoreAddonService())->getInstallAddonList();
$depend_service = new CoreDependService();
@ -380,9 +383,6 @@ class UpgradeService extends BaseAdminService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $addon);
// 编译 fixed-group 固定模板组件代码文件
$this->compileFixedComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $addon);
// 编译 pages.json 页面路由代码文件
$this->installPageCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR);

View File

@ -15,6 +15,9 @@ use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use app\dict\sys\FileDict;
use app\model\diy\Diy;
use app\model\diy\DiyTheme;
use app\service\core\diy\CoreDiyService;
use app\service\core\site\CoreSiteService;
use core\base\BaseApiService;
/**
@ -149,4 +152,37 @@ class DiyService extends BaseApiService
return $data;
}
/**
* 获取自定义主题配色
* @return array
*/
public function getDiyTheme()
{
$site_addon = ( new CoreSiteService() )->getSiteCache($this->site_id);
$addon_list = array_merge($site_addon['apps'],$site_addon['site_addons']);
$theme_data = (new DiyTheme())->where([['site_id', '=', $this->site_id]])->column('id,color_name,color_mark,value,diy_value,title','addon');
$defaultColor = ( new CoreDiyService() )->getDefaultColor();
$app_theme['app'] = [
'color_name' => $theme_data['app']['color_name'] ?? $defaultColor['name'],
'color_mark' => $theme_data['app']['color_mark'] ?? $defaultColor['title'],
'value' => $theme_data['app']['value'] ?? $defaultColor['theme'],
'diy_value' => $theme_data['app']['diy_value'] ?? '',
];
$data = [];
foreach ($addon_list as $key=>$value){
if (isset($value['support_app']) && empty($value['support_app']) && $value['type'] == 'addon'){
continue;
}
$default_theme_data = array_values(array_filter(event('ThemeColor', [ 'key' => $value['key']])))[0] ?? [];
$data[$value['key']]['color_mark'] = $theme_data[$value['key']]['color_mark'] ?? ($default_theme_data ? $default_theme_data[ 'name' ] : $defaultColor['name']);
$data[$value['key']]['color_name'] = $theme_data[$value['key']]['color_name'] ?? ($default_theme_data ? $default_theme_data[ 'title' ] : $defaultColor['title']);
$data[$value['key']]['value'] = $theme_data[$value['key']]['value'] ?? ($default_theme_data ? $default_theme_data[ 'theme' ] : $defaultColor['theme']);
$data[$value['key']]['diy_value'] = $theme_data[$value['key']]['diy_value'] ?? '';
}
if (count($site_addon[ 'apps' ]) > 1) {
$data = array_merge($app_theme,$data);
}
return $data;
}
}

View File

@ -0,0 +1,320 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\api\diy_form;
use app\model\diy_form\DiyForm;
use app\model\diy_form\DiyFormRecords;
use app\model\diy_form\DiyFormWriteConfig;
use app\model\member\Member;
use app\model\member\MemberLabel;
use app\model\member\MemberLevel;
use app\service\core\diy_form\CoreDiyFormRecordsService;
use core\base\BaseApiService;
use core\exception\ApiException;
/**
* 万能表单服务层
* Class DiyFormService
* @package app\service\api\diy
*/
class DiyFormService extends BaseApiService
{
public function __construct()
{
parent::__construct();
$this->model = new DiyForm();
}
/**
* 获取万能表单信息
* @param int $form_id
* @param string $field
* @return mixed
*/
public function getInfo(int $form_id, $field = 'form_id, page_title, title, type, status, value, share, remark')
{
$write_config = ( new DiyFormWriteConfig() )->where([
[ 'form_id', '=', $form_id ],
[ 'site_id', '=', $this->site_id ]
])->findOrEmpty()->toArray();
$error = [];
$info = $this->model->field($field)->where([ [ 'form_id', '=', $form_id ], [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
if (!empty($info)) {
if (!empty($info[ 'value' ][ 'value' ])) {
foreach ($info[ 'value' ][ 'value' ] as $k => $v) {
if ($v[ 'isHidden' ]) {
unset($info[ 'value' ][ 'value' ][ $k ]); // 过滤隐藏的组件
}
}
$info[ 'value' ][ 'value' ] = array_values($info[ 'value' ][ 'value' ]);
}
if (!empty($write_config) && !empty($this->member_id)) {
if ($error_msg = $this->checkMemberCanJoinOrNot($this->member_id, $write_config)) {
$error[] = $error_msg;
}
if ($error_msg = $this->checkFormWriteTime($write_config)) {
$error[] = $error_msg;
}
if ($error_msg = $this->checkFormWriteLimitNum($form_id, $write_config)) {
$error[] = $error_msg;
}
if ($error_msg = $this->checkMemberWriteLimitNum($this->member_id, $form_id, $write_config)) {
$error[] = $error_msg;
}
}
} else {
$error[] = [
'title' => '当前表单无法查看',
'type' => '表单状态',
'desc' => '该表单已关闭'
];
}
$info[ 'error' ] = $error;
return $info;
}
/**
* 判断当前会员是否可以填写表单
* @param int $member_id
* @param array $config
* @return array
*/
public function checkMemberCanJoinOrNot($member_id, $config)
{
$member_info = ( new Member() )->where([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $this->site_id ] ])->field('member_level,member_label')->findOrEmpty()->toArray();
if (empty($member_info)) throw new ApiException('MEMBER_NOT_EXIST');
$error = [];
switch ($config[ 'join_member_type' ]) {
case 'all_member':
break;
case 'selected_member_level':
if (!in_array($member_info[ 'member_level' ], $config[ 'level_ids' ])) {
$level_names = ( new MemberLevel() )->where([ [ 'level_id', 'in', $config[ 'level_ids' ] ], [ 'site_id', '=', $this->site_id ] ])->column('level_name');
$error = [
'title' => '当前表单无法查看',
'type' => '允许填写用户',
'desc' => '该表单已设置仅限“' . implode('、', $level_names) . '等级”的用户填写'
];
}
break;
case 'selected_member_label':
if (empty($member_info[ 'member_label' ])) $member_info[ 'member_label' ] = [];
if (empty(array_intersect($member_info[ 'member_label' ], $config[ 'label_ids' ]))) {
$label_names = ( new MemberLabel() )->where([ [ 'label_id', 'in', $config[ 'label_ids' ] ], [ 'site_id', '=', $this->site_id ] ])->column('label_name');
$error = [
'title' => '当前表单无法查看',
'type' => '允许填写用户',
'desc' => '该表单已设置仅限“' . implode('、', $label_names) . '标签”的用户填写'
];
}
break;
}
return $error;
}
/**
* 检查会员填写表单次数限制
* @return array
*/
public function checkMemberWriteLimitNum($member_id, $form_id, $config)
{
$form_records_model = new DiyFormRecords();
$error = [];
switch ($config[ 'member_write_type' ]) {
case 'no_limit':
break;
case 'diy':
$member_write_rule = $config[ 'member_write_rule' ];
switch ($member_write_rule[ 'time_unit' ]) {
case 'day':
$time_text = '天';
break;
case 'week':
$time_text = '周';
break;
case 'month':
$time_text = '月';
break;
case 'year':
$time_text = '年';
break;
}
$count = $form_records_model->where([
[ 'form_id', '=', $form_id ],
[ 'site_id', '=', $this->site_id ],
[ 'member_id', '=', $member_id ]
])->whereTime('create_time', '-' . $member_write_rule[ 'time_value' ] . ' ' . $member_write_rule[ 'time_unit' ])->count();
if ($count >= $member_write_rule[ 'num' ]) {
$error = [
'title' => '您的填写次数已达上限',
'type' => '允许填写次数(每人)',
'desc' => '该表单已设置“每人每' . $member_write_rule[ 'time_value' ] . $time_text . '可填写' . $member_write_rule[ 'num' ] . '次”'
];
}
break;
}
return $error;
}
/**
* 检查表单填写次数限制
* @return array
*/
public function checkFormWriteLimitNum($form_id, $config)
{
$form_records_model = new DiyFormRecords();
$error = [];
switch ($config[ 'form_write_type' ]) {
case 'no_limit':
break;
case 'diy':
$form_write_rule = $config[ 'form_write_rule' ];
switch ($form_write_rule[ 'time_unit' ]) {
case 'day':
$time_text = '天';
break;
case 'week':
$time_text = '周';
break;
case 'month':
$time_text = '月';
break;
case 'year':
$time_text = '年';
break;
}
$count = $form_records_model->where([
[ 'form_id', '=', $form_id ],
[ 'site_id', '=', $this->site_id ]
])->whereTime('create_time', '-' . $form_write_rule[ 'time_value' ] . ' ' . $form_write_rule[ 'time_unit' ])->count();
if ($count >= $form_write_rule[ 'num' ]) {
$error = [
'title' => '表单总填写次数已达上限',
'type' => '允许填写次数(总)',
'desc' => '该表单已设置“每' . $form_write_rule[ 'time_value' ] . $time_text . '可填写' . $form_write_rule[ 'num' ] . '次”'
];
}
break;
}
return $error;
}
/**
* 检查表单填写时间限制
* @param array $config
* @return array
*/
public function checkFormWriteTime($config)
{
$error = [];
switch ($config[ 'time_limit_type' ]) {
case 'no_limit':
break;
case 'specify_time':
$specify_time = $config[ 'time_limit_rule' ][ 'specify_time' ] ?? [];
if (!empty($specify_time)) {
if (time() < $specify_time[ 0 ] || time() > $specify_time[ 1 ]) {
$error = [
'title' => '当前时间无法查看',
'type' => '允许查看时间',
'desc' => '该表单已设置“' . date('Y-m-d H:i:s', $specify_time[ 0 ]) . '-' . date('Y-m-d H:i:s', $specify_time[ 1 ]) . '”可查看'
];
}
}
break;
case 'open_day_time':
$open_day_time = $config[ 'time_limit_rule' ][ 'open_day_time' ] ?? [];
if (!empty($open_day_time)) {
$start_time = strtotime(date('Y-m-d', time())) + $open_day_time[ 0 ];
$end_time = strtotime(date('Y-m-d', time())) + $open_day_time[ 1 ];
if (time() < $start_time || time() > $end_time) {
$error = [
'title' => '当前时间无法查看',
'type' => '允许查看时间',
'desc' => '该表单已设置“每天' . date('H:i', $start_time) . '-' . date('H:i', $end_time) . '”可查看'
];
}
}
break;
}
return $error;
}
/**
* 提交填表记录
* @param array $data
* @return array
*/
public function addRecord(array $data = [])
{
$data[ 'site_id' ] = $this->site_id;
$data[ 'member_id' ] = $this->member_id;
$info = $this->model->field('status')->where([ [ 'form_id', '=', $data[ 'form_id' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
if (empty($info)) throw new ApiException('DIY_FORM_NOT_EXIST');
if ($info[ 'status' ] == 0) throw new ApiException('DIY_FORM_NOT_OPEN');
$write_config = ( new DiyFormWriteConfig() )->where([
[ 'form_id', '=', $data[ 'form_id' ] ],
[ 'site_id', '=', $this->site_id ]
])->findOrEmpty()->toArray();
if (!empty($write_config)) {
if ($error_msg = $this->checkMemberCanJoinOrNot($this->member_id, $write_config)) {
throw new ApiException($error_msg[ 'desc' ]);
}
if ($error_msg = $this->checkFormWriteTime($write_config)) {
throw new ApiException($error_msg[ 'desc' ]);
}
if ($error_msg = $this->checkFormWriteLimitNum($data[ 'form_id' ], $write_config)) {
throw new ApiException($error_msg[ 'desc' ]);
}
if ($error_msg = $this->checkMemberWriteLimitNum($this->member_id, $data[ 'form_id' ], $write_config)) {
throw new ApiException($error_msg[ 'desc' ]);
}
}
return ( new CoreDiyFormRecordsService() )->add($data);
}
/**
* 获取表单填写结果信息
* @param array $params
* @return mixed
*/
public function getResult($params = [])
{
$diy_form_records_model = new DiyFormRecords();
$field = 'record_id,form_id,create_time';
return $diy_form_records_model->field($field)->where([ [ 'site_id', '=', $this->site_id ], [ 'record_id', '=', $params[ 'record_id' ] ], [ 'member_id', '=', $this->member_id ] ])->with([ 'submitConfig' ])->findOrEmpty()->toArray();
}
/**
* 获取表单填写记录循环diy-group每个表单组件实现各自的渲染处理
* @param array $params
* @return mixed
*/
public function getFormRecordInfo($params = [])
{
$diy_form_records_model = new DiyFormRecords();
$field = 'record_id,form_id,create_time';
$info = $diy_form_records_model->field($field)->where([ [ 'site_id', '=', $this->site_id ], [ 'record_id', '=', $params[ 'record_id' ] ], [ 'member_id', '=', $this->member_id ] ])
->with([
// 关联填写字段列表
'recordsFieldList' => function($query) {
$query->field('id, form_id, form_field_id, record_id, field_key, field_type, field_name, field_value, field_required, field_unique, privacy_protection, update_num, update_time')->append([ 'handle_field_value', 'render_value' ]);
}
])->findOrEmpty()->toArray();
return $info;
}
}

View File

@ -130,4 +130,29 @@ class AuthService extends BaseApiService
];
}
/**
* 获取手机号
* @param string $mobile_code
* @return array
*/
public function getMobile(string $mobile_code)
{
$result = ( new CoreWeappAuthService() )->getUserPhoneNumber($this->site_id, $mobile_code);
if (empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST');
if ($result[ 'errcode' ] != 0) throw new ApiException($result[ 'errmsg' ]);
$phone_info = $result[ 'phone_info' ];
$mobile = $phone_info[ 'purePhoneNumber' ];
if (empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST');
$member_service = new MemberService();
$mobile_member = $member_service->findMemberInfo([ 'mobile' => $mobile, 'site_id' => $this->site_id ]);
if (!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST');
return [
'mobile' => $mobile
];
}
}

View File

@ -75,8 +75,8 @@ class LoginService extends BaseApiService
$token_info = $this->createToken($member_info);
event("MemberLogin", $member_info);
return [
'token' => $token_info['token'],
'expires_time' => $token_info['params']['exp'],
'token' => $token_info[ 'token' ],
'expires_time' => $token_info[ 'params' ][ 'exp' ],
'mobile' => $member_info->mobile
];
}
@ -90,7 +90,7 @@ class LoginService extends BaseApiService
public function account(string $username, string $password)
{
$member_service = new MemberService();
$member_info = $member_service->findMemberInfo(['username|mobile' => $username, 'site_id' => $this->site_id]);
$member_info = $member_service->findMemberInfo([ 'username|mobile' => $username, 'site_id' => $this->site_id ]);
if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在
if (!check_password($password, $member_info->password)) return false;//密码与账号不匹配
return $this->login($member_info, MemberLoginTypeDict::USERNAME);
@ -98,26 +98,29 @@ class LoginService extends BaseApiService
/**
* 手机号登录
* @param string $mobile
* @param array $params
* @return array
*/
public function mobile(string $mobile){
public function mobile($params)
{
//校验手机验证码
$this->checkMobileCode($mobile);
$this->checkMobileCode($params[ 'mobile' ]);
//登录注册配置
$config = (new MemberConfigService())->getLoginConfig();
$is_mobile = $config['is_mobile'];
$config = ( new MemberConfigService() )->getLoginConfig();
$is_mobile = $config[ 'is_mobile' ];
$is_bind_mobile = $config[ 'is_bind_mobile' ];
if ($is_mobile != 1 && $is_bind_mobile != 1) throw new AuthException('MOBILE_LOGIN_UNOPENED');
$member_service = new MemberService();
$member_info = $member_service->findMemberInfo(['mobile' => $mobile, 'site_id' => $this->site_id]);
$member_info = $member_service->findMemberInfo([ 'mobile' => $params[ 'mobile' ], 'site_id' => $this->site_id ]);
if ($member_info->isEmpty()) {
//开启强制绑定手机号,登录会自动注册并绑定手机号
if ($is_bind_mobile == 1) {
$data = array (
'mobile' => $mobile,
$data = array(
'mobile' => $params[ 'mobile' ],
'nickname' => $params[ 'nickname' ],
'headimg' => $params[ 'headimg' ]
);
return (new RegisterService())->register($mobile, $data, MemberRegisterTypeDict::MOBILE, false);
return ( new RegisterService() )->register($params[ 'mobile' ], $data, MemberRegisterTypeDict::MOBILE, false);
} else {
throw new AuthException('MEMBER_NOT_EXIST');//账号不存在
}
@ -130,16 +133,16 @@ class LoginService extends BaseApiService
* @param $member_info
* @return array|null
*/
public function createToken($member_info): ?array
public function createToken($member_info) : ?array
{
$expire_time = env('system.api_token_expire_time') ?? 3600;//todo 不一定和管理端合用这个token时限
return TokenAuth::createToken($member_info->member_id, AppTypeDict::API, ['member_id' => $member_info->member_id, 'username' => $member_info->username, 'site_id' => $member_info->site_id], $expire_time);
return TokenAuth::createToken($member_info->member_id, AppTypeDict::API, [ 'member_id' => $member_info->member_id, 'username' => $member_info->username, 'site_id' => $member_info->site_id ], $expire_time);
}
/**
* 登陆退出(当前账户)
*/
public function logout(): ?bool
public function logout() : ?bool
{
self::clearToken($this->member_id, $this->request->apiToken());
return true;
@ -151,7 +154,7 @@ class LoginService extends BaseApiService
* @param string|null $token
* @return bool|null
*/
public static function clearToken(int $member_id, ?string $token = ''): ?bool
public static function clearToken(int $member_id, ?string $token = '') : ?bool
{
TokenAuth::clearToken($member_id, AppTypeDict::API, $token);
return true;
@ -162,24 +165,23 @@ class LoginService extends BaseApiService
* @param string|null $token
* @return array
*/
public function parseToken(?string $token){
if(empty($token))
{
public function parseToken(?string $token)
{
if (empty($token)) {
//定义专属于授权认证机制的错误响应, 定义专属语言包
throw new AuthException('MUST_LOGIN', 401);
}
try {
$token_info = TokenAuth::parseToken($token, AppTypeDict::API);
} catch ( Throwable $e ) {
} catch (Throwable $e) {
// if(env('app_debug', false)){
// throw new AuthException($e->getMessage(), 401);
// }else{
throw new AuthException('LOGIN_EXPIRE', 401);
throw new AuthException('LOGIN_EXPIRE', 401);
// }
}
if(!$token_info)
{
if (!$token_info) {
throw new AuthException('MUST_LOGIN', 401);
}
//验证有效次数或过期时间
@ -189,31 +191,34 @@ class LoginService extends BaseApiService
/**
* 手机发送验证码
* @param $mobile
* @param string $type 发送短信的业务场景
* @param string $type 发送短信的业务场景
* @return array
* @throws Exception
*/
public function sendMobileCode($mobile, string $type = ''){
(new CaptchaService())->check();
if(empty($mobile)) throw new AuthException('MOBILE_NEEDED');
public function sendMobileCode($mobile, string $type = '')
{
( new CaptchaService() )->check();
if (empty($mobile)) throw new AuthException('MOBILE_NEEDED');
//发送
if(!in_array($type, SmsDict::SCENE_TYPE)) throw new AuthException('MEMBER_MOBILE_CAPTCHA_ERROR');
if (!in_array($type, SmsDict::SCENE_TYPE)) throw new AuthException('MEMBER_MOBILE_CAPTCHA_ERROR');
$code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);// 生成4位随机数左侧补0
(new NoticeService())->send('member_verify_code', ['code' => $code, 'mobile' => $mobile]);
// ( new NoticeService() )->send('member_verify_code', [ 'code' => $code, 'mobile' => $mobile ]);
//将验证码存入缓存
$key = md5(uniqid('', true));
$cache_tag_name = "mobile_key".$mobile.$type;
$cache_tag_name = "mobile_key" . $mobile . $type;
$this->clearMobileCode($mobile, $type);
Cache::tag($cache_tag_name)->set($key, [ 'mobile' => $mobile, 'code' => $code, 'type' => $type], 600);
return ['key' => $key];
Cache::tag($cache_tag_name)->set($key, [ 'mobile' => $mobile, 'code' => $code, 'type' => $type ], 600);
return [ 'key' => $key ];
}
public function getMobileCodeCacheName(){
public function getMobileCodeCacheName()
{
}
public function clearMobileCode($mobile, $type){
$cache_tag_name = "mobile_key".$mobile.$type;
public function clearMobileCode($mobile, $type)
{
$cache_tag_name = "mobile_key" . $mobile . $type;
Cache::tag($cache_tag_name)->clear();
}
@ -222,17 +227,18 @@ class LoginService extends BaseApiService
* @param string $mobile
* @return true
*/
public function checkMobileCode(string $mobile){
if(empty($mobile)) throw new AuthException('MOBILE_NEEDED');
public function checkMobileCode(string $mobile)
{
if (empty($mobile)) throw new AuthException('MOBILE_NEEDED');
$mobile_key = request()->param('mobile_key', '');
$mobile_code = request()->param('mobile_code', '');
if(empty($mobile_key) || empty($mobile_code)) throw new AuthException('MOBILE_CAPTCHA_ERROR');
if (empty($mobile_key) || empty($mobile_code)) throw new AuthException('MOBILE_CAPTCHA_ERROR');
$cache = Cache::get($mobile_key);
if(empty($cache)) throw new AuthException('MOBILE_CAPTCHA_ERROR');
$temp_mobile = $cache['mobile'];
$temp_code = $cache['code'];
$temp_type = $cache['type'];
if($temp_mobile != $mobile || $temp_code != $mobile_code) throw new AuthException('MOBILE_CAPTCHA_ERROR');
if (empty($cache)) throw new AuthException('MOBILE_CAPTCHA_ERROR');
$temp_mobile = $cache[ 'mobile' ];
$temp_code = $cache[ 'code' ];
$temp_type = $cache[ 'type' ];
if ($temp_mobile != $mobile || $temp_code != $mobile_code) throw new AuthException('MOBILE_CAPTCHA_ERROR');
$this->clearMobileCode($temp_mobile, $temp_type);
return true;
@ -243,27 +249,28 @@ class LoginService extends BaseApiService
* @param $member
* @return true
*/
public function bingOpenid($member){
public function bingOpenid($member)
{
$open_id = $this->request->param('openid');
if(!empty($open_id)){
Log::write('channel_1'.$this->channel);
if(!empty($this->channel)){
if (!empty($open_id)) {
Log::write('channel_1' . $this->channel);
if (!empty($this->channel)) {
$openid_field = match($this->channel){
'wechat' => 'wx_openid',
'wechat' => 'wx_openid',
'weapp' => 'weapp_openid',
default => ''
};
if(!empty($openid_field)){
if(!$member->isEmpty()){
if(empty($member->$openid_field)){
if (!empty($openid_field)) {
if (!$member->isEmpty()) {
if (empty($member->$openid_field)) {
//todo 定义当前第三方授权方没有退出登录功能,故这儿不做openid是否存在账号验证
// $member_service = new MemberService();
// $open_member = $member_service->findMemberInfo([$openid_field => $open_id, 'site_id' => $this->site_id]);
$member->$openid_field = $open_id;
$member->save();
}else{
if( $member->$openid_field != $open_id){
} else {
if ($member->$openid_field != $open_id) {
throw new AuthException('MEMBER_IS_BIND_AUTH');
}
}
@ -279,11 +286,12 @@ class LoginService extends BaseApiService
* @param string $mobile
* @param string $password
*/
public function resetPassword(string $mobile, string $password){
public function resetPassword(string $mobile, string $password)
{
$member_service = new MemberService();
//校验手机验证码
$this->checkMobileCode($mobile);
$member_info = $member_service->findMemberInfo(['mobile' => $mobile, 'site_id' => $this->site_id]);
$member_info = $member_service->findMemberInfo([ 'mobile' => $mobile, 'site_id' => $this->site_id ]);
if ($member_info->isEmpty()) throw new AuthException('MOBILE_NOT_EXIST_MEMBER');//账号不存在
//todo 需要考虑一下,新的密码和原密码一样能否通过验证
$password_hash = create_password($password);
@ -291,19 +299,22 @@ class LoginService extends BaseApiService
'password' => $password_hash,
);
$member_service->editByFind($member_info, $data);
self::clearToken($member_info['member_id'], $this->request->apiToken());
self::clearToken($member_info[ 'member_id' ], $this->request->apiToken());
return true;
}
public function loginScanCode(){
public function loginScanCode()
{
}
public function loginByScanCode(){
public function loginByScanCode()
{
}
public function checkScanCode(){
public function checkScanCode()
{
}

View File

@ -11,6 +11,7 @@
namespace app\service\api\login;
use app\dict\common\ChannelDict;
use app\dict\member\MemberLoginTypeDict;
use app\dict\member\MemberRegisterTypeDict;
use app\job\member\SetMemberNoJob;

View File

@ -47,7 +47,7 @@ class MemberCashOutAccountService extends BaseApiService
*/
public function getInfo(int $account_id)
{
$field = 'account_id,site_id,member_id,account_type,bank_name,realname,account_no';
$field = 'account_id,site_id,member_id,account_type,bank_name,realname,account_no, transfer_payment_code';
return $this->model->where([['account_id', '=', $account_id], ['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id]])->field($field)->findOrEmpty()->toArray();
}

View File

@ -52,7 +52,7 @@ class MemberCashOutService extends BaseApiService
*/
public function getInfo(int $id)
{
$field = 'id,site_id,cash_out_no,member_id,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_time,apply_money,rate,service_money,money,audit_time,status,remark,create_time,refuse_reason';
$field = 'id,site_id,cash_out_no,member_id,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_time,apply_money,rate,service_money,money,audit_time,status,remark,create_time,refuse_reason, transfer_no, transfer_payee, transfer_payment_code';
return $this->model->where([['id', '=', $id], ['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id]])->with(['memberInfo', 'transfer'])->field($field)->append(['account_type_name', 'transfer_type_name', 'status_name', 'transfer_status_name'])->findOrEmpty()->toArray();
}

View File

@ -37,9 +37,10 @@ class MemberConfigService extends BaseApiService
} catch (\Exception $e) {
$res[ 'is_auth_register' ] = 0;
$res[ 'is_force_access_user_info' ] = 0;
$res[ 'is_bind_mobile' ] = 0;
}
}
return $res;
}
}
}

View File

@ -22,11 +22,9 @@ use core\base\BaseApiService;
use core\exception\ApiException;
use core\exception\AuthException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use GuzzleHttp\Exception\GuzzleException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Model;
/**
@ -76,10 +74,16 @@ class WeappAuthService extends BaseApiService
/**
* 登录
* @param string $code
* @param $data
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws InvalidConfigException
* @throws ModelNotFoundException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
*/
public function login(string $code)
public function login($data)
{
[
@ -88,7 +92,7 @@ class WeappAuthService extends BaseApiService
// $avatar,
// $nickname,
// $sex
] = $this->getUserInfoByCode($code);
] = $this->getUserInfoByCode($data[ 'code' ]);
$member_service = new MemberService();
$member_info = $member_service->findMemberInfo([ 'weapp_openid' => $openid, 'site_id' => $this->site_id ]);
@ -98,23 +102,74 @@ class WeappAuthService extends BaseApiService
$member_info->weapp_openid = $openid;
}
}
$config = ( new MemberConfigService() )->getLoginConfig();
$is_auth_register = $config[ 'is_auth_register' ];
$is_force_access_user_info = $config[ 'is_force_access_user_info' ];
$is_bind_mobile = $config[ 'is_bind_mobile' ];
if ($member_info->isEmpty()) {
// $config = ( new MemberConfigService() )->getLoginConfig();
// $is_auth_register = $config[ 'is_auth_register' ];
// 去掉强制绑定手机号判断,否则开启强制绑定的情况下小程序第三方注册无法注册
// 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, wx_unionid: $unionid);
// if ($is_auth_register == 1) {
// } else {
// return [ 'openid' => $openid, 'unionid' => $unionid ];
// }
// 开启自动注册会员
if ($is_auth_register) {
// 开启强制获取会员信息并且开启强制绑定手机号,必须获取全部信息才能进行注册
if ($is_force_access_user_info && $is_bind_mobile) {
if (!empty($data[ 'nickname' ]) && !empty($data[ 'headimg' ]) && !empty($data[ 'mobile' ])) {
return $this->register($openid, $data[ 'mobile' ], $data[ 'mobile_code' ], $unionid, $data[ 'nickname' ], $data[ 'headimg' ]);
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // 将重要信息返回给前端保存
}
} else if ($is_force_access_user_info) {
// 开启强制获取会员信息时,必须获取到昵称和头像才能进行注册
if (!empty($data[ 'nickname' ]) && !empty($data[ 'headimg' ])) {
return $this->register($openid, '', '', $unionid, $data[ 'nickname' ], $data[ 'headimg' ]);
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // 将重要信息返回给前端保存
}
} else if ($is_bind_mobile) {
// 开启强制绑定手机号,必须获取手机号才能进行注册
if (!empty($data[ 'mobile' ]) || !empty($data[ 'mobile_code' ])) {
return $this->register($openid, $data[ 'mobile' ], $data[ 'mobile_code' ], $unionid);
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // 将重要信息返回给前端保存
}
} else if (!$is_force_access_user_info && !$is_bind_mobile) {
// 关闭强制获取用户信息、并且关闭强制绑定手机号的情况下允许注册
return $this->register($openid, '', '', $unionid);
}
} else {
// 关闭自动注册,但是开启了强制绑定手机号,必须获取手机号才能进行注册
if ($is_bind_mobile) {
if (!empty($data[ 'mobile' ]) || !empty($data[ 'mobile_code' ])) {
return $this->register($openid, $data[ 'mobile' ], $data[ 'mobile_code' ], $unionid);
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // 将重要信息返回给前端保存
}
}
}
} else {
//可能会更新用户和粉丝表
// 可能会更新用户和粉丝表
$login_service = new LoginService();
// 开启自动注册会员,获取到昵称和头像进行修改
if ($is_auth_register) {
if ($is_force_access_user_info) {
if (!empty($data[ 'nickname' ])) {
$member_info[ 'nickname' ] = $data[ 'nickname' ];
}
if (!empty($data[ 'headimg' ])) {
$member_info[ 'headimg' ] = $data[ 'headimg' ];
}
}
if ($is_bind_mobile) {
// if (!empty($data[ 'mobile' ])) {
// $member_info[ 'mobile' ] = $data[ 'mobile' ];
// }
}
}
return $login_service->login($member_info, MemberLoginTypeDict::WEAPP);
}
//todo 业务落地
}
/**
@ -122,14 +177,17 @@ class WeappAuthService extends BaseApiService
* @param string $openid
* @param string $mobile
* @param string $mobile_code
* @param string $wx_unionid
* @param string $nickname
* @param string $headimg
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws GuzzleException
* @throws InvalidConfigException
* @throws ModelNotFoundException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
*/
public function register(string $openid, string $mobile = '', string $mobile_code = '', string $wx_unionid = '')
public function register(string $openid, string $mobile = '', string $mobile_code = '', string $wx_unionid = '', $nickname = '', $headimg = '')
{
if (empty($openid)) throw new AuthException('AUTH_LOGIN_TAG_NOT_EXIST');
@ -158,7 +216,9 @@ class WeappAuthService extends BaseApiService
return $register_service->register($mobile ?? '',
[
'weapp_openid' => $openid,
'wx_unionid' => $wx_unionid
'wx_unionid' => $wx_unionid,
'nickname' => $nickname,
'headimg' => $headimg,
],
MemberRegisterTypeDict::WEAPP,
$is_verify_mobile ?? false

View File

@ -122,17 +122,35 @@ class WechatAuthService extends BaseApiService
}
}
if ($member_info->isEmpty()) {
// $config = ( new MemberConfigService() )->getLoginConfig();
// $is_auth_register = $config[ 'is_auth_register' ];
// 去掉强制绑定手机号判断,否则开启强制绑定的情况下公众号第三方注册无法注册
// 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, '', $nickname, $avatar, $unionid);
// if ($is_auth_register == 1) {
// } else {
// return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
// }
$config = ( new MemberConfigService() )->getLoginConfig();
$is_auth_register = $config[ 'is_auth_register' ];
$is_force_access_user_info = $config[ 'is_force_access_user_info' ];
$is_bind_mobile = $config[ 'is_bind_mobile' ];
// 开启自动注册会员
if ($is_auth_register) {
// 开启强制获取会员信息并且开启强制绑定手机号,必须获取手机号才能进行注册,由于公众号无法主动获取,所以不能注册
if ($is_force_access_user_info && $is_bind_mobile) {
return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
} else if ($is_force_access_user_info) {
// 开启强制获取会员信息时,必须获取到昵称和头像才能进行注册
if (!empty($nickname) && !empty($avatar)) {
return $this->register($openid, '', $nickname, $avatar, $unionid); // 获取到昵称和头像,然后进行注册
} else {
return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
}
} else if ($is_bind_mobile) {
// 开启强制绑定手机号,必须获取手机号才能进行注册,由于公众号无法主动获取,所以不能注册
return [ 'openid' => $openid, 'unionid' => $unionid ];
} else if (!$is_force_access_user_info && !$is_bind_mobile) {
// 关闭强制获取用户信息、并且关闭强制绑定手机号的情况下允许注册
return $this->register($openid, '', $nickname, $avatar, $unionid);
}
}
} else {
//可能会更新用户和粉丝表
// 可能会更新用户和粉丝表
$login_service = new LoginService();
// 若用户头像为空,那么从微信获取头像和昵称,然后进行更新
if (empty($member_info->headimg)) {

View File

@ -653,9 +653,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $this->addon);
// 编译 fixed-group 固定模板组件代码文件
$this->compileFixedComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $this->addon);
// 编译 pages.json 页面路由代码文件
$this->uninstallPageCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR);
@ -685,9 +682,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $this->addon);
// 编译 fixed-group 固定模板组件代码文件
$this->compileFixedComponentsCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $this->addon);
// 编译 pages.json 页面路由代码文件
$this->installPageCode($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR);

View File

@ -63,7 +63,7 @@ trait WapTrait
$file_name = 'diy-' . $path;
$content .= " <template v-if=\"component.componentName == '{$name}'\">\n";
$content .= " <$file_name :component=\"component\" :global=\"data.global\" :index=\"index\" :pullDownRefreshCount=\"props.pullDownRefreshCount\" :scrollBool=\"diyGroup.componentsScrollBool.{$name}\" />\n";
$content .= " <$file_name ref=\"diy{$name}Ref\" :component=\"component\" :global=\"data.global\" :index=\"index\" :scrollBool=\"diyGroup.componentsScrollBool.{$name}\" />\n";
$content .= " </template>\n";
}
}
@ -101,7 +101,7 @@ trait WapTrait
$file_name = 'diy-' . $path;
$content .= " <template v-if=\"component.componentName == '{$name}'\">\n";
$content .= " <$file_name :component=\"component\" :global=\"data.global\" :index=\"index\" :pullDownRefreshCount=\"props.pullDownRefreshCount\" :scrollBool=\"diyGroup.componentsScrollBool.{$name}\" />\n";
$content .= " <$file_name ref=\"diy{$name}Ref\" :component=\"component\" :global=\"data.global\" :index=\"index\" :scrollBool=\"diyGroup.componentsScrollBool.{$name}\" />\n";
$content .= " </template>\n";
$addon_import_content .= " import diy{$name} from '@/addon/" . $v . "/components/diy/{$path}/index.vue';\n";
@ -113,7 +113,7 @@ trait WapTrait
$content .= " </view>\n";
$content .= " </view>\n";
$content .= " <template v-if=\"diyStore.mode == '' && data.global.bottomTabBarSwitch\">\n";
$content .= " <template v-if=\"diyStore.mode == '' && data.global && data.global.bottomTabBarSwitch\">\n";
$content .= " <view class=\"pt-[20rpx]\"></view>\n";
$content .= " <tabbar />\n";
$content .= " </template>\n";
@ -129,19 +129,22 @@ trait WapTrait
$content .= " import topTabbar from '@/components/top-tabbar/top-tabbar.vue'\n";
$content .= " import useDiyStore from '@/app/stores/diy';\n";
$content .= " import { useDiyGroup } from './useDiyGroup';\n";
$content .= " import { ref } from 'vue';\n\n";
$content .= " import { ref,getCurrentInstance } from 'vue';\n\n";
$content .= " const props = defineProps(['data']);\n";
$content .= " const instance: any = getCurrentInstance();\n";
$content .= " const getFormRef = () => {\n";
$content .= " return {\n";
$content .= " componentRefs: instance.refs\n";
$content .= " }\n";
$content .= " }\n";
$content .= " const props = defineProps(['data','pullDownRefreshCount']);\n";
$content .= " const topTabbarRef = ref(null);\n";
$content .= " const diyStore = useDiyStore();\n";
$content .= " const diyGroup = useDiyGroup({\n";
$content .= " ...props,\n";
$content .= " getFormRef() {\n";
$content .= " return {\n";
$content .= " topTabbarRef: topTabbarRef.value\n";
$content .= " }\n";
$content .= " }\n";
$content .= " getFormRef\n";
$content .= " });\n";
$content .= " const data = ref(diyGroup.data);\n\n";
$content .= " // 监听页面加载完成\n";
@ -151,7 +154,8 @@ trait WapTrait
$content .= " diyGroup.onPageScroll();\n";
$content .= " defineExpose({\n";
$content .= " refresh: diyGroup.refresh\n";
$content .= " refresh: diyGroup.refresh,\n";
$content .= " getFormRef\n";
$content .= " })\n";
$content .= "</script>\n";
@ -163,98 +167,6 @@ trait WapTrait
return file_put_contents($compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'addon/components/diy/group/index.vue'), $content);
}
/**
* 编译 fixed-group 固定模板组件代码文件
* @param $compile_path
* @param $addon
* @return false|int
*/
public function compileFixedComponentsCode($compile_path, $addon)
{
$content = "<template>\n";
$content .= " <view class=\"fixed-group\">\n";
$root_path = $compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'app/components/fixed'); // 系统固定模板组件根目录
$file_arr = getFileMap($root_path);
if (!empty($file_arr)) {
foreach ($file_arr as $ck => $cv) {
if (str_contains($cv, 'index.vue')) {
$path = str_replace($root_path . '/', '', $ck);
$path = str_replace('/index.vue', '', $path);
if ($path == 'group') {
continue;
}
$file_name = 'fixed-' . $path;
$content .= " <template v-if=\"props.data.global.component == '{$path}'\">\n";
$content .= " <$file_name :data=\"props.data\" :pullDownRefreshCount=\"props.pullDownRefreshCount\"></$file_name>\n";
$content .= " </template>\n";
}
}
}
// 查询已安装的插件
$addon_import_content = "";
$addon_service = new CoreAddonService();
$addon_list = $addon_service->getInstallAddonList();
$addon_arr = [];
if (!empty($addon_list)) {
foreach ($addon_list as $k => $v) {
$addon_arr[] = $v[ 'key' ];
}
}
$addon_arr[] = $addon; // 追加新装插件
$addon_arr = array_unique($addon_arr);
foreach ($addon_arr as $k => $v) {
$addon_path = $compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'addon/' . $v . '/components/fixed'); // 插件固定模板组件根目录
$addon_file_arr = getFileMap($addon_path);
if (!empty($addon_file_arr)) {
foreach ($addon_file_arr as $ck => $cv) {
if (str_contains($cv, 'index.vue')) {
$path = str_replace($addon_path . '/', '', $ck);
$path = str_replace('/index.vue', '', $path);
// 获取自定义组件 key 关键词
$name_arr = explode('-', $path);
foreach ($name_arr as $nk => $nv) {
// 首字母大写
$name_arr[ $nk ] = strtoupper($nv[ 0 ] ?? '') . substr($nv, 1);
}
$name = implode('', $name_arr);
$file_name = 'fixed-' . $path;
$content .= " <template v-if=\"props.data.global.component == '{$path}'\">\n";
$content .= " <$file_name :data=\"props.data\" :pullDownRefreshCount=\"props.pullDownRefreshCount\"></$file_name>\n";
$content .= " </template>\n";
$addon_import_content .= " import fixed{$name} from '@/addon/" . $v . "/components/fixed/{$path}/index.vue';\n";
}
}
}
}
$content .= " </view>\n";
$content .= "</template>\n";
$content .= "<script lang=\"ts\" setup>\n";
if (!empty($addon_import_content)) {
$content .= $addon_import_content;
}
$content .= " const props = defineProps(['data','pullDownRefreshCount']);\n";
$content .= "</script>\n";
$content .= "<style lang=\"scss\" scoped>\n";
$content .= " @import './index.scss';\n";
$content .= "</style>\n";
return file_put_contents($compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'addon/components/fixed/group/index.vue'), $content);
}
/**
* 编译 pages.json 页面路由代码文件,// {{PAGE}}
* @param $compile_path

View File

@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\diy;
use app\dict\sys\ConfigKeyDict;
use app\model\sys\SysConfig;
use app\service\core\sys\CoreConfigService;
use core\base\BaseCoreService;
use think\Model;
/**
* 自定义页面服务层
* Class CoreDiyService
* @package app\service\core\diy
*/
class CoreDiyService extends BaseCoreService
{
/**
* 获取系统默认主题配色
* @return array
*/
public function getDefaultColor()
{
return [
'title' => '商务蓝',
'name' => 'blue',
'theme' => [
'--primary-color' => '#007aff', // 主色
'--primary-help-color' => '#007aff', // 辅色
'--price-text-color' => '#FF4142',// 价格颜色
'--primary-color-dark' => '#398ade', // 灰色
'--primary-color-disabled' => '#9acafc', // 禁用色
'--primary-color-light' => '#ecf5ff', // 边框色(深)
'--primary-color-light2' => '#fff7f7', // 边框色(淡)
'--page-bg-color' => '#f6f6f6', // 页面背景色
],
];
}
/**
* 获取默认主题配色
* @return array
*/
public function getDefaultThemeColor()
{
return [
[
'title' => '商务蓝',
'name' => 'blue',
'theme' => [
'--primary-color' => '#007aff', // 主色
'--primary-help-color' => '#007aff', // 辅色
'--price-text-color' => '#FF4142',// 价格颜色
'--primary-color-dark' => '#398ade', // 灰色
'--primary-color-disabled' => '#9acafc', // 禁用色
'--primary-color-light' => '#ecf5ff', // 边框色(深)
'--primary-color-light2' => '#fff7f7', // 边框色(淡)
'--page-bg-color' => '#f6f6f6', // 页面背景色
],
],
[
'title' => '热情红',
'name' => 'red',
'theme' => [
'--primary-color' => '#FF4142', // 主色
'--primary-help-color' => '#FB7939', // 辅色
'--price-text-color' => '#FF4142',// 价格颜色
'--primary-color-dark' => '#F26F3E', // 灰色
'--primary-color-disabled' => '#FFB397', // 禁用色
'--primary-color-light' => '#FFEAEA', // 边框色(深)
'--primary-color-light2' => '#fff7f7', // 边框色(淡)
'--page-bg-color' => '#f6f6f6', // 页面背景色
],
],
[
'title' => '活力橙',
'name' => 'orange',
'theme' => [
'--primary-color' => '#FA6400', // 主色
'--primary-help-color' => '#FA6400', // 辅色
'--price-text-color' => '#FF2525',// 价格颜色
'--primary-color-dark' => '#F48032', // 灰色
'--primary-color-disabled' => '#FFC29A', // 禁用色
'--primary-color-light' => '#FFF4ED', // 边框色(深)
'--primary-color-light2' => '#FFF4ED', // 边框色(淡)
'--page-bg-color' => '#f6f6f6', // 页面背景色
],
]
];
}
}

View File

@ -0,0 +1,315 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\diy_form;
use app\model\diy_form\DiyFormSubmitConfig;
use app\model\diy_form\DiyFormWriteConfig;
use core\base\BaseCoreService;
use core\exception\CommonException;
/**
* 万能表单配置
* Class CoreDiyFormConfigService
* @package app\service\core\diy_form
*/
class CoreDiyFormConfigService extends BaseCoreService
{
public function __construct()
{
parent::__construct();
}
/**
* 添加表单填写配置
* @param $data
*/
public function addWriteConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
$save_data = [
'site_id' => $data[ 'site_id' ],
'form_id' => $data[ 'form_id' ], // 所属万能表单id
'write_way' => $data[ 'write_way' ] ?? 'no_limit', // 填写方式no_limit不限制scan仅限微信扫一扫url仅限链接进入
'join_member_type' => $data[ 'join_member_type' ] ?? 'all_member', // 参与会员all_member所有会员参与selected_member_level指定会员等级selected_member_label指定会员标签
'level_ids' => array_map(function($item) { return (string) $item; }, $data[ 'level_ids' ] ?? []), // 会员等级id集合
'label_ids' => array_map(function($item) { return (string) $item; }, $data[ 'label_ids' ] ?? []), // 会员标签id集合
'member_write_type' => $data[ 'member_write_type' ] ?? 'no_limit', // 每人可填写次数no_limit不限制diy自定义
// 每人可填写次数自定义规则
'member_write_rule' => $data[ 'member_write_rule' ] ?? [
'time_value' => 1, // 时间
'time_unit' => 'day', // 时间单位
'num' => 1 // 可填写次数
],
'form_write_type' => $data[ 'form_write_type' ] ?? 'no_limit', // 表单可填写数量no_limit不限制diy自定义
// 表单可填写总数自定义规则
'form_write_rule' => $data[ 'form_write_rule' ] ?? [
'time_value' => 1, // 时间
'time_unit' => 'day', // 时间单位
'num' => 1 // 可填写次数
],
'time_limit_type' => $data[ 'time_limit_type' ] ?? 'no_limit', // 填写时间限制类型no_limit不限制 specify_time指定开始结束时间open_day_time设置每日开启时间
// 填写时间限制规则
'time_limit_rule' => $data[ 'time_limit_rule' ] ?? [
'specify_time' => [], // 指定开始结束时间
'open_day_time' => [], // 设置每日开启时间
],
'is_allow_update_content' => $data[ 'is_allow_update_content' ] ?? 0, // 是否允许修改自己填写的内容01
'write_instruction' => $data[ 'write_instruction' ] ?? '', // 表单填写须知
'create_time' => time(),
'update_time' => time(),
];
$res = ( new DiyFormWriteConfig() )->create($save_data);
return $res->id;
}
/**
* 编辑表单填写配置
* @param $data
* @return bool
*/
public function editWriteConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
if (empty($data[ 'id' ])) {
throw new CommonException('缺少表单配置id');
}
$count = ( new DiyFormWriteConfig() )->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'id', '=', $data[ 'id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ]
])->count();
if (empty($count)) {
throw new CommonException('表单填写配置不存在');
}
$save_data = [
'write_way' => $data[ 'write_way' ] ?? 'no_limit', // 填写方式no_limit不限制scan仅限微信扫一扫url仅限链接进入
'join_member_type' => $data[ 'join_member_type' ] ?? 'all_member', // 参与会员all_member所有会员参与selected_member_level指定会员等级selected_member_label指定会员标签
'level_ids' => array_map(function($item) { return (string) $item; }, $data[ 'level_ids' ] ?? []), // 会员等级id集合
'label_ids' => array_map(function($item) { return (string) $item; }, $data[ 'label_ids' ] ?? []), // 会员标签id集合
'member_write_type' => $data[ 'member_write_type' ] ?? 'no_limit', // 每人可填写次数no_limit不限制diy自定义
// 每人可填写次数自定义规则
'member_write_rule' => $data[ 'member_write_rule' ] ?? [
'time_value' => 1, // 时间
'time_unit' => 'day', // 时间单位
'num' => 1 // 可填写次数
],
'form_write_type' => $data[ 'form_write_type' ] ?? 'no_limit', // 表单可填写数量no_limit不限制diy自定义// 表单可填写总数自定义规则
'form_write_rule' => $data[ 'form_write_rule' ] ?? [
'time_value' => 1, // 时间
'time_unit' => 'day', // 时间单位
'num' => 1 // 可填写次数
],
'time_limit_type' => $data[ 'time_limit_type' ] ?? 'no_limit', // 填写时间限制类型no_limit不限制 specify_time指定开始结束时间open_day_time设置每日开启时间
// 填写时间限制规则
'time_limit_rule' => $data[ 'time_limit_rule' ] ?? [
'specify_time' => [], // 指定开始结束时间
'open_day_time' => [], // 设置每日开启时间
],
'is_allow_update_content' => $data[ 'is_allow_update_content' ] ?? 0, // 是否允许修改自己填写的内容01
'write_instruction' => $data[ 'write_instruction' ] ?? '', // 表单填写须知
'update_time' => time(),
];
if (!empty($save_data[ 'time_limit_rule' ][ 'specify_time' ])) {
$start_time = strtotime($save_data[ 'time_limit_rule' ][ 'specify_time' ][ 0 ]);
$end_time = strtotime($save_data[ 'time_limit_rule' ][ 'specify_time' ][ 1 ]);
$save_data[ 'time_limit_rule' ][ 'specify_time' ] = [ $start_time, $end_time ];
}
if (!empty($save_data[ 'time_limit_rule' ][ 'open_day_time' ])) {
$current_timestamp = strtotime(date('Y-m-d'));
$start_time_arr = explode(':', $save_data[ 'time_limit_rule' ][ 'open_day_time' ][ 0 ]);
$start_time = strtotime("{$start_time_arr[ 0 ]}:{$start_time_arr[ 1 ]}") - $current_timestamp;
$end_time_arr = explode(':', $save_data[ 'time_limit_rule' ][ 'open_day_time' ][ 1 ]);
$end_time = strtotime("{$end_time_arr[ 0 ]}:{$end_time_arr[ 1 ]}") - $current_timestamp;
$save_data[ 'time_limit_rule' ][ 'open_day_time' ] = [ $start_time, $end_time ];
}
( new DiyFormWriteConfig() )->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'id', '=', $data[ 'id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ]
])->update($save_data);
return true;
}
/**
* 获取表单填写配置
* @param $data
* @return mixed
*/
public function getWriteConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
$field = 'id, form_id, write_way, join_member_type, level_ids, label_ids, member_write_type, member_write_rule, form_write_type, form_write_rule, time_limit_type, time_limit_rule, is_allow_update_content, write_instruction';
$info = ( new DiyFormWriteConfig() )->field($field)->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ]
])->findOrEmpty()->toArray();
if (!empty($info)) {
if (isset($info[ 'label_ids' ]) && !empty($info[ 'label_ids' ])) {
$info[ 'label_ids' ] = array_map('intval', $info[ 'label_ids' ]);
}
if (isset($info[ 'level_ids' ]) && !empty($info[ 'level_ids' ])) {
$info[ 'level_ids' ] = array_map('intval', $info[ 'level_ids' ]);
}
if (!empty($info[ 'time_limit_rule' ][ 'specify_time' ])) {
$start_time = date('Y-m-d H:i:s', $info[ 'time_limit_rule' ][ 'specify_time' ][ 0 ]);
$end_time = date('Y-m-d H:i:s', $info[ 'time_limit_rule' ][ 'specify_time' ][ 1 ]);
$info[ 'time_limit_rule' ][ 'specify_time' ] = [ $start_time, $end_time ];
}
if (!empty($info[ 'time_limit_rule' ][ 'open_day_time' ])) {
$start_timestamp = strtotime(date('Y-m-d', time())) + $info[ 'time_limit_rule' ][ 'open_day_time' ][ 0 ];
$start_time = date('H:i', $start_timestamp);
$end_timestamp = strtotime(date('Y-m-d', time())) + $info[ 'time_limit_rule' ][ 'open_day_time' ][ 1 ];
$end_time = date('H:i', $end_timestamp);
$info[ 'time_limit_rule' ][ 'open_day_time' ] = [ $start_time, $end_time ];
}
}
return $info;
}
/**
* 添加表单提交成功页配置
* @param $data
* @return mixed
*/
public function addSubmitConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
$save_data = [
'site_id' => $data[ 'site_id' ],
'form_id' => $data[ 'form_id' ], // 所属万能表单id
'submit_after_action' => $data[ 'submit_after_action' ] ?? 'text', // 填表人提交后操作text文字信息voucher核销凭证
'tips_type' => $data[ 'tips_type' ] ?? 'default', // 提示内容类型default默认提示diy自定义提示
'tips_text' => $data[ 'tips_text' ] ?? '', // 自定义提示内容
'time_limit_type' => $data[ 'time_limit_type' ] ?? 'no_limit', // 核销凭证有效期限制类型no_limit不限制specify_time指定固定开始结束时间submission_time按提交时间设置有效期
// 核销凭证时间限制规则json格式 todo 结构待定
'time_limit_rule' => $data[ 'time_limit_rule' ] ?? [],
// 核销凭证内容json格式 todo 结构待定
'voucher_content_rule' => $data[ 'voucher_content_rule' ] ?? [],
// 填写成功后续操作
'success_after_action' => $data[ 'success_after_action' ] ?? [
'share' => false, // 转发填写内容
'finish' => true, // 完成
'goback' => true // 返回
],
'create_time' => time(),
'update_time' => time(),
];
$res = ( new DiyFormSubmitConfig() )->create($save_data);
return $res->id;
}
/**
* 编辑表单提交成功页配置
* @param $data
* @return mixed
*/
public function editSubmitConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
if (empty($data[ 'id' ])) {
throw new CommonException('缺少表单配置id');
}
$count = ( new DiyFormSubmitConfig() )->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'id', '=', $data[ 'id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ]
])->count();
if (empty($count)) {
throw new CommonException('表单提交成功页配置不存在');
}
$save_data = [
'site_id' => $data[ 'site_id' ],
'form_id' => $data[ 'form_id' ], // 所属万能表单id
'submit_after_action' => $data[ 'submit_after_action' ] ?? 'text', // 填表人提交后操作text文字信息voucher核销凭证
'tips_type' => $data[ 'tips_type' ] ?? 'default', // 提示内容类型default默认提示diy自定义提示
'tips_text' => $data[ 'tips_text' ] ?? '', // 自定义提示内容
'time_limit_type' => $data[ 'time_limit_type' ] ?? 'no_limit', // 核销凭证有效期限制类型no_limit不限制specify_time指定固定开始结束时间submission_time按提交时间设置有效期
// 核销凭证时间限制规则json格式 todo 结构待定
'time_limit_rule' => $data[ 'time_limit_rule' ] ?? [],
// 核销凭证内容json格式 todo 结构待定
'voucher_content_rule' => $data[ 'voucher_content_rule' ] ?? [],
// 填写成功后续操作
'success_after_action' => $data[ 'success_after_action' ] ?? [
'share' => false, // 转发填写内容
'finish' => true, // 完成
'goback' => true // 返回
],
'update_time' => time(),
];
( new DiyFormSubmitConfig() )->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'id', '=', $data[ 'id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ],
])->update($save_data);
return true;
}
/**
* 获取表单提交成功页配置
* @param $data
* @return mixed
*/
public function getSubmitConfig($data)
{
if (empty($data[ 'form_id' ])) {
throw new CommonException('缺少表单id');
}
$field = 'id, form_id, submit_after_action, tips_type, tips_text, time_limit_type, time_limit_rule, voucher_content_rule, success_after_action';
$info = ( new DiyFormSubmitConfig() )->field($field)->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ]
])->findOrEmpty()->toArray();
if (!empty($info)) {
// todo 靠后完善,处理核销凭证数据结构
}
return $info;
}
}

View File

@ -0,0 +1,238 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\diy_form;
use app\model\diy_form\DiyForm;
use app\model\diy_form\DiyFormFields;
use app\model\diy_form\DiyFormRecords;
use app\model\diy_form\DiyFormRecordsFields;
use core\base\BaseCoreService;
use core\exception\CommonException;
use think\facade\Db;
/**
* 万能表单使用记录
* Class CoreDiyFormRecordsService
* @package app\service\core\diy
*/
class CoreDiyFormRecordsService extends BaseCoreService
{
public function __construct()
{
parent::__construct();
$this->model = new DiyFormRecords();
}
/**
* 获取使用记录分页列表
* @param array $data
* @return array
*/
public function getPage(array $data = [])
{
$where[ 'create_time' ] = $data[ 'create_time' ];
$member_where = [];
if (!empty($data[ 'keyword' ])) {
$member_where[] = [ 'member_no|nickname|username|mobile', 'like', '%' . $data[ 'keyword' ] . '%' ];
}
$field = 'record_id, form_id, member_id, relate_id, create_time';
$order = "create_time desc";
$search_model = $this->model->where([
[ 'diy_form_records.site_id', '=', $data[ 'site_id' ] ],
[ 'form_id', '=', $data [ 'form_id' ] ]
])->field($field)->withSearch([ 'create_time' ], $where)
->withJoin([
'member' => function($query) use ($member_where) {
$query->where($member_where);
}
])->with([
// 关联表单字段列表 todo 靠后完善
// 'formFieldList' => function($query) {
// $query->field('id, form_id, form_field_id, record_id, member_id, field_key, field_type, field_name, field_value, update_num, update_time');
// },
// 关联填写字段列表
'recordsFieldList' => function($query) {
$query->field('id, form_id, form_field_id, record_id, member_id, field_key, field_type, field_name, field_value, update_num, update_time')->append([ 'handle_field_value', 'render_value', 'detailComponent' ]);
}
])
->order($order);
return $this->pageQuery($search_model, function($item) {
$list_key = array_column($item[ 'recordsFieldList' ]->toArray(), 'field_key');
$recordsFieldList = array_combine($list_key, $item[ 'recordsFieldList' ]->toArray());
$item[ 'recordsFieldList' ] = $recordsFieldList;
});
}
/**
* 获取使用记录详情
* @param array $data
* @return array
*/
public function getInfo(array $data = [])
{
$field = 'record_id,value';
$info = $this->model->field($field)->where([ [ 'record_id', '=', $data[ 'record_id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ])
->with([
// 关联填写字段列表
'recordsFieldList' => function($query) {
$query->field('id, form_id, form_field_id, record_id, member_id, field_key, field_type, field_name, field_value, update_num, update_time')->append([ 'handle_field_value', 'render_value', 'detailComponent' ]);
}
])->findOrEmpty()->toArray();
if (!empty($info)) {
$list_key = array_column($info[ 'recordsFieldList' ], 'field_key');
$recordsFieldList = array_combine($list_key, $info[ 'recordsFieldList' ]);
$info[ 'recordsFieldList' ] = $recordsFieldList;
}
return $info;
}
/**
* 获取使用记录详情
* @param array $data
* @return bool
*/
public function del($data)
{
return $this->model->where([ [ 'record_id', '=', $data[ 'record_id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ])->delete();
}
/**
* 提交填表记录
* @param $data
* @return array
*/
public function add($data)
{
try {
$form_info = ( new DiyForm() )->where([
[ 'form_id', '=', $data[ 'form_id' ] ],
[ 'site_id', '=', $data[ 'site_id' ] ],
])->field('form_id,status')->findOrEmpty()->toArray();
// 无效表单id
if (empty($form_info)) {
return [];
}
// 过滤未启用的表单
if (!empty($form_info) && $form_info[ 'status' ] == 0) {
return [];
}
Db::startTrans();
$data[ 'create_time' ] = time();
// todo $data[ 'value' ] 考虑过滤存储数据,靠后完善,修改表单可能会用到
$res = $this->model->create($data);
$diy_form_records_fields_model = new DiyFormRecordsFields();
$form_field_list = ( new DiyFormFields() )->field('field_key,field_required,field_unique')->where([
[ 'form_id', '=', $data[ 'form_id' ] ],
[ 'site_id', '=', $data[ 'site_id' ] ],
])->select()->toArray();
if ($form_field_list) {
$list_key = array_column($form_field_list, 'field_key');
$form_field_list = array_combine($list_key, $form_field_list);
}
$diy_form_records_fields = [];
if (!empty($data[ 'value' ])) {
// $value = json_decode($data[ 'value' ], true);
foreach ($data[ 'value' ] as $component) {
// 过滤非表单组件和表单提交按钮组件
if ($component[ 'componentType' ] != 'diy_form' || $component[ 'componentName' ] == 'FormSubmit' || $component[ 'isHidden' ]) {
continue;
}
$field_value = $component[ 'field' ][ 'value' ];
$check_field_value = $field_value;
if (is_array($field_value)) {
$check_field_value = $diy_form_records_fields_model->getRenderValueAttr('', [ 'field_value' => json_encode($field_value, JSON_UNESCAPED_UNICODE) , 'field_type' => $component[ 'componentName' ]]);
}
$form_field_info = $form_field_list[ $component[ 'id' ] ] ?? [];
if (!empty($form_field_info)) {
if ($form_field_info[ 'field_required' ] == 1 && empty($field_value)) {
throw new CommonException($component[ 'componentTitle' ] . '不能为空');
} else if (empty($check_field_value)) {
// 过滤空数据
continue;
}
// 检测字段是否重复
$field_values = ( new DiyFormRecordsFields() )->where([
[ 'site_id', '=', $data[ 'site_id' ] ],
[ 'form_id', '=', $data[ 'form_id' ] ],
[ 'field_key', '=', $component[ 'id' ] ],
[ 'field_type', '=', $component[ 'componentName' ] ]
])->column('field_value');
if ($form_field_info[ 'field_unique' ] == 1 && in_array($field_value, $field_values)) {
throw new CommonException($component[ 'componentTitle' ] . '不能重复');
}
} else if (empty($check_field_value)) {
// 过滤空数据
continue;
}
if (is_array($field_value)) {
$field_value = json_encode($field_value, JSON_UNESCAPED_UNICODE);
}
$diy_form_records_fields[] = [
'site_id' => $data[ 'site_id' ],
'form_id' => $data[ 'form_id' ], // 所属万能表单id
// 'form_field_id'=>'', // todo 暂无,靠后完善
'record_id' => $res->record_id, // 关联表单填写记录id
'member_id' => $data[ 'member_id' ], // 填写会员id
'field_key' => $component[ 'id' ], // 字段唯一标识
'field_type' => $component[ 'componentName' ], // 字段类型
'field_name' => $component[ 'field' ][ 'name' ] ?? '', // 字段名称
// 'field_remark' => $component[ 'field' ][ 'remark' ][ 'text' ] ?? '', // 字段说明
'field_value' => $field_value, // 字段值
'field_required' => $component[ 'field' ][ 'required' ], // 字段是否必填 0:否 1:是
'field_hidden' => $component[ 'isHidden' ], // 字段是否隐藏 0:否 1:是
'field_unique' => $component[ 'field' ][ 'unique' ], // 字段内容防重复 0:否 1:是
'privacy_protection' => $component[ 'field' ][ 'privacyProtection' ], // 隐私保护 0:关闭 1:开启
'create_time' => time(),
'update_time' => time()
];
}
}
if (!empty($diy_form_records_fields)) {
$diy_form_records_fields_model->insertAll($diy_form_records_fields);
$diy_form = new DiyForm();
// 累计填写数量
$diy_form->where([ [ 'form_id', '=', $data[ 'form_id' ] ] ])->inc('write_num', 1)->update();
$diy_form_fields_model = new DiyFormFields();
foreach ($diy_form_records_fields as $field) {
// 字段累计填写数量
$diy_form_fields_model->where([ [ 'form_id', '=', $data[ 'form_id' ] ], [ 'field_key', '=', $field[ 'field_key' ] ], [ 'site_id', '=', $field[ 'site_id' ] ] ])->inc('write_num', 1)->update();
}
}
Db::commit();
return $res->record_id;
} catch (\Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
}
}

View File

@ -44,7 +44,7 @@ class CoreMemberAccountService extends BaseCoreService
throw new CommonException('ACCOUNT_INSUFFICIENT');
}
$data = array(
$data = [
'site_id' => $site_id,
'member_id' => $member_id,
'account_type' => $account_type,
@ -56,7 +56,7 @@ class CoreMemberAccountService extends BaseCoreService
'mobile' => $member_info[ 'mobile' ],
'memo' => $memo,
'related_id' => $related_id,
);
];
Db::startTrans();
try {

View File

@ -29,7 +29,7 @@ class CoreMemberCashOutAccountService extends BaseCoreService
}
public function getInfo(int $account_id, int $site_id, int $member_id){
$field = 'account_id,site_id,member_id,account_type,bank_name,realname,account_no';
$field = 'account_id,site_id,member_id,account_type,bank_name,realname,account_no, transfer_payment_code';
return $this->model->where([['account_id', '=', $account_id], ['site_id', '=', $site_id], ['member_id', '=', $member_id]])->field($field)->findOrEmpty()->toArray();
}
}

View File

@ -40,19 +40,169 @@ class CoreMemberCashOutService extends BaseCoreService
$this->model = new MemberCashOut();
}
/**
* 提现转账完成
* @param $site_id
* @param $transfer_no
* @return true
*/
public function transferFinish($site_id, $transfer_no)
{
$cash_out = $this->model->where(
[
['site_id', '=', $site_id],
['transfer_no', '=', $transfer_no]
]
)->findOrEmpty();
if ($cash_out->isEmpty()) throw new CommonException('RECHARGE_LOG_NOT_EXIST');
if ($cash_out['status'] != MemberCashOutDict::WAIT_TRANSFER && $cash_out['status'] != MemberCashOutDict::TRANSFER_ING) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_TRANSFER');
//减去提现中金额
$this->give($site_id, $cash_out);
$cash_out->save([
'status' => MemberCashOutDict::TRANSFERED,
'transfer_time' => time()
]);
return true;
}
/**
* 累加提现金额,累减提现中金额
* @param int $site_id
* @param MemberCashOut $cash_out
* @return true
*/
public function give(int $site_id, MemberCashOut $cash_out)
{
$core_member_service = new CoreMemberService();
$member = $core_member_service->find($site_id, $cash_out->member_id);
if ($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$member->save(
[
$cash_out->account_type . '_cash_outing' => $member[$cash_out->account_type . '_cash_outing'] - $cash_out->apply_money
]
);
return true;
}
/**
* 获取对象
* @param int $site_id
* @param int $id
* @return MemberCashOut|array|mixed|Model
*/
public function find(int $site_id, int $id){
public function find(int $site_id, int $id)
{
return $this->model->where([
['site_id', '=', $site_id],
['id', '=', $id],
])->findOrEmpty();
}
/**
* 申请提现
* @param int $site_id
* @param int $member_id
* @param array $data
* @return true
*/
public function apply(int $site_id, int $member_id, array $data)
{
$core_member_service = new CoreMemberService();
$member = $core_member_service->find($site_id, $member_id);
if ($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$config = (new CoreMemberConfigService())->getCashOutConfig($site_id);
$is_open = $config['is_open'];
if ($is_open == 0) throw new CommonException('CASHOUT_NOT_OPEN');
$apply_money = $data['apply_money'];
if ($apply_money < $config['min']) throw new CommonException('CASHOUT_MONEY_TOO_LITTLE');
$transfer_type = $data['transfer_type'];
if (!in_array($transfer_type, $config['transfer_type'])) throw new CommonException('CASHOUT_TYPE_NOT_OPEN');
$service_money = format_round_money($apply_money * $config['rate'] / 100);
$min = $config['min'];
if ($apply_money < $min) throw new CommonException('CASHOUT_MONEY_TOO_LITTLE');
// $apply_money, $transfer_type, $transfer_realname, $transfer_mobile, $transfer_bank, $transfer_account
$money = $apply_money - $service_money;
$account_type = $data['account_type'] ?? MemberAccountTypeDict::MONEY;
$cash_out_account = [];
if ($transfer_type != TransferDict::WECHAT) {
$cash_out_account = (new CoreMemberCashOutAccountService())->getInfo($data['account_id'], $site_id, $member_id);
if (empty($cash_out_account)) throw new CommonException('CASH_OUT_ACCOUNT_NOT_EXIST');
} else {
$data_transfer_payee = $data['transfer_payee'] ?? [];
if (empty($data_transfer_payee)) throw new CommonException('CASH_OUT_ACCOUNT_NOT_FOUND_VALUE');//转账到微信零钱缺少参数
$transfer_payee = [
'open_id' => $data_transfer_payee['open_id'] ?? '',
'channel' => $data_transfer_payee['channel'] ?? '',
];
}
Db::startTrans();
try {
$data = [
'member_id' => $member_id,
'site_id' => $site_id,
'cash_out_no' => $this->createCashOutNo($site_id),
'status' => MemberCashOutDict::WAIT_AUDIT,
'account_type' => $account_type,
'apply_money' => $apply_money,
'service_money' => $service_money,
'money' => $money,
'transfer_type' => $transfer_type,
'transfer_realname' => $cash_out_account['realname'] ?? '',
'transfer_mobile' => $member['mobile'] ?? '',
'transfer_bank' => $cash_out_account['bank_name'] ?? '',
'transfer_account' => $cash_out_account['account_no'] ?? '',
'transfer_payment_code' => $cash_out_account['transfer_payment_code'] ?? '',//收款码
'transfer_payee' => $transfer_payee ?? [],//对接线上转账数据
'rate' => $config['rate'],
];
$cash_out = $this->model->create($data);
//扣除对应账户金额
$member_account_service = new CoreMemberAccountService();
$member_account_service->addLog($site_id, $member_id, $account_type, -$apply_money, 'cash_out', get_lang('MEMBER_APPLY_CASHOUT'), $cash_out->id);
$member->save(
[
$account_type . '_cash_outing' => $member[$account_type . '_cash_outing'] + $apply_money
]
);
if ($config['is_auto_verify']) {
$core_member_cash_out_service = new CoreMemberCashOutService();
$core_member_cash_out_service->audit($site_id, $cash_out->id, 'agree');
}
Db::commit();
return $cash_out['id'];
} catch ( Exception $e ) {
Db::rollback();
throw new CommonException($e->getMessage());
}
return true;
}
/**
* 创建订单编号
* @param int $site_id
* @return string
*/
public function createCashOutNo(int $site_id)
{
$time_str = date('YmdHi');
$max_no = Cache::get('cash_out_no_' . $site_id . '_' . $time_str);
if (!isset($max_no) || empty($max_no)) {
$max_no = 1;
} else {
++$max_no;
}
$cash_out_no = $time_str . $site_id . sprintf('%03d', $max_no);
Cache::set('cash_out_no_' . $site_id . '_' . $time_str, $max_no);
return $cash_out_no;
}
/**
* @param int $site_id
* @param int $id
@ -60,12 +210,13 @@ class CoreMemberCashOutService extends BaseCoreService
* @param array $data
* @return true
*/
public function audit(int $site_id, int $id, string $action, $data = []){
public function audit(int $site_id, int $id, string $action, $data = [])
{
$cash_out = $this->find($site_id, $id);
if($cash_out->isEmpty()) throw new CommonException('CASHOUT_LOG_NOT_EXIST');
if($cash_out['status'] != MemberCashOutDict::WAIT_AUDIT) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_AUDIT');
switch($action){
if ($cash_out->isEmpty()) throw new CommonException('CASHOUT_LOG_NOT_EXIST');
if ($cash_out['status'] != MemberCashOutDict::WAIT_AUDIT) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_AUDIT');
switch ($action) {
case 'agree'://同意
$this->agree($site_id, $cash_out, $data);
break;
@ -83,39 +234,23 @@ class CoreMemberCashOutService extends BaseCoreService
* @param array $data
* @return true
*/
public function agree(int $site_id, MemberCashOut $cash_out, array $data = []){
public function agree(int $site_id, MemberCashOut $cash_out, array $data = [])
{
$cash_out->save([
'audit_time' => time(),
'status' => MemberCashOutDict::WAIT_TRANSFER
]);
$config = (new CoreMemberConfigService())->getCashOutConfig($site_id);
if($config['is_auto_transfer']){
if ($config['is_auto_transfer']) {
try {
$this->transfer($site_id, $cash_out['id']);
} catch ( Throwable $e) {
} catch ( Throwable $e ) {
}
}
return true;
}
/**
* 拒绝
* @param int $site_id
* @param MemberCashOut $cash_out
* @param array $data
* @return true
*/
public function refuse(int $site_id, MemberCashOut $cash_out, array $data){
$cash_out->save([
'audit_time' => time(),
'status' => MemberCashOutDict::REFUSE,
'refuse_reason' => $data['refuse_reason']
]);
$this->giveback($site_id, $cash_out);
return true;
}
/**
* 转账
* @param int $site_id
@ -123,146 +258,102 @@ class CoreMemberCashOutService extends BaseCoreService
* @param array $data
* @return true
*/
public function transfer(int $site_id, int $id, array $data = []){
$transfer_type = $data['transfer_type'] ?? '';
public function transfer(int $site_id, int $id, array $data = [])
{
Db::startTrans();
try {
$transfer_type = $data['transfer_type'] ?? '';
$cash_out = $this->find($site_id, $id);
if($cash_out->isEmpty()) throw new CommonException('RECHARGE_LOG_NOT_EXIST');
if($cash_out['status'] != MemberCashOutDict::WAIT_TRANSFER) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_TRANSFER');
$transfer_no = $cash_out['transfer_no'];
if(!$transfer_no){
$transfer_no = (new CoreTransferService())->create($site_id, PayDict::MEMBER, $cash_out['member_id'], $cash_out['money'], CashOutTypeDict::MEMBER_CASH_OUT, get_lang('MEMBER_CASHOUT_TRANSFER'));
$cash_out->save(
[
'transfer_no' => $transfer_no
]
);
}
if($transfer_type != TransferDict::OFFLINE){
$data['transfer_type'] = $cash_out['transfer_type'];
$data['transfer_realname'] = $cash_out['transfer_realname'];
$data['transfer_mobile'] = $cash_out['transfer_mobile'];
$data['transfer_bank'] = $cash_out['transfer_bank'];
$data['transfer_account'] = $cash_out['transfer_account'];
$transfer_type = $cash_out['transfer_type'];
if($transfer_type == TransferDict::WECHAT){
//根据转账方式和会员的授权信息来判断可以使用的转账方式
$member = (new CoreMemberService())->find($site_id, $cash_out['member_id']);
if(!empty($member['wx_openid'])){
$data['openid'] = $member['wx_openid'];
} else if(!empty($member['weapp_openid'])){
$data['openid'] = $member['wweapp_openid'];
}else{
$data['openid'] = '';
}
$data['openid'] = $member['wx_openid'];
$cash_out = $this->find($site_id, $id);
if ($cash_out->isEmpty()) throw new CommonException('RECHARGE_LOG_NOT_EXIST');
if ($cash_out['status'] != MemberCashOutDict::WAIT_TRANSFER && $cash_out['status'] != MemberCashOutDict::TRANSFER_ING) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_TRANSFER');
$transfer_no = $cash_out['transfer_no'];
if (!$transfer_no) {
$transfer_no = (new CoreTransferService())->create($site_id, PayDict::MEMBER, $cash_out['member_id'], $cash_out['money'], CashOutTypeDict::MEMBER_CASH_OUT, get_lang('MEMBER_CASHOUT_TRANSFER'));
$cash_out->save(
[
'transfer_no' => $transfer_no,
'status' => MemberCashOutDict::TRANSFER_ING
]
);
}
}else{
$transfer_type = $cash_out['transfer_type'];
if ($transfer_type != TransferDict::OFFLINE) {
$data['transfer_type'] = $cash_out['transfer_type'];
$data['transfer_realname'] = $cash_out['transfer_realname'];
$data['transfer_mobile'] = $cash_out['transfer_mobile'];
$data['transfer_bank'] = $cash_out['transfer_bank'];
$data['transfer_account'] = $cash_out['transfer_account'];
$data['transfer_payment_code'] = $cash_out['transfer_payment_code'];
$transfer_type = $cash_out['transfer_type'];
if ($transfer_type == TransferDict::WECHAT) {//如果是转账到微信钱包则需要获取openid
//根据转账方式和会员的授权信息来判断可以使用的转账方式
// $member = (new CoreMemberService())->find($site_id, $cash_out['member_id']);
// if(!empty($member['wx_openid'])){
// $data['openid'] = $member['wx_openid'];
// } else if(!empty($member['weapp_openid'])){
// $data['openid'] = $member['wweapp_openid'];
// }else{
// $data['openid'] = '';
// }
// $data['openid'] = $member['wx_openid'];
$data['transfer_payee'] = $cash_out['transfer_payee'] ?? [];
}
} else {
$transfer_type = $cash_out['transfer_type'];
}
$result = (new CoreTransferService())->transfer($site_id, $transfer_no, $transfer_type, $data);
Db::commit();
return true;
// 提交事务
} catch (\Exception $e) {
Db::rollback();
// 回滚事务
throw new CommonException($e->getMessage());
}
$result = (new CoreTransferService())->transfer($site_id, $transfer_no, $transfer_type, $data);
return true;
}
/**
* 提现转账完成
* @param $site_id
* @param $transfer_no
* @return true
*/
public function transferFinish($site_id, $transfer_no){
$cash_out = $this->model->where(
[
['site_id', '=', $site_id],
['transfer_no', '=', $transfer_no]
]
)->findOrEmpty();
if($cash_out->isEmpty()) throw new CommonException('RECHARGE_LOG_NOT_EXIST');
if($cash_out['status'] != MemberCashOutDict::WAIT_TRANSFER) throw new CommonException('CASHOUT_STATUS_NOT_IN_WAIT_TRANSFER');
//减去提现中金额
$this->give($site_id, $cash_out);
$cash_out->save([
'status' => MemberCashOutDict::TRANSFERED,
'transfer_time' => time()
]);
return true;
}
/**
* 申请提现
* 拒绝
* @param int $site_id
* @param int $member_id
* @param MemberCashOut $cash_out
* @param array $data
* @return true
*/
public function apply(int $site_id, int $member_id, array $data){
public function refuse(int $site_id, MemberCashOut $cash_out, array $data)
{
$cash_out->save([
'audit_time' => time(),
'status' => MemberCashOutDict::REFUSE,
'refuse_reason' => $data['refuse_reason']
]);
$this->giveback($site_id, $cash_out);
return true;
}
/**
* 返还用户的对应账户
* @param int $site_id
* @param MemberCashOut $cash_out
* @return true
*/
public function giveback(int $site_id, MemberCashOut $cash_out)
{
$core_member_account_service = new CoreMemberAccountService();
$core_member_account_service->addLog($site_id, $cash_out->member_id, $cash_out->account_type, $cash_out->apply_money, 'cash_out', get_lang('CASHOUT_IS_REFUSE'), $cash_out->id);
$core_member_service = new CoreMemberService();
$member = $core_member_service->find($site_id, $member_id);
if($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$config = (new CoreMemberConfigService())->getCashOutConfig($site_id);
$is_open = $config['is_open'];
if($is_open == 0) throw new CommonException('CASHOUT_NOT_OPEN');
$apply_money = $data['apply_money'];
if($apply_money < $config['min']) throw new CommonException('CASHOUT_MONEY_TOO_LITTLE');
$transfer_type = $data['transfer_type'];
if(!in_array($transfer_type, $config['transfer_type'])) throw new CommonException('CASHOUT_TYPE_NOT_OPEN');
$service_money = format_round_money($apply_money * $config['rate']/100);
$min = $config['min'];
if($apply_money < $min) throw new CommonException('CASHOUT_MONEY_TOO_LITTLE');
// $apply_money, $transfer_type, $transfer_realname, $transfer_mobile, $transfer_bank, $transfer_account
$money = $apply_money - $service_money;
$account_type = $data['account_type'] ?? MemberAccountTypeDict::MONEY;
$cash_out_account = [];
if ($transfer_type != TransferDict::WECHAT) {
$cash_out_account = (new CoreMemberCashOutAccountService())->getInfo($data['account_id'], $site_id, $member_id);
if (empty($cash_out_account)) throw new CommonException('CASH_OUT_ACCOUNT_NOT_EXIST');
}
Db::startTrans();
try {
$data = array(
'member_id' => $member_id,
'site_id' => $site_id,
'cash_out_no' => $this->createCashOutNo($site_id),
'status' => MemberCashOutDict::WAIT_AUDIT,
'account_type' => $account_type,
'apply_money' => $apply_money,
'service_money' => $service_money,
'money' => $money,
'transfer_type' => $transfer_type,
'transfer_realname' => $cash_out_account['realname'] ?? '',
'transfer_mobile' => $member['mobile'] ?? '',
'transfer_bank' => $cash_out_account['bank_name'] ?? '',
'transfer_account' => $cash_out_account['account_no'] ?? '',
'rate' => $config['rate'],
);
$cash_out = $this->model->create($data);
//扣除对应账户金额
$member_account_service = new CoreMemberAccountService();
$member_account_service->addLog($site_id, $member_id, $account_type, -$apply_money, 'cash_out', get_lang('MEMBER_APPLY_CASHOUT'), $cash_out->id);
$member->save(
[
$account_type.'_cash_outing' => $member[$account_type.'_cash_outing'] + $apply_money
]
);
if ($config['is_auto_verify']) {
$core_member_cash_out_service = new CoreMemberCashOutService();
$core_member_cash_out_service->audit($site_id, $cash_out->id, 'agree');
}
Db::commit();
}catch ( Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}
$member = $core_member_service->find($site_id, $cash_out->member_id);
if ($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$member->save(
[
$cash_out->account_type . '_cash_outing' => $member[$cash_out->account_type . '_cash_outing'] - $cash_out->apply_money
]
);
return true;
}
@ -271,68 +362,35 @@ class CoreMemberCashOutService extends BaseCoreService
* @param $site_id
* @return array|array[]
*/
public function getTransferType($site_id){
public function getTransferType($site_id)
{
$config = (new CoreMemberConfigService())->getCashOutConfig($site_id);
return TransferDict::getTransferType($config['transfer_type'], false);
}
/**
* 返还用户的对应账户
* 备注
* @param int $site_id
* @param MemberCashOut $cash_out
* @param int $id
* @param array $data
* @return true
*/
public function giveback(int $site_id, MemberCashOut $cash_out){
$core_member_account_service = new CoreMemberAccountService();
$core_member_account_service->addLog($site_id, $cash_out->member_id, $cash_out->account_type, $cash_out->apply_money, 'cash_out', get_lang('CASHOUT_IS_REFUSE'), $cash_out->id);
$core_member_service = new CoreMemberService();
$member = $core_member_service->find($site_id, $cash_out->member_id);
if($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$member->save(
[
$cash_out->account_type.'_cash_outing' => $member[$cash_out->account_type.'_cash_outing'] - $cash_out->apply_money
]
);
return true;
}
/**
* 累加提现金额,累减提现中金额
* @param int $site_id
* @param MemberCashOut $cash_out
* @return true
*/
public function give(int $site_id, MemberCashOut $cash_out){
$core_member_service = new CoreMemberService();
$member = $core_member_service->find($site_id, $cash_out->member_id);
if($member->isEmpty()) throw new CommonException('MEMBER_NOT_EXIST');
$member->save(
[
$cash_out->account_type.'_cash_outing' => $member[$cash_out->account_type.'_cash_outing'] - $cash_out->apply_money
]
);
return true;
}
/**
* 创建订单编号
* @param int $site_id
* @return string
*/
public function createCashOutNo(int $site_id)
public function remark(int $site_id, int $id, array $data)
{
$time_str = date('YmdHi');
$max_no = Cache::get("cash_out_no_" . $site_id . "_" . $time_str);
$cash_out = $this->find($site_id, $id);
$cash_out->save([
'remark' => $data['remark']
]);
return true;
}
if (!isset($max_no) || empty($max_no)) {
$max_no = 1;
} else {
++$max_no;
}
$cash_out_no = $time_str . $site_id . sprintf('%03d', $max_no);
Cache::set("cash_out_no_" . $site_id . "_" . $time_str, $max_no);
return $cash_out_no;
public function checkTransferStatus(int $site_id, int $id){
$cash_out = $this->find($site_id, $id);
$core_transfer_service = new CoreTransferService();
$status = $core_transfer_service->check($site_id, [
'transfer_no' => $cash_out['transfer_no']
]);
return true;
}
}

View File

@ -166,14 +166,14 @@ class CorePayEventService extends BaseCoreService
* @return array
* @throws Exception
*/
public function transfer(float $money, string $transfer_no, string $to_no, string $to_name, string $remark, array $transfer_list = [], string $to_type = '', string $product_code = '', string $scene = '')
public function transfer(float $money, string $transfer_no, string|array $to_no, string $to_name, string $remark, array $transfer_list = [], string $to_type = '', string $product_code = '', string $scene = '')
{
$transfer_type = TransferDict::getPayTypeByTransfer($this->type);
switch ($transfer_type) {
case PayDict::WECHATPAY:
case TransferDict::WECHAT:
$money = (int) bcmul($money, 100);
break;
case PayDict::ALIPAY:
case TransferDict::ALIPAY:
break;
}
return $this->app('transfer')->transfer([

View File

@ -89,11 +89,15 @@ class CoreTransferService extends BaseCoreService
'openid' => $data['openid'] ?? '',
'transfer_voucher' => $data['transfer_voucher'] ?? '',
'transfer_remark' => $data['transfer_remark'] ?? '',
'transfer_payee' => $data['transfer_payee'] ?? [],
'transfer_payment_code' => $data['transfer_payment_code'] ?? ''
);
$transfer->save($transfer_data);
switch($transfer_type){
case TransferDict::WECHAT:
$transfer_account = $data['openid'];
$out_batch_no = create_no();
$transfer_account = $data['transfer_payee'] ?? [];
$transfer_account['out_batch_no'] = $out_batch_no;
break;
}
$params = [];
@ -103,6 +107,13 @@ class CoreTransferService extends BaseCoreService
// $params['batch_id'] = $result['batch_id'];
// $params['out_batch_no'] = $result['out_batch_no'];
//将返回的数据交给转账通知
$update_data = [
'batch_id' => $result['batch_id'] ?? ''
];
if(!empty($out_batch_no)){
$update_data['out_batch_no'] = $out_batch_no;
}
$transfer->save($update_data);
$this->transferNotify($site_id, $transfer_no, $result);
return true;
}catch( Throwable $e){
@ -131,7 +142,7 @@ class CoreTransferService extends BaseCoreService
$transfer = $this->findTransferByTransferNo($site_id, $transfer_no);
if($transfer->isEmpty()) throw new PayException('TRANSFER_ORDER_INVALID');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING, TransferDict::FAIL])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
$status = $params['status'] ?? TransferDict::DEALING;
switch($status){
case TransferDict::SUCCESS:
@ -158,7 +169,7 @@ class CoreTransferService extends BaseCoreService
$transfer = $this->findTransferByTransferNo($site_id, $transfer_no);
if($transfer->isEmpty()) throw new PayException('TRANSFER_ORDER_INVALID');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING, TransferDict::FAIL])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
$trade_type = $transfer->trade_type;
$data = [
@ -200,7 +211,7 @@ class CoreTransferService extends BaseCoreService
$transfer = $this->findTransferByTransferNo($site_id, $transfer_no);
if($transfer->isEmpty()) throw new PayException('TRANSFER_ORDER_INVALID');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
if(!in_array($transfer['transfer_status'], [TransferDict::WAIT, TransferDict::DEALING, TransferDict::FAIL])) throw new PayException('TRANFER_STATUS_NOT_IN_WAIT_TANSFER');
$data = array(
'transfer_time' => time(),
'transfer_status' => TransferDict::FAIL,
@ -217,10 +228,10 @@ class CoreTransferService extends BaseCoreService
$transfer_no = $data['transfer_no'];
$transfer = $this->findTransferByTransferNo($site_id, $transfer_no);
if($transfer->isEmpty()) throw new PayException('TRANSFER_ORDER_INVALID');
if(!in_array($transfer['transfer_status'], [TransferDict::DEALING, TransferDict::WAIT]) ) throw new PayException('TRANFER_IS_CHANGE');//只有待转账和转账中的订单可以校验
if(!in_array($transfer['transfer_status'], [TransferDict::DEALING, TransferDict::WAIT, TransferDict::FAIL]) ) throw new PayException('TRANFER_IS_CHANGE');//只有待转账和转账中的订单可以校验
//查询第三方支付单据
$transfer_info = $this->pay_event->init($site_id, $transfer->channel, $transfer->type)->getTransfer($transfer_no, $transfer['batch_id'] ?? '');
$transfer_info = $this->pay_event->init($site_id, 'transfer', $transfer->transfer_type)->getTransfer($transfer_no, $transfer['out_batch_no'] ?? '');
if(empty($transfer_info)) throw new PayException('TRANSFER_ORDER_INVALID');//查询不到转账信息
$status = $transfer_info['status'];
switch($status){
@ -234,7 +245,7 @@ class CoreTransferService extends BaseCoreService
$this->fail($site_id, $transfer_no);
break;
}
return true;
return $status;
}
/**

View File

@ -49,7 +49,7 @@ class CorePosterService extends BaseCoreService
*/
public function del($condition)
{
( new Poster() )->delete($condition);
( new Poster() )->where($condition)->delete();
return true;
}
@ -216,7 +216,7 @@ class CorePosterService extends BaseCoreService
}
}
}
if (!is_dir($dir) && !mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
}
@ -225,4 +225,4 @@ class CorePosterService extends BaseCoreService
return $this->driver($site_id, 'poster')->createPoster($poster, $dir, $file_path);
}
}
}

View File

@ -54,10 +54,11 @@ class CoreSiteService extends BaseCoreService
[ 'site_id', '=', $site_id ],
];
$info = $this->model->where($where)->field('site_id, site_name, front_end_name, front_end_logo,front_end_icon, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id, district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, app, addons, site_domain')->append([ 'status_name' ])->findOrEmpty()->toArray();
// dump($info);die;
if (!empty($info)) {
$site_addons = ( new CoreSiteService() )->getAddonKeysBySiteId((int) $site_id);
$info[ 'apps' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::APP ] ])->field('key,title,desc,icon,type')->select()->toArray();
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::ADDON ] ])->field('key,title,desc,icon,type')->select()->toArray();
$info[ 'apps' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::APP ] ])->field('key,title,desc,icon,type,support_app')->select()->toArray();
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::ADDON ] ])->field('key,title,desc,icon,type,support_app')->select()->toArray();
}
return $info;
},

View File

@ -13,6 +13,7 @@ namespace app\service\core\sys;
use app\model\sys\SysConfig;
use core\base\BaseCoreService;
use think\facade\Cache;
use think\Model;
/**
@ -22,6 +23,8 @@ use think\Model;
*/
class CoreConfigService extends BaseCoreService
{
public static $cache_tag_name = 'sys_config';
public function __construct()
{
parent::__construct();
@ -36,11 +39,29 @@ class CoreConfigService extends BaseCoreService
*/
public function getConfig(int $site_id, string $key)
{
$cache_name = 'site_config_cache';
$where = array(
[ 'config_key', '=', $key ],
[ 'site_id', '=', $site_id ]
);
return $this->model->where($where)->field('id,site_id,config_key,value,status,create_time,update_time')->findOrEmpty()->toArray();
// 缓存清理
$info = cache_remember(
$cache_name . $key . "_" . $site_id,
function() use ($where) {
$data = $this->model->where($where)->field('id,site_id,config_key,value,status,create_time,update_time')->findOrEmpty()->toArray();
//数据库中无数据返回-1
if (empty($data)) {
return -1;
}
return $data;
},
self::$cache_tag_name . $site_id
);
// 检测缓存-1 返回空数据
if ($info == -1) {
return [];
}
return $info;
}
/**
@ -70,6 +91,7 @@ class CoreConfigService extends BaseCoreService
$res = $this->model->where($where)->save($data);
}
Cache::tag(self::$cache_tag_name . $site_id)->clear();
return $res;
}

View File

@ -78,12 +78,16 @@ class CoreExportService extends BaseCoreService
/**
* 获取导出数据列
* @param int $site_id
* @param string $type
* @param array $where
* @return array|mixed
*/
public function getExportDataColumn($type = '')
public function getExportDataColumn($site_id = 0, $type = '', $where = [])
{
$type_array = event("ExportDataType");
$param['site_id'] = $site_id;
$param['where'] = $where;
$type_array = event("ExportDataType", $param);
$type_list = [];
foreach ($type_array as $v)
{
@ -94,7 +98,10 @@ class CoreExportService extends BaseCoreService
/**
* 获取导出数据源
* @param int $site_id
* @param string $type
* @param array $where
* @param array $page
* @return array|mixed
*/
public function getExportData($site_id = 0, $type = '', $where = [], $page = [])

View File

@ -154,8 +154,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($dir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $addon);
// 编译 fixed-group 固定模板组件代码文件
$this->compileFixedComponentsCode($dir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $addon);
// 编译 加载插件标题语言包
$this->compileLocale($dir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $addon);

View File

@ -0,0 +1,103 @@
<?php
namespace app\upgrade\v100;
use app\model\site\Site;
use app\model\sys\SysAttachment;
use app\model\sys\SysAttachmentCategory;
class Upgrade
{
public function handle()
{
$addon_dir = root_path() . 'addon';
if (is_dir($addon_dir)) {
$addons = array_diff(scandir($addon_dir), [ '.', '..' ]);
foreach ($addons as $addon) {
$this->handleAddonUniappPages($addon);
}
}
$this->addDefaultData();
}
private function handleAddonUniappPages($addon)
{
$addon_uniapp_pages = str_replace('/', DIRECTORY_SEPARATOR, project_path() . "niucloud/addon/{$addon}/package/uni-app-pages.php");
if (file_exists($addon_uniapp_pages)) {
$content = file_get_contents($addon_uniapp_pages);
// 正则表达式用于捕获每个页面配置项
$pagePattern = '/\{(?:[^{}]|(?R))*\}/';
// 提取所有页面配置
preg_match_all($pagePattern, $content, $matches);
$addon_pages = [];
foreach ($matches[ 0 ] as $match) {
$addon_pages[] = " " . str_replace("$addon/pages/", "pages/", $match);
}
$content = '<?php' . PHP_EOL;
$content .= 'return [' . PHP_EOL . " 'pages' => <<<EOT" . PHP_EOL . ' // PAGE_BEGIN' . PHP_EOL;
$content .= ' {' . PHP_EOL . ' "root": "addon/' . $addon . '", ' . PHP_EOL . ' "pages": [' . PHP_EOL;
$content .= implode("," . PHP_EOL, $addon_pages);
$content .= PHP_EOL . ' ]' . PHP_EOL . ' },' . PHP_EOL . '// PAGE_END' . PHP_EOL . 'EOT' . PHP_EOL . '];';
file_put_contents($addon_uniapp_pages, $content);
}
}
public function addDefaultData()
{
$site_model = new Site();
$category_model = new SysAttachmentCategory();
$attachment_model = new SysAttachment();
$site_ids = $site_model->column('site_id');
foreach ($site_ids as $site_id) {
// 创建素材
$category_info = $category_model->where([
[ 'site_id', '=', $site_id ],
[ 'name', '=', '默认素材' ]
])->field('id')->findOrEmpty()->toArray();
if (!empty($category_info)) {
$category_id = $category_info[ 'id' ];
} else {
$attachment_category = $category_model->create([
'site_id' => $site_id,
'pid' => 0,
'type' => 'image',
'name' => '默认素材',
'sort' => 0
]);
$category_id = $attachment_category->id;
}
$attachment_list = [
'site_id' => $site_id,
'name' => time() . $site_id . $category_id . 'nav_sow_community.png', // 附件名称
'real_name' => '种草社区', // 原始文件名
'path' => 'static/resource/images/attachment/nav_sow_community.png', // 完整地址
'url' => 'static/resource/images/attachment/nav_sow_community.png', // 网络地址
'dir' => 'static/resource/images/attachment', // 附件路径
'att_size' => '24576', // 附件大小
'att_type' => 'image', // 附件类型image,video
'storage_type' => 'local', // 图片上传类型 local本地 aliyun 阿里云oss qiniu 七牛 ....
'cate_id' => $category_id, // 素材分类id
'create_time' => time()
];
$exist_attachment_list = $attachment_model->where([
[ 'site_id', '=', $site_id ],
[ 'path', '=', 'static/resource/images/attachment/nav_sow_community.png' ]
])->field('path')->findOrEmpty()->toArray();
if (empty($exist_attachment_list)) {
$attachment_model->create($attachment_list);
}
}
}
}

View File

@ -0,0 +1,158 @@
ALTER TABLE `pay_transfer` CHANGE COLUMN `transfer_fail_reason` `transfer_fail_reason` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '失败原因';
ALTER TABLE `pay_transfer` ADD COLUMN `transfer_payment_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '收款码图片';
ALTER TABLE `pay_transfer` ADD COLUMN `transfer_payee` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '在线转账数据(json)';
ALTER TABLE `pay_transfer` ADD COLUMN `out_batch_no` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '扩展数据,主要用于记录接收到线上打款的业务数据编号';
ALTER TABLE `pay_transfer` MODIFY COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE `pay_transfer` MODIFY `transfer_payment_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '收款码图片' AFTER `transfer_remark`;
ALTER TABLE `member_cash_out_account` ADD COLUMN `transfer_payment_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '收款码';
ALTER TABLE `member_cash_out` ADD COLUMN `transfer_payee` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '转账收款方(json),主要用于对接在线的打款方式';
ALTER TABLE `member_cash_out` ADD COLUMN `transfer_payment_code` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '收款码图片';
ALTER TABLE `member_cash_out` MODIFY `transfer_payee` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '转账收款方(json),主要用于对接在线的打款方式' AFTER `transfer_account`;
ALTER TABLE `member_cash_out` MODIFY `transfer_payment_code` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '收款码图片' AFTER `transfer_payee`;
DROP TABLE IF EXISTS `diy_theme`;
CREATE TABLE `diy_theme` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '标题',
`type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '插件类型appaddon',
`addon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '所属应用app系统shop商城、o2o上门服务',
`color_mark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '颜色标识',
`color_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '颜色名称',
`mode` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模式default默认【跟随系统】diy自定义配色',
`value` TEXT DEFAULT NULL COMMENT '配色',
`diy_value` TEXT DEFAULT NULL COMMENT '自定义配色',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='自定义主题配色表';
DROP TABLE IF EXISTS `diy_form_write_config`;
CREATE TABLE `diy_form_write_config` (
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`write_way` VARCHAR(255) NOT NULL COMMENT '填写方式no_limit不限制scan仅限微信扫一扫url仅限链接进入',
`join_member_type` VARCHAR(255) NOT NULL DEFAULT 'all_member' COMMENT '参与会员all_member所有会员参与selected_member_level指定会员等级selected_member_label指定会员标签',
`level_ids` TEXT DEFAULT NULL COMMENT '会员等级id集合',
`label_ids` TEXT DEFAULT NULL COMMENT '会员标签id集合',
`member_write_type` VARCHAR(255) NOT NULL COMMENT '每人可填写次数no_limit不限制diy自定义',
`member_write_rule` TEXT NOT NULL COMMENT '每人可填写次数自定义规则',
`form_write_type` VARCHAR(255) NOT NULL COMMENT '表单可填写数量no_limit不限制diy自定义',
`form_write_rule` TEXT NOT NULL COMMENT '表单可填写总数自定义规则',
`time_limit_type` VARCHAR(255) NOT NULL DEFAULT '0' COMMENT '填写时间限制类型no_limit不限制 specify_time指定开始结束时间open_day_time设置每日开启时间',
`time_limit_rule` TEXT NOT NULL COMMENT '填写时间限制规则',
`is_allow_update_content` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '是否允许修改自己填写的内容01',
`write_instruction` TEXT DEFAULT NULL COMMENT '表单填写须知',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写配置表';
DROP TABLE IF EXISTS `diy_form_submit_config`;
CREATE TABLE `diy_form_submit_config` (
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`submit_after_action` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '填表人提交后操作text文字信息voucher核销凭证',
`tips_type` VARCHAR(255) NOT NULL COMMENT '提示内容类型default默认提示diy自定义提示',
`tips_text` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '自定义提示内容',
`time_limit_type` VARCHAR(255) NOT NULL DEFAULT '0' COMMENT '核销凭证有效期限制类型no_limit不限制specify_time指定固定开始结束时间submission_time按提交时间设置有效期',
`time_limit_rule` TEXT DEFAULT NULL COMMENT '核销凭证时间限制规则json格式',
`voucher_content_rule` TEXT DEFAULT NULL COMMENT '核销凭证内容json格式',
`success_after_action` TEXT DEFAULT NULL COMMENT '填写成功后续操作',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单提交页配置表';
DROP TABLE IF EXISTS `diy_form_records_fields`;
CREATE TABLE `diy_form_records_fields` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`form_field_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联表单字段id',
`record_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联表单填写记录id',
`member_id` INT(11) NOT NULL DEFAULT 0 COMMENT '填写会员id',
`field_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段唯一标识',
`field_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段类型',
`field_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段名称',
`field_value` LONGTEXT NOT NULL COMMENT '字段值,根据类型展示对应效果',
`field_required` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否必填 0:否 1:是',
`field_hidden` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否隐藏 0:否 1:是',
`field_unique` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段内容防重复 0:否 1:是',
`privacy_protection` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '隐私保护 0:关闭 1:开启',
`update_num` INT(11) NOT NULL DEFAULT 0 COMMENT '字段修改次数',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写字段表';
DROP TABLE IF EXISTS `diy_form_records`;
CREATE TABLE `diy_form_records` (
`record_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '表单填写记录id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`value` LONGTEXT DEFAULT NULL COMMENT '填写的表单数据',
`member_id` INT(11) NOT NULL DEFAULT 0 COMMENT '填写人会员id',
`relate_id` INT(11) NOT NULL DEFAULT 0 COMMENT '关联业务id',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
PRIMARY KEY (`record_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单填写记录表';
DROP TABLE IF EXISTS `diy_form_fields`;
CREATE TABLE `diy_form_fields` (
`field_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '字段id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`form_id` INT(11) NOT NULL DEFAULT 0 COMMENT '所属万能表单id',
`field_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段唯一标识',
`field_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段类型',
`field_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段名称',
`field_remark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '字段说明',
`field_default` TEXT DEFAULT NULL COMMENT '字段默认值',
`write_num` INT(11) NOT NULL DEFAULT 0 COMMENT '字段填写总数量',
`field_required` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否必填 0:否 1:是',
`field_hidden` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段是否隐藏 0:否 1:是',
`field_unique` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '字段内容防重复 0:否 1:是',
`privacy_protection` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '隐私保护 0:关闭 1:开启',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`field_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单字段表';
DROP TABLE IF EXISTS `diy_form`;
CREATE TABLE `diy_form` (
`form_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '表单id',
`site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`page_title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单名称(用于后台展示)',
`title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单名称(用于前台展示)',
`type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '表单类型',
`status` TINYINT(4) NOT NULL DEFAULT 0 COMMENT '状态0关闭1开启',
`template` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板名称',
`value` LONGTEXT DEFAULT NULL COMMENT '表单数据json格式包含展示组件',
`addon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '所属插件标识',
`share` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '分享内容',
`write_num` INT(11) NOT NULL DEFAULT 0 COMMENT '表单填写总数量',
`remark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '备注说明',
`create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`form_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='万能表单表';

View File

@ -14,7 +14,7 @@ namespace app\validate\diy;
use think\Validate;
/**
* 系统表单验证器
* 万能表单验证器
* Class DiyForm
* @package app\validate\diy
*/

View File

@ -1,6 +1,6 @@
<?php
return [
'version' => '0.5.6',
'code' => '202412210001'
'version' => '1.0.0',
'code' => '202501170001'
];

View File

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\dict;
use app\service\admin\site\SiteService;
class DiyFormComponent extends BaseDict
{
/**
* 万能表单组件配置
* @param array $data
* @return array|mixed
*/
public function load(array $data)
{
$addons = ( new SiteService() )->getAddonKeysBySiteId();
$components_files = [];
foreach ($addons as $v) {
$components_path = $this->getAddonDictPath($v) . "diy_form" . DIRECTORY_SEPARATOR . "components.php";
if (is_file($components_path)) {
$components_files[] = $components_path;
}
}
$components_files_data = $this->loadFiles($components_files);
$components = $data;
foreach ($components_files_data as $file_data) {
$components = empty($components) ? $file_data : array_merge2($components, $file_data);
}
return $components;
}
}

View File

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\dict;
use app\service\admin\site\SiteService;
class DiyFormTemplate extends BaseDict
{
/**
* 万能表单模版
* @param array $data
* @return array|mixed
*/
public function load(array $data)
{
$addons = ( new SiteService() )->getAddonKeysBySiteId();
$components_files = [];
foreach ($addons as $v) {
$components_path = $this->getAddonDictPath($v) . "diy_form" . DIRECTORY_SEPARATOR . "template.php";
if (is_file($components_path)) {
$components_files[] = $components_path;
}
}
$components_files_data = $this->loadFiles($components_files);
$components = $data;
foreach ($components_files_data as $file_data) {
$components = empty($components) ? $file_data : array_merge2($components, $file_data);
}
return $components;
}
}

View File

@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\dict;
use app\service\admin\site\SiteService;
class DiyFormType extends BaseDict
{
/**
* 万能表单组件配置
* @param array $data
* @return array|mixed
*/
public function load(array $data)
{
$addons = ( new SiteService() )->getAddonKeysBySiteId();
$components_files = [];
foreach ($addons as $v) {
$components_path = $this->getAddonDictPath($v) . "diy_form" . DIRECTORY_SEPARATOR . "type.php";
if (is_file($components_path)) {
$components_files[] = $components_path;
}
}
$components_files_data = $this->loadFiles($components_files);
$components = $data;
foreach ($components_files_data as $file_data) {
$components = empty($components) ? $file_data : array_merge2($components, $file_data);
}
return $components;
}
}

View File

@ -43,6 +43,7 @@ class UniappLink extends BaseDict
$addon_service = new AddonService();
$addon_info_list = $addon_service->getAddonListByKeys(array_keys($link_files));
if (empty($addon_info_list)) return [];
if (!empty($params[ 'params' ][ 'query' ]) && $params[ 'params' ][ 'query' ] == 'addon') {
$list_key = array_column($addon_info_list, 'key');

View File

@ -2,6 +2,7 @@
namespace core\pay;
use app\dict\common\ChannelDict;
use app\dict\pay\OnlinePayDict;
use app\dict\pay\RefundDict;
use app\dict\pay\TransferDict;
@ -224,21 +225,32 @@ class Wechatpay extends BasePay
*/
public function transfer(array $params)
{
$to_data = $params['to_no'];//收款人数据
$channel = $to_data['channel'] ?? '';//渠道
$open_id = $to_data['open_id'] ?? '';//openid
if(empty($this->config['mch_id']) || empty($this->config['mch_secret_key']) || empty($this->config['mch_secret_cert']) || empty($this->config['mch_public_cert_path'])){
throw new PayException('WECHAT_TRANSFER_CONFIG_NOT_EXIST');
}
//这儿的批次信息可能是这儿生成的,但依然需要记录
$order = [
'out_batch_no' => $params['transfer_no'] . '',//
'batch_name' => $params['remark'],
'batch_remark' => $params['remark'],
'out_batch_no' => ($to_data['out_batch_no'] ?? '') . '',//
'batch_name' => $params['remark'] ?? '',
'batch_remark' => $params['remark'] ?? '',
];
if($channel == ChannelDict::WEAPP){
$order['_type'] = 'mini';
}
$transfer_list = $params['transfer_list'];
//单笔转账
if (empty($transfer_list)) {
$transfer_list = [
[
'transfer_no' => $params['transfer_no'] . '1',
'transfer_no' => $params['transfer_no'],
'money' => (int)$params['money'],
'remark' => $params['remark'],
'openid' => $params['to_no']
'openid' => $open_id
]
];
}
@ -247,7 +259,7 @@ class Wechatpay extends BasePay
foreach ($transfer_list as $k => $v) {
$item_transfer = [
'out_detail_no' => $params['transfer_no'] . $k,
'out_detail_no' => $params['transfer_no'],
'transfer_amount' => (int)$v['money'],
'transfer_remark' => $v['remark'],
'openid' => $v['openid'],
@ -261,20 +273,35 @@ class Wechatpay extends BasePay
}
$order['total_amount'] = $total_amount;
$order['total_num'] = $total_num;
$result = $this->returnFormat(Pay::wechat()->transfer($order));
if (!empty($result['code'])) {
try {
$result = $this->returnFormat(Pay::wechat()->transfer($order));
if (!empty($result['code'])) {
// if($result['code'] == 'PARAM_ERROR'){
// throw new PayException();
// }else if($result['code'] == 'INVALID_REQUEST'){
// throw new PayException();
// }
if ($result['code'] == 'INVALID_REQUEST') {
throw new PayException(700010);
if ($result['code'] == 'INVALID_REQUEST') {
throw new PayException(700010);
}
throw new PayException($result['message']);
}
throw new PayException($result['message']);
$tran_status_list = [
'PROCESSING' => TransferDict::DEALING,
'ACCEPTED' => TransferDict::DEALING,
'CLOSED' => TransferDict::FAIL,
'FINISHED' => TransferDict::SUCCESS,
];
return ['batch_id' => $result['batch_id'], 'out_batch_no' => $result['out_batch_no'], 'status' => $tran_status_list[$result['batch_status']]];
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
return ['batch_id' => $result['batch_id'], 'out_batch_no' => $result['out_batch_no'], 'status' => TransferDict::SUCCESS];
}
/**
@ -465,28 +492,35 @@ class Wechatpay extends BasePay
* @throws ContainerException
* @throws InvalidParamsException
*/
public function getTransfer(string $transfer_no, $out_transfer_no = '')
public function getTransfer(string $transfer_no, $out_batch_no = '')
{
$order = [
'out_batch_no' => $out_transfer_no,
'out_batch_no' => $out_batch_no,
'out_detail_no' => $transfer_no,
'_action' => 'transfer',
];
$result = Pay::wechat()->query($order);
$result = $this->returnFormat($result);
//微信转账状态
$transfer_status_array = [
'INIT' => TransferDict::DEALING,//初始态。 系统转账校验中
'WAIT_PAY' => TransferDict::DEALING,
'PROCESSING' => TransferDict::DEALING,
'FAIL' => TransferDict::FAIL,
'SUCCESS' => TransferDict::SUCCESS,
];
return [
'status' => $transfer_status_array[$result['status']],
'transfer_no' => $transfer_no
];
try {
$result = Pay::wechat()->query($order);
$result = $this->returnFormat($result);
//微信转账状态
$transfer_status_array = [
'INIT' => TransferDict::DEALING,//初始态。 系统转账校验中
'WAIT_PAY' => TransferDict::DEALING,
'PROCESSING' => TransferDict::DEALING,
'FAIL' => TransferDict::FAIL,
'SUCCESS' => TransferDict::SUCCESS,
];
return [
'status' => $transfer_status_array[$result['detail_status']],
'transfer_no' => $transfer_no
];
}catch(Throwable $e){
return [
'status' => TransferDict::DEALING,
'transfer_no' => $transfer_no
];
}
}