From c1e13b7b46ab6fae40a7b49a2ce4506d34b10d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?= <1518079521@qq.com> Date: Tue, 6 Aug 2024 17:46:36 +0800 Subject: [PATCH] update niucloud --- niucloud/app/Request.php | 2 +- .../controller/addon/AddonDevelop.php | 1 - .../app/adminapi/controller/auth/Auth.php | 51 +- .../app/adminapi/controller/login/Login.php | 15 +- .../app/adminapi/controller/member/Member.php | 1 - .../app/adminapi/controller/notice/Notice.php | 15 - .../app/adminapi/controller/sys/Config.php | 60 - .../app/adminapi/controller/sys/Poster.php | 2 +- .../app/adminapi/controller/sys/Printer.php | 279 ++++ .../app/adminapi/controller/user/User.php | 11 + .../adminapi/controller/weapp/Delivery.php | 1 - .../app/adminapi/controller/weapp/Version.php | 1 - niucloud/app/adminapi/route/auth.php | 2 - niucloud/app/adminapi/route/dict.php | 4 +- niucloud/app/adminapi/route/diy.php | 2 +- niucloud/app/adminapi/route/member.php | 2 +- niucloud/app/adminapi/route/notice.php | 2 - niucloud/app/adminapi/route/route.php | 6 +- niucloud/app/adminapi/route/stat.php | 34 - niucloud/app/adminapi/route/sys.php | 75 +- niucloud/app/adminapi/route/user.php | 2 + niucloud/app/api/controller/login/Login.php | 32 +- .../app/api/controller/login/Register.php | 19 +- .../app/api/controller/member/Account.php | 14 +- niucloud/app/api/controller/member/Member.php | 3 - niucloud/app/api/controller/sys/Verify.php | 2 +- niucloud/app/api/controller/weapp/Weapp.php | 12 +- niucloud/app/api/controller/wechat/Wechat.php | 71 +- niucloud/app/api/route/route.php | 12 +- niucloud/app/command/Menu.php | 1 - niucloud/app/command/queue/Queue.php | 53 +- niucloud/app/command/schedule/Schedule.php | 39 +- niucloud/app/command/workerman/Workerman.php | 91 +- niucloud/app/dict/addon/AddonDict.php | 2 +- niucloud/app/dict/diy/ComponentDict.php | 2 + niucloud/app/dict/diy/LinkDict.php | 9 +- niucloud/app/dict/diy/PagesDict.php | 56 +- niucloud/app/dict/member/MemberLevelDict.php | 26 +- .../app/dict/member/account_change_type.php | 6 + niucloud/app/dict/menu/admin.php | 124 +- niucloud/app/dict/poster/ComponentDict.php | 29 +- niucloud/app/dict/schedule/schedule.php | 25 +- niucloud/app/dict/site/SiteAccountLogDict.php | 33 - niucloud/app/dict/site/SiteDict.php | 35 - niucloud/app/dict/sys/ConfigKeyDict.php | 2 - niucloud/app/dict/sys/FileDict.php | 5 +- niucloud/app/dict/sys/PrinterDict.php | 62 + niucloud/app/event.php | 12 +- niucloud/app/install/controller/Index.php | 60 +- niucloud/app/install/source/database.sql | 1208 +++++++++-------- niucloud/app/install/view/base.html | 1 - niucloud/app/install/view/index/step-3.html | 4 +- niucloud/app/install/view/index/step-5.html | 33 +- .../SetMemberNoJob.php} | 18 +- niucloud/app/lang/en/api.php | 2 +- niucloud/app/lang/en/dict.php | 8 - niucloud/app/lang/zh-cn/api.php | 13 +- niucloud/app/lang/zh-cn/dict.php | 19 +- niucloud/app/lang/zh-cn/validate.php | 8 +- .../MemberExportDataListener.php | 15 +- .../MemberExportTypeListener.php | 2 +- .../listener/system/AdminIndexListener.php | 30 - niucloud/app/listener/system/Poster.php | 2 +- niucloud/app/model/addon/Addon.php | 2 +- niucloud/app/model/dict/Dict.php | 14 +- niucloud/app/model/diy/Diy.php | 4 +- niucloud/app/model/diy/DiyRoute.php | 2 +- .../app/model/generator/GenerateTable.php | 6 +- niucloud/app/model/member/Member.php | 56 +- .../app/model/member/MemberAccountLog.php | 14 + niucloud/app/model/member/MemberCashOut.php | 2 +- niucloud/app/model/member/MemberLabel.php | 4 +- niucloud/app/model/member/MemberLevel.php | 3 +- niucloud/app/model/sys/Poster.php | 4 +- niucloud/app/model/sys/SysExport.php | 2 +- niucloud/app/model/sys/SysNoticeLog.php | 2 +- niucloud/app/model/sys/SysNoticeSmsLog.php | 2 +- niucloud/app/model/sys/SysPrinter.php | 106 ++ niucloud/app/model/sys/SysPrinterTemplate.php | 94 ++ niucloud/app/model/sys/SysRole.php | 11 +- niucloud/app/model/sys/SysUser.php | 71 +- niucloud/app/model/sys/SysUserLog.php | 6 +- niucloud/app/model/verify/Verifier.php | 1 - niucloud/app/model/verify/Verify.php | 17 +- .../admin/applet/AppletDownloadService.php | 1 - .../app/service/admin/auth/AuthService.php | 93 +- .../service/admin/diy/DiyConfigService.php | 4 +- .../app/service/admin/diy/DiyRouteService.php | 2 +- .../admin/generator/GenerateService.php | 2 - .../generator/core/AdminApiRouteGenerator.php | 3 - .../generator/core/ValidateGenerator.php | 2 +- .../generator/core/WebIndexGenerator.php | 1 - .../admin/generator/vm/site_service.vm | 4 +- .../admin/member/MemberAccountService.php | 4 +- .../service/admin/member/MemberService.php | 1 - .../admin/member/MemberSignService.php | 6 +- .../app/service/admin/notice/SmsService.php | 2 +- .../service/admin/pay/PayChannelService.php | 2 + .../app/service/admin/pay/RefundService.php | 2 - .../service/admin/sys/AttachmentService.php | 11 +- .../app/service/admin/sys/ConfigService.php | 260 +--- .../app/service/admin/sys/MenuService.php | 260 ++-- .../app/service/admin/sys/PrinterService.php | 250 ++++ .../admin/sys/PrinterTemplateService.php | 134 ++ .../app/service/admin/sys/RoleService.php | 5 +- .../app/service/admin/sys/SystemService.php | 2 - .../app/service/admin/user/UserService.php | 21 +- .../admin/wechat/WechatMenuService.php | 1 - .../app/service/api/diy/DiyConfigService.php | 2 +- .../app/service/api/login/AuthService.php | 48 +- .../app/service/api/login/ConfigService.php | 48 + .../app/service/api/login/LoginService.php | 27 +- .../app/service/api/login/RegisterService.php | 33 +- .../api/member/MemberAccountService.php | 131 +- .../service/api/member/MemberLevelService.php | 7 +- .../app/service/api/member/MemberService.php | 3 - .../service/api/member/MemberSignService.php | 56 +- niucloud/app/service/api/sys/TaskService.php | 2 - .../app/service/api/upload/UploadService.php | 10 +- .../app/service/api/verify/VerifyService.php | 73 +- .../service/api/weapp/WeappAuthService.php | 88 +- .../service/api/wechat/WechatAuthService.php | 76 +- .../service/api/wechat/WechatServeService.php | 2 - .../addon/CoreAddonDevelopBuildService.php | 1 - .../service/core/addon/CoreAddonService.php | 2 +- niucloud/app/service/core/addon/WapTrait.php | 192 +-- .../service/core/diy/CoreDiyConfigService.php | 21 +- .../app/service/core/diy/CoreDiyService.php | 4 - .../core/member/CoreMemberAccountService.php | 35 +- .../core/member/CoreMemberConfigService.php | 104 +- .../service/core/member/CoreMemberService.php | 18 +- .../service/core/niucloud/CoreAuthService.php | 2 - .../core/niucloud/CoreCloudBaseService.php | 1 - .../core/niucloud/CoreCloudBuildService.php | 1 - .../core/niucloud/CoreModuleService.php | 1 - .../core/niucloud/CoreNotifyService.php | 6 - .../service/core/pay/CoreAccountService.php | 2 +- .../service/core/pay/CorePayEventService.php | 20 +- .../app/service/core/pay/CorePayService.php | 137 +- .../service/core/poster/CorePosterService.php | 19 +- .../core/printer/CorePrinterService.php | 321 +++++ .../core/schedule/CoreScheduleService.php | 12 +- .../core/weapp/CoreWeappAuthService.php | 22 +- .../core/weapp/CoreWeappConfigService.php | 51 +- .../core/weapp/CoreWeappDeliveryService.php | 20 +- .../service/core/weapp/CoreWeappService.php | 24 +- .../core/wechat/CoreWechatApiService.php | 20 +- .../core/wechat/CoreWechatConfigService.php | 62 +- .../core/wechat/CoreWechatMediaService.php | 13 +- .../service/core/wechat/CoreWechatService.php | 18 +- niucloud/app/upgrade/v130/upgrade.sql | 4 - niucloud/app/upgrade/v140/Upgrade.php | 69 + niucloud/app/upgrade/v140/upgrade.sql | 49 + niucloud/app/validate/channel/Weapp.php | 2 +- niucloud/app/validate/channel/Wechat.php | 2 +- niucloud/app/validate/member/Address.php | 39 +- niucloud/app/validate/sys/Printer.php | 49 + niucloud/app/validate/sys/PrinterTemplate.php | 39 + niucloud/config/install.php | 2 +- niucloud/config/niucloud.php | 2 +- niucloud/config/upload.php | 16 +- niucloud/config/version.php | 4 +- niucloud/core/base/BaseModel.php | 10 + niucloud/core/dict/Printer.php | 40 + niucloud/core/exception/HomeException.php | 18 - niucloud/core/pay/Wechatpay.php | 1 - niucloud/core/poster/Poster.php | 174 ++- niucloud/core/poster/PosterLoader.php | 1 - .../Stat.php => core/printer/BasePrinter.php} | 30 +- .../printer/KdniaoPrinter.php} | 42 +- .../printer/PrinterLoader.php} | 35 +- .../core/printer/sdk/yilianyun/Autoloader.php | 32 + .../sdk/yilianyun/api/ExpressPrintService.php | 36 + .../sdk/yilianyun/api/OauthService.php | 22 + .../sdk/yilianyun/api/PicturePrintService.php | 22 + .../sdk/yilianyun/api/PrintMenuService.php | 19 + .../sdk/yilianyun/api/PrintService.php | 20 + .../sdk/yilianyun/api/PrinterService.php | 313 +++++ .../printer/sdk/yilianyun/api/RpcService.php | 19 + .../sdk/yilianyun/config/YlyConfig.php | 68 + .../demo/authorization_code_mode/callback.php | 141 ++ .../yilianyun/demo/client_mode/callback.php | 136 ++ .../core/printer/sdk/yilianyun/demo/index.php | 11 + .../core/printer/sdk/yilianyun/demo/init.php | 15 + .../sdk/yilianyun/oauth/YlyOauthClient.php | 152 +++ .../sdk/yilianyun/protocol/YlyRpcClient.php | 104 ++ niucloud/core/sms/Aliyun.php | 16 +- niucloud/core/sms/BaseSms.php | 2 +- niucloud/core/sms/SmsLoader.php | 10 +- niucloud/core/sms/Tencent.php | 20 +- niucloud/core/template/Weapp.php | 1 - niucloud/core/template/Wechat.php | 1 - niucloud/core/upload/Aliyun.php | 2 +- niucloud/core/upload/Qiniu.php | 2 +- niucloud/core/upload/Tencent.php | 2 +- niucloud/core/util/Barcode.php | 38 +- niucloud/core/util/Queue.php | 3 - 197 files changed, 5194 insertions(+), 2640 deletions(-) create mode 100644 niucloud/app/adminapi/controller/sys/Printer.php delete mode 100644 niucloud/app/adminapi/route/stat.php delete mode 100644 niucloud/app/dict/site/SiteAccountLogDict.php delete mode 100644 niucloud/app/dict/site/SiteDict.php create mode 100644 niucloud/app/dict/sys/PrinterDict.php rename niucloud/app/job/{sys/AddonInstall.php => member/SetMemberNoJob.php} (67%) rename niucloud/app/listener/{member => member_export}/MemberExportDataListener.php (76%) rename niucloud/app/listener/{member => member_export}/MemberExportTypeListener.php (98%) delete mode 100644 niucloud/app/listener/system/AdminIndexListener.php create mode 100644 niucloud/app/model/sys/SysPrinter.php create mode 100644 niucloud/app/model/sys/SysPrinterTemplate.php create mode 100644 niucloud/app/service/admin/sys/PrinterService.php create mode 100644 niucloud/app/service/admin/sys/PrinterTemplateService.php create mode 100644 niucloud/app/service/api/login/ConfigService.php create mode 100644 niucloud/app/service/core/printer/CorePrinterService.php create mode 100644 niucloud/app/upgrade/v140/Upgrade.php create mode 100644 niucloud/app/upgrade/v140/upgrade.sql create mode 100644 niucloud/app/validate/sys/Printer.php create mode 100644 niucloud/app/validate/sys/PrinterTemplate.php create mode 100644 niucloud/core/dict/Printer.php delete mode 100644 niucloud/core/exception/HomeException.php rename niucloud/{app/adminapi/controller/stat/Stat.php => core/printer/BasePrinter.php} (60%) rename niucloud/{app/adminapi/controller/stat/SiteStat.php => core/printer/KdniaoPrinter.php} (59%) rename niucloud/{app/listener/system/SiteIndexListener.php => core/printer/PrinterLoader.php} (60%) create mode 100644 niucloud/core/printer/sdk/yilianyun/Autoloader.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/ExpressPrintService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/OauthService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/PicturePrintService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/PrintMenuService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/PrintService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/PrinterService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/api/RpcService.php create mode 100644 niucloud/core/printer/sdk/yilianyun/config/YlyConfig.php create mode 100644 niucloud/core/printer/sdk/yilianyun/demo/authorization_code_mode/callback.php create mode 100644 niucloud/core/printer/sdk/yilianyun/demo/client_mode/callback.php create mode 100644 niucloud/core/printer/sdk/yilianyun/demo/index.php create mode 100644 niucloud/core/printer/sdk/yilianyun/demo/init.php create mode 100644 niucloud/core/printer/sdk/yilianyun/oauth/YlyOauthClient.php create mode 100644 niucloud/core/printer/sdk/yilianyun/protocol/YlyRpcClient.php diff --git a/niucloud/app/Request.php b/niucloud/app/Request.php index ab6e8b12d..e60fb0ef8 100644 --- a/niucloud/app/Request.php +++ b/niucloud/app/Request.php @@ -57,7 +57,7 @@ class Request extends \think\Request $filter_rule = [ "/<(\\/?)(script|i?frame|style|html|body|title|link|metaf|alert|font|object|\\?|\\%)([^>]*?)>/isU", "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU", - "/select|join|where|drop|like|modify|rename|insert|update|table|database|alter|truncate|\'|\/\*|\.\.\/|\.\/|union|into|load_file|outfile/is" + "/\\b(select|join|where|drop|like|modify|rename|insert|update|table|database|alter|truncate|\'|\/\*|\.\.\/|\.\/|union|into|load_file|outfile)\\b/is" ]; return preg_replace($filter_rule, '', $param); } diff --git a/niucloud/app/adminapi/controller/addon/AddonDevelop.php b/niucloud/app/adminapi/controller/addon/AddonDevelop.php index bf5e0896b..c10734b9f 100644 --- a/niucloud/app/adminapi/controller/addon/AddonDevelop.php +++ b/niucloud/app/adminapi/controller/addon/AddonDevelop.php @@ -13,7 +13,6 @@ namespace app\adminapi\controller\addon; use app\dict\addon\AddonDict; use app\service\admin\addon\AddonDevelopService; -use app\service\admin\niucloud\AppService; use core\base\BaseAdminController; use think\Response; diff --git a/niucloud/app/adminapi/controller/auth/Auth.php b/niucloud/app/adminapi/controller/auth/Auth.php index 124ab1daf..8f4748cea 100644 --- a/niucloud/app/adminapi/controller/auth/Auth.php +++ b/niucloud/app/adminapi/controller/auth/Auth.php @@ -25,34 +25,20 @@ class Auth extends BaseAdminController public function authMenuList() { $data = $this->request->params([ - ['status', 1], - ['is_tree', 1], - ['is_button', 1] + [ 'status', 1 ], + [ 'is_tree', 1 ], + [ 'is_button', 1 ] ]); - return success((new AuthService())->getAuthMenuList($data['status'], $data['is_tree'], $data['is_button'])); + return success(( new AuthService() )->getAuthMenuList($data[ 'status' ], $data[ 'is_tree' ], $data[ 'is_button' ])); } - /** - * 获取授权应用 - * @return void - */ - public function getAuthAddonList(){ - $data = $this->request->params([ - ['type', ''], - ['title', ''], - ['support_app',''] - ]); - return success((new AuthService())->getAuthAddonList($data)); - } - - /** * 获取登录用户信息 * @return Response */ public function get() { - return success((new AuthService())->getAuthInfo()); + return success(( new AuthService() )->getAuthInfo()); } /** @@ -63,11 +49,11 @@ class Auth extends BaseAdminController public function modify($field) { $data = $this->request->params([ - ['value', ''], - ['field', $field] + [ 'value', '' ], + [ 'field', $field ] ]); // $this->validate($data, 'app\validate\sys\User.modify'); - (new AuthService())->modifyAuth($field, $data['value']); + ( new AuthService() )->modifyAuth($field, $data[ 'value' ]); return success('MODIFY_SUCCESS'); } @@ -77,23 +63,12 @@ class Auth extends BaseAdminController public function edit() { $data = $this->request->params([ - ['real_name', ''], - ['head_img', ''], - ['password', ''], - ['original_password', ''] + [ 'real_name', '' ], + [ 'head_img', '' ], + [ 'password', '' ], + [ 'original_password', '' ] ]); - (new AuthService())->editAuth($data); + ( new AuthService() )->editAuth($data); return success('MODIFY_SUCCESS'); } - - /** - * 授权应用加星 - */ - public function setStar(){ - $data = $this->request->params([ - ['key', ''], - ]); - (new AuthService())->setAddonStat($data['key']); - return success('SUCCESS'); - } } diff --git a/niucloud/app/adminapi/controller/login/Login.php b/niucloud/app/adminapi/controller/login/Login.php index a535f5072..879b695da 100644 --- a/niucloud/app/adminapi/controller/login/Login.php +++ b/niucloud/app/adminapi/controller/login/Login.php @@ -13,7 +13,6 @@ namespace app\adminapi\controller\login; use app\service\admin\auth\ConfigService; use app\service\admin\auth\LoginService; -use app\service\core\menu\CoreMenuService; use core\base\BaseAdminController; use think\Response; @@ -27,12 +26,12 @@ class Login extends BaseAdminController { $data = $this->request->params([ - ['username', ''], - ['password', ''], + [ 'username', '' ], + [ 'password', '' ], ]); //参数验证 //验证码验证 - $result = (new LoginService())->login($data['username'], $data['password']); + $result = ( new LoginService() )->login($data[ 'username' ], $data[ 'password' ]); if (!$result) { //账号密码错误...., 重置验证码 return fail('USER_ERROR'); @@ -47,7 +46,7 @@ class Login extends BaseAdminController */ public function logout() { - (new LoginService)->logout(); + ( new LoginService )->logout(); return success('LOGOUT'); } @@ -58,10 +57,6 @@ class Login extends BaseAdminController */ public function getConfig() { - return success((new ConfigService())->getConfig()); - } - - public function test() { - + return success(( new ConfigService() )->getConfig()); } } diff --git a/niucloud/app/adminapi/controller/member/Member.php b/niucloud/app/adminapi/controller/member/Member.php index 4beff8306..70cba88a2 100644 --- a/niucloud/app/adminapi/controller/member/Member.php +++ b/niucloud/app/adminapi/controller/member/Member.php @@ -15,7 +15,6 @@ use app\dict\member\MemberDict; use app\dict\member\MemberRegisterChannelDict; use app\dict\member\MemberRegisterTypeDict; use app\service\admin\member\MemberService; -use app\service\core\sys\CoreExportService; use core\base\BaseAdminController; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; diff --git a/niucloud/app/adminapi/controller/notice/Notice.php b/niucloud/app/adminapi/controller/notice/Notice.php index 0388e9a4b..8d95fc408 100644 --- a/niucloud/app/adminapi/controller/notice/Notice.php +++ b/niucloud/app/adminapi/controller/notice/Notice.php @@ -94,21 +94,6 @@ class Notice extends BaseAdminController return success(); } - /** - * 消息列表 - * @return Response - */ - public function getLogList() - { - $data = $this->request->params([ - ['key', ''], - ['receiver', ''], - ]); - - $res = (new NoticeService())->getLogPage($data); - return success($res); - } - /** * 消息修改 * @return Response diff --git a/niucloud/app/adminapi/controller/sys/Config.php b/niucloud/app/adminapi/controller/sys/Config.php index 2b2fe86ea..9588874e1 100644 --- a/niucloud/app/adminapi/controller/sys/Config.php +++ b/niucloud/app/adminapi/controller/sys/Config.php @@ -134,46 +134,6 @@ class Config extends BaseAdminController return success((new ConfigService())->getMap()); } - /** - * 获取站点首页列表(如果正在使用is_use = 1) - */ - public function getSiteIndexList() - { - return success((new ConfigService())->getSiteIndexList()); - } - - /** - * 首页配置 - */ - public function setSiteIndex() - { - $data = $this->request->params([ - ['view_path', ''], - ]); - (new ConfigService())->setSiteIndexConfig($data); - return success(); - } - - /** - * 获取站点首页列表(如果正在使用is_use = 1) - */ - public function getAdminIndexList() - { - return success((new ConfigService())->getAdminIndexList()); - } - - /** - * 首页配置 - */ - public function setAdminIndex() - { - $data = $this->request->params([ - ['view_path', ''], - ]); - (new ConfigService())->setAdminIndexConfig($data); - return success(); - } - /** * 获取手机端首页列表 */ @@ -186,26 +146,6 @@ class Config extends BaseAdminController return success(( new ConfigService() )->getWapIndexList($data)); } - /** - * 设置快捷菜单 - */ - public function setShortcutMenu() - { - $data = $this->request->params([ - ['menu', []], - ]); - (new ConfigService())->setShortcutMenu($data['menu']); - return success(); - } - - /** - * 获取站点快捷菜单 - */ - public function getShortcutMenu() - { - return success(data: (new ConfigService())->getShortcutMenu()); - } - /** * 获取开发者key * @return Response diff --git a/niucloud/app/adminapi/controller/sys/Poster.php b/niucloud/app/adminapi/controller/sys/Poster.php index fbc273f67..2cfa760a0 100644 --- a/niucloud/app/adminapi/controller/sys/Poster.php +++ b/niucloud/app/adminapi/controller/sys/Poster.php @@ -190,7 +190,7 @@ class Poster extends BaseAdminController ] ], // 数据参数 [ 'channel', 'h5' ] ]); - return success(data: poster($this->request->siteId(), ...$data)); + return success(data: poster(...$data)); } } diff --git a/niucloud/app/adminapi/controller/sys/Printer.php b/niucloud/app/adminapi/controller/sys/Printer.php new file mode 100644 index 000000000..878b2c5f6 --- /dev/null +++ b/niucloud/app/adminapi/controller/sys/Printer.php @@ -0,0 +1,279 @@ +request->params([ + [ "printer_name", "" ], + ]); + return success(( new PrinterService() )->getPage($data)); + } + + /** + * 获取小票打印机列表 + * @return \think\Response + */ + public function lists() + { + $data = $this->request->params([ + [ "printer_name", "" ], + ]); + return success(( new PrinterService() )->getList($data)); + } + + /** + * 小票打印机详情 + * @param int $id + * @return \think\Response + */ + public function info(int $id) + { + return success(( new PrinterService() )->getInfo($id)); + } + + /** + * 添加小票打印机 + * @return \think\Response + */ + public function add() + { + $data = $this->request->params([ + [ "brand", "" ], + [ "printer_name", "" ], + [ "printer_code", "" ], + [ "printer_key", "" ], + [ "open_id", "" ], + [ "apikey", "" ], + [ 'template_type', '' ], + [ 'trigger', '' ], + [ "value", "" ], + [ "print_width", "" ], + [ "status", 0 ], + ]); + $this->validate($data, 'app\validate\sys\Printer.add'); + $id = ( new PrinterService() )->add($data); + return success('ADD_SUCCESS', [ 'id' => $id ]); + } + + /** + * 小票打印机编辑 + * @param $id 小票打印机id + * @return \think\Response + */ + public function edit(int $id) + { + $data = $this->request->params([ + [ "brand", "" ], + [ "printer_name", "" ], + [ "printer_code", "" ], + [ "printer_key", "" ], + [ "open_id", "" ], + [ "apikey", "" ], + [ 'template_type', '' ], + [ 'trigger', '' ], + [ "value", "" ], + [ "print_width", "" ], + [ "status", 0 ], + ]); + $this->validate($data, 'app\validate\sys\Printer.edit'); + ( new PrinterService() )->edit($id, $data); + return success('EDIT_SUCCESS'); + } + + /** + * 修改小票打印机状态 + * @return \think\Response + */ + public function modifyStatus() + { + $data = $this->request->params([ + [ "printer_id", 0 ], + [ "status", 0 ], + ]); + ( new PrinterService() )->modifyStatus($data); + return success('SUCCESS'); + } + + /** + * 小票打印机删除 + * @param $id 小票打印机id + * @return \think\Response + */ + public function del(int $id) + { + ( new PrinterService() )->del($id); + return success('DELETE_SUCCESS'); + } + + /** + * 获取小票打印模板分页列表 + * @return \think\Response + */ + public function templatePageLists() + { + $data = $this->request->params([ + [ "template_type", "" ], + [ "template_name", "" ], + ]); + return success(( new PrinterTemplateService() )->getPage($data)); + } + + /** + * 获取小票打印模板列表 + * @return \think\Response + * @throws \think\db\exception\DbException + */ + public function templateLists() + { + $data = $this->request->params([ + [ "template_type", "" ], + [ "template_name", "" ], + ]); + return success(( new PrinterTemplateService() )->getList($data)); + } + + /** + * 小票打印模板详情 + * @param int $id + * @return \think\Response + */ + public function templateInfo(int $id) + { + return success(( new PrinterTemplateService() )->getInfo($id)); + } + + /** + * 添加小票打印模板 + * @return \think\Response + */ + public function templateAdd() + { + $data = $this->request->params([ + [ "template_type", "" ], + [ "template_name", "" ], + [ "value", "" ], + ]); + $this->validate($data, 'app\validate\sys\PrinterTemplate.add'); + $id = ( new PrinterTemplateService() )->add($data); + return success('ADD_SUCCESS', [ 'id' => $id ]); + } + + /** + * 小票打印模板编辑 + * @param $id 小票打印模板id + * @return \think\Response + */ + public function templateEdit(int $id) + { + $data = $this->request->params([ + [ "template_type", "" ], + [ "template_name", "" ], + [ "value", "" ], + ]); + $this->validate($data, 'app\validate\sys\PrinterTemplate.edit'); + ( new PrinterTemplateService() )->edit($id, $data); + return success('EDIT_SUCCESS'); + } + + /** + * 小票打印模板删除 + * @param $id 小票打印模板id + * @return \think\Response + */ + public function templateDel(int $id) + { + ( new PrinterTemplateService() )->del($id); + return success('DELETE_SUCCESS'); + } + + /** + * 获取小票打印模板类型 + * @return array|\think\Response + */ + public function getType() + { + return success(( new PrinterService() )->getType()); + } + + /** + * 获取小票打印机设备品牌 + * @return array|\think\Response + */ + public function getBrand() + { + $data = $this->request->params([ + [ "brand", "" ], + ]); + return success(( new PrinterService() )->getBrand($data[ 'brand' ])); + } + + /** + * 测试打印 + * @param int $id + * @return \think\Response + */ + public function testPrint(int $id) + { + ( new PrinterService() )->testPrint($id); + return success('SUCCESS'); + } + + /** + * 刷新打印机token + * @param int $id + * @return \think\Response + */ + public function refreshToken(int $id) + { + ( new PrinterService() )->refreshToken($id); + return success('SUCCESS'); + } + + /** + * 打印小票内容 + * @return \think\Response + */ + public function printTicket() + { + $data = $this->request->params([ + [ "type", "" ], // 小票模板类型 + [ "trigger", "" ], // 触发时机 + [ 'business', [] ] // 业务参数,根据自身业务传值 + ]); + + $res = ( new PrinterService() )->printTicket($data); + if ($res[ 'code' ] == 0) { + return success('SUCCESS'); + } else { + return fail($res[ 'message' ]); + } + } + +} diff --git a/niucloud/app/adminapi/controller/user/User.php b/niucloud/app/adminapi/controller/user/User.php index 1d934cad0..bc54ad73d 100644 --- a/niucloud/app/adminapi/controller/user/User.php +++ b/niucloud/app/adminapi/controller/user/User.php @@ -50,6 +50,17 @@ class User extends BaseAdminController return success((new UserService())->getInfo($uid)); } + public function getUserAll() + { + $data = $this->request->params([ + ['username', ''], + ['realname', ''], + ['create_time', []], + ]); + $list = (new UserService())->getUserAll($data); + return success($list); + } + /** * 新增用户 * @return Response diff --git a/niucloud/app/adminapi/controller/weapp/Delivery.php b/niucloud/app/adminapi/controller/weapp/Delivery.php index 6fc59b37d..6b37f0b82 100644 --- a/niucloud/app/adminapi/controller/weapp/Delivery.php +++ b/niucloud/app/adminapi/controller/weapp/Delivery.php @@ -13,7 +13,6 @@ namespace app\adminapi\controller\weapp; use app\service\admin\weapp\WeappDeliveryService; use core\base\BaseAdminController; -use think\Response; /** * 小程序发货信息管理服务 diff --git a/niucloud/app/adminapi/controller/weapp/Version.php b/niucloud/app/adminapi/controller/weapp/Version.php index 86be2e640..e64af8988 100644 --- a/niucloud/app/adminapi/controller/weapp/Version.php +++ b/niucloud/app/adminapi/controller/weapp/Version.php @@ -13,7 +13,6 @@ namespace app\adminapi\controller\weapp; use app\service\admin\weapp\WeappVersionService; use core\base\BaseAdminController; -use Exception; use think\Response; /** diff --git a/niucloud/app/adminapi/route/auth.php b/niucloud/app/adminapi/route/auth.php index 8938c80e4..61af423d0 100644 --- a/niucloud/app/adminapi/route/auth.php +++ b/niucloud/app/adminapi/route/auth.php @@ -24,8 +24,6 @@ Route::group('auth', function () { /***************************************************** 授权信息 ****************************************************/ //授权用户站点菜单 Route::get('authmenu', 'auth.Auth/authMenuList'); - //授权用户站点应用 - Route::get('authaddon', 'auth.Auth/getAuthAddonList'); //授权用户信息 Route::get('get', 'auth.Auth/get'); //授权用户信息 diff --git a/niucloud/app/adminapi/route/dict.php b/niucloud/app/adminapi/route/dict.php index 40ce6401a..7d11e7850 100644 --- a/niucloud/app/adminapi/route/dict.php +++ b/niucloud/app/adminapi/route/dict.php @@ -16,7 +16,6 @@ use app\adminapi\middleware\AdminCheckToken; use app\adminapi\middleware\AdminLog; -// USER_CODE_BEGIN -- sys_dict Route::group('dict', function () { //数据字典列表 @@ -39,5 +38,4 @@ Route::group('dict', function () { AdminCheckToken::class, AdminCheckRole::class, AdminLog::class -]); -// USER_CODE_END -- sys_dict +]); \ No newline at end of file diff --git a/niucloud/app/adminapi/route/diy.php b/niucloud/app/adminapi/route/diy.php index f5282dc8b..d6ecef716 100644 --- a/niucloud/app/adminapi/route/diy.php +++ b/niucloud/app/adminapi/route/diy.php @@ -54,7 +54,7 @@ Route::group('diy', function() { Route::get('link', 'diy.Diy/getLink'); // 设为使用 - Route::put('use', 'diy.Diy/setUse'); + Route::put('use/:id', 'diy.Diy/setUse'); // 获取页面模板 Route::get('template', 'diy.Diy/getTemplate'); diff --git a/niucloud/app/adminapi/route/member.php b/niucloud/app/adminapi/route/member.php index c12f962ab..0e0c2b127 100644 --- a/niucloud/app/adminapi/route/member.php +++ b/niucloud/app/adminapi/route/member.php @@ -18,7 +18,7 @@ use think\facade\Route; /** * 路由 */ -Route::group('member', function () { +Route::group('member', function() { /***************************************************** 会员管理 ****************************************************/ //会员列表 Route::get('member', 'member.Member/lists'); diff --git a/niucloud/app/adminapi/route/notice.php b/niucloud/app/adminapi/route/notice.php index 7c1fbf62d..2886f74c0 100644 --- a/niucloud/app/adminapi/route/notice.php +++ b/niucloud/app/adminapi/route/notice.php @@ -32,8 +32,6 @@ Route::group('notice', function () { Route::get('notice/sms/:sms_type', 'notice.Notice/smsConfig'); //短信配置修改 Route::put('notice/sms/:sms_type', 'notice.Notice/editSms'); - //消息发送记录 - Route::get('notice/log', 'notice.Notice/getLogList'); //消息修改 Route::post('notice/edit', 'notice.Notice/edit'); diff --git a/niucloud/app/adminapi/route/route.php b/niucloud/app/adminapi/route/route.php index dfff7b138..d3ec38f0a 100644 --- a/niucloud/app/adminapi/route/route.php +++ b/niucloud/app/adminapi/route/route.php @@ -15,7 +15,7 @@ use think\facade\Route; /** * 路由 */ -Route::group(function () { +Route::group(function() { //用户登录 Route::get('login', 'login.Login/login'); @@ -26,9 +26,7 @@ Route::group(function () { Route::get('captcha/create', 'login.Captcha/create'); //一次校验验证码 Route::get('captcha/check', 'login.Captcha/check'); - - Route::get('test', 'login.Login/test'); }); //加载插件路由 -(new DictLoader("Route"))->load(['app_type' => 'adminapi']); +( new DictLoader("Route") )->load([ 'app_type' => 'adminapi' ]); diff --git a/niucloud/app/adminapi/route/stat.php b/niucloud/app/adminapi/route/stat.php deleted file mode 100644 index 8cc2c50f2..000000000 --- a/niucloud/app/adminapi/route/stat.php +++ /dev/null @@ -1,34 +0,0 @@ -middleware([ - AdminCheckToken::class, - AdminCheckRole::class, - AdminLog::class -]); diff --git a/niucloud/app/adminapi/route/sys.php b/niucloud/app/adminapi/route/sys.php index 631222a3b..58f177855 100644 --- a/niucloud/app/adminapi/route/sys.php +++ b/niucloud/app/adminapi/route/sys.php @@ -86,24 +86,6 @@ Route::group('sys', function() { //地图设置 Route::get('config/map', 'sys.Config/getMap'); - //首页加载设置 - Route::put('config/site_index', 'sys.Config/setSiteIndex'); - //获取首页加载 - Route::get('config/site_index', 'sys.Config/getSiteIndexList'); - - //平台首页加载设置 - Route::put('config/admin_index', 'sys.Config/setAdminIndex'); - //获取平台首页加载 - Route::get('config/admin_index', 'sys.Config/getAdminIndexList'); - - // 获取手机端首页加载 - Route::get('config/wap_index', 'sys.Config/getWapIndexList'); - - //快捷菜单设置 - Route::put('config/shortcut_menu', 'sys.Config/setShortcutMenu'); - //获取快捷菜单 - Route::get('config/shortcut_menu', 'sys.Config/getShortcutMenu'); - //登录注册设置 Route::get('config/login', 'login.Config/getConfig'); //登录注册设置 @@ -274,6 +256,63 @@ Route::group('sys', function() { /***************************************************** 获取布局 ****************************************************/ Route::get('layout', 'sys.System/layout'); Route::put('layout', 'sys.System/setLayout'); + + /***************************************************** 小票打印管理 ****************************************************/ + + // 小票打印机分页列表 + Route::get('printer', 'sys.Printer/pages'); + + // 小票打印机列表 + Route::get('printer/list', 'sys.Printer/lists'); + + // 小票打印机详情 + Route::get('printer/:id', 'sys.Printer/info'); + + // 添加小票打印机 + Route::post('printer', 'sys.Printer/add'); + + // 编辑小票打印机 + Route::put('printer/:id', 'sys.Printer/edit'); + + // 修改小票打印机状态 + Route::put('printer/status', 'sys.Printer/modifyStatus'); + + // 删除小票打印机 + Route::delete('printer/:id', 'sys.Printer/del'); + + // 小票打印模板分页列表 + Route::get('printer/template', 'sys.Printer/templatePageLists'); + + // 小票打印模板列表 + Route::get('printer/template/list', 'sys.Printer/templateLists'); + + // 小票打印模板详情 + Route::get('printer/template/:id', 'sys.Printer/templateInfo'); + + // 添加小票打印模板 + Route::post('printer/template', 'sys.Printer/templateAdd'); + + // 编辑小票打印模板 + Route::put('printer/template/:id', 'sys.Printer/templateEdit'); + + // 删除小票打印模板 + Route::delete('printer/template/:id', 'sys.Printer/templateDel'); + + // 获取小票打印模板类型 + Route::get('printer/type', 'sys.Printer/getType'); + + // 获取小票打印机设备品牌 + Route::get('printer/brand', 'sys.Printer/getBrand'); + + // 刷新易联云打印机token + Route::put('printer/refreshtoken/:id', 'sys.Printer/refreshToken'); + + // 测试易联云打印 + Route::put('printer/testprint/:id', 'sys.Printer/testPrint'); + + // 打印小票内容 + Route::post('printer/printticket', 'sys.Printer/printTicket'); + })->middleware([ AdminCheckToken::class, AdminCheckRole::class, diff --git a/niucloud/app/adminapi/route/user.php b/niucloud/app/adminapi/route/user.php index af7fcd862..d80cb2c56 100644 --- a/niucloud/app/adminapi/route/user.php +++ b/niucloud/app/adminapi/route/user.php @@ -19,6 +19,8 @@ use think\facade\Route; Route::group('user', function () { /***************************************************** 用户 ****************************************************/ Route::get('', 'user.User/lists'); + //全部用户列表 + Route::get('user_all', 'user.User/getUserAll'); //用户详情 Route::get(':uid', 'user.User/info'); //用户新增 diff --git a/niucloud/app/api/controller/login/Login.php b/niucloud/app/api/controller/login/Login.php index 226ad4af8..8f3562388 100644 --- a/niucloud/app/api/controller/login/Login.php +++ b/niucloud/app/api/controller/login/Login.php @@ -11,7 +11,9 @@ namespace app\api\controller\login; +use app\dict\member\MemberLoginTypeDict; use app\service\api\captcha\CaptchaService; +use app\service\api\login\ConfigService; use app\service\api\login\LoginService; use core\base\BaseController; use Exception; @@ -25,20 +27,20 @@ class Login extends BaseController */ public function login() { - $data = $this->request->params([ - ['username', ''], - ['password', ''], + [ 'username', '' ], + [ 'password', '' ], ]); + //校验登录注册配置 + ( new ConfigService() )->checkLoginConfig(MemberLoginTypeDict::USERNAME); //参数验证 //验证码验证 - $result = (new LoginService())->account($data['username'], $data['password']); + $result = ( new LoginService() )->account($data[ 'username' ], $data[ 'password' ]); if (!$result) { //账号密码错误, 重置验证码 return fail('ACCOUNT_OR_PASSWORD_ERROR'); } return success($result); - } /** @@ -47,7 +49,7 @@ class Login extends BaseController */ public function logout() { - (new LoginService)->logout(); + ( new LoginService )->logout(); return success('MEMBER_LOGOUT'); } @@ -57,7 +59,7 @@ class Login extends BaseController */ public function captcha() { - return success((new CaptchaService())->create()); + return success(( new CaptchaService() )->create()); } /** @@ -69,9 +71,9 @@ class Login extends BaseController public function sendMobileCode($type) { $data = $this->request->params([ - ['mobile', ''], + [ 'mobile', '' ], ]); - return success((new LoginService())->sendMobileCode($data['mobile'], $type)); + return success(( new LoginService() )->sendMobileCode($data[ 'mobile' ], $type)); } /** @@ -81,9 +83,11 @@ class Login extends BaseController public function mobile() { $data = $this->request->params([ - ['mobile', ''], + [ 'mobile', '' ], ]); - return success((new LoginService())->mobile($data['mobile'])); + //校验登录注册配置 + ( new ConfigService() )->checkLoginConfig(MemberLoginTypeDict::MOBILE); + return success(( new LoginService() )->mobile($data[ 'mobile' ])); } /** @@ -93,12 +97,12 @@ class Login extends BaseController public function resetPassword() { $data = $this->request->params([ - ['mobile', ''], - ['password', ''] + [ 'mobile', '' ], + [ 'password', '' ] ]); //参数验证 $this->validate($data, 'app\validate\member\Member.reset_password'); - (new LoginService())->resetPassword($data['mobile'], $data['password']); + ( new LoginService() )->resetPassword($data[ 'mobile' ], $data[ 'password' ]); return success('PASSWORD_RESET_SUCCESS'); } } diff --git a/niucloud/app/api/controller/login/Register.php b/niucloud/app/api/controller/login/Register.php index 96b5157b5..2702c9072 100644 --- a/niucloud/app/api/controller/login/Register.php +++ b/niucloud/app/api/controller/login/Register.php @@ -11,6 +11,8 @@ namespace app\api\controller\login; +use app\dict\member\MemberLoginTypeDict; +use app\service\api\login\ConfigService; use app\service\api\login\RegisterService; use core\base\BaseController; use think\Response; @@ -26,14 +28,16 @@ class Register extends BaseController { $data = $this->request->params([ - ['username', ''], - ['password', ''], - ['mobile', ''], + [ 'username', '' ], + [ 'password', '' ], + [ 'mobile', '' ], ]); + //校验登录注册配置 + ( new ConfigService() )->checkLoginConfig(MemberLoginTypeDict::USERNAME); //参数验证 $this->validate($data, 'app\validate\member\Member.account_register'); //验证码验证 - $result = (new RegisterService())->account($data['username'], $data['password'], $data['mobile']); + $result = ( new RegisterService() )->account($data[ 'username' ], $data[ 'password' ], $data[ 'mobile' ]); return success($result); } @@ -44,16 +48,17 @@ class Register extends BaseController public function mobile() { $data = $this->request->params([ - ['mobile', ''], + [ 'mobile', '' ], ]); + //校验登录注册配置 + ( new ConfigService() )->checkLoginConfig(MemberLoginTypeDict::MOBILE); //参数验证 $this->validate($data, [ 'mobile' => 'require|mobile' ]); //验证码验证 - $result = (new RegisterService())->mobile($data['mobile']); + $result = ( new RegisterService() )->mobile($data[ 'mobile' ]); return success($result); } - } diff --git a/niucloud/app/api/controller/member/Account.php b/niucloud/app/api/controller/member/Account.php index a588dce58..0002f3529 100644 --- a/niucloud/app/api/controller/member/Account.php +++ b/niucloud/app/api/controller/member/Account.php @@ -33,10 +33,12 @@ class Account extends BaseApiController public function point(): Response { $data = $this->request->params([ - ['from_type', ''] + ['from_type', ''], + ['amount_type', 'all'],//全部all 收入income 支出disburse + ['create_time', []], ]); $data['account_type'] = MemberAccountTypeDict::POINT; - return success((new MemberAccountService())->getPage($data)); + return success((new MemberAccountService())->getPointPage($data)); } /** @@ -59,9 +61,11 @@ class Account extends BaseApiController public function balanceList(): Response { $data = $this->request->params([ - ['from_type', ''] + ['from_type', ''], + ['trade_type', ''], + ['create_time', []] ]); - return success((new MemberAccountService())->getPages($data)); + return success((new MemberAccountService())->getBalancePage($data)); } /** @@ -98,9 +102,11 @@ class Account extends BaseApiController public function commission(): Response { $data = $this->request->params([ + ['keyword', ''], ['from_type', ''], ['account_data_gt', ''], ['account_data_lt', ''], + ['create_time', []], ]); $data['account_type'] = MemberAccountTypeDict::COMMISSION; return success((new MemberAccountService())->getPage($data)); diff --git a/niucloud/app/api/controller/member/Member.php b/niucloud/app/api/controller/member/Member.php index 3719d9a29..c8a5087af 100644 --- a/niucloud/app/api/controller/member/Member.php +++ b/niucloud/app/api/controller/member/Member.php @@ -15,9 +15,6 @@ use app\service\api\login\AuthService; use app\service\api\member\MemberLogService; use app\service\api\member\MemberService; use core\base\BaseApiController; -use think\db\exception\DataNotFoundException; -use think\db\exception\DbException; -use think\db\exception\ModelNotFoundException; use think\Response; class Member extends BaseApiController diff --git a/niucloud/app/api/controller/sys/Verify.php b/niucloud/app/api/controller/sys/Verify.php index e328c8292..c19835535 100644 --- a/niucloud/app/api/controller/sys/Verify.php +++ b/niucloud/app/api/controller/sys/Verify.php @@ -11,7 +11,6 @@ namespace app\api\controller\sys; -use app\service\api\scan\ScanService; use app\service\api\verify\VerifyService; use core\base\BaseApiController; use think\Response; @@ -64,6 +63,7 @@ class Verify extends BaseApiController ['relate_tag', 0], ['type', ''], ['code', ''], + ['keyword', ''], ['create_time', []] ]); return success(data:(new VerifyService())->getRecordsPageByVerifier($data)); diff --git a/niucloud/app/api/controller/weapp/Weapp.php b/niucloud/app/api/controller/weapp/Weapp.php index 3b81291c7..b5998d346 100644 --- a/niucloud/app/api/controller/weapp/Weapp.php +++ b/niucloud/app/api/controller/weapp/Weapp.php @@ -48,7 +48,6 @@ class Weapp extends BaseApiController return success($weapp_auth_service->register($data[ 'openid' ], $data[ 'mobile' ], $data[ 'mobile_code' ], $data[ 'unionid' ])); } - public function subscribeMessage() { $data = $this->request->params([ [ 'keys', '' ] ]); @@ -68,7 +67,6 @@ class Weapp extends BaseApiController if ($result) { return success([ 'is_trade_managed' => true ]); } - } catch (\Exception $e) { } return success([ 'is_trade_managed' => false ]); @@ -86,7 +84,17 @@ class Weapp extends BaseApiController $wechat_template_service = new WeappDeliveryService(); $result = $wechat_template_service->getMsgJumpPath($data[ 'out_trade_no' ]); return success([ 'path' => $result ]); + } + /** + * 更新openid + * @return Response + */ + public function updateOpenid() + { + $data = $this->request->params([ [ 'code', '' ] ]); + $weapp_auth_service = new WeappAuthService(); + return success($weapp_auth_service->updateOpenid($data[ 'code' ])); } } diff --git a/niucloud/app/api/controller/wechat/Wechat.php b/niucloud/app/api/controller/wechat/Wechat.php index 52d3b2226..9375de9be 100644 --- a/niucloud/app/api/controller/wechat/Wechat.php +++ b/niucloud/app/api/controller/wechat/Wechat.php @@ -13,7 +13,6 @@ namespace app\api\controller\wechat; use app\service\api\wechat\WechatAuthService; use core\base\BaseController; -use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; @@ -27,38 +26,41 @@ class Wechat extends BaseController * 获取跳转获取code * @return Response */ - public function getCodeUrl(){ + public function getCodeUrl() + { $data = $this->request->params([ - ['url', ''], - ['scopes', ''] + [ 'url', '' ], + [ 'scopes', '' ] ]); $wechat_auth_service = new WechatAuthService(); - return success($wechat_auth_service->authorization($data['url'], $data['scopes'])); + return success($wechat_auth_service->authorization($data[ 'url' ], $data[ 'scopes' ])); } /** * code获取微信信息 * @return Response */ - public function getWechatUser(){ + public function getWechatUser() + { $data = $this->request->params([ - ['code', ''], + [ 'code', '' ], ]); $wechat_auth_service = new WechatAuthService(); - $data = $wechat_auth_service->userFromCode($data['code']); - return success(['data'=> json_encode($data)]); + $data = $wechat_auth_service->userFromCode($data[ 'code' ]); + return success([ 'data' => json_encode($data) ]); } /** * 授权信息登录 * @return Response */ - public function wechatLogin(){ + public function wechatLogin() + { $data = $this->request->params([ - ['data', ''], + [ 'data', '' ], ]); $wechat_auth_service = new WechatAuthService(); - [$avatar, $nickname, $openid, $unionid] = json_decode($data['data'], true); + [ $avatar, $nickname, $openid, $unionid ] = json_decode($data[ 'data' ], true); return success($wechat_auth_service->login($openid, $nickname, $avatar, $unionid)); } @@ -69,63 +71,78 @@ class Wechat extends BaseController * @throws DbException * @throws ModelNotFoundException */ - public function login(){ + public function login() + { $data = $this->request->params([ - ['code', ''], + [ 'code', '' ], ]); $wechat_auth_service = new WechatAuthService(); - return success($wechat_auth_service->loginByCode($data['code'])); + return success($wechat_auth_service->loginByCode($data[ 'code' ])); } /** * 注册 * @return Response */ - public function register(){ + public function register() + { $data = $this->request->params([ - ['openid', ''], - ['unionid', ''], - ['mobile', ''], + [ 'openid', '' ], + [ 'unionid', '' ], + [ 'mobile', '' ], ]); //参数验证 $this->validate($data, [ 'mobile' => 'mobile' ]); $wechat_auth_service = new WechatAuthService(); - return success($wechat_auth_service->register($data['openid'], $data['mobile'], wx_unionid: $data['unionid'])); + return success($wechat_auth_service->register($data[ 'openid' ], $data[ 'mobile' ], wx_unionid: $data[ 'unionid' ])); } /** * 同步 * @return Response */ - public function sync(){ + public function sync() + { $data = $this->request->params([ - ['code', ''], + [ 'code', '' ], ]); $wechat_auth_service = new WechatAuthService(); - return success($wechat_auth_service->sync($data['code'])); + return success($wechat_auth_service->sync($data[ 'code' ])); } /** * 获取jssdk config * @return Response */ - public function jssdkConfig(){ + public function jssdkConfig() + { $data = $this->request->params([ - ['url', ''], + [ 'url', '' ], ]); $wechat_auth_service = new WechatAuthService(); - return success($wechat_auth_service->jssdkConfig($data['url'])); + return success($wechat_auth_service->jssdkConfig($data[ 'url' ])); } /** * 扫码登录 * @return Response */ - public function scanLogin(){ + public function scanLogin() + { $wechat_auth_service = new WechatAuthService(); return success($wechat_auth_service->scanLogin()); + } + /** + * 更新openid + * @return Response + */ + public function updateOpenid() + { + $data = $this->request->params([ [ 'code', '' ] ]); + $wechat_auth_service = new WechatAuthService(); + return success($wechat_auth_service->updateOpenid($data[ 'code' ])); } } diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 9468d3e22..a7cb335eb 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -100,8 +100,6 @@ Route::group(function() { Route::get('site', 'sys.Config/site'); //场景域名 Route::get('scene_domain', 'sys.Config/getSceneDomain'); - // 获取手机端首页列表 - Route::get('wap_index', 'sys.Config/getWapIndexList'); // 获取地图设置 Route::get('map', 'sys.Config/getMap'); @@ -144,5 +142,15 @@ Route::group(function() { })->middleware(ApiChannel::class) ->middleware(ApiCheckToken::class) ->middleware(ApiLog::class); + +Route::group(function() { + //公众号更新用户openid + Route::put('wechat/update_openid', 'wechat.Wechat/updateOpenid'); + //小程序更新用户openid + Route::put('weapp/update_openid', 'weapp.Weapp/updateOpenid'); + +})->middleware(ApiChannel::class) + ->middleware(ApiCheckToken::class, true) + ->middleware(ApiLog::class); //加载插件路由 ( new DictLoader("Route") )->load([ 'app_type' => 'api' ]); diff --git a/niucloud/app/command/Menu.php b/niucloud/app/command/Menu.php index fa1eed5e1..3f3bcf7b4 100644 --- a/niucloud/app/command/Menu.php +++ b/niucloud/app/command/Menu.php @@ -7,7 +7,6 @@ use app\service\admin\install\InstallSystemService; use app\service\core\menu\CoreMenuService; use think\console\Command; use think\console\Input; -use think\console\input\Argument; use think\console\input\Option; use think\console\Output; diff --git a/niucloud/app/command/queue/Queue.php b/niucloud/app/command/queue/Queue.php index c5210cb7f..4ad808dd1 100644 --- a/niucloud/app/command/queue/Queue.php +++ b/niucloud/app/command/queue/Queue.php @@ -18,17 +18,16 @@ use Workerman\Worker; class Queue extends Command { use WorkerCommand; + public function configure() { -// 指令配置 + // 指令配置 $this->setName('queue:listen') ->addArgument('action', Argument::OPTIONAL, "start|stop|restart|reload|status|connections", 'start') ->addOption('mode', 'm', Option::VALUE_OPTIONAL, 'Run the workerman server in daemon mode.') ->setDescription('基于Redis的消息队列,支持消息延迟处理。'); } - - /** * 执行任务 * @return void @@ -36,16 +35,15 @@ class Queue extends Command protected function execute(Input $input, Output $output) { $this->resetCli($input, $output); - Worker::$pidFile = runtime_path() .'workerman_queue.pid'; - Worker::$logFile = runtime_path().'workerman.log'; + Worker::$pidFile = runtime_path() . 'workerman_queue.pid'; + Worker::$logFile = runtime_path() . 'workerman.log'; $worker = new Worker(); $worker->name = 'queue_work'; // $worker->count = 3; - $worker->onWorkerStart = function () use($output){ + $worker->onWorkerStart = function() use ($output) { // 定时,每10秒一次 - Timer::add(30, function()use($output) - { - (new SysSchedule())->select(); + Timer::add(30, function() use ($output) { + ( new SysSchedule() )->select(); }); $redis_option = [ 'connect_timeout' => 10, @@ -53,31 +51,31 @@ class Queue extends Command 'retry_seconds' => 5, 'prefix' => md5(root_path()) ]; - if(!empty(env('redis.redis_password'))){ - $redis_option['auth'] = env('redis.redis_password'); + if (!empty(env('redis.redis_password'))) { + $redis_option[ 'auth' ] = env('redis.redis_password'); } - $redis_option['db'] = env('redis.select'); - $client = new Client('redis://'.env('redis.redis_hostname').':'.env('redis.port'), $redis_option); + $redis_option[ 'db' ] = env('redis.select'); + $client = new Client('redis://' . env('redis.redis_hostname') . ':' . env('redis.port'), $redis_option); $queue_list = $this->getAllQueue(); - foreach ($queue_list as $queue_class_name){ + foreach ($queue_list as $queue_class_name) { $queue_class_name = str_replace('.php', '', $queue_class_name); // 订阅 - $client->subscribe($queue_class_name, function($data) use($queue_class_name, $output){ - echo "\n".'['.date('Y-m-d H:i:s').']'." Processing:" . $queue_class_name; - try{ - $class_name = '\\' .$queue_class_name; + $client->subscribe($queue_class_name, function($data) use ($queue_class_name, $output) { + echo "\n" . '[' . date('Y-m-d H:i:s') . ']' . " Processing:" . $queue_class_name; + try { + $class_name = '\\' . $queue_class_name; $class = new $class_name(); $class->fire($data); } catch (\Throwable $e) { - Log::write(date('Y-m-d H:i:s').',队列有错误:'.$queue_class_name.'_'.$e->getMessage().'_'.$e->getFile().'_'.$e->getLine()); + Log::write(date('Y-m-d H:i:s') . ',队列有错误:' . $queue_class_name . '_' . $e->getMessage() . '_' . $e->getFile() . '_' . $e->getLine()); } - echo "\n".'['.date('Y-m-d H:i:s').']'." Processed:" . $queue_class_name; + echo "\n" . '[' . date('Y-m-d H:i:s') . ']' . " Processed:" . $queue_class_name; }); } // 消费失败触发的回调(可选) - $client->onConsumeFailure(function (\Throwable $exception, $package) use($output){ - echo "\n"."队列 " . $package['queue'] . " 消费失败,".$exception->getMessage(); + $client->onConsumeFailure(function(\Throwable $exception, $package) use ($output) { + echo "\n" . "队列 " . $package[ 'queue' ] . " 消费失败," . $exception->getMessage(); }); }; Worker::runAll(); @@ -87,26 +85,27 @@ class Queue extends Command * 捕获所有队列任务 * @return array */ - public function getAllQueue(){ + public function getAllQueue() + { $class_list = []; $system_dir = root_path() . 'app' . DIRECTORY_SEPARATOR . 'job'; $addon_dir = root_path() . 'addon' . DIRECTORY_SEPARATOR; - if(is_dir($system_dir)){ + if (is_dir($system_dir)) { search_dir($system_dir, $app_data, root_path()); $class_list = array_merge($class_list, $app_data); } - $addons = (new CoreAddonService())->getInstallAddonList(); + $addons = ( new CoreAddonService() )->getInstallAddonList(); foreach ($addons as $v) { - $addon_path = $addon_dir .$v['key']. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR. 'job'; + $addon_path = $addon_dir . $v[ 'key' ] . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'job'; if (is_dir($addon_path)) { search_dir($addon_path, $addon_data, root_path()); $class_list = array_merge($class_list, $addon_data); } } - foreach($class_list as &$v){ + foreach ($class_list as &$v) { $v = str_replace('.php', '', $v); $v = str_replace('/', '\\', $v); } diff --git a/niucloud/app/command/schedule/Schedule.php b/niucloud/app/command/schedule/Schedule.php index 4ca17e915..9e90b141d 100644 --- a/niucloud/app/command/schedule/Schedule.php +++ b/niucloud/app/command/schedule/Schedule.php @@ -16,6 +16,7 @@ use Workerman\Worker; class Schedule extends Command { use WorkerCommand; + public function configure() { // 指令配置 @@ -25,8 +26,6 @@ class Schedule extends Command ->setDescription('定时任务,类似linux的crontab。支持秒级别定时。'); } - - /** * 执行任务 * @return void @@ -34,27 +33,27 @@ class Schedule extends Command protected function execute(Input $input, Output $output) { $this->resetCli($input, $output); - Worker::$pidFile = runtime_path() .'workerman_schedule.pid'; + Worker::$pidFile = runtime_path() . 'workerman_schedule.pid'; $worker = new Worker(); $worker->name = 'schedule_work'; $worker->count = 1; - $output->writeln('['.date('Y-m-d H:i:s').']'." Schedule Starting..."); + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Schedule Starting..."); // 设置时区,避免运行结果与预期不一致 date_default_timezone_set('PRC'); - $worker->onWorkerStart = function () use($output){ + $worker->onWorkerStart = function() use ($output) { // // 每分钟的第1秒执行.用于计划任务是否仍在执行 - new Crontab('*/10 * * * * *', function(){ - $file = root_path('runtime').'.schedule'; + new Crontab('*/10 * * * * *', function() { + $file = root_path('runtime') . '.schedule'; file_put_contents($file, time()); }); $core_schedule_service = new CoreScheduleService(); //查询所有的计划任务 - $task_list = $core_schedule_service->getList(['status' => ScheduleDict::ON]); - $output->writeln('['.date('Y-m-d H:i:s').']'." Schedule Started."); + $task_list = $core_schedule_service->getList([ 'status' => ScheduleDict::ON ]); + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Schedule Started."); foreach ($task_list as $item) { //获取定时任务时间字符串 - new Crontab($this->getCrontab($item['time']), function () use ($core_schedule_service, $item, $output) { - if(!empty($item['class'])){ + new Crontab($this->getCrontab($item[ 'time' ]), function() use ($core_schedule_service, $item, $output) { + if (!empty($item[ 'class' ])) { $core_schedule_service->execute($item, $output); } @@ -77,14 +76,14 @@ class Schedule extends Command * @param $data * @return string */ - protected function getCrontab($data): string + protected function getCrontab($data) : string { - $sec = $data['sec'] ?? '*'; - $min = $data['min'] ?? '*'; - $hour = $data['hour'] ?? '*'; - $day = $data['day'] ?? '*'; - $week = $data['week'] ?? '*'; - $type = $data['type'] ?? ''; + $sec = $data[ 'sec' ] ?? '*'; + $min = $data[ 'min' ] ?? '*'; + $hour = $data[ 'hour' ] ?? '*'; + $day = $data[ 'day' ] ?? '*'; + $week = $data[ 'week' ] ?? '*'; + $type = $data[ 'type' ] ?? ''; switch ($type) { case 'sec':// 每隔几秒 $crontab = '*/' . $sec . ' * * * * *'; @@ -99,10 +98,10 @@ class Schedule extends Command $crontab = '0 ' . $min . ' ' . $hour . ' */' . $day . ' * *'; break; case 'week':// 每周一次,周几具体时间执行 - $crontab = '0 ' .$min . ' ' . $hour . ' * * ' . $week; + $crontab = '0 ' . $min . ' ' . $hour . ' * * ' . $week; break; case 'month':// 每月一次,某日具体时间执行 - $crontab = '0 ' .$min . ' ' . $hour . ' ' . $day . ' * *'; + $crontab = '0 ' . $min . ' ' . $hour . ' ' . $day . ' * *'; break; } return $crontab ?? '0 */1 * * * *'; diff --git a/niucloud/app/command/workerman/Workerman.php b/niucloud/app/command/workerman/Workerman.php index f37e749d8..4cfce6da2 100644 --- a/niucloud/app/command/workerman/Workerman.php +++ b/niucloud/app/command/workerman/Workerman.php @@ -21,6 +21,7 @@ use Workerman\Worker; class Workerman extends Command { use WorkerCommand; + public function configure() { // 指令配置 @@ -30,8 +31,6 @@ class Workerman extends Command ->setDescription('Workerman,高性能PHP应用容器'); } - - /** * 执行任务 * @return void @@ -40,48 +39,47 @@ class Workerman extends Command { $this->resetCli($input, $output); //计划任务 - Worker::$pidFile = runtime_path() .'workerman_schedule.pid'; + Worker::$pidFile = runtime_path() . 'workerman_schedule.pid'; $worker = new Worker(); $worker->name = 'schedule_work'; $worker->count = 1; // 设置时区,避免运行结果与预期不一致 date_default_timezone_set('PRC'); - $worker->onWorkerStart = function () use($output){ - $output->writeln('['.date('Y-m-d H:i:s').']'." Schedule Starting..."); + $worker->onWorkerStart = function() use ($output) { + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Schedule Starting..."); // // 每分钟的第1秒执行.用于计划任务是否仍在执行 - new Crontab('*/10 * * * * *', function(){ - $file = root_path('runtime').'.schedule'; + new Crontab('*/10 * * * * *', function() { + $file = root_path('runtime') . '.schedule'; file_put_contents($file, time()); }); $core_schedule_service = new CoreScheduleService(); //查询所有的计划任务 - $task_list = $core_schedule_service->getList(['status' => ScheduleDict::ON]); + $task_list = $core_schedule_service->getList([ 'status' => ScheduleDict::ON ]); foreach ($task_list as $item) { //获取定时任务时间字符串 - new Crontab($this->getCrontab($item['time']), function () use ($core_schedule_service, $item, $output) { - if(!empty($item['class'])){ + new Crontab($this->getCrontab($item[ 'time' ]), function() use ($core_schedule_service, $item, $output) { + if (!empty($item[ 'class' ])) { $core_schedule_service->execute($item, $output); } }); } - $output->writeln('['.date('Y-m-d H:i:s').']'." Schedule Started."); + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Schedule Started."); }; //消息队列 - Worker::$pidFile = runtime_path() .'workerman_queue.pid'; - Worker::$logFile = runtime_path().'workerman.log'; + Worker::$pidFile = runtime_path() . 'workerman_queue.pid'; + Worker::$logFile = runtime_path() . 'workerman.log'; $worker = new Worker(); $worker->name = 'queue_work'; // $worker->count = 3; - $worker->onWorkerStart = function () use($output){ - $output->writeln('['.date('Y-m-d H:i:s').']'." Queue Starting..."); + $worker->onWorkerStart = function() use ($output) { + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Queue Starting..."); // 定时,每10秒一次 - Timer::add(30, function()use($output) - { - (new SysSchedule())->select(); + Timer::add(30, function() use ($output) { + ( new SysSchedule() )->select(); }); $redis_option = [ 'connect_timeout' => 10, @@ -89,33 +87,33 @@ class Workerman extends Command 'retry_seconds' => 5, 'prefix' => md5(root_path()) ]; - if(!empty(env('redis.redis_password'))){ - $redis_option['auth'] = env('redis.redis_password'); + if (!empty(env('redis.redis_password'))) { + $redis_option[ 'auth' ] = env('redis.redis_password'); } - $redis_option['db'] = env('redis.select'); - $client = new Client('redis://'.env('redis.redis_hostname').':'.env('redis.port'), $redis_option); + $redis_option[ 'db' ] = env('redis.select'); + $client = new Client('redis://' . env('redis.redis_hostname') . ':' . env('redis.port'), $redis_option); $queue_list = $this->getAllQueue(); - foreach ($queue_list as $queue_class_name){ + foreach ($queue_list as $queue_class_name) { $queue_class_name = str_replace('.php', '', $queue_class_name); // 订阅 - $client->subscribe($queue_class_name, function($data) use($queue_class_name, $output){ - $output->writeln('[queue]['.date('Y-m-d H:i:s').']'." Processing:" . $queue_class_name); - try{ - $class_name = '\\' .$queue_class_name; + $client->subscribe($queue_class_name, function($data) use ($queue_class_name, $output) { + $output->writeln('[queue][' . date('Y-m-d H:i:s') . ']' . " Processing:" . $queue_class_name); + try { + $class_name = '\\' . $queue_class_name; $class = new $class_name(); $class->fire($data); } catch (\Throwable $e) { - Log::write(date('Y-m-d H:i:s').',队列有错误:'.$queue_class_name.'_'.$e->getMessage().'_'.$e->getFile().'_'.$e->getLine()); + Log::write(date('Y-m-d H:i:s') . ',队列有错误:' . $queue_class_name . '_' . $e->getMessage() . '_' . $e->getFile() . '_' . $e->getLine()); } - $output->writeln('[queue]['.date('Y-m-d H:i:s').']'." Processed:" . $queue_class_name); + $output->writeln('[queue][' . date('Y-m-d H:i:s') . ']' . " Processed:" . $queue_class_name); }); } // 消费失败触发的回调(可选) - $client->onConsumeFailure(function (\Throwable $exception, $package) use($output){ - $output->writeln('[queue]队列 ' . $package['queue'] . " 消费失败,".$exception->getMessage()); + $client->onConsumeFailure(function(\Throwable $exception, $package) use ($output) { + $output->writeln('[queue]队列 ' . $package[ 'queue' ] . " 消费失败," . $exception->getMessage()); }); - $output->writeln('['.date('Y-m-d H:i:s').']'." Queue Started."); + $output->writeln('[' . date('Y-m-d H:i:s') . ']' . " Queue Started."); }; Worker::runAll(); } @@ -133,14 +131,14 @@ class Workerman extends Command * @param $data * @return string */ - protected function getCrontab($data): string + protected function getCrontab($data) : string { - $sec = $data['sec'] ?? '*'; - $min = $data['min'] ?? '*'; - $hour = $data['hour'] ?? '*'; - $day = $data['day'] ?? '*'; - $week = $data['week'] ?? '*'; - $type = $data['type'] ?? ''; + $sec = $data[ 'sec' ] ?? '*'; + $min = $data[ 'min' ] ?? '*'; + $hour = $data[ 'hour' ] ?? '*'; + $day = $data[ 'day' ] ?? '*'; + $week = $data[ 'week' ] ?? '*'; + $type = $data[ 'type' ] ?? ''; switch ($type) { case 'sec':// 每隔几秒 $crontab = '*/' . $sec . ' * * * * *'; @@ -155,10 +153,10 @@ class Workerman extends Command $crontab = '0 ' . $min . ' ' . $hour . ' */' . $day . ' * *'; break; case 'week':// 每周一次,周几具体时间执行 - $crontab = '0 ' .$min . ' ' . $hour . ' * * ' . $week; + $crontab = '0 ' . $min . ' ' . $hour . ' * * ' . $week; break; case 'month':// 每月一次,某日具体时间执行 - $crontab = '0 ' .$min . ' ' . $hour . ' ' . $day . ' * *'; + $crontab = '0 ' . $min . ' ' . $hour . ' ' . $day . ' * *'; break; } return $crontab ?? '0 */1 * * * *'; @@ -168,26 +166,27 @@ class Workerman extends Command * 捕获所有队列任务 * @return array */ - public function getAllQueue(){ + public function getAllQueue() + { $class_list = []; $system_dir = root_path() . 'app' . DIRECTORY_SEPARATOR . 'job'; $addon_dir = root_path() . 'addon' . DIRECTORY_SEPARATOR; - if(is_dir($system_dir)){ + if (is_dir($system_dir)) { search_dir($system_dir, $app_data, root_path()); $class_list = array_merge($class_list, $app_data); } - $addons = (new CoreAddonService())->getInstallAddonList(); + $addons = ( new CoreAddonService() )->getInstallAddonList(); foreach ($addons as $v) { - $addon_path = $addon_dir .$v['key']. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR. 'job'; + $addon_path = $addon_dir . $v[ 'key' ] . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'job'; if (is_dir($addon_path)) { search_dir($addon_path, $addon_data, root_path()); $class_list = array_merge($class_list, $addon_data); } } - foreach($class_list as &$v){ + foreach ($class_list as &$v) { $v = str_replace('.php', '', $v); $v = str_replace('/', '\\', $v); } diff --git a/niucloud/app/dict/addon/AddonDict.php b/niucloud/app/dict/addon/AddonDict.php index 67d1966ac..69890efb6 100644 --- a/niucloud/app/dict/addon/AddonDict.php +++ b/niucloud/app/dict/addon/AddonDict.php @@ -36,7 +36,7 @@ class AddonDict // 插件关键字黑名单 const ADDON_KEY_BLACK_LIST = [ - 'addon', 'aliapp', 'app', 'applet', 'auht', 'channel', 'dict', 'diy', 'generator', 'home', 'member', 'niucloud', + 'addon', 'aliapp', 'app', 'applet', 'auth', 'channel', 'dict', 'diy', 'generator', 'home', 'member', 'niucloud', 'notice', 'pay', 'site', 'sys', 'upload', 'home', 'user', 'weapp', 'wechat' ]; diff --git a/niucloud/app/dict/diy/ComponentDict.php b/niucloud/app/dict/diy/ComponentDict.php index 27662de22..abd3706c6 100644 --- a/niucloud/app/dict/diy/ComponentDict.php +++ b/niucloud/app/dict/diy/ComponentDict.php @@ -552,6 +552,8 @@ class ComponentDict 'value' => [ "imageSize" => 40, "aroundRadius" => 0, + 'style' => 'style-1', + "styleName" => "风格一", "bottomPosition" => "lowerRight", // 左上:upperLeft,右上:upperRight,左下:lowerLeft,右下:lowerRight "list" => [ [ diff --git a/niucloud/app/dict/diy/LinkDict.php b/niucloud/app/dict/diy/LinkDict.php index 5b77d1888..e149ded70 100644 --- a/niucloud/app/dict/diy/LinkDict.php +++ b/niucloud/app/dict/diy/LinkDict.php @@ -114,7 +114,14 @@ class LinkDict 'url' => '/app/pages/verify/index', 'is_share' => 1, 'action' => '' - ] + ], + [ + 'name' => 'MEMBER_CONTACT', + 'title' => get_lang('dict_diy.member_contact'), + 'url' => '/app/pages/member/contact', + 'is_share' => 1, + 'action' => '' + ], ] ], 'DIY_PAGE' => [ diff --git a/niucloud/app/dict/diy/PagesDict.php b/niucloud/app/dict/diy/PagesDict.php index 3da0fdf78..31a896502 100644 --- a/niucloud/app/dict/diy/PagesDict.php +++ b/niucloud/app/dict/diy/PagesDict.php @@ -62,7 +62,7 @@ class PagesDict "margin" => [ "top" => 10, "bottom" => 10, - "both" => 16 + "both" => 10 ], "ignore" => [], "list" => [] @@ -152,10 +152,11 @@ class PagesDict 'topStatusBar' => [ 'isShow' => true, 'bgColor' => "#ffffff", - 'isTransparent' => false, + 'rollBgColor' => "#ffffff", 'style' => 'style-1', 'styleName' => '风格1', 'textColor' => "#333333", + 'rollTextColor' => "#333333", 'textAlign' => 'center', 'inputPlaceholder' => '请输入搜索关键词', 'imgUrl' => '', @@ -217,16 +218,17 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 0, - "both" => 12 + "both" => 10 ] ], - 'topStatusBar' => [ + "topStatusBar" => [ 'isShow' => true, 'bgColor' => "#ffffff", - 'isTransparent' => false, + 'rollBgColor' => "#ffffff", 'style' => 'style-1', 'styleName' => '风格1', 'textColor' => "#333333", + 'rollTextColor' => "#333333", 'textAlign' => 'center', 'inputPlaceholder' => '请输入搜索关键词', 'imgUrl' => '', @@ -269,7 +271,7 @@ class PagesDict "margin" => [ "top" => 12, "bottom" => 6, - "both" => 16 + "both" => 10 ], "style" => "style-1", "styleName" => "风格1", @@ -306,7 +308,7 @@ class PagesDict "margin" => [ "top" => 6, "bottom" => 0, - "both" => 16 + "both" => 10 ] ], [ @@ -359,7 +361,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 0, - "both" => 16 + "both" => 10 ] ], [ @@ -400,7 +402,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 6, - "both" => 16 + "both" => 10 ], "ignore" => [], "list" => [ @@ -467,7 +469,11 @@ class PagesDict [ "title" => "联系客服", "link" => [ - "name" => "" + "name" => "MEMBER_CONTACT", + "parent" => "MEMBER_LINK", + "title" => "客服", + "url" => "/app/pages/member/contact", + "action" => "" ], "imageUrl" => "static/resource/images/diy/horz_m_service.png", "label" => [ @@ -570,7 +576,11 @@ class PagesDict [ "title" => "联系客服", "link" => [ - "name" => "" + "name" => "MEMBER_CONTACT", + "parent" => "MEMBER_LINK", + "title" => "客服", + "url" => "/app/pages/member/contact", + "action" => "" ], "imageUrl" => "static/resource/images/diy/vert_m_service.png", "label" => [ @@ -618,7 +628,7 @@ class PagesDict "margin" => [ "top" => 6, "bottom" => 12, - "both" => 16 + "both" => 10 ] ] ] @@ -660,7 +670,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 0, - "both" => 12 + "both" => 10 ] ], 'topStatusBar' => [ @@ -749,7 +759,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 0, - "both" => 16 + "both" => 10 ] ], [ @@ -802,7 +812,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 0, - "both" => 16 + "both" => 10 ] ], [ @@ -843,7 +853,7 @@ class PagesDict "margin" => [ "top" => 0, "bottom" => 6, - "both" => 16 + "both" => 10 ], "ignore" => [], "list" => [ @@ -910,7 +920,11 @@ class PagesDict [ "title" => "联系客服", "link" => [ - "name" => "" + "name" => "MEMBER_CONTACT", + "parent" => "MEMBER_LINK", + "title" => "客服", + "url" => "/app/pages/member/contact", + "action" => "" ], "imageUrl" => "static/resource/images/diy/horz_m_service.png", "label" => [ @@ -1013,7 +1027,11 @@ class PagesDict [ "title" => "联系客服", "link" => [ - "name" => "" + "name" => "MEMBER_CONTACT", + "parent" => "MEMBER_LINK", + "title" => "客服", + "url" => "/app/pages/member/contact", + "action" => "" ], "imageUrl" => "static/resource/images/diy/vert_m_service.png", "label" => [ @@ -1061,7 +1079,7 @@ class PagesDict "margin" => [ "top" => 6, "bottom" => 12, - "both" => 16 + "both" => 10 ] ] diff --git a/niucloud/app/dict/member/MemberLevelDict.php b/niucloud/app/dict/member/MemberLevelDict.php index f80a152e1..d91475247 100644 --- a/niucloud/app/dict/member/MemberLevelDict.php +++ b/niucloud/app/dict/member/MemberLevelDict.php @@ -24,49 +24,49 @@ class MemberLevelDict { return [ +// 'level_1' => [ +// 'bg_color' => '#414852', +// 'level_color' => '#666666', +// 'progress' => ['#999999','#666666'], +// 'gift'=> '#ECEBEB', +// ], 'level_1' => [ - 'bg_color' => '#414852', - 'level_color' => '#666666', - 'progress' => ['#999999','#666666'], - 'gift'=> '#ECEBEB', - ], - 'level_2' => [ 'bg_color' => '#354B54', 'level_color' => '#116787', 'progress' => ['#4BA5C7','#116787'], 'gift'=> '#F1FDFF', ], - 'level_3' => [ + 'level_2' => [ 'bg_color' => '#203B54', 'level_color' => '#286BAA', 'progress' => ['#529BDF','#286BAA'], 'gift'=> '#E3F2FF', ], - 'level_4' => [ + 'level_3' => [ 'bg_color' => '#403E32', 'level_color' => '#967600', 'progress' => ['#D1A400','#967600'], 'gift'=> '#FFFAE3', ], - 'level_5' => [ + 'level_4' => [ 'bg_color' => '#36354B', 'level_color' => '#4B3EF9', 'progress' => ['#8F87FF','#4B3EF9'], 'gift'=> '#E7EEFF', ], - 'level_6' => [ + 'level_5' => [ 'bg_color' => '#362F28', 'level_color' => '#9F5300', 'progress' => ['#EFA244','#9F5300'], 'gift'=> '#FFF5DC', ], - 'level_7' => [ + 'level_6' => [ 'bg_color' => '#322432', 'level_color' => '#DE43D6', 'progress' => ['#FFA0FA','#DE43D6'], 'gift'=> '#FFEAFF', ], - 'level_8' => [ + 'level_7' => [ 'bg_color' => '#301C1E', 'level_color' => '#DE000B', 'progress' => ['#FF8B36','#DE000B'], @@ -74,4 +74,4 @@ class MemberLevelDict ], ]; } -} +} \ No newline at end of file diff --git a/niucloud/app/dict/member/account_change_type.php b/niucloud/app/dict/member/account_change_type.php index c24df63ba..a88c53535 100644 --- a/niucloud/app/dict/member/account_change_type.php +++ b/niucloud/app/dict/member/account_change_type.php @@ -112,6 +112,8 @@ return [ 'inc' => 1, //是否减少 'dec' => 0, + //是否累增 + 'is_change_get' => 0, ], //会员升级礼包 'level_upgrade' => [ @@ -160,6 +162,8 @@ return [ 'inc' => 0, //是否减少 'dec' => 1, + //是否累增 + 'is_change_get' => 0, ], ], //会员佣金 @@ -182,6 +186,8 @@ return [ 'inc' => 0, //是否减少 'dec' => 1, + //是否累增 + 'is_change_get' => 0, ], ] ]; diff --git a/niucloud/app/dict/menu/admin.php b/niucloud/app/dict/menu/admin.php index 41bd0ae6e..edefcc555 100644 --- a/niucloud/app/dict/menu/admin.php +++ b/niucloud/app/dict/menu/admin.php @@ -2201,7 +2201,7 @@ return [ 'router_path' => 'setting/agreement', 'view_path' => 'setting/agreement', 'methods' => 'get', - 'sort' => '80', + 'sort' => '100', 'status' => '1', 'is_show' => '1', ], @@ -2289,7 +2289,7 @@ return [ 'router_path' => 'setting/storage', 'view_path' => 'setting/storage', 'methods' => 'get', - 'sort' => '30', + 'sort' => '98', 'status' => '1', 'is_show' => '1', 'children' => [ @@ -2333,7 +2333,7 @@ return [ 'router_path' => 'setting/export', 'view_path' => 'setting/export', 'methods' => 'get', - 'sort' => '30', + 'sort' => '97', 'status' => '1', 'is_show' => '1', 'children' => [ @@ -2352,7 +2352,123 @@ return [ 'is_show' => '1', ] ] - ] + ], + [ + '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/', + '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/', + '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/', + '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/', + 'router_path' => 'printer/template/edit', + 'view_path' => 'printer/template_edit', + 'methods' => 'put', + 'sort' => '0', + 'status' => '1', + 'is_show' => '0', + ], ] ], diff --git a/niucloud/app/dict/poster/ComponentDict.php b/niucloud/app/dict/poster/ComponentDict.php index f8f206941..691d4536f 100644 --- a/niucloud/app/dict/poster/ComponentDict.php +++ b/niucloud/app/dict/poster/ComponentDict.php @@ -37,6 +37,10 @@ class ComponentDict 'sort' => 10000, 'relate' => '', // 关联字段,空为不处理// 组件属性 'value' => '文本内容', + 'template' => [ + "width" => 165, // 宽度 + 'height' => 53 // 高度 + ] ], 'Image' => [ 'title' => "图片", @@ -68,10 +72,11 @@ class ComponentDict 'relate' => 'headimg', // 关联字段,空为不处理 'value' => '', 'template' => [ - "width" => 50, // 宽度 - 'height' => 50, // 高度 - 'minWidth' => 30, // 最小宽度 - 'minHeight' => 30, // 最小高度 + "width" => 100, // 宽度 + 'height' => 100, // 高度 + 'minWidth' => 60, // 最小宽度 + 'minHeight' => 60, // 最小高度 + 'shape' => 'circle' ], ], 'NickName' => [ @@ -84,10 +89,10 @@ class ComponentDict 'relate' => 'nickname', // 关联字段,空为不处理 'value' => '', 'template' => [ - "width" => 50, // 宽度 - 'height' => 50, // 高度 - 'minWidth' => 30, // 最小宽度 - 'minHeight' => 30, // 最小高度 + "width" => 164, // 宽度 + 'height' => 55, // 高度 + 'minWidth' => 120, // 最小宽度 + 'minHeight' => 50, // 最小高度 ], ], 'Draw' => [ @@ -100,10 +105,10 @@ class ComponentDict 'relate' => '', // 关联字段,空为不处理 'value' => '', 'template' => [ - "width" => 100, // 宽度 - 'height' => 100, // 高度 - 'minWidth' => 30, // 最小宽度 - 'minHeight' => 30, // 最小高度 + "width" => 200, // 宽度 + 'height' => 200, // 高度 + 'minWidth' => 60, // 最小宽度 + 'minHeight' => 60, // 最小高度 'drawType' => 'Polygon', 'bgColor' => '#eeeeee', 'points' => [], // [x,y]:左上,右上,右下,左下 diff --git a/niucloud/app/dict/schedule/schedule.php b/niucloud/app/dict/schedule/schedule.php index 53966d447..d291254db 100644 --- a/niucloud/app/dict/schedule/schedule.php +++ b/niucloud/app/dict/schedule/schedule.php @@ -12,28 +12,5 @@ return [ 'class' => '', 'function' => '' ], - [ - 'key' => 'site_expire_close', - 'name' => '站点到期自动关闭', - 'desc' => '', - 'time' => [ - 'type' => 'day', - 'day' => 1, - 'hour' => 1, - 'min' => 1 - ], - 'class' => 'app\job\schedule\SiteExpireClose', - 'function' => '' - ], - [ - 'key' => 'site_stat', - 'name' => '站点统计', - 'desc' => '', - 'time' => [ - 'type' => 'hour', - 'hour' => 1, - ], - 'class' => 'app\job\schedule\SiteStatJob', - 'function' => '' - ] ]; + diff --git a/niucloud/app/dict/site/SiteAccountLogDict.php b/niucloud/app/dict/site/SiteAccountLogDict.php deleted file mode 100644 index c9b95b670..000000000 --- a/niucloud/app/dict/site/SiteAccountLogDict.php +++ /dev/null @@ -1,33 +0,0 @@ - get_lang('dict_site.pay'),//支付 - self::REFUND => get_lang('dict_site.refund'),//退款 - self::TRANSFER => get_lang('dict_site.transfer'),//转账 - ]; - } - -} diff --git a/niucloud/app/dict/site/SiteDict.php b/niucloud/app/dict/site/SiteDict.php deleted file mode 100644 index 3edbf95dc..000000000 --- a/niucloud/app/dict/site/SiteDict.php +++ /dev/null @@ -1,35 +0,0 @@ - get_lang('dict_site.status_on'),//正常 - self::EXPIRE => get_lang('dict_site.status_expire'),//过期 - self::CLOSE => get_lang('dict_site.status_close'),//停止 - ]; - } - -} diff --git a/niucloud/app/dict/sys/ConfigKeyDict.php b/niucloud/app/dict/sys/ConfigKeyDict.php index efc70e8a8..510a936a3 100644 --- a/niucloud/app/dict/sys/ConfigKeyDict.php +++ b/niucloud/app/dict/sys/ConfigKeyDict.php @@ -30,8 +30,6 @@ class ConfigKeyDict public const H5 = 'h5';//h5 - public const WXOPLATFORM = 'WXOPLATFORM'; // 微信开放平台 - public const WEAPP_AUTHORIZATION_INFO = 'weapp_authorization_info'; public const WECHAT_AUTHORIZATION_INFO = 'wechat_authorization_info'; diff --git a/niucloud/app/dict/sys/FileDict.php b/niucloud/app/dict/sys/FileDict.php index c2e4d3152..93f5f0ea2 100644 --- a/niucloud/app/dict/sys/FileDict.php +++ b/niucloud/app/dict/sys/FileDict.php @@ -30,6 +30,8 @@ class FileDict public const MID = 'mid';//小程序上传 public const SMALL = 'small'; + public const EXCEL = 'excel';//excel导入 + /** * 附件类型 * @return array @@ -68,6 +70,7 @@ class FileDict self::IMAGE,//图片上传 self::VIDEO,//视频上传 self::APPLET,//小程序包上传 + self::EXCEL,//excel导入 ]; } @@ -83,4 +86,4 @@ class FileDict self::SMALL,//图片上传 ]; } -} +} \ No newline at end of file diff --git a/niucloud/app/dict/sys/PrinterDict.php b/niucloud/app/dict/sys/PrinterDict.php new file mode 100644 index 000000000..3a9b3a53c --- /dev/null +++ b/niucloud/app/dict/sys/PrinterDict.php @@ -0,0 +1,62 @@ + get_lang('dict_printer.yilianyun'), // 易联云打印机 + ]; + if ($brand == '') return $list; + return $list[ $brand ] ?? ''; + } + + /** + * 获取打印机模板类型 + * @param string $type + * @return array|null + */ + public static function getType($type = '') + { + $system_type = []; + + $type_list = ( new DictLoader("Printer") )->load($system_type); + + if ($type == '') { + return $type_list; + } else { + $data = []; + foreach ($type_list as $k => $v) { + if ($v[ 'key' ] == $type) { + $data = $v; + break; + } + } + return $data; + } + + } + +} \ No newline at end of file diff --git a/niucloud/app/event.php b/niucloud/app/event.php index 34eebcf15..104b46a6d 100644 --- a/niucloud/app/event.php +++ b/niucloud/app/event.php @@ -47,18 +47,10 @@ $system_event = [ ], //协议类型加载 'AgreementType' => [], - //站点首页加载 - 'SiteIndex' => [ - 'app\listener\system\SiteIndexListener' - ], // 站点端布局 'SiteLayout' => [ 'app\listener\system\SiteLayout' ], - //平台首页加载 - 'AdminIndex' => [ - 'app\listener\system\AdminIndexListener' - ], 'BottomNavigation' => [ 'app\listener\system\BottomNavigationListener' ], @@ -88,12 +80,12 @@ $system_event = [ //导出数据类型 'ExportDataType' => [ //会员导出 - 'app\listener\member\MemberExportTypeListener', + 'app\listener\member_export\MemberExportTypeListener', ], //导出数据源 'ExportData' => [ //会员导出 - 'app\listener\member\MemberExportDataListener', + 'app\listener\member_export\MemberExportDataListener', ], //统计执行 'StatExecute' => [], diff --git a/niucloud/app/install/controller/Index.php b/niucloud/app/install/controller/Index.php index 37bdf4cbd..72fef3603 100644 --- a/niucloud/app/install/controller/Index.php +++ b/niucloud/app/install/controller/Index.php @@ -38,7 +38,7 @@ class Index extends BaseInstall $host = ( empty($_SERVER[ 'REMOTE_ADDR' ]) ? $_SERVER[ 'REMOTE_HOST' ] : $_SERVER[ 'REMOTE_ADDR' ] ); $name = $_SERVER[ 'SERVER_NAME' ]; - $verison = !(version_compare(PHP_VERSION, '8.0.0') == -1); + $verison = !( version_compare(PHP_VERSION, '8.0.0') == -1 ); //pdo $pdo = extension_loaded('pdo') && extension_loaded('pdo_mysql'); $system_variables[] = [ "name" => "pdo", "need" => "开启", "status" => $pdo ]; @@ -71,9 +71,9 @@ class Index extends BaseInstall [ "path" => $project_path . DIRECTORY_SEPARATOR . 'web', "path_name" => "web/", "name" => "web端源码目录" ], [ "path" => $root_path . DIRECTORY_SEPARATOR . ".env", "path_name" => "niucloud/.env", "name" => "env" ], [ "path" => $root_path . DIRECTORY_SEPARATOR . ".example.env", "path_name" => "niucloud/.example_env", "name" => "env" ], - [ "path" => $root_path . DIRECTORY_SEPARATOR . 'runtime'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/runtime", "name" => "runtime" ], - [ "path" => $root_path . DIRECTORY_SEPARATOR . 'public'.DIRECTORY_SEPARATOR.'upload'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/public/upload", "name" => "upload" ], - [ "path" => $root_path . DIRECTORY_SEPARATOR . 'app'.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/app/install", "name" => "安装目录" ] + [ "path" => $root_path . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/runtime", "name" => "runtime" ], + [ "path" => $root_path . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/public/upload", "name" => "upload" ], + [ "path" => $root_path . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/app/install", "name" => "安装目录" ] ]; //目录 可读 可写检测 $is_dir = true; @@ -109,10 +109,11 @@ class Index extends BaseInstall } } - public function build() { + public function build() + { $install_user = Cache::get('install_user'); - $token = (new LoginService())->login($install_user['username'], $install_user['password']); - $this->assign('token', $token['token']); + $token = ( new LoginService() )->login($install_user[ 'username' ], $install_user[ 'password' ]); + $this->assign('token', $token[ 'token' ]); return $this->fetch('index/step-4'); } @@ -169,16 +170,24 @@ class Index extends BaseInstall ]; } else { - if (@mysqli_select_db($conn, $dbname)) { - $result = [ - "status" => 2, - "message" => "数据库存在,系统将覆盖数据库" - ]; - } else { + try { + if (@mysqli_select_db($conn, $dbname)) { + $result = [ + "status" => 2, + "message" => "数据库存在,系统将覆盖数据库" + ]; + } else { + $result = [ + "status" => 1, + "message" => "数据库不存在,系统将自动创建" + ]; + } + } catch (Exception $e) { $result = [ "status" => 1, "message" => "数据库不存在,系统将自动创建" ]; + return fail($result); } } @mysqli_close($conn); @@ -191,7 +200,7 @@ class Index extends BaseInstall } return success($result); - } catch ( Exception $e) { + } catch (Exception $e) { $result = [ "status" => -1, "message" => $e->getMessage() @@ -219,7 +228,7 @@ class Index extends BaseInstall $sqls = explode("\n", trim($sql)); $sqls = array_filter($sqls); foreach ($sqls as $query) { - $str1 = $query[0] ?? ''; + $str1 = $query[ 0 ] ?? ''; if ($str1 != '#' && $str1 != '-') $sql_query[ $num ] .= $query; } @@ -272,9 +281,9 @@ class Index extends BaseInstall } Cache::set('install_status', 1);//成功 - Cache::set('install_user', ['username' => $username, 'password' => $password]); + Cache::set('install_user', [ 'username' => $username, 'password' => $password ]); return success(); - } catch ( Exception $e) { + } catch (Exception $e) { $this->setSuccessLog([ '安装失败' . $e->getMessage(), 'error' ]); return fail('安装失败' . $e->getMessage()); } @@ -304,7 +313,7 @@ class Index extends BaseInstall return fail('菜单初始化失败'); } //初始化计划任务 - $res = ( new CoreScheduleInstallService())->installSystemSchedule(); + $res = ( new CoreScheduleInstallService() )->installSystemSchedule(); if (!$res) { $this->setSuccessLog([ '计划任务初始化失败', 'error' ]); return fail('计划任务初始化失败'); @@ -333,7 +342,7 @@ class Index extends BaseInstall Cache::set('install_status', 2);//成功 return success(); - } catch ( Exception $e) { + } catch (Exception $e) { $this->setSuccessLog([ '安装失败' . $e->getMessage(), 'error' ]); return fail('安装失败' . $e->getMessage()); } @@ -343,7 +352,8 @@ class Index extends BaseInstall * 安装插件 * @return true */ - public function installAddon() { + public function installAddon() + { $root_path = str_replace("\\", DIRECTORY_SEPARATOR, dirname(__FILE__, 4)); $root_path = str_replace("../", DIRECTORY_SEPARATOR, $root_path); $addon_path = $root_path . DIRECTORY_SEPARATOR . 'addon'; @@ -351,9 +361,9 @@ class Index extends BaseInstall $files = get_files_by_dir($addon_path); if (!empty($files)) { foreach ($files as $path) { - $data = (new CoreAddonService())->getAddonConfig($path); - if (isset($data['key'])) { - $install_service = (new CoreAddonInstallService($data['key'])); + $data = ( new CoreAddonService() )->getAddonConfig($path); + if (isset($data[ 'key' ])) { + $install_service = ( new CoreAddonInstallService($data[ 'key' ]) ); $install_service->installCheck(); $install_service->install(); } @@ -434,7 +444,7 @@ class Index extends BaseInstall $sql_item = $this->str_replace_first($table_name, $new_table_name, $sql); @mysqli_query($conn, $sql_item); if ($is_write) $this->setSuccessLog([ '创建表' . $table_name, 'success' ]); - } catch ( Exception $e) { + } catch (Exception $e) { $this->setSuccessLog([ $e->getMessage(), 'error' ]); return fail('数据库解析失败' . $e->getMessage()); } @@ -506,7 +516,7 @@ class Index extends BaseInstall if ($data[ 1 ] == 'error') { Cache::set('install_status', -1); } - $time = @(int)microtime(true); + $time = @(int) microtime(true); $data[] = date('Y-m-d H:i:s', $time); $install_data = Cache::get('install_data') ?? []; $install_data[] = $data; diff --git a/niucloud/app/install/source/database.sql b/niucloud/app/install/source/database.sql index fb12ad753..2294bd9bb 100644 --- a/niucloud/app/install/source/database.sql +++ b/niucloud/app/install/source/database.sql @@ -1,11 +1,13 @@  +SET NAMES utf8mb4; + DROP TABLE IF EXISTS `account_log`; CREATE TABLE `account_log` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `type` varchar(255) NOT NULL DEFAULT 'pay' COMMENT '账单类型pay,refund,transfer', - `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '交易金额', + `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '交易金额', `trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '对应类型交易单号', - `create_time` varchar(255) NOT NULL DEFAULT '0' COMMENT '添加时间', + `create_time` varchar(255) NOT NULL DEFAULT 0 COMMENT '添加时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='站点账单记录'; @@ -15,20 +17,21 @@ CREATE TABLE `addon` ( `title` varchar(40) NOT NULL DEFAULT '' COMMENT '插件名称', `icon` varchar(255) NOT NULL DEFAULT '' COMMENT '插件图标', `key` varchar(20) NOT NULL DEFAULT '' COMMENT '插件标识', - `desc` text COMMENT '插件描述', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态', + `desc` text NULL COMMENT '插件描述', + `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态', `author` varchar(40) NOT NULL DEFAULT '' COMMENT '作者', `version` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `install_time` int(11) NOT NULL DEFAULT '0' COMMENT '安装时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `install_time` int(11) NOT NULL DEFAULT 0 COMMENT '安装时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', `cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面', `type` varchar(255) NOT NULL DEFAULT 'app' COMMENT '插件类型app,addon', `support_app` varchar(255) NOT NULL DEFAULT '' COMMENT '插件支持的应用空表示通用插件', - `is_star` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否加星', + `is_star` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否加星', `compile` varchar(2000) NOT NULL DEFAULT '' COMMENT '编译端口', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='插件表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '插件表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `addon_log`; CREATE TABLE `addon_log` ( @@ -37,37 +40,40 @@ CREATE TABLE `addon_log` ( `key` varchar(20) NOT NULL DEFAULT '' COMMENT '插件标识', `from_version` varchar(20) NOT NULL DEFAULT '' COMMENT '升级前的版本号', `to_version` varchar(20) NOT NULL DEFAULT '' COMMENT '升级后的版本号', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='插件日志表'; + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '插件日志表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `applet_site_version`; CREATE TABLE `applet_site_version` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', - `version_id` int(11) NOT NULL DEFAULT '0' COMMENT '版本id', + `version_id` int(11) NOT NULL DEFAULT 0 COMMENT '版本id', `type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型', `action` varchar(20) NOT NULL DEFAULT '' COMMENT '操作方式 download 下载 upgrade 更新', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='站点小程序版本表'; + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '站点小程序版本表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `applet_version`; CREATE TABLE `applet_version` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `config` varchar(255) NOT NULL DEFAULT '' COMMENT '配置信息', `type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型', - `desc` text COMMENT '插件描述', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 下架 上架', + `desc` text NULL COMMENT '插件描述', + `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态 下架 上架', `uid` varchar(40) NOT NULL DEFAULT '' COMMENT '发布者', `path` varchar(255) NOT NULL DEFAULT '' COMMENT '小程序包地址', `version` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号', `version_num` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号数字(用于排序)', `release_version` varchar(20) NOT NULL DEFAULT '' COMMENT '发布线上版本号', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `delete_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='小程序版本表'; + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小程序版本表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `diy_page`; CREATE TABLE `diy_page` ( @@ -85,8 +91,9 @@ CREATE TABLE `diy_page` ( `visit_count` 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='自定义页面'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '自定义页面' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `diy_route`; CREATE TABLE `diy_route` ( @@ -95,39 +102,41 @@ CREATE TABLE `diy_route` ( `name` varchar(255) NOT NULL DEFAULT '' COMMENT '页面标识', `page` varchar(255) NOT NULL DEFAULT '' COMMENT '页面路径', `share` varchar(1000) NOT NULL DEFAULT '' COMMENT '分享内容', - `is_share` int(11) NOT NULL DEFAULT '0' COMMENT '是否支持分享', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='自定义路由'; + `is_share` int(11) NOT NULL DEFAULT 0 COMMENT '是否支持分享', + `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '自定义路由' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `generate_column`; CREATE TABLE `generate_column` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', - `table_id` int(11) NOT NULL DEFAULT '0' COMMENT '表id', + `table_id` int(11) NOT NULL DEFAULT 0 COMMENT '表id', `column_name` varchar(100) NOT NULL DEFAULT '' COMMENT '字段名称', `column_comment` varchar(300) NOT NULL DEFAULT '' COMMENT '字段描述', `column_type` varchar(100) NOT NULL DEFAULT '' COMMENT '字段类型', - `is_required` tinyint(4) DEFAULT '0' COMMENT '是否必填 0-非必填 1-必填', - `is_pk` tinyint(4) DEFAULT '0' COMMENT '是否为主键 0-不是 1-是', - `is_insert` tinyint(4) DEFAULT '0' COMMENT '是否为插入字段 0-不是 1-是', - `is_update` tinyint(4) DEFAULT '0' COMMENT '是否为更新字段 0-不是 1-是', - `is_lists` tinyint(4) DEFAULT '1' COMMENT '是否为列表字段 0-不是 1-是', - `is_query` tinyint(4) DEFAULT '1' COMMENT '是否为查询字段 0-不是 1-是', - `is_search` tinyint(4) DEFAULT '1' COMMENT '是否搜索字段', - `query_type` varchar(100) DEFAULT '=' COMMENT '查询类型', - `view_type` varchar(100) DEFAULT 'input' COMMENT '显示类型', - `dict_type` varchar(255) DEFAULT '' COMMENT '字典类型', - `addon` varchar(255) DEFAULT '' COMMENT '远程下拉关联应用', - `model` varchar(255) DEFAULT '' COMMENT '远程下拉关联model', - `label_key` varchar(255) DEFAULT '' COMMENT '远程下拉标题字段', - `value_key` varchar(255) DEFAULT '' COMMENT '远程下拉value字段', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `is_delete` tinyint(4) DEFAULT '0' COMMENT '是否为软删除字段 0-不是 1-是', - `is_order` tinyint(4) DEFAULT '0' COMMENT '是否为排序字段 0-不是 1-是', - `validate_type` varchar(255) DEFAULT '' COMMENT '验证类型', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='代码生成表字段信息表'; + `is_required` tinyint(1) NULL DEFAULT 0 COMMENT '是否必填 0-非必填 1-必填', + `is_pk` tinyint(1) NULL DEFAULT 0 COMMENT '是否为主键 0-不是 1-是', + `is_insert` tinyint(1) NULL DEFAULT 0 COMMENT '是否为插入字段 0-不是 1-是', + `is_update` tinyint(1) NULL DEFAULT 0 COMMENT '是否为更新字段 0-不是 1-是', + `is_lists` tinyint(1) NULL DEFAULT 1 COMMENT '是否为列表字段 0-不是 1-是', + `is_query` tinyint(1) NULL DEFAULT 1 COMMENT '是否为查询字段 0-不是 1-是', + `is_search` tinyint(1) NULL DEFAULT 1 COMMENT '是否搜索字段', + `query_type` varchar(100) NULL DEFAULT '=' COMMENT '查询类型', + `view_type` varchar(100) NULL DEFAULT 'input' COMMENT '显示类型', + `dict_type` varchar(255) NULL DEFAULT '' COMMENT '字典类型', + `addon` varchar(255) NULL DEFAULT '' COMMENT '远程下拉关联应用', + `model` varchar(255) NULL DEFAULT '' COMMENT '远程下拉关联model', + `label_key` varchar(255) NULL DEFAULT '' COMMENT '远程下拉标题字段', + `value_key` varchar(255) NULL DEFAULT '' COMMENT '远程下拉value字段', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + `is_delete` tinyint(4) NULL DEFAULT 0 COMMENT '是否为软删除字段 0-不是 1-是', + `is_order` tinyint(4) NULL DEFAULT 0 COMMENT '是否为排序字段 0-不是 1-是', + `validate_type` varchar(255) NULL DEFAULT '' COMMENT '验证类型', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成表字段信息表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `generate_table`; CREATE TABLE `generate_table` ( @@ -136,28 +145,29 @@ CREATE TABLE `generate_table` ( `table_content` varchar(255) NOT NULL DEFAULT '' COMMENT '描述前缀', `module_name` varchar(255) NOT NULL DEFAULT '' COMMENT '模块名', `class_name` varchar(255) NOT NULL DEFAULT '' COMMENT '类名前缀', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `edit_type` int(11) NOT NULL DEFAULT '1' COMMENT '编辑方式 1-弹框 2-新页面', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间', + `edit_type` int(11) NOT NULL DEFAULT 1 COMMENT '编辑方式 1-弹框 2-新页面', `addon_name` varchar(255) NOT NULL DEFAULT '' COMMENT '插件名', - `order_type` int(11) NOT NULL DEFAULT '0' COMMENT '排序方式 0-无排序 1-正序 2-倒序', + `order_type` int(11) NOT NULL DEFAULT 0 COMMENT '排序方式 0-无排序 1-正序 2-倒序', `parent_menu` varchar(255) NOT NULL DEFAULT '' COMMENT '上级菜单', - `relations` text COMMENT '关联配置', - `synchronous_number` int(11) NOT NULL DEFAULT '0' COMMENT '同步次数', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='代码生成表'; + `relations` text NULL COMMENT '关联配置', + `synchronous_number` int(11) NOT NULL DEFAULT 0 COMMENT '同步次数', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `jobs`; CREATE TABLE `jobs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `queue` varchar(255) NOT NULL, `payload` longtext NOT NULL, - `attempts` tinyint(3) unsigned NOT NULL DEFAULT '0', - `reserve_time` int(10) unsigned DEFAULT '0', - `available_time` int(10) unsigned DEFAULT '0', - `create_time` int(10) unsigned DEFAULT '0', - PRIMARY KEY (`id`), - KEY `queue` (`queue`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='消息队列任务表'; + `attempts` tinyint(4) UNSIGNED NOT NULL DEFAULT 0, + `reserve_time` int(11) UNSIGNED NULL DEFAULT 0, + `available_time` int(11) UNSIGNED NULL DEFAULT 0, + `create_time` int(11) UNSIGNED NULL DEFAULT 0, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '消息队列任务表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `jobs_failed`; CREATE TABLE `jobs_failed` ( @@ -167,20 +177,21 @@ CREATE TABLE `jobs_failed` ( `payload` longtext NOT NULL, `exception` longtext NOT NULL, `fail_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='消息队列任务失败记录表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '消息队列任务失败记录表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member`; CREATE TABLE `member` ( - `member_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `member_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', `member_no` varchar(255) NOT NULL DEFAULT '' COMMENT '会员编码', - `pid` int(11) NOT NULL DEFAULT '0' COMMENT '推广会员id', + `pid` int(11) NOT NULL DEFAULT 0 COMMENT '推广会员id', `username` varchar(255) NOT NULL DEFAULT '' COMMENT '会员用户名', `mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '手机号', `password` varchar(255) NOT NULL DEFAULT '' COMMENT '会员密码', - `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '会员昵称', + `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '会员昵称', `headimg` varchar(1000) NOT NULL DEFAULT '' COMMENT '会员头像', - `member_level` int(11) NOT NULL DEFAULT '0' COMMENT '会员等级', + `member_level` int(11) NOT NULL DEFAULT 0 COMMENT '会员等级', `member_label` varchar(255) NOT NULL DEFAULT '' COMMENT '会员标签', `wx_openid` varchar(255) NOT NULL DEFAULT '' COMMENT '微信用户openid', `weapp_openid` varchar(255) NOT NULL DEFAULT '' COMMENT '微信小程序openid', @@ -192,87 +203,81 @@ CREATE TABLE `member` ( `login_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '当前登录ip', `login_type` varchar(255) NOT NULL DEFAULT 'h5' COMMENT '当前登录的操作终端类型', `login_channel` varchar(255) NOT NULL DEFAULT '', - `login_count` int(11) NOT NULL DEFAULT '0' COMMENT '登录次数', - `login_time` int(11) NOT NULL DEFAULT '0' COMMENT '当前登录时间', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '注册时间', - `last_visit_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后访问时间', - `last_consum_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后消费时间', - `sex` tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别 0保密 1男 2女', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '用户状态 用户状态默认为1', + `login_count` int(11) NOT NULL DEFAULT 0 COMMENT '登录次数', + `login_time` int(11) NOT NULL DEFAULT 0 COMMENT '当前登录时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '注册时间', + `last_visit_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后访问时间', + `last_consum_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后消费时间', + `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '性别 0保密 1男 2女', + `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '用户状态 用户状态默认为1', `birthday` varchar(20) NOT NULL DEFAULT '' COMMENT '出生日期', - `point` int(11) NOT NULL DEFAULT '0' COMMENT '可用积分', - `point_get` int(11) NOT NULL DEFAULT '0' COMMENT '累计获取积分', - `balance` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '可用余额', - `balance_get` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '累计获取余额', - `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '可用余额(可提现)', - `money_get` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '累计获取余额(可提现)', - `money_cash_outing` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现中余额(可提现)', - `growth` int(11) NOT NULL DEFAULT '0' COMMENT '成长值', - `growth_get` int(11) NOT NULL DEFAULT '0' COMMENT '累计获得成长值', - `commission` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '当前佣金', - `commission_get` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '佣金获取', - `commission_cash_outing` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现中佣金', - `is_member` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否是会员', - `member_time` int(11) NOT NULL DEFAULT '0' COMMENT '成为会员时间', - `is_del` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0正常 1已删除', - `province_id` int(11) NOT NULL DEFAULT '0' COMMENT '省id', - `city_id` int(11) NOT NULL DEFAULT '0' COMMENT '市id', - `district_id` int(11) NOT NULL DEFAULT '0' COMMENT '区县id', + `point` int(11) NOT NULL DEFAULT 0 COMMENT '可用积分', + `point_get` int(11) NOT NULL DEFAULT 0 COMMENT '累计获取积分', + `balance` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '可用余额', + `balance_get` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '累计获取余额', + `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '可用余额(可提现)', + `money_get` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '累计获取余额(可提现)', + `money_cash_outing` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现中余额(可提现)', + `growth` int(11) NOT NULL DEFAULT 0 COMMENT '成长值', + `growth_get` int(11) NOT NULL DEFAULT 0 COMMENT '累计获得成长值', + `commission` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '当前佣金', + `commission_get` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '佣金获取', + `commission_cash_outing` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现中佣金', + `is_member` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否是会员', + `member_time` int(11) NOT NULL DEFAULT 0 COMMENT '成为会员时间', + `is_del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0正常 1已删除', + `province_id` int(11) NOT NULL DEFAULT 0 COMMENT '省id', + `city_id` int(11) NOT NULL DEFAULT 0 COMMENT '市id', + `district_id` int(11) NOT NULL DEFAULT 0 COMMENT '区县id', `address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址', `location` varchar(255) NOT NULL DEFAULT '' COMMENT '定位地址', - `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`member_id`), - KEY `mobile` (`mobile`), - KEY `password` (`password`), - KEY `username` (`username`), - KEY `weapp_openid` (`weapp_openid`), - KEY `wx_openid` (`wx_openid`), - KEY `wx_unionid` (`wx_unionid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员表'; + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`member_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_account_log`; CREATE TABLE `member_account_log` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', `account_type` varchar(255) NOT NULL DEFAULT 'point' COMMENT '账户类型', - `account_data` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '账户数据', - `account_sum` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变动后的账户余额', + `account_data` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '账户数据', + `account_sum` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '变动后的账户余额', `from_type` varchar(255) NOT NULL DEFAULT '' COMMENT '来源类型', `related_id` varchar(50) NOT NULL DEFAULT '' COMMENT '关联Id', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', `memo` varchar(255) NOT NULL DEFAULT '' COMMENT '备注信息', - PRIMARY KEY (`id`), - KEY `account_type` (`account_type`), - KEY `create_time` (`create_time`), - KEY `from_type` (`from_type`), - KEY `member_id` (`member_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员账单表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员账单表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_address`; CREATE TABLE `member_address` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', - `name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户姓名', - `mobile` varchar(255) NOT NULL DEFAULT '' COMMENT '手机', - `province_id` int(11) NOT NULL DEFAULT '0' COMMENT '省id', - `city_id` int(11) NOT NULL DEFAULT '0' COMMENT '市id', - `district_id` int(11) NOT NULL DEFAULT '0' COMMENT '区县id', - `address` varchar(255) NOT NULL DEFAULT '' COMMENT '地址信息', - `address_name` varchar(255) NOT NULL DEFAULT '', - `full_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址信息', - `lng` varchar(255) NOT NULL DEFAULT '' COMMENT '经度', - `lat` varchar(255) NOT NULL DEFAULT '' COMMENT '纬度', - `is_default` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否是默认地址', - PRIMARY KEY (`id`), - KEY `IDX_member_address` (`member_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员收货地址'; + `name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户姓名', + `mobile` varchar(255) NOT NULL DEFAULT '' COMMENT '手机', + `province_id` int NOT NULL DEFAULT 0 COMMENT '省id', + `city_id` int NOT NULL DEFAULT 0 COMMENT '市id', + `district_id` int NOT NULL DEFAULT 0 COMMENT '区县id', + `address` varchar(255) NOT NULL DEFAULT '' COMMENT '地址信息', + `address_name` varchar(255) NOT NULL DEFAULT '', + `full_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址信息', + `lng` varchar(255) NOT NULL DEFAULT '' COMMENT '经度', + `lat` varchar(255) NOT NULL DEFAULT '' COMMENT '纬度', + `is_default` tinyint NOT NULL DEFAULT 0 COMMENT '是否是默认地址', + PRIMARY KEY (`id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员收货地址' ROW_FORMAT = Dynamic; + +ALTER TABLE `member_address`ADD INDEX IDX_member_address (member_id); + DROP TABLE IF EXISTS `member_cash_out`; CREATE TABLE `member_cash_out` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cash_out_no` varchar(50) NOT NULL DEFAULT '' COMMENT '提现交易号', - `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', + `member_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id', `account_type` varchar(255) NOT NULL DEFAULT 'money' COMMENT '提现账户类型', `transfer_type` varchar(20) NOT NULL DEFAULT '0' COMMENT '转账提现类型', `transfer_realname` varchar(50) NOT NULL DEFAULT '' COMMENT '联系人名称', @@ -281,52 +286,50 @@ CREATE TABLE `member_cash_out` ( `transfer_account` varchar(255) 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 '转账时间', - `apply_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现申请金额', - `rate` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现手续费比率', - `service_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现手续费', - `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '提现到账金额', - `audit_time` int(11) NOT NULL DEFAULT '0' COMMENT '审核时间', - `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态1待审核2.待转账3已转账 -1拒绝 -2 已取消', - `remark` varchar(100) NOT NULL DEFAULT '' COMMENT '备注', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '申请时间', - `refuse_reason` varchar(100) NOT NULL DEFAULT '' COMMENT '拒绝理由', - `update_time` int(11) NOT NULL DEFAULT '0', + `transfer_time` int(11) NOT NULL DEFAULT 0 COMMENT '转账时间', + `apply_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现申请金额', + `rate` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现手续费比率', + `service_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现手续费', + `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现到账金额', + `audit_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间', + `status` int(11) NOT NULL DEFAULT 0 COMMENT '状态1待审核2.待转账3已转账 -1拒绝 -2 已取消', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '申请时间', + `refuse_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '拒绝理由', + `update_time` int(11) NOT NULL DEFAULT 0, `transfer_no` varchar(50) NOT NULL DEFAULT '' COMMENT '转账单号', - `cancel_time` int(11) NOT NULL DEFAULT '0' COMMENT '取消时间', + `cancel_time` int(11) NOT NULL DEFAULT 0 COMMENT '取消时间', `final_transfer_type` varchar(255) NOT NULL DEFAULT '' COMMENT '转账方式', - PRIMARY KEY (`id`), - KEY `member_withdraw_apply_time` (`create_time`), - KEY `member_withdraw_audit_time` (`audit_time`), - KEY `member_withdraw_status` (`status`), - KEY `member_withdraw_withdraw_no` (`cash_out_no`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员提现表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员提现表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_cash_out_account`; CREATE TABLE `member_cash_out_account` ( `account_id` int(11) NOT NULL AUTO_INCREMENT, - `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', + `member_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id', `account_type` varchar(255) NOT NULL DEFAULT '' COMMENT '账户类型', `bank_name` varchar(255) NOT NULL DEFAULT '' COMMENT '银行名称', `realname` varchar(255) NOT NULL DEFAULT '' COMMENT '真实名称', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` 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 '修改时间', `account_no` varchar(255) NOT NULL DEFAULT '' COMMENT '提现账户', - PRIMARY KEY (`account_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员提现账户'; + PRIMARY KEY (`account_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员提现账户' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_label`; CREATE TABLE `member_label` ( `label_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '标签id', `label_name` varchar(50) NOT NULL DEFAULT '' COMMENT '标签名称', `memo` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注', - `sort` 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 (`label_id`), - KEY `label_id` (`label_id`), - KEY `sort` (`sort`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员标签'; + `sort` 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 (`label_id`) USING BTREE, + INDEX `label_id`(`label_id` ASC) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员标签' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_level`; CREATE TABLE `member_level` ( @@ -339,9 +342,9 @@ CREATE TABLE `member_level` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `level_benefits` text COMMENT '等级权益', `level_gifts` text COMMENT '等级礼包', - PRIMARY KEY (`level_id`), - KEY `status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员等级'; + PRIMARY KEY (`level_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员等级' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `member_sign`; CREATE TABLE `member_sign` ( @@ -355,31 +358,33 @@ CREATE TABLE `member_sign` ( `start_time` int(11) NOT NULL DEFAULT '0' COMMENT '签到周期开始时间', `is_sign` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否签到(0未签到 1已签到)', PRIMARY KEY (`sign_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='会员签到表' ROW_FORMAT=DYNAMIC; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员签到表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `pay`; CREATE TABLE `pay` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', - `main_id` int(11) NOT NULL DEFAULT '0' COMMENT '支付会员id', + `main_id` int(11) NOT NULL DEFAULT 0 COMMENT '支付会员id', `out_trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号', `trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型', - `trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '业务id', + `trade_id` int(11) NOT NULL DEFAULT 0 COMMENT '业务id', `trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '交易单号', `body` varchar(1000) NOT NULL DEFAULT '' COMMENT '支付主体', - `money` decimal(10,2) NOT NULL COMMENT '支付金额', + `money` decimal(10, 2) NOT NULL COMMENT '支付金额', `voucher` varchar(255) NOT NULL DEFAULT '' COMMENT '支付票据', - `status` int(11) NOT NULL DEFAULT '0' COMMENT '支付状态(0.待支付 1. 支付中 2. 已支付 -1已取消)', + `status` int(11) NOT NULL DEFAULT 0 COMMENT '支付状态(0.待支付 1. 支付中 2. 已支付 -1已取消)', `json` varchar(255) NOT NULL DEFAULT '' COMMENT '支付扩展用支付信息', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `pay_time` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间', - `cancel_time` int(11) NOT NULL DEFAULT '0' COMMENT '关闭时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `pay_time` int(11) NOT NULL DEFAULT 0 COMMENT '支付时间', + `cancel_time` int(11) NOT NULL DEFAULT 0 COMMENT '关闭时间', `type` varchar(255) NOT NULL DEFAULT '' COMMENT '支付方式', `mch_id` varchar(50) NOT NULL DEFAULT '' COMMENT '商户收款账号', `main_type` varchar(255) NOT NULL DEFAULT '', `channel` varchar(50) NOT NULL DEFAULT '' COMMENT '支付渠道', `fail_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '失败原因', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='支付记录表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付记录表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `pay_channel`; CREATE TABLE `pay_channel` ( @@ -387,12 +392,13 @@ CREATE TABLE `pay_channel` ( `type` varchar(255) NOT NULL DEFAULT '' COMMENT '支付类型', `channel` varchar(255) NOT NULL DEFAULT '' COMMENT '支付渠道', `config` text NOT NULL COMMENT '支付配置', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `status` int(11) NOT NULL DEFAULT '0' COMMENT '是否启用', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='支付渠道配置表'; + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + `status` int(11) NOT NULL DEFAULT 0 COMMENT '是否启用', + `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付渠道配置表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `pay_refund`; CREATE TABLE `pay_refund` ( @@ -401,29 +407,30 @@ CREATE TABLE `pay_refund` ( `out_trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号', `type` varchar(255) NOT NULL DEFAULT '' COMMENT '支付方式', `channel` varchar(50) NOT NULL DEFAULT '' COMMENT '支付渠道', - `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '支付金额', + `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '支付金额', `reason` varchar(255) NOT NULL DEFAULT '' COMMENT '退款原因', `status` varchar(255) NOT NULL DEFAULT '0' COMMENT '支付状态(0.待退款 1. 退款中 2. 已退款 -1已关闭)', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `refund_time` int(11) NOT NULL DEFAULT '0' COMMENT '支付时间', - `close_time` int(11) NOT NULL DEFAULT '0' COMMENT '关闭时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `refund_time` int(11) NOT NULL DEFAULT 0 COMMENT '支付时间', + `close_time` int(11) NOT NULL DEFAULT 0 COMMENT '关闭时间', `fail_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '失败原因', `voucher` varchar(255) NOT NULL DEFAULT '' COMMENT '支付凭证', `trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型', `trade_id` varchar(50) NOT NULL DEFAULT '' COMMENT '业务关联id', `refund_type` varchar(255) NOT NULL DEFAULT '' COMMENT '退款方式', `main_type` varchar(255) NOT NULL DEFAULT '' COMMENT '操作人类型', - `main_id` int(11) NOT NULL DEFAULT '0' COMMENT '操作人', - `pay_refund_no` varchar(255) NOT NULL DEFAULT '' COMMENT '外部支付方式的退款单号', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='支付记录表'; + `main_id` int NOT NULL DEFAULT 0 COMMENT '操作人', + `pay_refund_no` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '外部支付方式的退款单号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '退款记录表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `pay_transfer`; CREATE TABLE `pay_transfer` ( `id` int(11) NOT NULL AUTO_INCREMENT, `trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型', `transfer_no` varchar(50) NOT NULL DEFAULT '' COMMENT '转账单号', - `main_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', + `main_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id', `main_type` varchar(255) NOT NULL DEFAULT '' COMMENT '主体类型', `transfer_type` varchar(20) NOT NULL DEFAULT '' COMMENT '转账类型', `transfer_realname` varchar(50) NOT NULL DEFAULT '' COMMENT '联系人名称', @@ -434,18 +441,16 @@ CREATE TABLE `pay_transfer` ( `transfer_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '凭证说明', `transfer_fail_reason` varchar(255) 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', + `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, `batch_id` varchar(500) NOT NULL DEFAULT '' COMMENT '转账批次id', - PRIMARY KEY (`id`), - KEY `member_withdraw_apply_time` (`create_time`), - KEY `member_withdraw_audit_time` (`transfer_time`), - KEY `member_withdraw_status` (`transfer_status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='转账表'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '转账表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `stat_hour`; CREATE TABLE `stat_hour` ( @@ -483,37 +488,437 @@ CREATE TABLE `stat_hour` ( `hour_22` decimal(10,2) NOT NULL DEFAULT '0.00', `hour_23` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='小时统计表' ROW_FORMAT=DYNAMIC; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小时统计表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `sys_agreement`; CREATE TABLE `sys_agreement` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `agreement_key` varchar(255) NOT NULL DEFAULT '' COMMENT '协议关键字', `title` varchar(255) NOT NULL DEFAULT '' COMMENT '协议标题', - `content` text COMMENT '协议内容', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`id`), - KEY `agreement_key` (`agreement_key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='协议表'; + `content` text NULL COMMENT '协议内容', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '协议表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `sys_area`; CREATE TABLE `sys_area` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级', + `pid` int(11) NOT NULL DEFAULT 0 COMMENT '父级', `name` varchar(50) NOT NULL DEFAULT '' COMMENT '名称', `shortname` varchar(30) NOT NULL DEFAULT '' COMMENT '简称', `longitude` varchar(30) NOT NULL DEFAULT '' COMMENT '经度', `latitude` varchar(30) NOT NULL DEFAULT '' COMMENT '纬度', - `level` smallint(6) NOT NULL DEFAULT '0' COMMENT '级别', - `sort` mediumint(9) NOT NULL DEFAULT '0' COMMENT '排序', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态1有效', - PRIMARY KEY (`id`), - KEY `area` (`name`,`shortname`), - KEY `level` (`level`,`sort`,`status`), - KEY `longitude` (`longitude`,`latitude`), - KEY `pid` (`pid`) -) ENGINE=InnoDB AUTO_INCREMENT=460400501 DEFAULT CHARSET=utf8mb4 COMMENT='地址表'; + `level` smallint(6) NOT NULL DEFAULT 0 COMMENT '级别', + `sort` mediumint(9) NOT NULL DEFAULT 0 COMMENT '排序', + `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态1有效', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '地址表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_attachment`; +CREATE TABLE `sys_attachment` ( + `att_id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL DEFAULT '' COMMENT '附件名称', + `real_name` varchar(255) NOT NULL DEFAULT '' COMMENT '原始文件名', + `path` varchar(255) NOT NULL DEFAULT '' COMMENT '完整地址', + `dir` varchar(200) NOT NULL DEFAULT '' COMMENT '附件路径', + `att_size` char(30) NOT NULL DEFAULT '' COMMENT '附件大小', + `att_type` char(30) NOT NULL DEFAULT '' COMMENT '附件类型image,video', + `storage_type` varchar(20) NOT NULL DEFAULT '' COMMENT '图片上传类型 local本地 aliyun 阿里云oss qiniu 七牛 ....', + `cate_id` int(11) NOT NULL DEFAULT 0 COMMENT '相关分类', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '上传时间', + `update_time` int(11) NOT NULL DEFAULT 0, + `url` varchar(255) NOT NULL DEFAULT '' COMMENT '网络地址', + PRIMARY KEY (`att_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '附件管理表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_attachment_category`; +CREATE TABLE `sys_attachment_category` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pid` int(11) NOT NULL DEFAULT 0 COMMENT '父级ID', + `type` varchar(50) NOT NULL DEFAULT '' COMMENT '文件管理类型(image,video)', + `name` varchar(50) NOT NULL DEFAULT '' COMMENT '分类名称', + `enname` varchar(50) NOT NULL DEFAULT '' COMMENT '分类目录', + `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `id`(`id` ASC) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '附件分类表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_config`; +CREATE TABLE `sys_config` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `config_key` varchar(255) NOT NULL DEFAULT '' COMMENT '配置项关键字', + `value` text NULL COMMENT '配置值json', + `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否启用 1启用 0不启用', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统配置表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_cron_task`; +CREATE TABLE `sys_cron_task` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `status` int(11) NOT NULL DEFAULT 1 COMMENT '任务状态', + `count` int(11) NOT NULL DEFAULT 0 COMMENT '执行次数', + `title` char(50) NOT NULL DEFAULT '' COMMENT '任务名称', + `type` varchar(255) NOT NULL DEFAULT '' COMMENT '任务模式 cron 定时任务 crond 周期任务', + `crond_type` char(200) NOT NULL DEFAULT '' COMMENT '任务周期', + `crond_length` int(11) NOT NULL DEFAULT 0 COMMENT '任务周期', + `task` varchar(500) NOT NULL DEFAULT '' COMMENT '任务命令', + `data` longtext NULL COMMENT '附加参数', + `status_desc` varchar(1000) NOT NULL DEFAULT '' COMMENT '上次执行结果', + `last_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后执行时间', + `next_time` int(11) NOT NULL DEFAULT 0 COMMENT '下次执行时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = ' 系统任务' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_dict`; +CREATE TABLE `sys_dict` ( + `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id', + `name` varchar(50) NOT NULL DEFAULT '' COMMENT '字典名称', + `key` varchar(100) NOT NULL DEFAULT '' COMMENT '字典关键词', + `dictionary` text NOT NULL COMMENT '字典数据', + `memo` varchar(255) NOT NULL DEFAULT '', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_export`; +CREATE TABLE `sys_export` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', + `export_key` varchar(255) NOT NULL DEFAULT '' COMMENT '主题关键字', + `export_num` int(11) NOT NULL DEFAULT '0' COMMENT '导出数据数量', + `file_path` varchar(255) NOT NULL DEFAULT '' COMMENT '文件存储路径', + `file_size` varchar(255) NOT NULL DEFAULT '' COMMENT '文件大小', + `export_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '导出状态', + `fail_reason` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '失败原因', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '导出时间', + PRIMARY KEY (`id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '导出报表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `verifier`; +CREATE TABLE `verifier` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', + `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', + `verify_type` varchar(255) NOT NULL DEFAULT '' COMMENT '核销类型', + PRIMARY KEY (`id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '核销员表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `verify`; +CREATE TABLE `verify` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `code` varchar(255) NOT NULL DEFAULT '' COMMENT '核销码', + `data` varchar(255) NOT NULL DEFAULT '' COMMENT '核销参数', + `type` varchar(30) NOT NULL DEFAULT '' COMMENT '核销类型', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '核销时间', + `verifier_member_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销会员id', + `value` varchar(1000) NOT NULL DEFAULT '' COMMENT '核销内容', + `body` varchar(500) NOT NULL DEFAULT '' COMMENT '描述', + `relate_tag` varchar(255) NOT NULL DEFAULT '' COMMENT '业务标识', + PRIMARY KEY (`id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '核销记录' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_menu`; +CREATE TABLE `sys_menu` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '菜单ID', + `app_type` varchar(255) NOT NULL DEFAULT 'admin' COMMENT '应用类型', + `menu_name` varchar(32) NOT NULL DEFAULT '' COMMENT '菜单名称', + `menu_short_name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单短标题', + `menu_key` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单标识(菜单输入,接口自动生成)', + `parent_key` varchar(255) NOT NULL DEFAULT '' COMMENT '父级key', + `menu_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '菜单类型 0目录 1菜单 2按钮', + `icon` varchar(500) NOT NULL DEFAULT '' COMMENT '图标 菜单有效', + `api_url` varchar(100) NOT NULL DEFAULT '' COMMENT 'api接口地址', + `router_path` varchar(128) NOT NULL DEFAULT '' COMMENT '菜单路由地址 前端使用', + `view_path` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单文件地址', + `methods` varchar(10) NOT NULL DEFAULT '' COMMENT '提交方式POST GET PUT DELETE', + `sort` int NOT NULL DEFAULT 1 COMMENT '排序', + `status` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '正常,禁用(禁用后不允许访问)', + `is_show` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否显示', + `create_time` int(11) NOT NULL DEFAULT 0, + `delete_time` int(11) NOT NULL DEFAULT 0, + `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', + `source` varchar(255) NOT NULL DEFAULT 'system' COMMENT '菜单来源 system 系统文件 create 新建菜单 generator 代码生成器', + `menu_attr` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单属性 common 公共 system 系统', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_notice`; +CREATE TABLE `sys_notice` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `key` varchar(50) NOT NULL DEFAULT '' COMMENT '标识', + `sms_content` text NULL COMMENT '短信配置参数', + `is_wechat` tinyint(4) NOT NULL DEFAULT 0 COMMENT '公众号模板消息(0:关闭,1:开启)', + `is_weapp` tinyint(4) NOT NULL DEFAULT 0 COMMENT '小程序订阅消息(0:关闭,1:开启)', + `is_sms` tinyint(4) NOT NULL DEFAULT 0 COMMENT '发送短信(0:关闭,1:开启)', + `wechat_template_id` varchar(255) NOT NULL DEFAULT '' COMMENT '微信模版消息id', + `weapp_template_id` varchar(255) NOT NULL DEFAULT '' COMMENT '微信小程序订阅消息id', + `sms_id` varchar(255) NOT NULL DEFAULT '' COMMENT '短信id(对应短信配置)', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间', + `wechat_first` varchar(255) NOT NULL DEFAULT '' COMMENT '微信头部', + `wechat_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '微信说明', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '通知模型' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_notice_log`; +CREATE TABLE `sys_notice_log` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '通知记录ID', + `key` varchar(255) NULL DEFAULT '' COMMENT '消息key', + `notice_type` varchar(50) NULL DEFAULT 'sms' COMMENT '消息类型(sms,wechat.weapp)', + `uid` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '通知的用户id', + `member_id` int(11) NOT NULL DEFAULT 0 COMMENT '消息的会员id', + `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人用户昵称或姓名', + `receiver` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人(对应手机号,openid)', + `content` text NULL COMMENT '消息数据', + `is_click` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '点击次数', + `is_visit` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '访问次数', + `visit_time` int(11) NOT NULL DEFAULT 0 COMMENT '访问时间', + `create_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '消息时间', + `result` varchar(1000) NOT NULL DEFAULT '' COMMENT '结果', + `params` text NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '通知记录表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_notice_sms_log`; +CREATE TABLE `sys_notice_sms_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', + `mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号码', + `sms_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发送关键字(注册、找回密码)', + `key` varchar(32) NOT NULL DEFAULT '' COMMENT '发送关键字(注册、找回密码)', + `template_id` varchar(50) NOT NULL DEFAULT '', + `content` text NOT NULL COMMENT '发送内容', + `params` text NOT NULL COMMENT '数据参数', + `status` varchar(32) NOT NULL DEFAULT 'sending' COMMENT '发送状态:sending-发送中;success-发送成功;fail-发送失败', + `result` text NULL COMMENT '短信结果', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `send_time` int(11) NOT NULL DEFAULT 0 COMMENT '发送时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '短信发送表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_role`; +CREATE TABLE `sys_role` ( + `role_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '角色id', + `role_name` varchar(255) NOT NULL DEFAULT '' COMMENT '角色名称', + `rules` text NULL COMMENT '角色权限(menus_id)', + `addon_keys` text COMMENT '角色应用权限(应用key)', + `status` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后修改时间', + PRIMARY KEY (`role_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_poster`; +CREATE TABLE `sys_poster` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(255) NOT NULL DEFAULT '' COMMENT '海报名称', + `type` varchar(255) NOT NULL DEFAULT '' COMMENT '海报类型', + `channel` varchar(255) NOT NULL DEFAULT '' COMMENT '海报支持渠道', + `value` text COMMENT '配置值json', + `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否启用 1启用 2不启用', + `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', + `is_default` int(11) NOT NULL DEFAULT '0' COMMENT '是否默认海报,1:是,0:否', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '海报表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_printer`; +CREATE TABLE `sys_printer` ( + `printer_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `printer_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机名称', + `brand` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '设备品牌(易联云,365,飞鹅)', + `printer_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机编号', + `printer_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机秘钥', + `open_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开发者id', + `apikey` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开发者密钥', + `template_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '小票打印模板类型,多个逗号隔开', + `trigger` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '触发打印时机', + `value` LONGTEXT DEFAULT NULL COMMENT '打印模板数据,json格式', + `print_width` VARCHAR(255) NOT NULL DEFAULT '58mm' COMMENT '纸张宽度', + `status` TINYINT(4) NOT NULL DEFAULT 1 COMMENT '状态(0,关闭,1:开启)', + `create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`printer_id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小票打印机' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_printer_template`; +CREATE TABLE `sys_printer_template` ( + `template_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `template_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板名称', + `template_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板类型', + `value` LONGTEXT DEFAULT NULL COMMENT '模板数据,json格式', + `create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`template_id`) +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小票打印模板' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_schedule`; +CREATE TABLE `sys_schedule` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', + `key` varchar(255) NOT NULL DEFAULT '' COMMENT '计划任务模板key', + `status` int(11) NOT NULL DEFAULT 1 COMMENT '任务状态 是否启用', + `time` varchar(500) NOT NULL DEFAULT '' COMMENT '任务周期 json结构', + `count` int(11) NOT NULL DEFAULT 0 COMMENT '执行次数', + `last_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后执行时间', + `next_time` int(11) NOT NULL DEFAULT 0 COMMENT '下次执行时间', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统任务' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( + `uid` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '系统用户ID', + `username` varchar(255) NOT NULL DEFAULT '' COMMENT '用户账号', + `head_img` varchar(255) NOT NULL DEFAULT '', + `password` varchar(100) NOT NULL DEFAULT '' COMMENT '用户密码', + `real_name` varchar(16) NOT NULL DEFAULT '' COMMENT '实际姓名', + `last_ip` varchar(50) NOT NULL DEFAULT '' COMMENT '最后一次登录ip', + `last_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '最后一次登录时间', + `create_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间', + `login_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '登录次数', + `is_del` tinyint(3) UNSIGNED NOT NULL DEFAULT 0, + `delete_time` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + `status` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '后台管理员状态 1有效0无效', + `role_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '权限组', + `is_admin` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否是管理员', + PRIMARY KEY (`uid`) USING BTREE, + INDEX `uid`(`uid` ASC) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '后台管理员表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_user_log`; +CREATE TABLE `sys_user_log` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员操作记录ID', + `ip` varchar(50) NOT NULL DEFAULT '' COMMENT '登录IP', + `uid` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员id', + `username` varchar(64) NOT NULL DEFAULT '' COMMENT '管理员姓名', + `url` varchar(128) NOT NULL DEFAULT '' COMMENT '链接', + `params` longtext DEFAULT NULL COMMENT '参数', + `type` varchar(32) NOT NULL DEFAULT '' COMMENT '请求方式', + `create_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '管理员操作记录表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `sys_user_role`; +CREATE TABLE `sys_user_role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', + `role_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '角色id', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间', + `is_admin` int(11) NOT NULL DEFAULT 0 COMMENT '是否是超级管理员', + `status` int(11) NOT NULL DEFAULT 1 COMMENT '状态', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户权限表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `weapp_version`; +CREATE TABLE `weapp_version` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `version` varchar(255) NOT NULL DEFAULT '', + `version_no` int(11) NOT NULL DEFAULT 1, + `desc` varchar(255) NOT NULL DEFAULT '' COMMENT '说明', + `create_time` int(11) NOT NULL DEFAULT 0, + `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态', + `update_time` int(11) NOT NULL DEFAULT 0, + `fail_reason` text DEFAULT NULL, + `task_key` varchar(20) NOT NULL DEFAULT '' COMMENT '上传任务key', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小程序版本' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `wechat_fans`; +CREATE TABLE `wechat_fans` ( + `fans_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '粉丝ID', + `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '昵称', + `avatar` varchar(500) NOT NULL DEFAULT '' COMMENT '头像', + `sex` smallint(6) NOT NULL DEFAULT 1 COMMENT '性别', + `language` varchar(20) NOT NULL DEFAULT '' COMMENT '用户语言', + `country` varchar(60) NOT NULL DEFAULT '' COMMENT '国家', + `province` varchar(255) NOT NULL DEFAULT '' COMMENT '省', + `city` varchar(255) NOT NULL DEFAULT '' COMMENT '城市', + `district` varchar(255) NOT NULL DEFAULT '' COMMENT '行政区/县', + `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '用户的标识,对当前公众号唯一 用户的唯一身份ID', + `unionid` varchar(255) NOT NULL DEFAULT '' COMMENT '粉丝unionid', + `groupid` int(11) NOT NULL DEFAULT 0 COMMENT '粉丝所在组id', + `is_subscribe` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否订阅', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', + `subscribe_time` int(11) NOT NULL DEFAULT 0 COMMENT '关注时间', + `subscribe_scene` varchar(100) NOT NULL DEFAULT '' COMMENT '返回用户关注的渠道来源', + `unsubscribe_time` int(11) NOT NULL DEFAULT 0 COMMENT '取消关注时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '粉丝信息最后更新时间', + `app_id` int(11) NOT NULL DEFAULT 0 COMMENT '应用appid', + PRIMARY KEY (`fans_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信粉丝列表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `wechat_media`; +CREATE TABLE `wechat_media` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` varchar(255) NOT NULL DEFAULT '' COMMENT '类型', + `value` text NULL COMMENT '值', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + `media_id` varchar(70) NOT NULL DEFAULT '0' COMMENT '微信端返回的素材id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信素材表' ROW_FORMAT = Dynamic; + + +DROP TABLE IF EXISTS `wechat_reply`; +CREATE TABLE `wechat_reply` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(64) NOT NULL DEFAULT '' COMMENT '规则名称', + `keyword` varchar(64) NOT NULL DEFAULT '' COMMENT '关键词', + `reply_type` varchar(30) NOT NULL DEFAULT '' COMMENT '回复类型 subscribe-关注回复 keyword-关键字回复 default-默认回复', + `matching_type` varchar(30) NOT NULL DEFAULT '1' COMMENT '匹配方式:full 全匹配;like-模糊匹配', + `content` text NOT NULL COMMENT '回复内容', + `sort` int UNSIGNED NOT NULL DEFAULT 50 COMMENT '排序', + `create_time` int NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int NOT NULL DEFAULT 0 COMMENT '更新时间', + `delete_time` int NOT NULL DEFAULT 0 COMMENT '删除时间', + `reply_method` varchar(50) NOT NULL DEFAULT '' COMMENT '回复方式 all 全部 rand随机', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '公众号消息回调表' ROW_FORMAT = Dynamic; + + +INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '1', '', '1'); + +INSERT INTO `sys_user_role` VALUES ('1', '1', '', '0', '1', '1'); INSERT INTO `sys_area` VALUES (110000, 0, '北京市', '北京', '116.40529', '39.904987', 1, 0, 1), @@ -4161,376 +4566,3 @@ INSERT INTO `sys_area` VALUES (460400407, 460400, '国营八一农场', '国营八一农场', '109.364519', '19.413460', 3, 0, 1), (460400499, 460400, '洋浦经济开发区', '洋浦经济开发区', '109.202064', '19.736941', 3, 0, 1), (460400500, 460400, '华南热作学院', '华南热作学院', '109.494073', '19.505382', 3, 0, 1); - -DROP TABLE IF EXISTS `sys_attachment`; -CREATE TABLE `sys_attachment` ( - `att_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL DEFAULT '' COMMENT '附件名称', - `real_name` varchar(255) NOT NULL DEFAULT '' COMMENT '原始文件名', - `path` varchar(255) NOT NULL DEFAULT '' COMMENT '完整地址', - `dir` varchar(200) NOT NULL DEFAULT '' COMMENT '附件路径', - `att_size` char(30) NOT NULL DEFAULT '' COMMENT '附件大小', - `att_type` char(30) NOT NULL DEFAULT '' COMMENT '附件类型image,video', - `storage_type` varchar(20) NOT NULL DEFAULT '' COMMENT '图片上传类型 local本地 aliyun 阿里云oss qiniu 七牛 ....', - `cate_id` int(11) NOT NULL DEFAULT '0' COMMENT '相关分类', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '上传时间', - `update_time` int(11) NOT NULL DEFAULT '0', - `url` varchar(255) NOT NULL DEFAULT '' COMMENT '网络地址', - PRIMARY KEY (`att_id`), - KEY `cate_id` (`cate_id`), - KEY `create_time` (`create_time`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='附件管理表'; - -DROP TABLE IF EXISTS `sys_attachment_category`; -CREATE TABLE `sys_attachment_category` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级ID', - `type` varchar(50) NOT NULL DEFAULT '' COMMENT '文件管理类型(image,video)', - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '分类名称', - `enname` varchar(50) NOT NULL DEFAULT '' COMMENT '分类目录', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - PRIMARY KEY (`id`), - KEY `pid` (`pid`), - KEY `sort` (`sort`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='附件分类表'; - -DROP TABLE IF EXISTS `sys_config`; -CREATE TABLE `sys_config` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', - `config_key` varchar(255) NOT NULL DEFAULT '' COMMENT '配置项关键字', - `value` text COMMENT '配置值json', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否启用 1启用 0不启用', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', - PRIMARY KEY (`id`), - KEY `config_key` (`config_key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='系统配置表'; - -DROP TABLE IF EXISTS `sys_cron_task`; -CREATE TABLE `sys_cron_task` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `status` int(11) NOT NULL DEFAULT '1' COMMENT '任务状态', - `count` int(11) NOT NULL DEFAULT '0' COMMENT '执行次数', - `title` char(50) NOT NULL DEFAULT '' COMMENT '任务名称', - `type` varchar(255) NOT NULL DEFAULT '' COMMENT '任务模式 cron 定时任务 crond 周期任务', - `crond_type` char(200) NOT NULL DEFAULT '' COMMENT '任务周期', - `crond_length` int(11) NOT NULL DEFAULT '0' COMMENT '任务周期', - `task` varchar(500) NOT NULL DEFAULT '' COMMENT '任务命令', - `data` longtext COMMENT '附加参数', - `status_desc` varchar(1000) NOT NULL DEFAULT '' COMMENT '上次执行结果', - `last_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后执行时间', - `next_time` int(11) NOT NULL DEFAULT '0' COMMENT '下次执行时间', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT=' 系统任务'; - -DROP TABLE IF EXISTS `sys_dict`; -CREATE TABLE `sys_dict` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '字典名称', - `key` varchar(100) NOT NULL DEFAULT '' COMMENT '字典关键词', - `dictionary` text NOT NULL COMMENT '字典数据', - `memo` varchar(255) NOT NULL DEFAULT '', - `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 `sys_export`; -CREATE TABLE `sys_export` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', - `export_key` varchar(255) NOT NULL DEFAULT '' COMMENT '主题关键字', - `export_num` int(11) NOT NULL DEFAULT '0' COMMENT '导出数据数量', - `file_path` varchar(255) NOT NULL DEFAULT '' COMMENT '文件存储路径', - `file_size` varchar(255) NOT NULL DEFAULT '' COMMENT '文件大小', - `export_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '导出状态', - `fail_reason` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '失败原因', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '导出时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='导出报表' ROW_FORMAT=DYNAMIC; - -DROP TABLE IF EXISTS `verifier`; -CREATE TABLE `verifier` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', - `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `verify_type` varchar(255) NOT NULL DEFAULT '' COMMENT '核销类型', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='核销员表' ROW_FORMAT=DYNAMIC; - -DROP TABLE IF EXISTS `verify`; -CREATE TABLE `verify` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(255) NOT NULL DEFAULT '' COMMENT '核销码', - `data` varchar(255) NOT NULL DEFAULT '' COMMENT '核销参数', - `type` varchar(30) NOT NULL DEFAULT '' COMMENT '核销类型', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '核销时间', - `verifier_member_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销会员id', - `value` varchar(1000) NOT NULL DEFAULT '' COMMENT '核销内容', - `body` varchar(500) NOT NULL DEFAULT '' COMMENT '描述', - `relate_tag` varchar(255) NOT NULL DEFAULT '' COMMENT '业务标识', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='核销记录' ROW_FORMAT=DYNAMIC; - -DROP TABLE IF EXISTS `sys_menu`; -CREATE TABLE `sys_menu` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '菜单ID', - `app_type` varchar(255) NOT NULL DEFAULT 'admin' COMMENT '应用类型', - `menu_name` varchar(32) NOT NULL DEFAULT '' COMMENT '菜单名称', - `menu_key` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单标识(菜单输入,接口自动生成)', - `parent_key` varchar(255) NOT NULL DEFAULT '' COMMENT '父级key', - `menu_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '菜单类型 0目录 1菜单 2按钮', - `icon` varchar(500) NOT NULL DEFAULT '' COMMENT '图标 菜单有效', - `api_url` varchar(100) NOT NULL DEFAULT '' COMMENT 'api接口地址', - `router_path` varchar(128) NOT NULL DEFAULT '' COMMENT '菜单路由地址 前端使用', - `view_path` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单文件地址', - `methods` varchar(10) NOT NULL DEFAULT '' COMMENT '提交方式POST GET PUT DELETE', - `sort` int(11) NOT NULL DEFAULT '1' COMMENT '排序', - `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '正常,禁用(禁用后不允许访问)', - `is_show` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否显示', - `create_time` int(11) NOT NULL DEFAULT '0', - `delete_time` int(11) NOT NULL DEFAULT '0', - `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', - `source` varchar(255) NOT NULL DEFAULT 'system' COMMENT '菜单来源 system 系统文件 create 新建菜单 generator 代码生成器', - `menu_attr` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单属性 common 公共 system 系统', - `menu_short_name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单短标题', - PRIMARY KEY (`id`), - KEY `is_show` (`is_show`), - KEY `menu_key` (`menu_key`,`app_type`), - KEY `parent_key` (`parent_key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='菜单表'; - -DROP TABLE IF EXISTS `sys_notice`; -CREATE TABLE `sys_notice` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `key` varchar(50) NOT NULL DEFAULT '' COMMENT '标识', - `sms_content` text COMMENT '短信配置参数', - `is_wechat` tinyint(4) NOT NULL DEFAULT '0' COMMENT '公众号模板消息(0:关闭,1:开启)', - `is_weapp` tinyint(4) NOT NULL DEFAULT '0' COMMENT '小程序订阅消息(0:关闭,1:开启)', - `is_sms` tinyint(4) NOT NULL DEFAULT '0' COMMENT '发送短信(0:关闭,1:开启)', - `wechat_template_id` varchar(255) NOT NULL DEFAULT '' COMMENT '微信模版消息id', - `weapp_template_id` varchar(255) NOT NULL DEFAULT '' COMMENT '微信小程序订阅消息id', - `sms_id` varchar(255) NOT NULL DEFAULT '' COMMENT '短信id(对应短信配置)', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `wechat_first` varchar(255) NOT NULL DEFAULT '' COMMENT '微信头部', - `wechat_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '微信说明', - PRIMARY KEY (`id`), - KEY `message_key` (`key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='通知模型'; - -DROP TABLE IF EXISTS `sys_notice_log`; -CREATE TABLE `sys_notice_log` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '通知记录ID', - `key` varchar(255) DEFAULT '' COMMENT '消息key', - `notice_type` varchar(50) DEFAULT 'sms' COMMENT '消息类型(sms,wechat.weapp)', - `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '通知的用户id', - `member_id` int(11) NOT NULL DEFAULT '0' COMMENT '消息的会员id', - `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人用户昵称或姓名', - `receiver` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人(对应手机号,openid)', - `content` text COMMENT '消息数据', - `is_click` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数', - `is_visit` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '访问次数', - `visit_time` int(11) NOT NULL DEFAULT '0' COMMENT '访问时间', - `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '消息时间', - `result` varchar(1000) NOT NULL DEFAULT '' COMMENT '结果', - `params` text, - PRIMARY KEY (`id`), - KEY `member_id` (`member_id`), - KEY `message_key` (`key`), - KEY `uid` (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='通知记录表'; - -DROP TABLE IF EXISTS `sys_notice_sms_log`; -CREATE TABLE `sys_notice_sms_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', - `mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号码', - `sms_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发送关键字(注册、找回密码)', - `key` varchar(32) NOT NULL DEFAULT '' COMMENT '发送关键字(注册、找回密码)', - `template_id` varchar(50) NOT NULL DEFAULT '', - `content` text NOT NULL COMMENT '发送内容', - `params` text NOT NULL COMMENT '数据参数', - `status` varchar(32) NOT NULL DEFAULT 'sending' COMMENT '发送状态:sending-发送中;success-发送成功;fail-发送失败', - `result` text COMMENT '短信结果', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `send_time` int(11) NOT NULL DEFAULT '0' COMMENT '发送时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', - `delete_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 `sys_poster`; -CREATE TABLE `sys_poster` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(255) NOT NULL DEFAULT '' COMMENT '海报名称', - `type` varchar(255) NOT NULL DEFAULT '' COMMENT '海报类型', - `channel` varchar(255) NOT NULL DEFAULT '' COMMENT '海报支持渠道', - `value` text COMMENT '配置值json', - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否启用 1启用 2不启用', - `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', - `is_default` int(11) NOT NULL DEFAULT '0' COMMENT '是否默认海报,1:是,0:否', - `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 `sys_role`; -CREATE TABLE `sys_role` ( - `role_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '角色id', - `role_name` varchar(255) NOT NULL DEFAULT '' COMMENT '角色名称', - `rules` text COMMENT '角色权限(menus_id)', - `addon_keys` text COMMENT '角色应用权限(应用key)', - `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后修改时间', - PRIMARY KEY (`role_id`), - KEY `status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='角色表'; - -DROP TABLE IF EXISTS `sys_schedule`; -CREATE TABLE `sys_schedule` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件', - `key` varchar(255) NOT NULL DEFAULT '' COMMENT '计划任务模板key', - `status` int(11) NOT NULL DEFAULT '1' COMMENT '任务状态 是否启用', - `time` varchar(500) NOT NULL DEFAULT '' COMMENT '任务周期 json结构', - `count` int(11) NOT NULL DEFAULT '0' COMMENT '执行次数', - `last_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后执行时间', - `next_time` int(11) NOT NULL DEFAULT '0' COMMENT '下次执行时间', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='系统任务'; - -DROP TABLE IF EXISTS `sys_user`; -CREATE TABLE `sys_user` ( - `uid` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '系统用户ID', - `username` varchar(255) NOT NULL DEFAULT '' COMMENT '用户账号', - `head_img` varchar(255) NOT NULL DEFAULT '', - `password` varchar(100) NOT NULL DEFAULT '' COMMENT '用户密码', - `real_name` varchar(16) NOT NULL DEFAULT '' COMMENT '实际姓名', - `last_ip` varchar(50) NOT NULL DEFAULT '' COMMENT '最后一次登录ip', - `last_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间', - `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', - `login_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数', - `is_del` tinyint(3) unsigned NOT NULL DEFAULT '0', - `delete_time` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', - `status` tinyint(4) NOT NULL DEFAULT '1', - `role_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '权限组', - `is_admin` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否是管理员', - PRIMARY KEY (`uid`), - KEY `uid` (`uid`), - KEY `delete_time` (`delete_time`), - KEY `is_del` (`is_del`), - KEY `password` (`password`), - KEY `update_time` (`update_time`), - KEY `username` (`username`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='后台管理员表'; - -INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '1', '', '1'); - -DROP TABLE IF EXISTS `sys_user_log`; -CREATE TABLE `sys_user_log` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员操作记录ID', - `ip` varchar(50) NOT NULL DEFAULT '' COMMENT '登录IP', - `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员id', - `username` varchar(64) NOT NULL DEFAULT '' COMMENT '管理员姓名', - `url` varchar(128) NOT NULL DEFAULT '' COMMENT '链接', - `params` longtext COMMENT '参数', - `type` varchar(32) NOT NULL DEFAULT '' COMMENT '请求方式', - `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间', - PRIMARY KEY (`id`), - KEY `create_time` (`create_time`), - KEY `uid` (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='管理员操作记录表'; - -DROP TABLE IF EXISTS `sys_user_role`; -CREATE TABLE `sys_user_role` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', - `role_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '角色id', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间', - `is_admin` int(11) NOT NULL DEFAULT '0' COMMENT '是否是超级管理员', - `status` int(11) NOT NULL DEFAULT '1' COMMENT '状态', - PRIMARY KEY (`id`), - KEY `create_time` (`create_time`), - KEY `uid` (`uid`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户权限表'; - -INSERT INTO `sys_user_role` VALUES ('1', '1', '', '0', '1', '1'); - -DROP TABLE IF EXISTS `weapp_version`; -CREATE TABLE `weapp_version` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `version` varchar(255) NOT NULL DEFAULT '', - `version_no` int(11) NOT NULL DEFAULT '1', - `desc` varchar(255) NOT NULL DEFAULT '' COMMENT '说明', - `create_time` int(11) NOT NULL DEFAULT '0', - `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态', - `update_time` int(11) NOT NULL DEFAULT '0', - `fail_reason` text, - `task_key` varchar(20) NOT NULL DEFAULT '' COMMENT '上传任务key', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci; - -DROP TABLE IF EXISTS `wechat_fans`; -CREATE TABLE `wechat_fans` ( - `fans_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '粉丝ID', - `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '昵称', - `avatar` varchar(500) NOT NULL DEFAULT '' COMMENT '头像', - `sex` smallint(6) NOT NULL DEFAULT '1' COMMENT '性别', - `language` varchar(20) NOT NULL DEFAULT '' COMMENT '用户语言', - `country` varchar(60) NOT NULL DEFAULT '' COMMENT '国家', - `province` varchar(255) NOT NULL DEFAULT '' COMMENT '省', - `city` varchar(255) NOT NULL DEFAULT '' COMMENT '城市', - `district` varchar(255) NOT NULL DEFAULT '' COMMENT '行政区/县', - `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '用户的标识,对当前公众号唯一 用户的唯一身份ID', - `unionid` varchar(255) NOT NULL DEFAULT '' COMMENT '粉丝unionid', - `groupid` int(11) NOT NULL DEFAULT '0' COMMENT '粉丝所在组id', - `is_subscribe` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否订阅', - `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', - `subscribe_time` int(11) NOT NULL DEFAULT '0' COMMENT '关注时间', - `subscribe_scene` varchar(100) NOT NULL DEFAULT '' COMMENT '返回用户关注的渠道来源', - `unsubscribe_time` int(11) NOT NULL DEFAULT '0' COMMENT '取消关注时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '粉丝信息最后更新时间', - `app_id` int(11) NOT NULL DEFAULT '0' COMMENT '应用appid', - PRIMARY KEY (`fans_id`), - KEY `openid` (`openid`), - KEY `unionid` (`unionid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='微信粉丝列表'; - -DROP TABLE IF EXISTS `wechat_media`; -CREATE TABLE `wechat_media` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(255) NOT NULL DEFAULT '' COMMENT '类型', - `value` text COMMENT '值', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `media_id` varchar(70) NOT NULL DEFAULT '0' COMMENT '微信端返回的素材id', - PRIMARY KEY (`id`), - KEY `type` (`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='微信素材表'; - -DROP TABLE IF EXISTS `wechat_reply`; -CREATE TABLE `wechat_reply` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(64) NOT NULL DEFAULT '' COMMENT '规则名称', - `keyword` varchar(64) NOT NULL DEFAULT '' COMMENT '关键词', - `reply_type` varchar(30) NOT NULL DEFAULT '' COMMENT '回复类型 subscribe-关注回复 keyword-关键字回复 default-默认回复', - `matching_type` varchar(30) NOT NULL DEFAULT '1' COMMENT '匹配方式:full 全匹配;like-模糊匹配', - `content` text NOT NULL COMMENT '回复内容', - `sort` int(10) unsigned NOT NULL DEFAULT '50' COMMENT '排序', - `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', - `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', - `reply_method` varchar(50) NOT NULL DEFAULT '' COMMENT '回复方式 all 全部 rand随机', - PRIMARY KEY (`id`), - KEY `keyword` (`keyword`,`reply_type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT='公众号消息回调表'; diff --git a/niucloud/app/install/view/base.html b/niucloud/app/install/view/base.html index 18929f0be..33d2856af 100644 --- a/niucloud/app/install/view/base.html +++ b/niucloud/app/install/view/base.html @@ -4,7 +4,6 @@ 安装程序 - {$install_config['website_name']} - diff --git a/niucloud/app/install/view/index/step-3.html b/niucloud/app/install/view/index/step-3.html index f5859f242..ca7e4437d 100644 --- a/niucloud/app/install/view/index/step-3.html +++ b/niucloud/app/install/view/index/step-3.html @@ -159,13 +159,13 @@
- +
{/block} {block name='script'} - {/block} diff --git a/niucloud/app/job/sys/AddonInstall.php b/niucloud/app/job/member/SetMemberNoJob.php similarity index 67% rename from niucloud/app/job/sys/AddonInstall.php rename to niucloud/app/job/member/SetMemberNoJob.php index e8ef71b4a..2615d6da1 100644 --- a/niucloud/app/job/sys/AddonInstall.php +++ b/niucloud/app/job/member/SetMemberNoJob.php @@ -9,23 +9,19 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\job\sys; +namespace app\job\member; -use app\service\core\addon\CoreAddonInstallService; +use app\service\core\member\CoreMemberService; use core\base\BaseJob; /** - * 队列异步执行插件安装任务 + * 队列设置会员会员码 */ -class AddonInstall extends BaseJob +class SetMemberNoJob extends BaseJob { - public function doJob($addon, $task) + public function doJob($member_id) { - (new CoreAddonInstallService($addon))->executeTask($task); - } - - public function failed($data) - { - + CoreMemberService::setMemberNo($member_id); + return true; } } diff --git a/niucloud/app/lang/en/api.php b/niucloud/app/lang/en/api.php index 9d833c6e8..310032dce 100644 --- a/niucloud/app/lang/en/api.php +++ b/niucloud/app/lang/en/api.php @@ -28,7 +28,7 @@ return [ 'DOWNLOAD_FAIL' => 'download fail', 'SET_SUCCESS' => 'set success', 'AGREEMENT_TYPE_NOT_EXIST' => 'agreement type is not exit', - 'FIELD_NOT_FOUND' => 'cloumn is not exit', + 'FIELD_NOT_FOUND' => 'column is not exit', 'REFRESH_SUCCESS' => 'refresh success', 'CAPTCHA_ERROR' => 'captcha fail', diff --git a/niucloud/app/lang/en/dict.php b/niucloud/app/lang/en/dict.php index 571aaccfb..7d686442b 100644 --- a/niucloud/app/lang/en/dict.php +++ b/niucloud/app/lang/en/dict.php @@ -35,14 +35,6 @@ return [ 'status_on' => 'on', 'status_off' => 'off' ], - // 站点 - 'dict_site' => [ - //站点类型 - 'type_cms' => 'cms', - 'status_on' => 'on', - 'status_experience' => 'experience', - 'status_expire' => 'expire' - ], 'dict_notice' => [ 'type_sms' => 'sms', 'type_wechat' => 'wechat', diff --git a/niucloud/app/lang/zh-cn/api.php b/niucloud/app/lang/zh-cn/api.php index 779638a81..42b4d3501 100644 --- a/niucloud/app/lang/zh-cn/api.php +++ b/niucloud/app/lang/zh-cn/api.php @@ -91,7 +91,7 @@ return [ 'USER_NOT_EXIST' => '用户不存在', 'NO_SITE_USER_ROLE' => '用户不存在关联权限', 'ADMIN_NOT_ALLOW_EDIT_ROLE' => '超级管理员不允许改动权限', - 'USERNAME_REPEAT' => '用户名重复', + 'USERNAME_REPEAT' => '账号重复', 'SITE_USER_EXIST' => '该用户已存在', //角色管理 @@ -110,7 +110,7 @@ return [ 'OSS_FILE_URL_NOT_EXIST' => '远程资源文件地址不能为空', 'BASE_IMAGE_FILE_NOT_EXIST' => 'base图片资源不能为空', 'UPLOAD_TYPE_NOT_SUPPORT' => '不支持的上传类型', - 'FILE_ERROE' => '无效的资源', + 'FILE_ERROR' => '无效的资源', 'UPLOAD_STORAGE_TYPE_ALL_CLOSE' => '至少要有一个启用的存储方式', 'STORAGE_NOT_HAS_HTTP_OR_HTTPS' => '空间域名请补全http://或https://', @@ -137,6 +137,7 @@ return [ 'ACCOUNT_OR_PASSWORD_ERROR' => '账号或密码错误', 'MEMBER_LOCK' => '账号被锁定', 'MEMBER_NOT_EXIST' => '账号不存在', + 'MEMBER_OPENID_EXIST' => 'openid已存在', 'MEMBER_LOGOUT' => '账号退出', 'MEMBER_TYPE_NOT_EXIST' => '账户类型不存在', 'MEMBER_IS_EXIST' => '账号已存在', @@ -204,7 +205,7 @@ return [ 'PAY_SUCCESS' => '当前支付已完成', 'PAY_IS_REMOVE' => '当前支付已取消', 'PAYMENT_METHOD_NOT_EXIST' => '你选择的支付方式未启用', - 'PAYMENT_METHOD_NOT_SCENE'=> '你选择的支付方式不适用于当前场景', + 'PAYMENT_METHOD_NOT_SCENE' => '你选择的支付方式不适用于当前场景', 'TREAT_PAYMENT_IS_OPEN' => '只有待支付时可以关闭', 'TRANFER_STATUS_NOT_IN_WAIT_TANSFER' => '当前转账未处于待转账状态', 'TRANSFER_ORDER_INVALID' => '无效的转账单据', @@ -277,7 +278,9 @@ return [ 'CONTINUE_SIGN' => '连签', 'DAYS' => '天!', 'SIGN_SUCCESS' => '签到成功', + 'SIGN_AWARD' => '签到奖励', 'GET_AWARD' => '恭喜您获得以下奖励', + 'WILL_GET_AWARD' => '您将获得以下奖励', //导出相关 'EXPORT_SUCCESS' => '导出成功', @@ -290,5 +293,7 @@ return [ 'WECHAT_OPLATFORM_NOT_EXIST' => '未配置微信开放平台', 'WEAPP_EXIST' => '该小程序已经授权给其他站点', 'WECHAT_EXIST' => '该公众号已经授权给其他站点', - 'PLEASE_ADD_FIRST_SITE_GROUP' => '请先添加站点套餐' + 'PLEASE_ADD_FIRST_SITE_GROUP' => '请先添加站点套餐', + + 'PRINTER_NOT_EXIST' => '打印机不存在' ]; diff --git a/niucloud/app/lang/zh-cn/dict.php b/niucloud/app/lang/zh-cn/dict.php index 975349bc1..0d3ee434c 100644 --- a/niucloud/app/lang/zh-cn/dict.php +++ b/niucloud/app/lang/zh-cn/dict.php @@ -38,18 +38,6 @@ return [ 'status_off' => '停用' ], // 站点 - 'dict_site' => [ - //站点类型 - 'type_cms' => 'cms', - 'status_on' => '正常', - 'status_experience' => '体验期', - 'status_expire' => '已到期', - 'status_close' => '已停止', - 'pay' => '支付', - 'refund' => '退款', - 'transfer' => '转账', - ], - // 站点 'dict_site_index' => [ //站点类型 'system' => '框架首页', @@ -232,6 +220,7 @@ return [ 'member_my_level' => '会员等级', 'member_my_sign_in' => '我的签到', 'member_verify_index' => '核销台', + 'member_contact' => '客服', 'diy_page' => '自定义页面', 'diy_link' => '自定义链接', @@ -239,7 +228,7 @@ return [ 'diy_make_phone_call' => '拨打电话' ], // 自定义海报 - 'dict_diy_poster'=>[ + 'dict_diy_poster' => [ 'component_type_basic' => '基础组件', ], //短信相关 @@ -379,4 +368,8 @@ return [ 'status_not_sign' => '未签到', 'status_signed' => '已签到' ], + // 打印机品牌 + 'dict_printer' => [ + 'yilianyun' => '易联云打印机' + ] ]; diff --git a/niucloud/app/lang/zh-cn/validate.php b/niucloud/app/lang/zh-cn/validate.php index 2f49f65e8..0c688f79b 100644 --- a/niucloud/app/lang/zh-cn/validate.php +++ b/niucloud/app/lang/zh-cn/validate.php @@ -30,11 +30,11 @@ return [ 'limit_between' => 'limit必须是正整数并且不能超过120', ], 'validate_user' => [ - 'username_require' => '用户名必须填写', - 'username_unique' => '用户名必须是惟一的', - 'username_max' => '用户名最多不能超过15个字符', + 'username_require' => '账号必须填写', + 'username_unique' => '账号必须是唯一的', + 'username_max' => '账号最多不能超过15个字符', 'real_name_require' => '实际姓名必须填写', - 'password_require' => '用户密码必须填写', + 'password_require' => '账号密码必须填写', ], //站点 'validate_site' => [ diff --git a/niucloud/app/listener/member/MemberExportDataListener.php b/niucloud/app/listener/member_export/MemberExportDataListener.php similarity index 76% rename from niucloud/app/listener/member/MemberExportDataListener.php rename to niucloud/app/listener/member_export/MemberExportDataListener.php index 91876d4c3..2a04bdf84 100644 --- a/niucloud/app/listener/member/MemberExportDataListener.php +++ b/niucloud/app/listener/member_export/MemberExportDataListener.php @@ -9,14 +9,14 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\listener\member; +namespace app\listener\member_export; use app\model\member\Member; /** * 会员导出数据源查询 - * Class MemberExportTypeListener - * @package app\listener\member + * Class MemberExportDataListener + * @package app\listener\member_export */ class MemberExportDataListener { @@ -26,7 +26,7 @@ class MemberExportDataListener $data = []; if ($param['type'] == 'member') { $model = new Member(); - $field = 'member_id, member_no, username, mobile, nickname, birthday, member_level, point, balance, money, growth, commission, register_channel, status, create_time, last_visit_time'; + $field = 'member_id, member_no, mobile, nickname, birthday, member_level, point, balance, money, growth, commission, register_channel, status, create_time, last_visit_time'; //查询导出数据 $search_model = $model->withSearch(['keyword','register_type', 'create_time', 'is_del', 'member_label', 'register_channel'], $param['where']) ->with(['memberLevelNameBind'])->field($field)->append(['register_channel_name', 'sex_name', 'status_name']); @@ -36,12 +36,11 @@ class MemberExportDataListener $data = $search_model->select()->toArray(); } foreach ($data as $key => $value) { - $data[$key]['username'] = !empty($value['username']) ? $value['username'] : '-'; $data[$key]['mobile'] = $value['mobile']."\t"; - $data[$key]['create_time'] = !empty($value['create_time']) ? $value['create_time'] : '0000-00-00 00:00:00'; - $data[$key]['last_visit_time'] = !empty($value['last_visit_time']) ? $value['last_visit_time'] : '0000-00-00 00:00:00'; + $data[$key]['create_time'] = !empty($value['create_time']) ? $value['create_time'] : ''; + $data[$key]['last_visit_time'] = !empty($value['last_visit_time']) ? $value['last_visit_time'] : ''; } } return $data; } -} +} \ No newline at end of file diff --git a/niucloud/app/listener/member/MemberExportTypeListener.php b/niucloud/app/listener/member_export/MemberExportTypeListener.php similarity index 98% rename from niucloud/app/listener/member/MemberExportTypeListener.php rename to niucloud/app/listener/member_export/MemberExportTypeListener.php index 238d48c69..88eee4ec8 100644 --- a/niucloud/app/listener/member/MemberExportTypeListener.php +++ b/niucloud/app/listener/member_export/MemberExportTypeListener.php @@ -9,7 +9,7 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\listener\member; +namespace app\listener\member_export; /** * 会员导出数据类型查询 diff --git a/niucloud/app/listener/system/AdminIndexListener.php b/niucloud/app/listener/system/AdminIndexListener.php deleted file mode 100644 index 11a523563..000000000 --- a/niucloud/app/listener/system/AdminIndexListener.php +++ /dev/null @@ -1,30 +0,0 @@ - get_lang("dict_admin_index.system"), - "view_path" => "index/index" - ] - ]; - } -} diff --git a/niucloud/app/listener/system/Poster.php b/niucloud/app/listener/system/Poster.php index a27807aa2..3808a8d82 100644 --- a/niucloud/app/listener/system/Poster.php +++ b/niucloud/app/listener/system/Poster.php @@ -38,7 +38,7 @@ class Poster $headimg = $member_info[ 'headimg' ]; if (empty($headimg)) { - $headimg = 'static/resource/images/default_headimg.jpg'; + $headimg = 'static/resource/images/default_headimg.png'; } $return_data = [ 'nickname' => $nickname, diff --git a/niucloud/app/model/addon/Addon.php b/niucloud/app/model/addon/Addon.php index 9283d1ab9..8043df03a 100644 --- a/niucloud/app/model/addon/Addon.php +++ b/niucloud/app/model/addon/Addon.php @@ -77,7 +77,7 @@ class Addon extends BaseModel */ public function searchTitleAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->whereLike('title', '%' . $value . '%'); } } diff --git a/niucloud/app/model/dict/Dict.php b/niucloud/app/model/dict/Dict.php index 3e7e46e7f..dc8952f76 100644 --- a/niucloud/app/model/dict/Dict.php +++ b/niucloud/app/model/dict/Dict.php @@ -12,9 +12,6 @@ namespace app\model\dict; use core\base\BaseModel; -use think\model\concern\SoftDelete; -use think\model\relation\HasMany; -use think\model\relation\HasOne; /** * 数据字典模型 @@ -24,8 +21,6 @@ use think\model\relation\HasOne; class Dict extends BaseModel { - - /** * 数据表主键 * @var string @@ -43,7 +38,7 @@ class Dict extends BaseModel ]; // 设置json类型字段 - protected $json = ['dictionary']; + protected $json = [ 'dictionary' ]; // 设置JSON数据返回数组 protected $jsonAssoc = true; @@ -54,7 +49,7 @@ class Dict extends BaseModel */ public function searchNameAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where("name", $value); } } @@ -66,12 +61,9 @@ class Dict extends BaseModel */ public function searchKeyAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where("key", $value); } } - - - } diff --git a/niucloud/app/model/diy/Diy.php b/niucloud/app/model/diy/Diy.php index 65ee05abe..cd515fee7 100644 --- a/niucloud/app/model/diy/Diy.php +++ b/niucloud/app/model/diy/Diy.php @@ -174,8 +174,8 @@ class Diy extends BaseModel */ public function searchTitleAttr($query, $value, $data) { - if ($value) { - $query->where("title|page_title", 'like', '%' . $value . '%'); + if ($value != '') { + $query->where("title|page_title", 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } diff --git a/niucloud/app/model/diy/DiyRoute.php b/niucloud/app/model/diy/DiyRoute.php index eadf97570..2317359b8 100644 --- a/niucloud/app/model/diy/DiyRoute.php +++ b/niucloud/app/model/diy/DiyRoute.php @@ -55,7 +55,7 @@ class DiyRoute extends BaseModel */ public function searchTitleAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where("title", 'like', '%' . $value . '%'); } } diff --git a/niucloud/app/model/generator/GenerateTable.php b/niucloud/app/model/generator/GenerateTable.php index 7c4a367c6..fdbc5eadc 100644 --- a/niucloud/app/model/generator/GenerateTable.php +++ b/niucloud/app/model/generator/GenerateTable.php @@ -44,7 +44,7 @@ class GenerateTable extends BaseModel */ public function searchTableNameAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where('table_name', 'like', '%' . $value . '%'); } } @@ -57,7 +57,7 @@ class GenerateTable extends BaseModel */ public function searchTableContentAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where('table_content', 'like', '%' . $value . '%'); } } @@ -70,7 +70,7 @@ class GenerateTable extends BaseModel */ public function searchAddonNameAttr($query, $value, $data) { - if ($value) { + if ($value != '') { if($value == 2) { $query->where('addon_name','=',''); diff --git a/niucloud/app/model/member/Member.php b/niucloud/app/model/member/Member.php index 3125af452..33bf0ee9e 100644 --- a/niucloud/app/model/member/Member.php +++ b/niucloud/app/model/member/Member.php @@ -62,7 +62,7 @@ class Member extends BaseModel protected $defaultSoftDelete = 0; // 设置json类型字段 - protected $json = ['member_label']; + protected $json = [ 'member_label' ]; // 设置JSON数据返回数组 protected $jsonAssoc = true; @@ -74,9 +74,9 @@ class Member extends BaseModel */ public function getStatusNameAttr($value, $data) { - if (empty($data['status'])) + if (empty($data[ 'status' ])) return ''; - return MemberDict::getStatus()[$data['status']] ?? ''; + return MemberDict::getStatus()[ $data[ 'status' ] ] ?? ''; } /** @@ -87,9 +87,9 @@ class Member extends BaseModel */ public function getRegisterChannelNameAttr($value, $data) { - if (empty($data['register_channel'])) + if (empty($data[ 'register_channel' ])) return ''; - return MemberRegisterChannelDict::getType()[$data['register_channel']] ?? ''; + return MemberRegisterChannelDict::getType()[ $data[ 'register_channel' ] ] ?? ''; } /** @@ -100,9 +100,9 @@ class Member extends BaseModel */ public function getRegisterTypeNameAttr($value, $data) { - if (empty($data['register_type'])) + if (empty($data[ 'register_type' ])) return ''; - return MemberRegisterTypeDict::getType()[$data['register_type']] ?? ''; + return MemberRegisterTypeDict::getType()[ $data[ 'register_type' ] ] ?? ''; } /** @@ -113,9 +113,9 @@ class Member extends BaseModel */ public function getLoginChannelNameAttr($value, $data) { - if (empty($data['login_channel'])) + if (empty($data[ 'login_channel' ])) return ''; - return ChannelDict::getType()[$data['login_channel']] ?? ''; + return ChannelDict::getType()[ $data[ 'login_channel' ] ] ?? ''; } /** @@ -126,9 +126,9 @@ class Member extends BaseModel */ public function getLoginTypeNameAttr($value, $data) { - if (empty($data['login_type'])) + if (empty($data[ 'login_type' ])) return ''; - return MemberLoginTypeDict::getType()[$data['login_type']] ?? ''; + return MemberLoginTypeDict::getType()[ $data[ 'login_type' ] ] ?? ''; } /** @@ -139,9 +139,9 @@ class Member extends BaseModel */ public function getSexNameAttr($value, $data) { - if (empty($data['sex'])) + if (empty($data[ 'sex' ])) return ''; - return CommonDict::getSexType()[$data['sex']] ?? ''; + return CommonDict::getSexType()[ $data[ 'sex' ] ] ?? ''; } /** @@ -161,8 +161,8 @@ class Member extends BaseModel */ public function searchKeywordAttr($query, $value, $data) { - if ($value) { - $query->where('member_no|username|nickname|mobile', 'like', '%' . $value . '%'); + if ($value != '') { + $query->where('member_no|username|nickname|mobile', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } @@ -217,7 +217,7 @@ class Member extends BaseModel public function searchMemberLevelAttr(Query $query, $value, $data) { if ($value) { - $query->where('member_level', '=', $value); + $query->where('member_level', '=', $value); } } @@ -229,14 +229,14 @@ class Member extends BaseModel */ 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]); + $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('create_time', $start_time, $end_time); } else if ($start_time > 0 && $end_time == 0) { - $query->where([['create_time', '>=', $start_time]]); + $query->where([ [ 'create_time', '>=', $start_time ] ]); } else if ($start_time == 0 && $end_time > 0) { - $query->where([['create_time', '<=', $end_time]]); + $query->where([ [ 'create_time', '<=', $end_time ] ]); } } @@ -248,22 +248,24 @@ class Member extends BaseModel */ public function searchJoinCreateTimeAttr(Query $query, $value, $data) { - $start_time = empty($value[0]) ? 0 : strtotime($value[0]); - $end_time = empty($value[1]) ? 0 : strtotime($value[1]); + $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('member.create_time', $start_time, $end_time); } else if ($start_time > 0 && $end_time == 0) { - $query->where([['member.create_time', '>=', $start_time]]); + $query->where([ [ 'member.create_time', '>=', $start_time ] ]); } else if ($start_time == 0 && $end_time > 0) { - $query->where([['member.create_time', '<=', $end_time]]); + $query->where([ [ 'member.create_time', '<=', $end_time ] ]); } } - public function memberLevelData() { + public function memberLevelData() + { return $this->hasOne(MemberLevel::class, 'level_id', 'member_level'); } - public function memberLevelNameBind() { - return $this->hasOne(MemberLevel::class, 'level_id', 'member_level')->bind(['member_level_name' => 'level_name']); + public function memberLevelNameBind() + { + return $this->hasOne(MemberLevel::class, 'level_id', 'member_level')->bind([ 'member_level_name' => 'level_name' ]); } } diff --git a/niucloud/app/model/member/MemberAccountLog.php b/niucloud/app/model/member/MemberAccountLog.php index a4ef86ae8..1aacecda8 100644 --- a/niucloud/app/model/member/MemberAccountLog.php +++ b/niucloud/app/model/member/MemberAccountLog.php @@ -14,6 +14,7 @@ namespace app\model\member; use app\dict\member\MemberAccountChangeTypeDict; use app\dict\member\MemberAccountTypeDict; use core\base\BaseModel; +use think\db\Query; use think\model\relation\HasOne; /** @@ -125,6 +126,19 @@ class MemberAccountLog extends BaseModel } } + /** + * 关键词搜索 + * @param $query + * @param $value + * @param $data + */ + public function searchKeywordAttr(Query $query, $value, $data) + { + if ($value != '') { + $query->whereLike('memo', '%'.$value.'%'); + } + } + /** * 金额大于 * @param $query diff --git a/niucloud/app/model/member/MemberCashOut.php b/niucloud/app/model/member/MemberCashOut.php index b1158e13d..7c62ca7c4 100644 --- a/niucloud/app/model/member/MemberCashOut.php +++ b/niucloud/app/model/member/MemberCashOut.php @@ -157,7 +157,7 @@ class MemberCashOut extends BaseModel */ public function searchCashOutNoAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where('cash_out_no', $value); } } diff --git a/niucloud/app/model/member/MemberLabel.php b/niucloud/app/model/member/MemberLabel.php index b2ed0415a..f1bcd5223 100644 --- a/niucloud/app/model/member/MemberLabel.php +++ b/niucloud/app/model/member/MemberLabel.php @@ -62,8 +62,8 @@ class MemberLabel extends BaseModel */ public function searchLabelNameAttr($query, $value, $data) { - if ($value) { - $query->where('label_name', 'like', '%' . $value . '%'); + if ($value != '') { + $query->where('label_name', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } diff --git a/niucloud/app/model/member/MemberLevel.php b/niucloud/app/model/member/MemberLevel.php index 688654e0c..db1517810 100644 --- a/niucloud/app/model/member/MemberLevel.php +++ b/niucloud/app/model/member/MemberLevel.php @@ -11,7 +11,6 @@ namespace app\model\member; -use app\service\core\member\CoreMemberService; use core\base\BaseModel; /** @@ -63,7 +62,7 @@ class MemberLevel extends BaseModel public function searchLevelNameAttr($query, $value, $data) { if ($value != '') { - $query->where('level_name', 'like', '%'.$value.'%'); + $query->where('level_name', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } } diff --git a/niucloud/app/model/sys/Poster.php b/niucloud/app/model/sys/Poster.php index ff752c6ae..451cf2291 100644 --- a/niucloud/app/model/sys/Poster.php +++ b/niucloud/app/model/sys/Poster.php @@ -66,8 +66,8 @@ class Poster extends BaseModel */ public function searchNameAttr($query, $value, $data) { - if ($value) { - $query->where("name", 'like', '%' . $value . '%'); + if ($value != '') { + $query->where("name", 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } diff --git a/niucloud/app/model/sys/SysExport.php b/niucloud/app/model/sys/SysExport.php index b6416e7e6..2b1ee10a7 100644 --- a/niucloud/app/model/sys/SysExport.php +++ b/niucloud/app/model/sys/SysExport.php @@ -70,7 +70,7 @@ class SysExport extends BaseModel public function searchExportKeyAttr(Query $query, $value, $data) { if ($value) { - $query->whereLike('export_key', '%' . $value . '%'); + $query->where('export_key', $value); } } diff --git a/niucloud/app/model/sys/SysNoticeLog.php b/niucloud/app/model/sys/SysNoticeLog.php index e5a29e8a5..2ea77094d 100644 --- a/niucloud/app/model/sys/SysNoticeLog.php +++ b/niucloud/app/model/sys/SysNoticeLog.php @@ -112,7 +112,7 @@ class SysNoticeLog extends BaseModel */ public function searchReceiverAttr($query, $value) { - if ($value) { + if ($value != '') { $query->where('receiver', $value); } } diff --git a/niucloud/app/model/sys/SysNoticeSmsLog.php b/niucloud/app/model/sys/SysNoticeSmsLog.php index 84e8ae30a..ac0e8ac66 100644 --- a/niucloud/app/model/sys/SysNoticeSmsLog.php +++ b/niucloud/app/model/sys/SysNoticeSmsLog.php @@ -143,7 +143,7 @@ class SysNoticeSmsLog extends BaseModel */ public function searchMobileAttr($query, $value) { - if ($value) { + if ($value != '') { $query->where('mobile', $value); } } diff --git a/niucloud/app/model/sys/SysPrinter.php b/niucloud/app/model/sys/SysPrinter.php new file mode 100644 index 000000000..1acea478b --- /dev/null +++ b/niucloud/app/model/sys/SysPrinter.php @@ -0,0 +1,106 @@ +where("printer_id", $value); + } + } + + /** + * 搜索器:小票打印机设备品牌(易联云,365,飞鹅) + * @param $value + * @param $data + */ + public function searchBrandAttr($query, $value, $data) + { + if ($value) { + $query->where("brand", $value); + } + } + + /** + * 搜索器:小票打印机打印机名称 + * @param $value + * @param $data + */ + public function searchPrinterNameAttr($query, $value, $data) + { + if ($value != '') { + $query->where("printer_name", 'like', '%' . $value . '%'); + } + } + + /** + * 搜索器:小票打印机状态(0,关闭,1:开启) + * @param $value + * @param $data + */ + public function searchStatusAttr($query, $value, $data) + { + if ($value !== '') { + $query->where("status", $value); + } + } + +} diff --git a/niucloud/app/model/sys/SysPrinterTemplate.php b/niucloud/app/model/sys/SysPrinterTemplate.php new file mode 100644 index 000000000..f81646380 --- /dev/null +++ b/niucloud/app/model/sys/SysPrinterTemplate.php @@ -0,0 +1,94 @@ +where("template_id", $value); + } + } + + /** + * 搜索器:小票打印模板模板类型 + * @param $value + * @param $data + */ + public function searchTemplateTypeAttr($query, $value, $data) + { + if ($value) { + $query->where("template_type", $value); + } + } + + /** + * 搜索器:小票打印模板模板名称 + * @param $value + * @param $data + */ + public function searchTemplateNameAttr($query, $value, $data) + { + if ($value != '') { + $query->where("template_name", 'like', '%' . $value . '%'); + } + } + +} diff --git a/niucloud/app/model/sys/SysRole.php b/niucloud/app/model/sys/SysRole.php index b708e1a76..b49f1e6a1 100644 --- a/niucloud/app/model/sys/SysRole.php +++ b/niucloud/app/model/sys/SysRole.php @@ -34,20 +34,13 @@ class SysRole extends BaseModel */ protected $name = 'sys_role'; // 设置json类型字段 - protected $json = ['rules','addon_keys']; + protected $json = [ 'rules', 'addon_keys' ]; // 设置JSON数据返回数组 protected $jsonAssoc = true; - /** - * 角色状态 - * @param $value - * @param $data - * @return string - */ public function getStatusNameAttr($value, $data) { - return RoleStatusDict::getStatus()[$data['status']] ?? ''; + return RoleStatusDict::getStatus()[ $data[ 'status' ] ] ?? ''; } - } diff --git a/niucloud/app/model/sys/SysUser.php b/niucloud/app/model/sys/SysUser.php index 3f7cbf74a..5c20aee20 100644 --- a/niucloud/app/model/sys/SysUser.php +++ b/niucloud/app/model/sys/SysUser.php @@ -14,7 +14,6 @@ namespace app\model\sys; use app\dict\sys\UserDict; use core\base\BaseModel; use think\model\concern\SoftDelete; -use think\model\relation\HasMany; /** * 系统用户模型 @@ -47,17 +46,16 @@ class SysUser extends BaseModel protected $deleteTime = 'delete_time'; // 设置json类型字段 - protected $json = ['role_ids']; + protected $json = [ 'role_ids' ]; // 设置JSON数据返回数组 protected $jsonAssoc = true; + /** * 定义软删除字段的默认值 * @var int */ protected $defaultSoftDelete = 0; - - /** * 状态字段转化 * @param $value @@ -66,13 +64,14 @@ class SysUser extends BaseModel */ public function getStatusNameAttr($value, $data) { - if (empty($data['status'])) return ''; - return UserDict::getStatus()[$data['status']] ?? ''; + if (empty($data[ 'status' ])) return ''; + return UserDict::getStatus()[ $data[ 'status' ] ] ?? ''; } + public function getCreateTimeAttr($value, $data) { - return $data['create_time'] ? get_date_by_time($data['create_time']) : ''; + return $data[ 'create_time' ] ? get_date_by_time($data[ 'create_time' ]) : ''; } /** @@ -82,8 +81,8 @@ class SysUser extends BaseModel */ public function searchUsernameAttr($query, $value) { - if ($value) { - $query->whereLike('username', '%' . $value . '%'); + if ($value != '') { + $query->whereLike('username', '%' . $this->handelSpecialCharacter($value) . '%'); } } @@ -95,26 +94,12 @@ class SysUser extends BaseModel */ public function searchRealnameAttr($query, $value) { - if ($value) { + if ($value != '') { $query->whereLike('real_name', '%' . $value . '%'); } } - /** - * 角色组筛选 - * @param $query - * @param $value - * @return void - */ - public function searchRoleIdsAttr($query, $value) - { - if ($value) { - $query->whereLike('role_ids', '%' . $value . '%'); - } - - } - /** * 是否删除搜索器 * @param $query @@ -124,17 +109,6 @@ class SysUser extends BaseModel $query->where('is_del', 0); } - /** - * 状态搜索器 - * @param $query - * @param $value - */ - public function searchStatusAttr($query, $value) - { - $query->where('status', $value); - } - - /** * 创建时间搜索器 * @param $query @@ -143,16 +117,33 @@ class SysUser extends BaseModel */ public function searchCreateTimeAttr($query, $value, $data) { - $start_time = empty($value[0]) ? 0 : strtotime($value[0]); - $end_time = empty($value[1]) ? 0 : strtotime($value[1]); + $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('sys_user.create_time', $start_time, $end_time); } else if ($start_time > 0 && $end_time == 0) { - $query->where([['sys_user.create_time', '>=', $start_time]]); + $query->where([ [ 'sys_user.create_time', '>=', $start_time ] ]); } else if ($start_time == 0 && $end_time > 0) { - $query->where([['sys_user.create_time', '<=', $end_time]]); + $query->where([ [ 'sys_user.create_time', '<=', $end_time ] ]); } } - + /** + * 创建时间搜索器 + * @param $query + * @param $value + * @param $data + */ + public function searchLastTimeAttr($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('sys_user.last_time', $start_time, $end_time); + } else if ($start_time > 0 && $end_time == 0) { + $query->where([ [ 'sys_user.last_time', '>=', $start_time ] ]); + } else if ($start_time == 0 && $end_time > 0) { + $query->where([ [ 'sys_user.last_time', '<=', $end_time ] ]); + } + } } diff --git a/niucloud/app/model/sys/SysUserLog.php b/niucloud/app/model/sys/SysUserLog.php index 2b7a7a7a1..8466e3ebe 100644 --- a/niucloud/app/model/sys/SysUserLog.php +++ b/niucloud/app/model/sys/SysUserLog.php @@ -61,7 +61,7 @@ class SysUserLog extends BaseModel */ public function searchUsernameAttr(Query $query, $value, $data) { - if ($value) { + if ($value != '') { $query->whereLike('username', '%' . $value . '%'); } } @@ -87,7 +87,7 @@ class SysUserLog extends BaseModel */ public function searchUrlAttr(Query $query, $value, $data) { - if ($value) { + if ($value != '') { $query->whereLike('url', '%' . $value . '%'); } } @@ -100,7 +100,7 @@ class SysUserLog extends BaseModel */ public function searchIpAttr(Query $query, $value, $data) { - if ($value) { + if ($value != '') { $query->whereLike('ip', '%' . $value . '%'); } } diff --git a/niucloud/app/model/verify/Verifier.php b/niucloud/app/model/verify/Verifier.php index 03922a962..89955425c 100644 --- a/niucloud/app/model/verify/Verifier.php +++ b/niucloud/app/model/verify/Verifier.php @@ -11,7 +11,6 @@ namespace app\model\verify; -use app\dict\verify\VerifyDict; use app\model\member\Member; use core\base\BaseModel; diff --git a/niucloud/app/model/verify/Verify.php b/niucloud/app/model/verify/Verify.php index 73679ed5d..5c5585bfc 100644 --- a/niucloud/app/model/verify/Verify.php +++ b/niucloud/app/model/verify/Verify.php @@ -54,8 +54,21 @@ class Verify extends BaseModel */ public function searchCodeAttr(Query $query, $value, $data) { - if ($value) { - $query->whereLike('code', '%'.$value.'%'); + if ($value != '') { + $query->whereLike('code', '%' . $this->handelSpecialCharacter($value) . '%'); + } + } + + /** + * 关键词搜索 + * @param $query + * @param $value + * @param $data + */ + public function searchKeywordAttr(Query $query, $value, $data) + { + if ($value != '') { + $query->whereLike('code|body', '%' . $this->handelSpecialCharacter($value) . '%'); } } diff --git a/niucloud/app/service/admin/applet/AppletDownloadService.php b/niucloud/app/service/admin/applet/AppletDownloadService.php index 9d839b308..8fd62e283 100644 --- a/niucloud/app/service/admin/applet/AppletDownloadService.php +++ b/niucloud/app/service/admin/applet/AppletDownloadService.php @@ -24,7 +24,6 @@ class AppletDownloadService extends BaseAdminService public function __construct() { parent::__construct(); - } diff --git a/niucloud/app/service/admin/auth/AuthService.php b/niucloud/app/service/admin/auth/AuthService.php index e03b7525b..ec9c9c581 100644 --- a/niucloud/app/service/admin/auth/AuthService.php +++ b/niucloud/app/service/admin/auth/AuthService.php @@ -12,7 +12,6 @@ namespace app\service\admin\auth; use app\Request; -use app\service\admin\addon\AddonService; use app\service\admin\sys\MenuService; use app\service\admin\sys\RoleService; use app\service\admin\user\UserService; @@ -34,7 +33,8 @@ class AuthService extends BaseAdminService * @return bool * @throws Exception */ - public function checkRole(Request $request){ + public function checkRole(Request $request) + { $rule = strtolower(trim($request->rule()->getRule())); $method = strtolower(trim($request->method())); @@ -42,12 +42,12 @@ class AuthService extends BaseAdminService $menu_service = new MenuService(); $all_menu_list = $menu_service->getAllApiList(); //先判断当前访问的接口是否收到权限的限制 - $method_menu_list = $all_menu_list[$method] ?? []; - if(!in_array($rule, $method_menu_list)) + $method_menu_list = $all_menu_list[ $method ] ?? []; + if (!in_array($rule, $method_menu_list)) return true; $auth_role_list = $this->getAuthApiList(); - if(!empty($auth_role_list[$method]) && in_array($rule, $auth_role_list[$method])) + if (!empty($auth_role_list[ $method ]) && in_array($rule, $auth_role_list[ $method ])) return true; throw new AuthException('NO_PERMISSION'); @@ -58,18 +58,19 @@ class AuthService extends BaseAdminService * 当前授权用户接口权限 * @return array */ - public function getAuthApiList(){ - $user_info = ( new UserService())->getUserCache($this->uid); - if(empty($user_info)) + public function getAuthApiList() + { + $user_info = ( new UserService() )->getUserCache($this->uid); + if (empty($user_info)) return []; - $is_admin = $user_info['is_admin'];//是否是超级管理员组 + $is_admin = $user_info[ 'is_admin' ];//是否是超级管理员组 $menu_service = new MenuService(); - if($is_admin){//查询全部启用的权限 + if ($is_admin) {//查询全部启用的权限 //获取站点信息 - return (new MenuService())->getAllApiList(1); - }else{ - $user_role_ids = $user_info['role_ids']; + return ( new MenuService() )->getAllApiList(1); + } else { + $user_role_ids = $user_info[ 'role_ids' ]; $role_service = new RoleService(); $menu_keys = $role_service->getMenuKeysByRoleIds($user_role_ids ?? []); return $menu_service->getApiListByMenuKeys($menu_keys); @@ -80,16 +81,17 @@ class AuthService extends BaseAdminService * 当前授权用户菜单权限 * @return array */ - public function getAuthMenuList($status = 'all', int $is_tree = 0, int $is_button = 1){ - $user_info = ( new UserService())->getUserCache($this->uid); - if(empty($user_info)) + public function getAuthMenuList($status = 'all', int $is_tree = 0, int $is_button = 1) + { + $user_info = ( new UserService() )->getUserCache($this->uid); + if (empty($user_info)) return []; - $is_admin = $user_info['is_admin'];//是否是超级管理员组 + $is_admin = $user_info[ 'is_admin' ];//是否是超级管理员组 $menu_service = new MenuService(); if ($is_admin) {//查询全部启用的权限 - return (new MenuService())->getAllMenuList($status, $is_tree, $is_button); + return ( new MenuService() )->getAllMenuList($status, $is_tree, $is_button); } else { - $user_role_ids = $user_info['role_ids']; + $user_role_ids = $user_info[ 'role_ids' ]; $role_service = new RoleService(); $menu_keys = $role_service->getMenuKeysByRoleIds($user_role_ids ?? []); return $menu_service->getMenuListByMenuKeys($menu_keys, $is_tree, is_button:$is_button); @@ -99,8 +101,9 @@ class AuthService extends BaseAdminService /** * 获取授权用户信息 */ - public function getAuthInfo(){ - return ( new UserService())->getUserCache($this->uid); + public function getAuthInfo() + { + return ( new UserService() )->getUserCache($this->uid); } /** @@ -108,51 +111,15 @@ class AuthService extends BaseAdminService * @param array $data * @return true */ - public function editAuth(array $data){ - if(!empty($data['password'])){ + public function editAuth(array $data) + { + if (!empty($data[ 'password' ])) { //检测原始密码是否正确 - $user = (new UserService())->find($this->uid); - if(!check_password($data['original_password'], $user->password)) + $user = ( new UserService() )->find($this->uid); + if (!check_password($data[ 'original_password' ], $user->password)) throw new AuthException('OLD_PASSWORD_ERROR'); } - return (new UserService())->edit($this->uid, $data); - } - - /** - * 获取当前账号授权的应用列表 - * @return array|mixed|string - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getAuthAddonList($data= []){ - $user_info = ( new UserService())->getUserCache($this->uid); - if(empty($user_info)) - return []; - $is_admin = $user_info['is_admin'];//是否是超级管理员组 - if($is_admin){//查询全部启用的权限 - if(empty($data['type'])){ - return (new AddonService())->getInstallAddonList($data); - }else{ - return (new AddonService())->getInstallStarAddonList($data); - } - }else{ - $user_role_ids = $user_info['role_ids']; - $role_service = new RoleService(); - $addon_keys = $role_service->getAddonKeysByRoleIds($user_role_ids ?? []); - if(empty($data['type'])){ - return (new AddonService())->getAddonListByKeys($addon_keys, $data); - }else{ - return (new AddonService())->getStatAddonLists($addon_keys, $data); - } - } - } - - /** - * 应用插件加星 - */ - public function setAddonStat($key){ - return (new AddonService())->setAddonStat($key); + return ( new UserService() )->edit($this->uid, $data); } } diff --git a/niucloud/app/service/admin/diy/DiyConfigService.php b/niucloud/app/service/admin/diy/DiyConfigService.php index 013e2f960..687fbe621 100644 --- a/niucloud/app/service/admin/diy/DiyConfigService.php +++ b/niucloud/app/service/admin/diy/DiyConfigService.php @@ -34,10 +34,10 @@ class DiyConfigService extends BaseAdminService { $list = ( new CoreDiyConfigService() )->getBottomList($params); - $apps = (new CoreAddonService())->getList([ ['type', '=', 'app'] ]); + $apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]); // 单应用,排除 系统 底部导航设置 - if (count($apps) == 1) { + if (count($list) > 1 && count($apps) == 1) { foreach ($list as $k => $v) { if ($v[ 'key' ] = 'app') { unset($list[ $k ]); diff --git a/niucloud/app/service/admin/diy/DiyRouteService.php b/niucloud/app/service/admin/diy/DiyRouteService.php index 15d1d0bc2..ebdac848c 100644 --- a/niucloud/app/service/admin/diy/DiyRouteService.php +++ b/niucloud/app/service/admin/diy/DiyRouteService.php @@ -50,7 +50,7 @@ class DiyRouteService extends BaseAdminService if (!empty($cv[ 'url' ])) { $is_add = true; - if (!empty($where[ 'title' ]) && !str_contains($cv[ 'title' ], $where[ 'title' ])) { + if (isset($where[ 'title' ]) && $where[ 'title' ] !='' && !str_contains($cv[ 'title' ], $where[ 'title' ])) { $is_add = false; } diff --git a/niucloud/app/service/admin/generator/GenerateService.php b/niucloud/app/service/admin/generator/GenerateService.php index c0b215981..629d91309 100644 --- a/niucloud/app/service/admin/generator/GenerateService.php +++ b/niucloud/app/service/admin/generator/GenerateService.php @@ -11,7 +11,6 @@ namespace app\service\admin\generator; -use app\model\addon\Addon; use app\model\generator\GenerateColumn; use app\model\generator\GenerateTable; use core\base\BaseAdminService; @@ -23,7 +22,6 @@ use think\db\exception\ModelNotFoundException; use think\facade\Db; use think\helper\Str; use think\Model; -use think\model\relation\HasOne; /** diff --git a/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php b/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php index b8159133a..599354dc1 100644 --- a/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php +++ b/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php @@ -11,9 +11,6 @@ namespace app\service\admin\generator\core; -use app\dict\sys\MenuDict; -use app\model\sys\SysMenu; -use think\facade\Cache; use think\helper\Str; /** diff --git a/niucloud/app/service/admin/generator/core/ValidateGenerator.php b/niucloud/app/service/admin/generator/core/ValidateGenerator.php index 49227048f..a1686a90d 100644 --- a/niucloud/app/service/admin/generator/core/ValidateGenerator.php +++ b/niucloud/app/service/admin/generator/core/ValidateGenerator.php @@ -307,6 +307,7 @@ class ValidateGenerator extends BaseGenerator $dir .= $this->moduleName . '/'; return $dir; } + /** * 生成的文件名 * @return string @@ -316,5 +317,4 @@ class ValidateGenerator extends BaseGenerator return $this->getUCaseClassName() . '.php'; } - } diff --git a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php index 78687c139..ccb616e8e 100644 --- a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php +++ b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php @@ -15,7 +15,6 @@ namespace app\service\admin\generator\core; -use app\service\core\menu\CoreMenuService; use think\helper\Str; /** diff --git a/niucloud/app/service/admin/generator/vm/site_service.vm b/niucloud/app/service/admin/generator/vm/site_service.vm index 6ed57a043..134c3d009 100644 --- a/niucloud/app/service/admin/generator/vm/site_service.vm +++ b/niucloud/app/service/admin/generator/vm/site_service.vm @@ -38,7 +38,7 @@ class {UCASE_NAME}Service extends BaseAdminService $field = '{FIELDS}'; $order = '{ORDER}'; - $search_model = {SEARCH_MODEL}; + $search_model = {SEARCH_MODEL} $list = $this->pageQuery($search_model); return $list; } @@ -52,7 +52,7 @@ class {UCASE_NAME}Service extends BaseAdminService { $field = '{FIELDS}'; - $info = {INFO_SEARCH_MODEL}; + $info = {INFO_SEARCH_MODEL} return $info; } diff --git a/niucloud/app/service/admin/member/MemberAccountService.php b/niucloud/app/service/admin/member/MemberAccountService.php index 0a97f8b0f..8b17f9c49 100644 --- a/niucloud/app/service/admin/member/MemberAccountService.php +++ b/niucloud/app/service/admin/member/MemberAccountService.php @@ -42,8 +42,8 @@ class MemberAccountService extends BaseAdminService $field = 'member_account_log.id, member_account_log.member_id, member_account_log.account_type, member_account_log.account_data,member_account_log.account_sum, member_account_log.from_type, member_account_log.related_id, member_account_log.create_time, member_account_log.memo'; $member_where = []; - if (!empty($where[ 'keywords' ])) { - $member_where[] = [ "member.member_no|member.nickname|member.mobile", 'like', '%' . $where[ 'keywords' ] . '%' ]; + if (isset($where[ 'keywords' ]) && $where[ 'keywords' ] != '') { + $member_where[] = [ "member.member_no|member.nickname|member.mobile", 'like', '%' . $this->model->handelSpecialCharacter($where[ 'keywords' ]) . '%' ]; } $search_model = $this->model->withSearch([ 'join_member_id' => 'member_id', 'account_type', 'from_type', 'join_create_time' => 'create_time' ], $where) ->withJoin( diff --git a/niucloud/app/service/admin/member/MemberService.php b/niucloud/app/service/admin/member/MemberService.php index 954d6f4b5..5ec9855da 100644 --- a/niucloud/app/service/admin/member/MemberService.php +++ b/niucloud/app/service/admin/member/MemberService.php @@ -16,7 +16,6 @@ use app\dict\member\MemberRegisterTypeDict; use app\model\member\Member; use app\service\admin\sys\ExportService; use app\service\core\member\CoreMemberService; -use app\service\core\sys\CoreExportService; use core\base\BaseAdminService; use core\dict\DictLoader; use core\exception\AdminException; diff --git a/niucloud/app/service/admin/member/MemberSignService.php b/niucloud/app/service/admin/member/MemberSignService.php index a32fe120e..64b9eafc8 100644 --- a/niucloud/app/service/admin/member/MemberSignService.php +++ b/niucloud/app/service/admin/member/MemberSignService.php @@ -36,9 +36,9 @@ class MemberSignService extends BaseAdminService public function getPage(array $where = []) { $member_where = []; - if(!empty($where['keywords'])) + if(isset($where['keywords']) && $where['keywords'] != '') { - $member_where = [['member.member_no|member.nickname|member.mobile', 'like', '%'.$where['keywords'].'%']]; + $member_where = [['member.member_no|member.nickname|member.mobile', 'like', '%' . $this->model->handelSpecialCharacter($where['keywords']) . '%']]; } $field = 'sign_id, member_sign.member_id, days, day_award, continue_award, continue_tag, member_sign.create_time, is_sign'; $search_model = $this->model->withSearch(['create_time'],$where)->where($member_where)->withJoin(["member" => ['member_no', 'mobile', 'nickname', 'headimg']])->field($field)->append(['is_sign_name'])->order('member_sign.create_time desc'); @@ -111,4 +111,4 @@ class MemberSignService extends BaseAdminService } return $info[ 'value' ]; } -} +} \ No newline at end of file diff --git a/niucloud/app/service/admin/notice/SmsService.php b/niucloud/app/service/admin/notice/SmsService.php index 651e660c8..195449eee 100644 --- a/niucloud/app/service/admin/notice/SmsService.php +++ b/niucloud/app/service/admin/notice/SmsService.php @@ -115,7 +115,7 @@ class SmsService extends BaseAdminService { $config['default'] = $sms_type; }else{ - $config['default'] = ''; + $config['default'] = $config['default'] == $sms_type ? '' : $config['default']; } foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param) { diff --git a/niucloud/app/service/admin/pay/PayChannelService.php b/niucloud/app/service/admin/pay/PayChannelService.php index ad8c9a1dd..359049a3b 100644 --- a/niucloud/app/service/admin/pay/PayChannelService.php +++ b/niucloud/app/service/admin/pay/PayChannelService.php @@ -154,6 +154,8 @@ class PayChannelService extends BaseAdminService 'collection_desc' => $data[ 'collection_desc' ] ?? '',// 必填-转账说明 ]; break; + default: + $config = $data; } return $config; } diff --git a/niucloud/app/service/admin/pay/RefundService.php b/niucloud/app/service/admin/pay/RefundService.php index 0a56bf035..6825c623e 100644 --- a/niucloud/app/service/admin/pay/RefundService.php +++ b/niucloud/app/service/admin/pay/RefundService.php @@ -12,10 +12,8 @@ namespace app\service\admin\pay; use app\dict\pay\PayDict; -use app\model\pay\Pay; use app\model\pay\Refund; use app\service\core\pay\CoreRefundService; -use app\service\core\paytype\CoreOfflineService; use core\base\BaseAdminService; /** diff --git a/niucloud/app/service/admin/sys/AttachmentService.php b/niucloud/app/service/admin/sys/AttachmentService.php index 5ea0def61..7b81b7e05 100644 --- a/niucloud/app/service/admin/sys/AttachmentService.php +++ b/niucloud/app/service/admin/sys/AttachmentService.php @@ -206,8 +206,7 @@ class AttachmentService extends BaseAdminService */ public function getCategoryPage(array $data) { - $where = array ( - ); + $where = array (); if (!empty($data[ 'type' ])) { $where[] = [ 'type', '=', $data[ 'type' ] ]; } @@ -231,8 +230,8 @@ class AttachmentService extends BaseAdminService if (!empty($data[ 'type' ])) { $where[] = [ 'type', '=', $data[ 'type' ] ]; } - if (!empty($data[ 'name' ])) { - $where[] = [ 'name', 'like', '%' . $data[ 'name' ] . '%' ]; + if (isset($data[ 'name' ]) && $data[ 'name' ] != '') { + $where[] = [ 'name', 'like', '%' . $this->model->handelSpecialCharacter($data[ 'name' ]) . '%' ]; } return SysAttachmentCategory::where($where)->field('id,name,type')->order('id desc')->select()->toArray(); } @@ -247,7 +246,7 @@ class AttachmentService extends BaseAdminService $icon_list = IconDict::getIcon(); foreach ($icon_list as $k => $v) { unset($icon_list[ $k ][ 'glyphs' ]); - if (!empty($data[ 'name' ]) && !str_contains($v['name'], $data['name'])) { + if (isset($data[ 'name' ]) && $data[ 'name' ] !='' && !str_contains($v['name'], $data['name'])) { unset($icon_list[ $k ]); } } @@ -310,4 +309,4 @@ class AttachmentService extends BaseAdminService return $res; } -} +} \ No newline at end of file diff --git a/niucloud/app/service/admin/sys/ConfigService.php b/niucloud/app/service/admin/sys/ConfigService.php index 96fb13b89..f48f0a2fb 100644 --- a/niucloud/app/service/admin/sys/ConfigService.php +++ b/niucloud/app/service/admin/sys/ConfigService.php @@ -39,7 +39,7 @@ class ConfigService extends BaseAdminService */ public function getCopyright() { - return (new CoreSysConfigService())->getCopyright(); + return ( new CoreSysConfigService() )->getCopyright(); } /** @@ -50,14 +50,14 @@ class ConfigService extends BaseAdminService public function setCopyright(array $value) { $data = [ - 'icp' => $value['icp'], - 'gov_record' => $value['gov_record'], - 'gov_url' => $value['gov_url'], - 'market_supervision_url' => $value['market_supervision_url'], - 'logo' => $value['logo'], - 'company_name' => $value['company_name'], - 'copyright_link' => $value['copyright_link'], - 'copyright_desc' => $value['copyright_desc'] + 'icp' => $value[ 'icp' ], + 'gov_record' => $value[ 'gov_record' ], + 'gov_url' => $value[ 'gov_url' ], + 'market_supervision_url' => $value[ 'market_supervision_url' ], + 'logo' => $value[ 'logo' ], + 'company_name' => $value[ 'company_name' ], + 'copyright_link' => $value[ 'copyright_link' ], + 'copyright_desc' => $value[ 'copyright_desc' ] ]; return $this->core_config_service->setConfig('COPYRIGHT', $data); } @@ -102,12 +102,14 @@ class ConfigService extends BaseAdminService { return $this->core_config_service->setConfig('WEB_SITE_INFO', $data); } + /** * 获取前端域名 * @return array|string[] */ - public function getSceneDomain(){ - return (new CoreSysConfigService())->getSceneDomain(); + public function getSceneDomain() + { + return ( new CoreSysConfigService() )->getSceneDomain(); } /** @@ -116,17 +118,16 @@ class ConfigService extends BaseAdminService */ public function getService() { - $info = (new CoreConfigService())->getConfig('SERVICE_INFO'); - if(empty($info)) - { + $info = ( new CoreConfigService() )->getConfig('SERVICE_INFO'); + if (empty($info)) { $info = []; - $info['value'] = [ + $info[ 'value' ] = [ 'wechat_code' => '', 'enterprise_wechat' => '', 'tel' => '', ]; } - return $info['value']; + return $info[ 'value' ]; } /** @@ -134,12 +135,12 @@ class ConfigService extends BaseAdminService * @param array $value * @return bool */ - public function setService (array $value) + public function setService(array $value) { $data = [ - "wechat_code" => $value['wechat_code'], - "enterprise_wechat" => $value['enterprise_wechat'], - "tel" => $value['tel'] + "wechat_code" => $value[ 'wechat_code' ], + "enterprise_wechat" => $value[ 'enterprise_wechat' ], + "tel" => $value[ 'tel' ] ]; return $this->core_config_service->setConfig('SERVICE_INFO', $data); @@ -181,215 +182,6 @@ class ConfigService extends BaseAdminService return $info[ 'value' ]; } - /** - * 获取站点主页配置 - * @return mixed|string[] - */ - public function getSiteIndexConfig() - { - $config = (new CoreConfigService())->getConfig("site_index"); - if(empty($config)) - { - $config['value'] = [ - 'view_path' => 'index/site_index' - ]; - }else{ - $result = event("SiteIndex"); - $index_list = []; - foreach ($result as $v) - { - $index_list = empty($index_list) ? $v: array_merge($index_list, $v); - } - $tag = 0; - $view_path = $config['value']['view_path']; - foreach ($index_list as $v) - { - $v_view_path = $v['view_path'] ?? ''; - if($view_path == $v_view_path) - { - $tag = 1; - break; - } - } - if($tag == 0) - { - $config['value'] = [ - 'view_path' => 'index/site_index' - ]; - } - - } - return $config['value']['view_path']; - } - - /** - * 站点主页配置 - * @param $data - * @return true - */ - public function setSiteIndexConfig($data) - { - $config = [ - 'view_path' => $data['view_path'] , - ]; - //检测是否路劲一个异常 - $index_list = $this->getSiteIndexList(); - $check_tag = 0; - foreach($index_list as $v) - { - if($v['view_path'] == $data['view_path']) - { - $check_tag = 1; - } - } - if($check_tag == 0) throw new AdminException('SITE_INDEX_VIEW_PATH_NOT_EXIST'); - (new CoreConfigService())->setConfig("site_index", $config); - return true; - } - - /** - * 获取站点配置的首页列表 - * @return array - */ - public function getSiteIndexList() - { - $result = event("SiteIndex"); - $index_list = []; - foreach ($result as $v) - { - $index_list = empty($index_list) ? $v: array_merge($index_list, $v); - } - $view_path = $this->getSiteIndexConfig(); - foreach ($index_list as $k => $v) - { - $v_view_path = $v['view_path'] ?? ''; - $index_list[$k]['is_use'] = ($v_view_path == $view_path) ? 1: 0; - } - return $index_list; - } - - /** - * 设置站点快捷菜单 - * @param $data - * @return bool - */ - public function setShortcutMenu($data) - { - (new CoreConfigService())->setConfig('shortcut_menu', $data); - return true; - } - - /** - * 获取站点快捷菜单 - * @return array|mixed - */ - public function getShortcutMenu() - { - $config = (new CoreConfigService())->getConfig('shortcut_menu'); - $menu = $config['value'] ?? []; - if(!empty($menu)){ - $menu_service = new MenuService(); - foreach($menu as $k => &$v){ - $menu_key = $v['menu_key'] ?? ''; - if($menu_key != ''){ - $item_router_path = $menu_service->getFullRouterPath($menu_key); - if(empty($item_router_path)){ - unset($v[$k]); - }else{ - $v['router_path'] = $item_router_path; - } - } - } - } - return $menu; - } - /** - * 获取平台主页配置 - * @return mixed|string[] - */ - public function getAdminIndexConfig() - { - $config = (new CoreConfigService())->getConfig("admin_index"); - if(empty($config)) - { - $config['value'] = [ - 'view_path' => 'index/index' - ]; - }else{ - $result = event("AdminIndex"); - $index_list = []; - foreach ($result as $v) - { - $index_list = empty($index_list) ? $v: array_merge($index_list, $v); - } - $tag = 0; - $view_path = $config['value']['view_path']; - foreach ($index_list as $v) - { - $v_view_path = $v['view_path'] ?? ''; - if($view_path == $v_view_path) - { - $tag = 1; - break; - } - } - if($tag == 0) - { - $config['value'] = [ - 'view_path' => 'index/index' - ]; - } - - } - return $config['value']['view_path']; - } - - /** - * 站点主页配置 - * @param $data - * @return true - */ - public function setAdminIndexConfig($data) - { - $config = [ - 'view_path' => $data['view_path'] , - ]; - //检测是否路劲一个异常 - $index_list = $this->getAdminIndexList(); - $check_tag = 0; - foreach($index_list as $v) - { - if($v['view_path'] == $data['view_path']) - { - $check_tag = 1; - } - } - if($check_tag == 0) throw new AdminException('ADMIN_INDEX_VIEW_PATH_NOT_EXIST'); - (new CoreConfigService())->setConfig("admin_index", $config); - return true; - } - - /** - * 获取站点配置的首页列表 - * @return array - */ - public function getAdminIndexList() - { - $result = event("AdminIndex"); - $index_list = []; - foreach ($result as $v) - { - $index_list = empty($index_list) ? $v: array_merge($index_list, $v); - } - $view_path = $this->getAdminIndexConfig(); - foreach ($index_list as $k => $v) - { - $v_view_path = $v['view_path'] ?? ''; - $index_list[$k]['is_use'] = ($v_view_path == $view_path) ? 1: 0; - } - return $index_list; - } - /** * 获取手机端首页列表 * @param $data @@ -404,8 +196,9 @@ class ConfigService extends BaseAdminService * 获取开发者key * @return array */ - public function getDeveloperToken() { - return (new CoreConfigService())->getConfigValue("DEVELOPER_TOKEN"); + public function getDeveloperToken() + { + return ( new CoreConfigService() )->getConfigValue("DEVELOPER_TOKEN"); } /** @@ -413,7 +206,8 @@ class ConfigService extends BaseAdminService * @param array $data * @return array */ - public function setDeveloperToken(array $data) { - return (new CoreConfigService())->setConfig("DEVELOPER_TOKEN", $data); + public function setDeveloperToken(array $data) + { + return ( new CoreConfigService() )->setConfig("DEVELOPER_TOKEN", $data); } } diff --git a/niucloud/app/service/admin/sys/MenuService.php b/niucloud/app/service/admin/sys/MenuService.php index 49e5b85b4..7c4fd0365 100644 --- a/niucloud/app/service/admin/sys/MenuService.php +++ b/niucloud/app/service/admin/sys/MenuService.php @@ -14,7 +14,6 @@ namespace app\service\admin\sys; use app\dict\sys\MenuDict; use app\dict\sys\MenuTypeDict; use app\model\sys\SysMenu; -use app\service\admin\addon\AddonService; use core\base\BaseAdminService; use core\dict\DictLoader; use core\exception\AdminException; @@ -33,6 +32,7 @@ class MenuService extends BaseAdminService { public static $cache_tag_name = 'menu_cache'; + public function __construct() { parent::__construct(); @@ -45,11 +45,11 @@ class MenuService extends BaseAdminService */ public function add(array $data) { - $menu = $this->find($data['menu_key']); - if(!$menu->isEmpty()) throw new AdminException('validate_menu.exit_menu_key');//创建失败 - $data['source'] = MenuDict::CREATE; - $res = (new SysMenu())->create($data); - if(!$res) throw new AdminException('ADD_FAIL');//创建失败 + $menu = $this->find($data[ 'menu_key' ]); + if (!$menu->isEmpty()) throw new AdminException('validate_menu.exit_menu_key');//创建失败 + $data[ 'source' ] = MenuDict::CREATE; + $res = ( new SysMenu() )->create($data); + if (!$res) throw new AdminException('ADD_FAIL');//创建失败 Cache::tag(self::$cache_tag_name)->clear(); return $res; @@ -64,17 +64,12 @@ class MenuService extends BaseAdminService */ public function edit(string $menu_key, array $data) { -// if($menu_key != $data['menu_key']) -// { -// $menu = $this->find($data['menu_key']); -// if(!$menu->isEmpty()) throw new AdminException('validate_menu.exit_menu_key');//创建失败 -// } $where = array( - ['menu_key', '=', $menu_key] + [ 'menu_key', '=', $menu_key ] ); //校验菜单是否可以修改 - $res = (new SysMenu())->update($data, $where); + $res = ( new SysMenu() )->update($data, $where); Cache::tag(self::$cache_tag_name)->clear(); return $res; } @@ -84,19 +79,21 @@ class MenuService extends BaseAdminService * @param string $menu_key * @return array */ - public function get(string $menu_key){ - return (new SysMenu())->where([['menu_key', '=', $menu_key]])->findOrEmpty()->toArray(); + public function get(string $menu_key) + { + return ( new SysMenu() )->where([ [ 'menu_key', '=', $menu_key ] ])->findOrEmpty()->toArray(); } /** * @param string $menu_key * @return SysMenu|array|mixed|Model */ - public function find(string $menu_key){ + public function find(string $menu_key) + { $where = array( - ['menu_key', '=', $menu_key] + [ 'menu_key', '=', $menu_key ] ); - $menu = (new SysMenu())->where($where)->findOrEmpty(); + $menu = ( new SysMenu() )->where($where)->findOrEmpty(); return $menu; } @@ -106,15 +103,16 @@ class MenuService extends BaseAdminService * @return bool * @throws DbException */ - public function del(string $menu_key){ + public function del(string $menu_key) + { //查询是否有下级菜单或按钮 $menu = $this->find($menu_key); - if((new SysMenu())->where([['parent_key', '=', $menu_key]])->count() > 0) + if (( new SysMenu() )->where([ [ 'parent_key', '=', $menu_key ] ])->count() > 0) throw new AdminException('MENU_NOT_ALLOW_DELETE'); $res = $menu->delete(); Cache::tag(self::$cache_tag_name)->clear(); - return $res; + return $res; } /** @@ -129,12 +127,12 @@ class MenuService extends BaseAdminService public function getMenuListByMenuKeys(array $menu_keys, int $is_tree = 0, $addon = 'all', $is_button = 1) { sort($menu_keys); - $cache_name = 'menu' . md5(implode("_", $menu_keys)) . $is_tree.$addon; + $cache_name = 'menu' . md5(implode("_", $menu_keys)) . $is_tree . $addon; $menu_list = cache_remember( $cache_name, - function () use ($menu_keys, $is_tree, $addon) { + function() use ($menu_keys, $is_tree, $addon) { $where = [ - ['menu_key', 'in', $menu_keys], + [ 'menu_key', 'in', $menu_keys ], ]; $addons = get_site_addons(); $addons[] = ''; @@ -142,16 +140,16 @@ class MenuService extends BaseAdminService $delete_menu_addon = []; $addon_loader = new DictLoader("Menu"); - if($addon != 'all'){ - $where[] = ['addon', '=', $addon]; + if ($addon != 'all') { + $where[] = [ 'addon', '=', $addon ]; - $delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => 'admin'])['delete'] ?? []; + $delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => 'admin' ])[ 'delete' ] ?? []; if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu; } else { - $where[] = ['addon', 'in', $addons]; + $where[] = [ 'addon', 'in', $addons ]; foreach ($addons as $addon) { - $delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => 'admin'])['delete'] ?? []; + $delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => 'admin' ])[ 'delete' ] ?? []; if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu; } } @@ -160,24 +158,22 @@ class MenuService extends BaseAdminService if (!empty($delete_menu_addon)) { $delete_intersect = array_intersect(...$delete_menu_addon); if (!empty($delete_intersect)) { - $where[] = ['menu_key', 'not in', $delete_intersect]; + $where[] = [ 'menu_key', 'not in', $delete_intersect ]; } } - if(!empty($app_type)){ - $where[] = ['app_type', '=', $app_type]; + if (!empty($app_type)) { + $where[] = [ 'app_type', '=', $app_type ]; } - return (new SysMenu())->where($where)->order('sort', 'desc')->select()->toArray(); + return ( new SysMenu() )->where($where)->order('sort', 'desc')->select()->toArray(); }, self::$cache_tag_name ); - foreach ($menu_list as &$v) - { - $lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key']; - $lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']); + foreach ($menu_list as &$v) { + $lang_menu_key = "dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ]; + $lang_menu_name = get_lang("dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ]); //语言已定义 - if($lang_menu_key != $lang_menu_name) - { - $v['menu_name'] = $lang_menu_name; + if ($lang_menu_key != $lang_menu_name) { + $v[ 'menu_name' ] = $lang_menu_name; } } @@ -190,39 +186,39 @@ class MenuService extends BaseAdminService */ public function getAllMenuList($status = 'all', $is_tree = 0, $is_button = 0) { - $cache_name = 'menu_api_' .$status . '_' . $is_tree .'_' . $is_button; + $cache_name = 'menu_api_' . $status . '_' . $is_tree . '_' . $is_button; $menu_list = cache_remember( $cache_name, - function () use ($status, $is_tree, $is_button) { - $where = []; + function() use ($status, $is_tree, $is_button) { + $where = [ + [ 'addon', 'in', array_merge([ '' ], get_site_addons()) ] + ]; if ($status != 'all') { - $where[] = ['status', '=', $status]; + $where[] = [ 'status', '=', $status ]; } // 排除菜单 $delete_menu_addon = []; $addon_loader = new DictLoader("Menu"); foreach (get_site_addons() as $addon) { - $delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => 'admin'])['delete'] ?? []; + $delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => 'admin' ])[ 'delete' ] ?? []; if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu; } if (!empty($delete_menu_addon)) { $delete_intersect = array_intersect(...$delete_menu_addon); if (!empty($delete_intersect)) { - $where[] = ['menu_key', 'not in', $delete_intersect]; + $where[] = [ 'menu_key', 'not in', $delete_intersect ]; } } - return (new SysMenu())->where($where)->order('sort desc')->select()->toArray(); + return ( new SysMenu() )->where($where)->order('sort desc')->select()->toArray(); }, self::$cache_tag_name ); - foreach ($menu_list as &$v) - { - $lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key']; + foreach ($menu_list as &$v) { + $lang_menu_key = 'dict_menu_admin' . '.' . $v[ 'menu_key' ]; $lang_menu_name = get_lang($lang_menu_key); //语言已定义 - if($lang_menu_key != $lang_menu_name) - { - $v['menu_name'] = $lang_menu_name; + if ($lang_menu_key != $lang_menu_name) { + $v[ 'menu_name' ] = $lang_menu_name; } } @@ -242,13 +238,13 @@ class MenuService extends BaseAdminService $cache_name = 'api' . md5(implode('_', $menu_keys)); return cache_remember( $cache_name, - function () use ($menu_keys) { + function() use ($menu_keys) { $where = [ - ['menu_key', 'in', $menu_keys] + [ 'menu_key', 'in', $menu_keys ] ]; - $menu_list = (new SysMenu())->where($where)->order('sort', 'desc')->column('api_url,methods'); + $menu_list = ( new SysMenu() )->where($where)->order('sort', 'desc')->column('api_url,methods'); foreach ($menu_list as $v) { - $auth_menu_list[$v['methods']][] = $v['api_url']; + $auth_menu_list[ $v[ 'methods' ] ][] = $v[ 'api_url' ]; } return $auth_menu_list ?? []; }, @@ -268,12 +264,12 @@ class MenuService extends BaseAdminService $cache_name = 'button' . md5(implode('_', $menu_keys)); return cache_remember( $cache_name, - function () use ($menu_keys) { + function() use ($menu_keys) { $where = [ - ['menu_key', 'in', $menu_keys], - ['menu_type', '=', MenuTypeDict::BUTTON] + [ 'menu_key', 'in', $menu_keys ], + [ 'menu_type', '=', MenuTypeDict::BUTTON ] ]; - return (new SysMenu())->where($where)->order('sort', 'desc')->column('menu_key'); + return ( new SysMenu() )->where($where)->order('sort', 'desc')->column('menu_key'); }, self::$cache_tag_name ); @@ -286,20 +282,20 @@ class MenuService extends BaseAdminService */ public function getAllApiList($status = 'all') { - $cache_name = 'all_api' .'_'. $status; + $cache_name = 'all_api' . '_' . $status; return cache_remember( $cache_name, - function () use ($status) { + function() use ($status) { $where = [ - ['api_url', '<>', ''], + [ 'api_url', '<>', '' ], ]; if ($status != 'all') { - $where[] = ['status', '=', $status]; + $where[] = [ 'status', '=', $status ]; } - $menu_list = (new SysMenu())->where($where)->order('sort', 'desc')->column('methods, api_url'); + $menu_list = ( new SysMenu() )->where($where)->order('sort', 'desc')->column('methods, api_url'); $auth_menu_list = []; foreach ($menu_list as $v) { - $auth_menu_list[$v['methods']][] = $v['api_url']; + $auth_menu_list[ $v[ 'methods' ] ][] = $v[ 'api_url' ]; } return $auth_menu_list; }, @@ -312,24 +308,24 @@ class MenuService extends BaseAdminService * @param $status * @return mixed|string */ - public function getAllMenuIdsByAppType($status = 'all'){ + public function getAllMenuIdsByAppType($status = 'all') + { $cache_name = 'menu_id_cache'; return cache_remember( $cache_name, - function () use ($status) { + function() use ($status) { $where = [ ]; if ($status != 'all') { - $where[] = ['status', '=', $status]; + $where[] = [ 'status', '=', $status ]; } - return (new SysMenu())->where($where)->order('sort desc')->column('menu_key'); + return ( new SysMenu() )->where($where)->order('sort desc')->column('menu_key'); }, self::$cache_tag_name ); } - /** * 获取所有按钮菜单 */ @@ -338,14 +334,14 @@ class MenuService extends BaseAdminService $cache_name = 'menu_api_' . $status . '_' . $is_tree; return cache_remember( $cache_name, - function () use ($status, $is_tree) { + function() use ($status, $is_tree) { $where = [ - ['menu_type', '=', MenuTypeDict::BUTTON], + [ 'menu_type', '=', MenuTypeDict::BUTTON ], ]; if ($status != 'all') { - $where[] = ['status', '=', $status]; + $where[] = [ 'status', '=', $status ]; } - return (new SysMenu())->where($where)->order('sort', 'desc')->column('menu_key'); + return ( new SysMenu() )->where($where)->order('sort', 'desc')->column('menu_key'); }, self::$cache_tag_name ); @@ -368,20 +364,20 @@ class MenuService extends BaseAdminService // 创建基于主键的数组引用 $refer = array(); foreach ($list as $key => $data) { - $refer[$data[$pk]] =& $list[$key]; + $refer[ $data[ $pk ] ] =& $list[ $key ]; } foreach ($list as $key => $data) { // 判断是否存在parent - $parent_id = $data[$pid]; + $parent_id = $data[ $pid ]; if ($root == $parent_id) { - $tree[] =& $list[$key]; + $tree[] =& $list[ $key ]; } else { - if (isset($refer[$parent_id])) { - $parent =& $refer[$parent_id]; - if ($list[$key]['menu_type'] == 2 && $is_button == 1) { - $parent[$button_name][] =& $list[$key]['menu_key']; + if (isset($refer[ $parent_id ])) { + $parent =& $refer[ $parent_id ]; + if ($list[ $key ][ 'menu_type' ] == 2 && $is_button == 1) { + $parent[ $button_name ][] =& $list[ $key ][ 'menu_key' ]; } else { - $parent[$child][] =& $list[$key]; + $parent[ $child ][] =& $list[ $key ]; } } @@ -397,17 +393,18 @@ class MenuService extends BaseAdminService * @param $menu_key * @return string */ - public function getFullRouterPath($menu_key){ - $menu = (new SysMenu())->where([['menu_key', '=', $menu_key]])->findOrEmpty($menu_key); - if($menu->isEmpty()) return ''; + public function getFullRouterPath($menu_key) + { + $menu = ( new SysMenu() )->where([ [ 'menu_key', '=', $menu_key ] ])->findOrEmpty($menu_key); + if ($menu->isEmpty()) return ''; $parents = []; $this->getParentDirectory($menu, $parents); $parents = array_reverse($parents); $router_path = implode('/', $parents); - if(!empty($router_path)){ - $router_path .= '/'.$menu['router_path']; - }else{ - $router_path = $menu['router_path']; + if (!empty($router_path)) { + $router_path .= '/' . $menu[ 'router_path' ]; + } else { + $router_path = $menu[ 'router_path' ]; } return $router_path; } @@ -418,11 +415,12 @@ class MenuService extends BaseAdminService * @param $parents * @return void */ - public function getParentDirectory(SysMenu $menu, &$parents){ - if(!$menu->isEmpty() && !empty($menu['parent_key'])){ - $parent_menu = (new SysMenu())->where([['menu_key', '=', $menu['parent_key']]])->findOrEmpty(); - if(!empty($parent_menu)){ - if(!empty($parent_menu['router_path'])) $parents[] = $parent_menu['router_path']; + public function getParentDirectory(SysMenu $menu, &$parents) + { + if (!$menu->isEmpty() && !empty($menu[ 'parent_key' ])) { + $parent_menu = ( new SysMenu() )->where([ [ 'menu_key', '=', $menu[ 'parent_key' ] ] ])->findOrEmpty(); + if (!empty($parent_menu)) { + if (!empty($parent_menu[ 'router_path' ])) $parents[] = $parent_menu[ 'router_path' ]; $this->getParentDirectory($parent_menu, $parents); } } @@ -432,79 +430,71 @@ class MenuService extends BaseAdminService public function getSystemMenu($status = 'all', $is_tree = 0, $is_button = 0) { - if ($status != 'all') { - $where[] = ['status', '=', $status]; + if ($is_button == 0) { + $where = [ + [ 'menu_type', 'in', [ 0, 1 ] ] + ]; } - $where[] = [ 'addon', '=','']; - $menu_list = (new SysMenu())->where($where)->order('sort desc')->select()->toArray(); - foreach ($menu_list as &$v) - { - $lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key']; + + if ($status != 'all') { + $where[] = [ 'status', '=', $status ]; + } + $where[] = [ 'addon', '=', '' ]; + $menu_list = ( new SysMenu() )->where($where)->order('sort desc')->select()->toArray(); + foreach ($menu_list as &$v) { + $lang_menu_key = 'dict_menu_admin' . '.' . $v[ 'menu_key' ]; $lang_menu_name = get_lang($lang_menu_key); //语言已定义 - if($lang_menu_key != $lang_menu_name) - { - $v['menu_name'] = $lang_menu_name; + if ($lang_menu_key != $lang_menu_name) { + $v[ 'menu_name' ] = $lang_menu_name; } } return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list; } - public function getAddonMenu($app_key,$status = 'all', $is_tree = 0, $is_button = 0) + public function getAddonMenu($app_key, $status = 'all', $is_tree = 0, $is_button = 0) { - if($is_button == 0) - { + if ($is_button == 0) { $where = [ - ['menu_type', 'in', [0,1]] + [ 'menu_type', 'in', [ 0, 1 ] ] ]; } if ($status != 'all') { - $where[] = ['status', '=', $status]; + $where[] = [ 'status', '=', $status ]; } - $where[] = [ 'addon', '=',$app_key]; - $menu_list = (new SysMenu())->where($where)->select()->toArray(); -// foreach ($menu_list as &$v) -// { -// $lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key']; -// $lang_menu_name = get_lang($lang_menu_key); -// //语言已定义 -// if($lang_menu_key != $lang_menu_name) -// { -// $v['menu_name'] = $lang_menu_name; -// } -// } + $where[] = [ 'addon', '=', $app_key ]; + $menu_list = ( new SysMenu() )->where($where)->select()->toArray(); return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list; } /** * 查询菜单类型为目录的菜单 * @param string $addon - * @return void + * @return array */ - public function getMenuByTypeDir(string $addon = 'system') { + public function getMenuByTypeDir(string $addon = 'system') + { $cache_name = 'menu_api_by_type_dir' . $addon; $menu_list = cache_remember( $cache_name, - function () use ($addon) { + function() use ($addon) { $where = [ - ['menu_type', '=', 0 ] + [ 'menu_type', '=', 0 ] ]; //查询应用 - $where[] = ['addon', '=', $addon == 'system' ? '' : $addon ]; - return (new SysMenu())->where($where)->order('sort desc')->select()->toArray(); + $where[] = [ 'addon', '=', $addon == 'system' ? '' : $addon ]; + return ( new SysMenu() )->where($where)->order('sort desc')->select()->toArray(); }, self::$cache_tag_name ); - foreach ($menu_list as &$v) - { - $lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key']; + foreach ($menu_list as &$v) { + $lang_menu_key = 'dict_menu_admin' . '.' . $v[ 'menu_key' ]; $lang_menu_name = get_lang($lang_menu_key); //语言已定义 - if($lang_menu_key != $lang_menu_name) - { - $v['menu_name'] = $lang_menu_name; + if ($lang_menu_key != $lang_menu_name) { + $v[ 'menu_name' ] = $lang_menu_name; } } diff --git a/niucloud/app/service/admin/sys/PrinterService.php b/niucloud/app/service/admin/sys/PrinterService.php new file mode 100644 index 000000000..370c9024e --- /dev/null +++ b/niucloud/app/service/admin/sys/PrinterService.php @@ -0,0 +1,250 @@ +model = new SysPrinter(); + } + + /** + * 获取小票打印机分页列表 + * @param array $where + * @return array + * @throws \think\db\exception\DbException + */ + public function getPage(array $where = []) + { + $field = 'printer_id,brand,printer_name,printer_code,printer_key,open_id,apikey,print_width,status,create_time'; + $order = 'create_time desc'; + + $search_model = $this->model->where([ [ 'printer_id', ">", 0 ] ])->withSearch([ "printer_name" ], $where)->field($field)->order($order)->append([ 'brand_name' ]); + $list = $this->pageQuery($search_model); + return $list; + } + + /** + * 获取小票打印机列表 + * @param array $where + * @param string $field + * @return array + * @throws \think\db\exception\DbException + */ + public function getList(array $where = [], $field = 'printer_id,brand,printer_name,printer_code,printer_key,open_id,apikey,print_width,status,create_time') + { + return ( new CorePrinterService() )->getList($where, $field); + } + + /** + * 获取小票打印机信息 + * @param int $id + * @return array + */ + public function getInfo(int $id) + { + $field = 'printer_id,brand,printer_name,printer_code,printer_key,open_id,apikey,value,print_width,status'; + + $info = $this->model->field($field)->where([ [ 'printer_id', "=", $id ] ])->findOrEmpty()->toArray(); + return $info; + } + + /** + * 添加小票打印机 + * @param array $data + * @return mixed + */ + public function add(array $data) + { + try { + Db::startTrans(); + + $res = $this->model->create($data); + + // 绑定易联云设备授权 + if ($data[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $result = ( new CorePrinterService() )->addPrinterYly($data); + if ($result[ 'code' ] != 0) { + Db::rollback(); + throw new CommonException($result[ 'message' ]); + } + } + + Db::commit(); + return $res->printer_id; + } catch (\Exception $e) { + Db::rollback(); + throw new CommonException($e->getMessage()); + } + } + + /** + * 小票打印机编辑 + * @param int $id + * @param array $data + * @return bool + */ + public function edit(int $id, array $data) + { + try { + Db::startTrans(); + + // 绑定易联云设备授权 + if ($data[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $result = ( new CorePrinterService() )->addPrinterYly($data); + if ($result[ 'code' ] != 0) { + Db::rollback(); + throw new CommonException($result[ 'message' ]); + } + } + + $this->model->where([ [ 'printer_id', '=', $id ] ])->update($data); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + throw new CommonException($e->getMessage()); + } + } + + /** + * 修改小票打印机状态 + * @param $data + * @return mixed + */ + public function modifyStatus($data) + { + return $this->model->where([ + [ 'printer_id', '=', $data[ 'printer_id' ] ], + ])->update([ 'status' => $data[ 'status' ] ]); + } + + /** + * 删除小票打印机 + * @param int $printer_id + * @return bool + */ + public function del(int $printer_id) + { + try { + Db::startTrans(); + $field = 'printer_id,brand,printer_code,open_id,apikey'; + $printer_info = $this->model->field($field)->where([ [ 'printer_id', "=", $printer_id ] ])->findOrEmpty()->toArray(); + + // 删除易联云打印机授权 + if ($printer_info[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $result = ( new CorePrinterService() )->deletePrinterYly($printer_info); + if ($result[ 'code' ] != 0) { + Db::rollback(); + throw new CommonException($result[ 'message' ]); + } + } + + $model = $this->model->where([ [ 'printer_id', '=', $printer_id ] ])->find(); + $res = $model->delete(); + Db::commit(); + return $res; + } catch (\Exception $e) { + Db::rollback(); + throw new CommonException($e->getMessage()); + } + } + + /** + * 获取小票打印模板类型 + * @return array|null + */ + public function getType() + { + return ( new CorePrinterService() )->getType(); + } + + /** + * 获取打印机设备品牌 + * @param $brand + * @return array|mixed|string + */ + public function getBrand($brand) + { + return ( new CorePrinterService() )->getBrand($brand); + } + + /**************************************************** 打印机管理(第三方) *********************************************************/ + + /******************** 易联云 start ************************/ + + /** + * 设置易联云小票打印token + * @param $data + * @return \app\model\sys\SysConfig|bool|\think\Model + */ + public function setYlyTokenConfig($data) + { + return ( new CorePrinterService() )->setYlyTokenConfig($data); + } + + /** + * 获取易联云配置 + * @return array + */ + public function getYlyTokenConfig() + { + return ( new CorePrinterService() )->getYlyTokenConfig(); + } + + /** + * 重新获取易联云token + * @param $printer_id + * @return mixed + */ + public function refreshToken($printer_id) + { + return ( new CorePrinterService() )->refreshToken($printer_id); + } + + /** + * 测试打印 + * @param $printer_id + * @return array + */ + public function testPrint($printer_id) + { + return ( new CorePrinterService() )->testPrint($printer_id); + } + + /** + * 打印小票内容 + * @param $params + */ + public function printTicket($params) + { + return ( new CorePrinterService() )->printTicket($params); + } + + /******************** 易联云 end ************************/ + +} diff --git a/niucloud/app/service/admin/sys/PrinterTemplateService.php b/niucloud/app/service/admin/sys/PrinterTemplateService.php new file mode 100644 index 000000000..5d3f487de --- /dev/null +++ b/niucloud/app/service/admin/sys/PrinterTemplateService.php @@ -0,0 +1,134 @@ +model = new SysPrinterTemplate(); + } + + /** + * 获取小票打印模板分页列表 + * @param array $where + * @return array + * @throws \think\db\exception\DbException + */ + public function getPage(array $where = []) + { + $field = 'template_id,template_type,template_name,value,create_time'; + $order = 'create_time desc'; + + $search_model = $this->model->where([ [ 'template_id', ">", 0 ] ])->withSearch([ "template_id", "template_type", "template_name" ], $where)->field($field)->order($order)->append([ 'template_type_name' ]); + $list = $this->pageQuery($search_model); + return $list; + } + + /** + * 获取小票打印模板列表 + * @param array $where + * @param string $field + * @return array + * @throws \think\db\exception\DbException + */ + public function getList(array $where = [], $field = 'template_id,template_type,template_name,value,create_time') + { + $order = 'create_time desc'; + return $this->model->where([ [ 'template_id', ">", 0 ] ])->withSearch([ "template_id", "template_type", "template_name" ], $where)->field($field)->order($order)->append([ 'template_type_name' ])->select()->toArray(); + } + + /** + * 获取小票打印模板信息 + * @param int $id + * @return array + */ + public function getInfo(int $id) + { + $field = 'template_id,template_type,template_name,value'; + + $info = $this->model->field($field)->where([ [ 'template_id', "=", $id ] ])->findOrEmpty()->toArray(); + return $info; + } + + /** + * 添加小票打印模板 + * @param array $data + * @return mixed + */ + public function add(array $data) + { + $res = $this->model->create($data); + return $res->template_id; + } + + /** + * 小票打印模板编辑 + * @param int $id + * @param array $data + * @return bool + */ + public function edit(int $id, array $data) + { + $this->model->where([ [ 'template_id', '=', $id ] ])->update($data); + return true; + } + + /** + * 删除小票打印模板 + * @param int $id + * @return bool + */ + public function del(int $id) + { + // 检测要删除的模板有没有被打印机使用 + $field = 'template_type'; + + $info = $this->model->field($field)->where([ [ 'template_id', "=", $id ] ])->findOrEmpty()->toArray(); + + $core_printer_service = new CorePrinterService(); + $printer_list = $core_printer_service->getList([ + [ 'template_type', 'like', '%"' . $info[ 'template_type' ] . '"%' ] + ], 'printer_id,printer_name,value'); + + if (!empty($printer_list)) { + foreach ($printer_list as $k => $v) { + if (!empty($v[ 'value' ])) { + foreach ($v[ 'value' ] as $value_k => $value_v) { + foreach ($value_v as $trigger_k => $trigger_v) { + if ($trigger_v[ 'template_id' ] == $id) { + throw new CommonException("该模板已被打印机 [{$v['printer_name']}] 使用,无法删除"); + break; + } + } + } + } + } + } + $model = $this->model->where([ [ 'template_id', '=', $id ] ])->find(); + $res = $model->delete(); + return $res; + } + +} diff --git a/niucloud/app/service/admin/sys/RoleService.php b/niucloud/app/service/admin/sys/RoleService.php index 6ce5bd0f7..5c0337244 100644 --- a/niucloud/app/service/admin/sys/RoleService.php +++ b/niucloud/app/service/admin/sys/RoleService.php @@ -12,7 +12,6 @@ namespace app\service\admin\sys; use app\dict\sys\RoleStatusDict; -use app\model\sys\SysMenu; use app\model\sys\SysRole; use app\model\sys\SysUser; use core\base\BaseAdminService; @@ -44,8 +43,8 @@ class RoleService extends BaseAdminService public function getPage(array $data) { $where = []; - if(!empty($data['role_name'])) { - $where[] = ['role_name', 'like', "%".$data['role_name']."%"]; + if(isset($data['role_name']) && $data['role_name'] !== '') { + $where[] = ['role_name', 'like', "%".$this->model->handelSpecialCharacter($data['role_name'])."%"]; } $field = 'role_id,role_name,status,create_time'; $search_model = $this->model->where($where)->field($field)->order('create_time desc')->append(['status_name']); diff --git a/niucloud/app/service/admin/sys/SystemService.php b/niucloud/app/service/admin/sys/SystemService.php index 710ade323..272403953 100644 --- a/niucloud/app/service/admin/sys/SystemService.php +++ b/niucloud/app/service/admin/sys/SystemService.php @@ -12,9 +12,7 @@ namespace app\service\admin\sys; use app\job\sys\CheckJob; -use app\service\core\sys\CoreConfigService; use core\base\BaseAdminService; -use core\exception\CommonException; use think\facade\Db; use Throwable; diff --git a/niucloud/app/service/admin/user/UserService.php b/niucloud/app/service/admin/user/UserService.php index 4e8b838fb..a791e04ec 100644 --- a/niucloud/app/service/admin/user/UserService.php +++ b/niucloud/app/service/admin/user/UserService.php @@ -78,13 +78,10 @@ class UserService extends BaseAdminService if (!empty($user?->userrole)) { $user->userrole->appendData(['role_array' => $this->getRoleByUserRoleIds($user->role_ids ?? [])]); } + return $user->append(['status_name'])->toArray(); } - - - - /** * 添加用户(添加用户,不添加站点) * @param array $data @@ -140,7 +137,6 @@ class UserService extends BaseAdminService } $this->edit($uid, $data); return true; - } @@ -279,6 +275,21 @@ class UserService extends BaseAdminService return (new SysUser())->where([['username', '=',$username]])->findOrEmpty(); } + /** + * 获取全部用户列表(用于平台整体用户管理) + * @param array $where + * @return array + */ + public function getUserAll(array $where) + { + $field = 'uid, username, head_img'; + return (new SysUser())->withSearch(['username', 'realname', 'create_time'], $where) + ->field($field) + ->order('uid desc') + ->select() + ->toArray(); + } + /** * 获取用户缓存 * @param int $uid diff --git a/niucloud/app/service/admin/wechat/WechatMenuService.php b/niucloud/app/service/admin/wechat/WechatMenuService.php index 19353d3a3..5f4e35b05 100644 --- a/niucloud/app/service/admin/wechat/WechatMenuService.php +++ b/niucloud/app/service/admin/wechat/WechatMenuService.php @@ -16,7 +16,6 @@ use app\service\core\sys\CoreConfigService; use app\service\core\wechat\CoreWechatApiService; use core\base\BaseAdminService; use core\exception\WechatException; -use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use GuzzleHttp\Exception\GuzzleException; use think\Model; diff --git a/niucloud/app/service/api/diy/DiyConfigService.php b/niucloud/app/service/api/diy/DiyConfigService.php index 2c30e4417..fde6276ae 100644 --- a/niucloud/app/service/api/diy/DiyConfigService.php +++ b/niucloud/app/service/api/diy/DiyConfigService.php @@ -35,7 +35,7 @@ class DiyConfigService extends BaseApiService $apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]); // 单应用,排除 系统 底部导航设置 - if (count($apps) == 1) { + if (count($list) > 1 && count($apps) == 1) { foreach ($list as $k => $v) { if ($v[ 'key' ] = 'app') { unset($list[ $k ]); diff --git a/niucloud/app/service/api/login/AuthService.php b/niucloud/app/service/api/login/AuthService.php index 493999f48..3a89123c0 100644 --- a/niucloud/app/service/api/login/AuthService.php +++ b/niucloud/app/service/api/login/AuthService.php @@ -36,13 +36,15 @@ class AuthService extends BaseApiService $this->model = new Member(); } - public function checkMember(Request $request){ + public function checkMember(Request $request) + { //如果登录信息非法就报错 - if($this->member_id > 0){ + if ($this->member_id > 0) { $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['member_id' => $this->member_id]); - if($member_info->isEmpty()) + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id ]); + if ($member_info->isEmpty()) { throw new AuthException('MEMBER_NOT_EXIST', 401); + } } return true; } @@ -52,16 +54,17 @@ class AuthService extends BaseApiService * @param Request $request * @return void */ - public function checkChannel(Request $request) { + public function checkChannel(Request $request) + { $channel = $request->getChannel(); switch ($channel) { case ChannelDict::H5: - $is_open = (int)(new CoreH5Service())->getH5()['is_open']; + $is_open = (int) ( new CoreH5Service() )->getH5()[ 'is_open' ]; if (!$is_open) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); break; case ChannelDict::PC: - $is_open = (int)(new CorePcService())->getPc()['is_open']; + $is_open = (int) ( new CorePcService() )->getPc()[ 'is_open' ]; if (!$is_open) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); break; } @@ -73,28 +76,29 @@ class AuthService extends BaseApiService * @param string $mobile_code * @return true */ - public function bindMobile(string $mobile, string $mobile_code){ + public function bindMobile(string $mobile, string $mobile_code) + { - if(empty($mobile)){ - $result = (new CoreWeappAuthService())->getUserPhoneNumber($mobile_code); - if(empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); + if (empty($mobile)) { + $result = ( new CoreWeappAuthService() )->getUserPhoneNumber($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'); - }else{ + $phone_info = $result[ 'phone_info' ]; + $mobile = $phone_info[ 'purePhoneNumber' ]; + if (empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); + } else { //todo 校验手机号验证码 - (new LoginService())->checkMobileCode($mobile); + ( new LoginService() )->checkMobileCode($mobile); } $member_service = new MemberService(); - $member = $member_service->findMemberInfo(['member_id' => $this->member_id]); - if($member->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST'); + $member = $member_service->findMemberInfo([ 'member_id' => $this->member_id ]); + if ($member->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST'); - $o_mobile = $member['mobile'];//原始手机号 - if(!empty($o_mobile) && $o_mobile == $mobile) throw new AuthException('MOBILE_NOT_CHANGE'); + $o_mobile = $member[ 'mobile' ];//原始手机号 + if (!empty($o_mobile) && $o_mobile == $mobile) throw new AuthException('MOBILE_NOT_CHANGE'); - $mobile_member = $member_service->findMemberInfo(['mobile' => $mobile]); - if(!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST'); + $mobile_member = $member_service->findMemberInfo([ 'mobile' => $mobile ]); + if (!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST'); // if(empty($mobile)) throw new AuthException('MOBILE_NEEDED');//必须填写 $member->save([ diff --git a/niucloud/app/service/api/login/ConfigService.php b/niucloud/app/service/api/login/ConfigService.php new file mode 100644 index 000000000..664c41300 --- /dev/null +++ b/niucloud/app/service/api/login/ConfigService.php @@ -0,0 +1,48 @@ +getLoginConfig(); + if ($type == MemberLoginTypeDict::USERNAME) { + $is_username = $config[ 'is_username' ]; + //未开启账号密码登录注册 + if ($is_username != 1) throw new AuthException('MEMBER_USERNAME_LOGIN_NOT_OPEN'); + } elseif ($type == MemberLoginTypeDict::MOBILE) { + $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'); + } + return true; + } + +} \ No newline at end of file diff --git a/niucloud/app/service/api/login/LoginService.php b/niucloud/app/service/api/login/LoginService.php index 552f2ea04..4aa18e680 100644 --- a/niucloud/app/service/api/login/LoginService.php +++ b/niucloud/app/service/api/login/LoginService.php @@ -12,6 +12,7 @@ namespace app\service\api\login; use app\dict\member\MemberLoginTypeDict; +use app\dict\member\MemberRegisterTypeDict; use app\dict\sys\AppTypeDict; use app\dict\sys\SmsDict; use app\model\member\Member; @@ -30,8 +31,8 @@ use Throwable; /** * 登录服务层 - * Class BaseService - * @package app\service + * Class LoginService + * @package app\service\api\login */ class LoginService extends BaseApiService { @@ -76,10 +77,10 @@ class LoginService extends BaseApiService return [ 'token' => $token_info['token'], 'expires_time' => $token_info['params']['exp'], + 'mobile' => $member_info->mobile ]; } - /** * 账号登录 * @param string $username @@ -95,7 +96,6 @@ class LoginService extends BaseApiService return $this->login($member_info, MemberLoginTypeDict::USERNAME); } - /** * 手机号登录 * @param string $mobile @@ -107,11 +107,21 @@ class LoginService extends BaseApiService //登录注册配置 $config = (new MemberConfigService())->getLoginConfig(); $is_mobile = $config['is_mobile']; - if($is_mobile != 1) throw new AuthException('MOBILE_LOGIN_UNOPENED'); + $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]); - if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 - + if ($member_info->isEmpty()) { + //开启强制绑定手机号,登录会自动注册并绑定手机号 + if ($is_bind_mobile == 1) { + $data = array ( + 'mobile' => $mobile, + ); + return (new RegisterService())->register($mobile, $data, MemberRegisterTypeDict::MOBILE, false); + } else { + throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 + } + } return $this->login($member_info, MemberLoginTypeDict::MOBILE); } @@ -147,7 +157,6 @@ class LoginService extends BaseApiService return true; } - /** * 解析token * @param string|null $token @@ -235,8 +244,6 @@ class LoginService extends BaseApiService * @return true */ public function bingOpenid($member){ - $config = (new MemberConfigService())->getLoginConfig(); - $is_auth_register = $config['is_auth_register']; $open_id = $this->request->param('openid'); if(!empty($open_id)){ Log::write('channel_1'.$this->channel); diff --git a/niucloud/app/service/api/login/RegisterService.php b/niucloud/app/service/api/login/RegisterService.php index 434216e17..d45c8cd03 100644 --- a/niucloud/app/service/api/login/RegisterService.php +++ b/niucloud/app/service/api/login/RegisterService.php @@ -13,11 +13,11 @@ namespace app\service\api\login; use app\dict\member\MemberLoginTypeDict; use app\dict\member\MemberRegisterTypeDict; +use app\job\member\SetMemberNoJob; use app\model\member\Member; use app\service\api\captcha\CaptchaService; use app\service\api\member\MemberConfigService; use app\service\api\member\MemberService; -use app\service\core\member\CoreMemberService; use core\base\BaseApiService; use core\exception\AuthException; use think\db\exception\DataNotFoundException; @@ -78,10 +78,10 @@ class RegisterService extends BaseApiService $member_id = ( new MemberService() )->add($data); $data[ 'member_id' ] = $member_id; event('MemberRegister', $data); - CoreMemberService::setMemberNo($member_id); + SetMemberNoJob::dispatch([ 'member_id' => $member_id ]); } $member_info = $member_service->findMemberInfo([ 'member_id' => $member_id ]); - if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号已存在 + if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 return ( new LoginService() )->login($member_info, $type); } @@ -95,7 +95,7 @@ class RegisterService extends BaseApiService $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $username = ''; for ($i = 0; $i < 2; $i++) { - $username .= $chars[ random_int(0, (strlen($chars) - 1)) ]; + $username .= $chars[ random_int(0, ( strlen($chars) - 1 )) ]; } return $microtime . strtoupper(base_convert(time() - 1420070400, 10, 36)) . $username; @@ -124,7 +124,7 @@ class RegisterService extends BaseApiService if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在 $password_hash = create_password($password); - $data = array ( + $data = array( 'username' => $username, 'password' => $password_hash, ); @@ -141,13 +141,14 @@ class RegisterService extends BaseApiService //登录注册配置 $config = ( new MemberConfigService() )->getLoginConfig(); $is_mobile = $config[ 'is_mobile' ]; + $is_bind_mobile = $config[ 'is_bind_mobile' ]; //未开启账号密码登录注册 - if ($is_mobile != 1) throw new AuthException('MEMBER_USERNAME_LOGIN_NOT_OPEN'); + 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 ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在 - $data = array ( + $data = array( 'mobile' => $mobile, ); return $this->register($mobile, $data, MemberRegisterTypeDict::MOBILE); @@ -184,13 +185,16 @@ class RegisterService extends BaseApiService MemberLoginTypeDict::WECHAT => 'wx_openid', MemberLoginTypeDict::WEAPP => 'weapp_openid', }; - if ($type == MemberLoginTypeDict::MOBILE || $is_bind_mobile == 1) { - if (empty($mobile)) throw new AuthException('MOBILE_NEEDED');//必须填写 - //todo 校验手机号验证码 - if ($is_verify) { - ( new LoginService() )->checkMobileCode($mobile); + if ($type == MemberLoginTypeDict::MOBILE || $type == MemberLoginTypeDict::WEAPP || $is_bind_mobile == 1) { + //增加判断,否则公众号第三方注册会提示手机号必须填写 + if ($type == MemberLoginTypeDict::MOBILE || ( $type == MemberLoginTypeDict::USERNAME && $is_bind_mobile == 1 )) { + if (empty($mobile)) throw new AuthException('MOBILE_NEEDED');//必须填写 + //todo 校验手机号验证码 + if ($is_verify) { + ( new LoginService() )->checkMobileCode($mobile); + } } - if ($is_bind_mobile == 1) { + if (!empty($mobile)) { $member_service = new MemberService(); $member = $member_service->findMemberInfo([ 'mobile' => $mobile ]); if (!$member->isEmpty()) { @@ -205,11 +209,10 @@ class RegisterService extends BaseApiService return $member->member_id; } } + $data[ 'mobile' ] = $mobile; } - $data[ 'mobile' ] = $mobile; } return $data; } - } diff --git a/niucloud/app/service/api/member/MemberAccountService.php b/niucloud/app/service/api/member/MemberAccountService.php index 50b56da46..2b20445e7 100644 --- a/niucloud/app/service/api/member/MemberAccountService.php +++ b/niucloud/app/service/api/member/MemberAccountService.php @@ -38,53 +38,81 @@ class MemberAccountService extends BaseApiService */ public function getPage(array $where = []) { - $where['member_id'] = $this->member_id; + $where[ 'member_id' ] = $this->member_id; $field = 'id, member_id, account_type, account_data, from_type, related_id, create_time, memo'; - $search_model = $this->model->where([['id', '>', 0]])->withSearch(['member_id','account_type', 'from_type', 'create_time','account_data_gt', 'account_data_lt'],$where)->field($field)->order('create_time desc')->append(['from_type_name', 'account_type_name']); + $search_model = $this->model->where([ [ 'id', '>', 0 ] ])->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time', 'account_data_gt', 'account_data_lt', 'keyword' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]); return $this->pageQuery($search_model); } /** - * 会员余额流水列表(新) + * 会员积分流水列表 * @param array $where * @return array */ - public function getPages(array $data = []) + public function getPointPage(array $where = []) { - - switch ($data['from_type']){ + $type_where = []; + switch ($where[ 'amount_type' ]) { case 'income': $type_where = [ - ['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]], - ['account_data', '>', 0 ], - ['from_type', '<>', 'cash_out'] + [ 'account_data', '>', 0 ], ]; break; case 'disburse': $type_where = [ - ['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]], - ['account_data', '<', 0 ], - ['from_type', '<>', 'cash_out'] + [ 'account_data', '<', 0 ], + ]; + break; + default: + break; + } + $where[ 'member_id' ] = $this->member_id; + $field = 'id, member_id, account_type, account_data, from_type, related_id, create_time, memo'; + $search_model = $this->model->where([ [ 'id', '>', 0 ] ])->where($type_where)->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time', 'account_data_gt', 'account_data_lt' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]); + $list = $this->pageQuery($search_model); + $list[ 'data' ] = $this->monthlyGrouping($list[ 'data' ]); + return $list; + } + + /** + * 会员余额流水列表 + * @param array $where + * @return array + */ + public function getBalancePage(array $data = []) + { + switch ($data[ 'trade_type' ]) { + case 'income': + $type_where = [ + [ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ], + [ 'account_data', '>', 0 ], + [ 'from_type', '<>', 'cash_out' ] + ]; + break; + case 'disburse': + $type_where = [ + [ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ], + [ 'account_data', '<', 0 ], + [ 'from_type', '<>', 'cash_out' ] ]; break; case 'cash_out': $type_where = [ - ['account_type', '=', MemberAccountTypeDict::MONEY], - ['from_type', '=', $data['from_type']] + [ 'account_type', '=', MemberAccountTypeDict::MONEY ], + [ 'from_type', '=', 'cash_out' ] ]; break; - default: $type_where = [ - ['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]], + [ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ], ]; break; } - - $where['member_id'] = $this->member_id; + $where[ 'member_id' ] = $this->member_id; + $where[ 'create_time' ] = $data[ 'create_time' ]; $field = 'id, member_id, account_type, account_data, account_sum, from_type, related_id, create_time, memo'; - $search_model = $this->model->where([['id', '>', 0]])->where($type_where)->withSearch(['member_id', 'create_time'],$where)->field($field)->order('create_time desc')->append(['from_type_name', 'account_type_name']); + $search_model = $this->model->where([ [ 'id', '>', 0 ] ])->where($type_where)->withSearch([ 'member_id', 'create_time' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]); return $this->pageQuery($search_model); } @@ -96,7 +124,7 @@ class MemberAccountService extends BaseApiService public function getInfo(int $id) { $field = 'id, member_id, account_type, account_data, from_type, related_id, create_time, memo'; - return $this->model->where([['id', '=', $id], ['member_id', '=', $this->member_id]])->field($field)->append(['from_type_name', 'account_type_name'])->findOrEmpty()->toArray(); + return $this->model->where([ [ 'id', '=', $id ], [ 'member_id', '=', $this->member_id ] ])->field($field)->append([ 'from_type_name', 'account_type_name' ])->findOrEmpty()->toArray(); } /** @@ -105,10 +133,11 @@ class MemberAccountService extends BaseApiService * @return int * @throws DbException */ - public function getCount(array $where = []){ - $where['member_id'] = $this->member_id; + public function getCount(array $where = []) + { + $where[ 'member_id' ] = $this->member_id; - return $this->model->where([['member_id', '>', 0]])->withSearch(['member_id','account_type', 'from_type', 'create_time'],$where)->count(); + return $this->model->where([ [ 'member_id', '>', 0 ] ])->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time' ], $where)->count(); } /** @@ -117,22 +146,58 @@ class MemberAccountService extends BaseApiService * @return int * @throws DbException */ - public function getPointCount(){ + public function getPointCount() + { $data = [ 'point' => 0, 'point_get' => 0, - 'use'=> 0,//使用 + 'use' => 0,//使用 ]; - $info = (new Member())->where([['member_id', '=', $this->member_id]])->field('point,point_get')->findOrEmpty()->toArray(); - $data['point'] = $info['point'] ?? 0; - $data['point_get'] = $info['point_get'] ?? 0; - $data['use'] = abs($this->model->where([ - ['member_id', '=', $this->member_id], - ['account_type', '=', MemberAccountTypeDict::POINT], - ['account_data', '<', 0] + $info = ( new Member() )->where([ [ 'member_id', '=', $this->member_id ] ])->field('point,point_get')->findOrEmpty()->toArray(); + $data[ 'point' ] = $info[ 'point' ] ?? 0; + $data[ 'point_get' ] = $info[ 'point_get' ] ?? 0; + $data[ 'use' ] = abs($this->model->where([ + [ 'member_id', '=', $this->member_id ], + [ 'account_type', '=', MemberAccountTypeDict::POINT ], + [ 'account_data', '<', 0 ] ])->sum('account_data')); return $data; } -} + /** + * 按年月分组数据(例如账单) + * @param array $arr_data 分组的数组 + * @param string $time_field 时间分组字段 + * @return array + */ + function monthlyGrouping($arr_data, $time_field = 'create_time') + { + if (empty($time_field)) { + return $arr_data; + } + //按月份分组 + $arr_month = []; + //全部年月数据 + $arr_return_data = []; + foreach ($arr_data as $data) { + //按月份分组 + $year_month = mb_substr($data[ $time_field ], 0, 7); + + $arr_month[ $year_month ][ 'month_data' ][] = $data; + + if (!isset($arr_month[ $year_month ][ 'month_info' ])) { + $arr_month[ $year_month ][ 'month_info' ] = + [ + 'year' => mb_substr($year_month, 0, 4), + 'month' => mb_substr($year_month, 5, 2), + ]; + } + } + foreach ($arr_month as $month) { + $arr_return_data[] = $month ?? []; + } + return $arr_return_data; + } + +} \ No newline at end of file diff --git a/niucloud/app/service/api/member/MemberLevelService.php b/niucloud/app/service/api/member/MemberLevelService.php index c62ec3df4..db1675d4a 100644 --- a/niucloud/app/service/api/member/MemberLevelService.php +++ b/niucloud/app/service/api/member/MemberLevelService.php @@ -33,7 +33,7 @@ class MemberLevelService extends BaseApiService * @return true */ public function getList(){ - $list = (new MemberLevel())->where([ ['level_id', '>', 0] ])->field('level_id,level_name,growth,remark,level_benefits,level_gifts')->order('growth asc')->select()->toArray(); + $list = (new MemberLevel())->where([ ['level_id', '>', 0 ] ])->field('level_id,level_name,growth,remark,level_benefits,level_gifts')->order('growth asc')->select()->toArray(); $level_style = MemberLevelDict::getStyle(); if (!empty($list)) { foreach ($list as $k => $item) { @@ -51,15 +51,16 @@ class MemberLevelService extends BaseApiService $length = empty($item['level_benefits']) ? 0 : count($item['level_benefits']); if ($length < 4) { + if (empty($item['level_benefits'])) $list[$k]['level_benefits'] = []; foreach ($filling as $key => $content) { - if (is_array($list[$k]['level_benefits']) && count($list[$k]['level_benefits']) == 4) break; + if (count($list[$k]['level_benefits']) == 4) break; $list[$k]['level_benefits'][$key] = [ 'content' => $content ]; } } - $level_key = $k % 8 + 1; + $level_key = $k % 7 + 1; $list[$k]['level_bg'] = '/static/resource/images/member/level/bg_'. $level_key .'.png'; $list[$k]['member_bg'] = '/static/resource/images/member/level/member_'. $level_key .'.png'; $list[$k]['level_icon'] = '/static/resource/images/member/level/level_icon'. $level_key .'.png'; diff --git a/niucloud/app/service/api/member/MemberService.php b/niucloud/app/service/api/member/MemberService.php index 68f53cf4f..28aecb04d 100644 --- a/niucloud/app/service/api/member/MemberService.php +++ b/niucloud/app/service/api/member/MemberService.php @@ -16,9 +16,6 @@ use app\service\core\member\CoreMemberService; use core\base\BaseApiService; use core\exception\ApiException; use core\util\Barcode; -use think\db\exception\DataNotFoundException; -use think\db\exception\DbException; -use think\db\exception\ModelNotFoundException; use think\Model; /** diff --git a/niucloud/app/service/api/member/MemberSignService.php b/niucloud/app/service/api/member/MemberSignService.php index 08736e53c..77ef39198 100644 --- a/niucloud/app/service/api/member/MemberSignService.php +++ b/niucloud/app/service/api/member/MemberSignService.php @@ -71,7 +71,7 @@ class MemberSignService extends BaseApiService if (!$sign_config['is_use']) throw new CommonException('SIGN_NOT_USE'); if (empty($sign_config['sign_period']) || empty($sign_config['day_award'])) throw new CommonException('SIGN_NOT_SET'); $sign_period = $sign_config['sign_period'];//签到周期 - $today = $this->model->where([ ['member_id', '=', $this->member_id]])->whereDay('create_time')->findOrEmpty()->toArray(); + $today = $this->model->where([['member_id', '=', $this->member_id]])->whereDay('create_time')->findOrEmpty()->toArray(); if (!empty($today)) throw new CommonException('SIGNED_TODAY'); Db::startTrans(); @@ -133,7 +133,7 @@ class MemberSignService extends BaseApiService $continue_data['continue_tag'] = $value['continue_tag'];//连签奖励标识 if ($value['receive_limit'] == 2) {//receive_limit (1.不限制 2.每人限领 receive_num 次) //周期开始时间 - $period_start_time = $this->model->where([ ['member_id', '=', $this->member_id], ['days', '=', 1], ['start_time', '>', 0]])->order('sign_id desc')->field('start_time')->limit(1)->value('start_time'); + $period_start_time = $this->model->where([['member_id', '=', $this->member_id], ['days', '=', 1], ['start_time', '>', 0]])->order('sign_id desc')->field('start_time')->limit(1)->value('start_time'); //周期结束时间 $period_end_time = strtotime("+$sign_period day", $period_start_time); //查询领取次数 @@ -193,7 +193,7 @@ class MemberSignService extends BaseApiService $data = []; $info = $this->getSign(); if ($info['is_use'] == 1) {//判断签到是否开启 - $model_result = $this->model->field('create_time')->where([ ['member_id', '=', $this->member_id]])->whereMonth('create_time', $year . '-' . sprintf("%02d", $month))->select(); + $model_result = $this->model->field('create_time')->where([['member_id', '=', $this->member_id]])->whereMonth('create_time', $year . '-' . sprintf("%02d", $month))->select(); $days = []; foreach ($model_result as $key => $value) { $day = date('d', strtotime($value['create_time'])); @@ -207,7 +207,7 @@ class MemberSignService extends BaseApiService //获取连签奖励最大天数 $max_continue_sign = max($continue_signs); //周期开始时间 - $period_start_time = $this->model->where([ ['member_id', '=', $this->member_id], ['days', '=', 1], ['start_time', '>', 0]])->order('sign_id desc')->field('start_time')->limit(1)->value('start_time'); + $period_start_time = $this->model->where([['member_id', '=', $this->member_id], ['days', '=', 1], ['start_time', '>', 0]])->order('sign_id desc')->field('start_time')->limit(1)->value('start_time'); if (!empty($period_start_time)) { //周期结束时间 $period_end_time = strtotime("+$sign_period day", $period_start_time); @@ -253,6 +253,7 @@ class MemberSignService extends BaseApiService public function getDayAward(int $year, int $month, int $day) { $max_continue_sign = 1;//连签奖励最大天数 + $continue_sign_day = 0;//连签奖励天数 $time = $year.'-'.sprintf("%02d", $month).'-'.sprintf("%02d", $day); $info = $this->getSign(); @@ -273,25 +274,29 @@ class MemberSignService extends BaseApiService $award = [];//当日奖励 //判断查询日期是否在签到周期内 if (in_array($time, $days_array)) { + $counter = 0;//计数器 foreach ($days_array as $key => $value) { + $counter++; if ($value == $time) { + + $continue_sign_day = $counter; $award['day_award'] = $info['day_award']; if (!empty($info['continue_award'])) { - $day = $key + 1; + $days = $key + 1; foreach ($info['continue_award'] as $k => $v) { $gift = $v; unset($gift['continue_sign'], $gift['continue_tag'], $gift['receive_limit'], $gift['receive_num']); if ($v['receive_limit'] == 1) {//不限制次数奖励添加 $period_num = intdiv($sign_period, $max_continue_sign);//周期内可循环轮次 for ($i = 0; $i < $period_num; $i++) { - if ($max_continue_sign * $i + $v['continue_sign'] == $day) { + if ($max_continue_sign * $i + $v['continue_sign'] == $days) { $award['continue_award'] = $gift; } } } else {//限制次数奖励添加 for ($i = 0; $i < $v['receive_num']; $i++) { - if ($max_continue_sign * $i + $v['continue_sign'] == $day) { + if ($max_continue_sign * $i + $v['continue_sign'] == $days) { $award['continue_award'] = $gift; } } @@ -300,9 +305,18 @@ class MemberSignService extends BaseApiService } } + if (!empty($info['continue_award'])) { + if ($counter % $max_continue_sign == 0) { + $counter = 0; + } + } else { + if ($counter % $sign_period == 0) { + $counter = 0; + } + } } } else { - $day_result = $this->model->field('create_time')->where([ ['member_id', '=', $this->member_id]])->whereDay('create_time', $time)->findOrEmpty()->toArray(); + $day_result = $this->model->field('create_time')->where([['member_id', '=', $this->member_id]])->whereDay('create_time', $time)->findOrEmpty()->toArray(); if (!empty($day_result)) { $award['day_award'] = $day_result['day_award']; $continue_award = $day_result['continue_award']; @@ -313,7 +327,19 @@ class MemberSignService extends BaseApiService } } $awards_total = $this->getTotalAward($award); - return $awards_total; + $continue_text = $continue_sign_day > 0 ? get_lang('CONTINUE_SIGN').$continue_sign_day.get_lang('DAYS') : ''; + $result['title'] = get_lang('SIGN_AWARD'); + $result['info'] = $continue_text.get_lang('WILL_GET_AWARD'); + $result['awards'] = $awards_total; + if ($awards_total) { + return $result; + } else { + return [ + 'title' => '', + 'info' => '', + 'awards' => [], + ]; + } } /** @@ -337,12 +363,6 @@ class MemberSignService extends BaseApiService $is_use_coupon_day = false; $is_use_coupon_continue = false; -// foreach ($awards['day_award'] as $key => $value) { -// if ($value['is_use'] == 1) { -// $awards['day_award'][$key] = $value; -// } -// } - if (!empty($awards['day_award']['point'])) { if ($awards['day_award']['point']['is_use'] == 1) { $is_use_point_day = true; @@ -413,8 +433,8 @@ class MemberSignService extends BaseApiService public function getSignConfig() { $info = $this->getSign(); - $today = $this->model->where([ ['member_id', '=', $this->member_id]])->whereDay('create_time')->findOrEmpty()->toArray(); - $yesterday = $this->model->where([ ['member_id', '=', $this->member_id]])->whereDay('create_time', 'yesterday')->findOrEmpty()->toArray(); + $today = $this->model->where([['member_id', '=', $this->member_id]])->whereDay('create_time')->findOrEmpty()->toArray(); + $yesterday = $this->model->where([['member_id', '=', $this->member_id]])->whereDay('create_time', 'yesterday')->findOrEmpty()->toArray(); if (!empty($info['day_award'])) { $day_award = (new CoreMemberService())->getGiftContent($info['day_award'],'member_sign'); $info['day_award'] = $day_award; @@ -519,4 +539,4 @@ class MemberSignService extends BaseApiService } } -} +} \ No newline at end of file diff --git a/niucloud/app/service/api/sys/TaskService.php b/niucloud/app/service/api/sys/TaskService.php index e4c20a2bd..c4fee6727 100644 --- a/niucloud/app/service/api/sys/TaskService.php +++ b/niucloud/app/service/api/sys/TaskService.php @@ -13,9 +13,7 @@ namespace app\service\api\sys; use app\service\core\member\CoreMemberConfigService; use app\service\core\member\CoreMemberService; -use app\service\core\scan\CoreScanService; use core\base\BaseApiService; -use core\dict\DictLoader; /** * Class BaseService diff --git a/niucloud/app/service/api/upload/UploadService.php b/niucloud/app/service/api/upload/UploadService.php index e05d8687f..308564472 100644 --- a/niucloud/app/service/api/upload/UploadService.php +++ b/niucloud/app/service/api/upload/UploadService.php @@ -36,7 +36,7 @@ class UploadService extends BaseApiService */ public function image($file) { - $dir = $this->root_path.'/image/'.date('Ym').'/'.date('d'); + $dir = $this->root_path . '/' . 'image' . '/' . date('Ym') . '/' . date('d'); $core_upload_service = new CoreUploadService(); return $core_upload_service->image($file, $dir, $this->cate_id); } @@ -49,7 +49,7 @@ class UploadService extends BaseApiService */ public function video($file) { - $dir = $this->root_path.'/video/'.date('Ym').'/'.date('d'); + $dir = $this->root_path . '/' . 'video' . '/' . date('Ym') . '/' . date('d'); $core_upload_service = new CoreUploadService(); return $core_upload_service->video($file, $dir, $this->cate_id); } @@ -63,10 +63,10 @@ class UploadService extends BaseApiService */ public function document($file, string $type = '') { - if(!in_array($type, FileDict::getSceneType())) + if (!in_array($type, FileDict::getSceneType())) throw new UploadFileException('UPLOAD_TYPE_ERROR'); - $dir = $this->root_path.'/document/'.date('Ym').'/'.date('d'); + $dir = $this->root_path . '/document/' . $type . '/' . date('Ym') . '/' . date('d'); $core_upload_service = new CoreUploadService(); return $core_upload_service->document($file, $type, $dir, StorageDict::LOCAL); } -} +} \ No newline at end of file diff --git a/niucloud/app/service/api/verify/VerifyService.php b/niucloud/app/service/api/verify/VerifyService.php index a8f42044c..98d9511e2 100644 --- a/niucloud/app/service/api/verify/VerifyService.php +++ b/niucloud/app/service/api/verify/VerifyService.php @@ -29,11 +29,11 @@ class VerifyService extends BaseApiService * @param $data = ['order_id' => , 'goods_id' => ] * @return string */ - public function getVerifyCode(string|int $type, array $data) + public function getVerifyCode($type, array $data) { - $list = (new CoreVerifyService())->create($this->member_id, $type, $data); + $list = ( new CoreVerifyService() )->create($this->member_id, $type, $data); $temp = []; - foreach($list as $item){ + foreach ($list as $item) { $temp[] = [ 'code' => $item, 'qrcode' => qrcode($item, '', [], outfile: false) @@ -47,8 +47,9 @@ class VerifyService extends BaseApiService * @param $code * @return bool */ - public function getInfoByCode($code){ - return (new CoreVerifyService())->getInfoByCode($code); + public function getInfoByCode($code) + { + return ( new CoreVerifyService() )->getInfoByCode($code); } /** @@ -56,17 +57,19 @@ class VerifyService extends BaseApiService * @param $code * @return bool */ - public function verify($code){ - return (new CoreVerifyService())->verify($code, $this->member_id); + public function verify($code) + { + return ( new CoreVerifyService() )->verify($code, $this->member_id); } /** * 校验是否是核销员 * @return bool */ - public function checkVerifier(){ - $verifier = (new Verifier())->where([['member_id', '=', $this->member_id]])->findOrEmpty(); - if(!$verifier->isEmpty()) return true; + public function checkVerifier() + { + $verifier = ( new Verifier() )->where([ [ 'member_id', '=', $this->member_id ] ])->findOrEmpty(); + if (!$verifier->isEmpty()) return true; return false; } @@ -76,20 +79,20 @@ class VerifyService extends BaseApiService * @return array * @throws \think\db\exception\DbException */ - public function getRecordsPageByVerifier(array $data){ + public function getRecordsPageByVerifier(array $data) + { $field = '*'; - $search_model = (new Verify())->where([ - ['verifier_member_id', '=', $this->member_id] - ]) - ->withSearch(['code', 'type', 'create_time', 'relate_tag'], $data) - ->with([ - 'member' => function($query){ - $query->field('member_id, nickname, mobile, headimg'); - } - ]) - ->field($field) - ->order('create_time desc') - ->append(['type_name']); + $search_model = ( new Verify() )->where([ + [ 'verifier_member_id', '=', $this->member_id ] + ])->withSearch([ 'code', 'type', 'create_time', 'relate_tag', 'keyword' ], $data) + ->with([ + 'member' => function($query) { + $query->field('member_id, nickname, mobile, headimg'); + } + ]) + ->field($field) + ->order('create_time desc') + ->append([ 'type_name' ]); return $this->pageQuery($search_model); } @@ -98,19 +101,17 @@ class VerifyService extends BaseApiService * @param int $id * @return array */ - public function getRecordsDetailByVerifier(string|int $code){ + public function getRecordsDetailByVerifier($code) + { $field = '*'; - return (new Verify())->where([ - ['verifier_member_id', '=', $this->member_id], - ['code', '=', $code] - ]) - ->with([ - 'member' => function($query){ - $query->field('member_id, nickname, mobile, headimg'); - } - ]) - ->field($field) - ->append(['type_name'])->findOrEmpty()->toArray(); + return ( new Verify() )->where([ + [ 'verifier_member_id', '=', $this->member_id ], + [ 'code', '=', $code ] + ])->with([ + 'member' => function($query) { + $query->field('member_id, nickname, mobile, headimg'); + } + ])->field($field)->append([ 'type_name' ])->findOrEmpty()->toArray(); } -} +} \ No newline at end of file diff --git a/niucloud/app/service/api/weapp/WeappAuthService.php b/niucloud/app/service/api/weapp/WeappAuthService.php index e7332098b..2ed68d8f7 100644 --- a/niucloud/app/service/api/weapp/WeappAuthService.php +++ b/niucloud/app/service/api/weapp/WeappAuthService.php @@ -13,7 +13,6 @@ namespace app\service\api\weapp; use app\dict\member\MemberLoginTypeDict; use app\dict\member\MemberRegisterTypeDict; -use app\model\member\Member; use app\service\api\login\LoginService; use app\service\api\login\RegisterService; use app\service\api\member\MemberConfigService; @@ -22,7 +21,6 @@ use app\service\core\weapp\CoreWeappAuthService; use core\base\BaseApiService; use core\exception\ApiException; use core\exception\AuthException; -use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use GuzzleHttp\Exception\GuzzleException; use think\db\exception\DataNotFoundException; @@ -40,6 +38,7 @@ class WeappAuthService extends BaseApiService { public $core_weapp_serve_service; + public function __construct() { parent::__construct(); @@ -52,15 +51,16 @@ class WeappAuthService extends BaseApiService * @return array * @throws InvalidConfigException */ - public function getUserInfoByCode(string $code){ + public function getUserInfoByCode(string $code) + { // $iv = $this->request->param('iv', ''); // $encrypted_data = $this->request->param('encrypted_data', ''); $result = $this->core_weapp_serve_service->session($code); // if(empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); // $userinfo = $this->core_weapp_serve_service->decryptData($result['session_key'], $iv, $encrypted_data); - $openid = $result['openid'] ?? '';//对应微信的 openid - $unionid = $result['unionid'] ?? '' ;//对应微信的 unionid - if(empty($openid)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); + $openid = $result[ 'openid' ] ?? '';//对应微信的 openid + $unionid = $result[ 'unionid' ] ?? '';//对应微信的 unionid + if (empty($openid)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); //todo 这儿还可能会获取用户昵称 头像 性别 ....用以更新会员信息 // $nickname = $userinfo['nickName'] ?? '';//对应微信的 nickname // $avatar = $userinfo['avatarUrl'] ?? '';//对应微信的 头像地址 @@ -91,23 +91,23 @@ class WeappAuthService extends BaseApiService ] = $this->getUserInfoByCode($code); $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['weapp_openid' => $openid]); + $member_info = $member_service->findMemberInfo([ 'weapp_openid' => $openid ]); if ($member_info->isEmpty() && !empty($unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $unionid]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $unionid ]); if (!$member_info->isEmpty()) { $member_info->weapp_openid = $openid; } } - if($member_info->isEmpty()){ - $config = (new MemberConfigService())->getLoginConfig(); - $is_bind_mobile = $config['is_bind_mobile']; - $is_auth_register = $config['is_auth_register']; - if($is_bind_mobile == 0 && $is_auth_register == 1){ + if ($member_info->isEmpty()) { + $config = ( new MemberConfigService() )->getLoginConfig(); + $is_auth_register = $config[ 'is_auth_register' ]; + // 去掉强制绑定手机号判断,否则开启强制绑定的情况下小程序第三方注册无法注册 + if ($is_auth_register == 1) { return $this->register($openid, wx_unionid: $unionid); - }else{ - return ['openid' => $openid, 'unionid' => $unionid]; + } else { + return [ 'openid' => $openid, 'unionid' => $unionid ]; } - }else{ + } else { //可能会更新用户和粉丝表 $login_service = new LoginService(); return $login_service->login($member_info, MemberLoginTypeDict::WEAPP); @@ -128,30 +128,28 @@ class WeappAuthService extends BaseApiService * @throws InvalidConfigException * @throws ModelNotFoundException */ - 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 = '') + { - if(empty($openid)) throw new AuthException('AUTH_LOGIN_TAG_NOT_EXIST'); - //todo openid可能还需要合法性验证 - $config = (new MemberConfigService())->getLoginConfig(); - $is_bind_mobile = $config['is_bind_mobile']; - if($is_bind_mobile == 1){ - if(empty($mobile)){ + if (empty($openid)) throw new AuthException('AUTH_LOGIN_TAG_NOT_EXIST'); + if (empty($mobile)) { + if (!empty($mobile_code)) { $result = $this->core_weapp_serve_service->getUserPhoneNumber($mobile_code); - if(empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); - $phone_info = $result['phone_info']; - $mobile = $phone_info['purePhoneNumber']; - if(empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); - $is_verify_mobile = false; - }else{ - $is_verify_mobile = true; + if (empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); + $phone_info = $result[ 'phone_info' ]; + $mobile = $phone_info[ 'purePhoneNumber' ]; + if (empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); } + $is_verify_mobile = false; + } else { + $is_verify_mobile = true; } $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['weapp_openid' => $openid]); - if(!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 + $member_info = $member_service->findMemberInfo([ 'weapp_openid' => $openid ]); + if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 if (!empty($wx_unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $wx_unionid]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $wx_unionid ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 } @@ -167,4 +165,28 @@ class WeappAuthService extends BaseApiService } + /** + * 更新openid(用于账号密码或手机号注册时未正常获取到openid时再次获取) + * @param string $code + * @return true + */ + public function updateOpenid(string $code) + { + [ + $openid, + $unionid, +// $avatar, +// $nickname, +// $sex + ] = $this->getUserInfoByCode($code); + $member_service = new MemberService(); + $member = $member_service->findMemberInfo([ 'weapp_openid' => $openid ]); + if (!$member->isEmpty()) throw new AuthException('MEMBER_OPENID_EXIST');//openid已存在 + + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id ]); + if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 + $member_service->editByFind($member_info, [ 'weapp_openid' => $openid ]); + return true; + } + } diff --git a/niucloud/app/service/api/wechat/WechatAuthService.php b/niucloud/app/service/api/wechat/WechatAuthService.php index 53cdc4490..f992de07f 100644 --- a/niucloud/app/service/api/wechat/WechatAuthService.php +++ b/niucloud/app/service/api/wechat/WechatAuthService.php @@ -25,7 +25,6 @@ use app\service\core\wechat\CoreWechatServeService; use core\base\BaseApiService; use core\exception\ApiException; use core\exception\AuthException; -use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; @@ -56,7 +55,7 @@ class WechatAuthService extends BaseApiService public function authorization(string $url = '', string $scopes = 'snsapi_base') { //todo 业务落地 - return ['url' => $this->core_wechat_serve_service->authorization($url, $scopes)]; + return [ 'url' => $this->core_wechat_serve_service->authorization($url, $scopes) ]; } /** @@ -70,18 +69,18 @@ class WechatAuthService extends BaseApiService if (empty($userinfo)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); $token_response = $userinfo->getTokenResponse(); if (empty($token_response)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); - $scope = $token_response['scope']; + $scope = $token_response[ 'scope' ]; if ($scope == 'snsapi_base') {//静默授权 - $openid = $token_response['openid'] ?? ''; + $openid = $token_response[ 'openid' ] ?? ''; } else { $openid = $userinfo->getId();//对应微信的 openid $nickname = $userinfo->getNickname();//对应微信的 nickname $avatar = $userinfo->getAvatar();//对应微信的 头像地址 } - $unionid = $userinfo->getRaw()['unionid'] ?? ''; + $unionid = $userinfo->getRaw()[ 'unionid' ] ?? ''; if (empty($openid)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); //todo 这儿还可能会获取用户昵称 头像 性别 ....用以更新会员信息 - return [$avatar ?? '', $nickname ?? '', $openid, $unionid]; + return [ $avatar ?? '', $nickname ?? '', $openid, $unionid ]; //todo 业务落地 } @@ -93,8 +92,9 @@ class WechatAuthService extends BaseApiService * @throws DbException * @throws ModelNotFoundException */ - public function loginByCode(string $code){ - [$avatar, $nickname, $openid, $unionid] = $this->userFromCode($code); + public function loginByCode(string $code) + { + [ $avatar, $nickname, $openid, $unionid ] = $this->userFromCode($code); return $this->login($openid, $nickname, $avatar, $unionid); } @@ -112,21 +112,21 @@ class WechatAuthService extends BaseApiService { $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['wx_openid' => $openid]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid ]); if ($member_info->isEmpty() && !empty($unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $unionid]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $unionid ]); if (!$member_info->isEmpty()) { $member_info->wx_openid = $openid; } } if ($member_info->isEmpty()) { - $config = (new MemberConfigService())->getLoginConfig(); - $is_bind_mobile = $config['is_bind_mobile']; - $is_auth_register = $config['is_auth_register']; - if ($is_bind_mobile == 0 && $is_auth_register == 1) { + $config = ( new MemberConfigService() )->getLoginConfig(); + $is_auth_register = $config[ 'is_auth_register' ]; + // 去掉强制绑定手机号判断,否则开启强制绑定的情况下公众号第三方注册无法注册 + if ($is_auth_register == 1) { return $this->register($openid, '', $nickname, $avatar, $unionid); } else { - return ['avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid]; + return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ]; } } else { //可能会更新用户和粉丝表 @@ -142,15 +142,15 @@ class WechatAuthService extends BaseApiService */ public function sync(string $code) { - [$avatar, $nickname, $openid] = $this->userFromCode($code); + [ $avatar, $nickname, $openid ] = $this->userFromCode($code); //更新粉丝 $core_wechat_fans_service = new CoreWechatFansService(); //这儿或许可以异步 - $core_wechat_fans_service->edit($openid, ['avatar' => $avatar, 'nickname' => $nickname]); + $core_wechat_fans_service->edit($openid, [ 'avatar' => $avatar, 'nickname' => $nickname ]); $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['wx_openid' => $openid]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid ]); if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 - $member_service->editByFind($member_info, ['headimg' => $avatar, 'nickname' => $nickname]); + $member_service->editByFind($member_info, [ 'headimg' => $avatar, 'nickname' => $nickname ]); return true; } @@ -160,6 +160,7 @@ class WechatAuthService extends BaseApiService * @param string $mobile * @param string $nickname * @param string $avatar + * @param string $wx_unionid * @return array * @throws DataNotFoundException * @throws DbException @@ -168,10 +169,10 @@ class WechatAuthService extends BaseApiService public function register(string $openid, string $mobile = '', string $nickname = '', string $avatar = '', string $wx_unionid = '') { $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['wx_openid' => $openid]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 if (!empty($wx_unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $wx_unionid]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $wx_unionid ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 } $register_service = new RegisterService(); @@ -190,14 +191,21 @@ class WechatAuthService extends BaseApiService /** * 获取jssdkconfig * @param string $url - * @return array|string + * @return mixed[] + * @throws \EasyWeChat\Kernel\Exceptions\HttpException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \Psr\SimpleCache\InvalidArgumentException + * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface + * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function jssdkConfig(string $url = '') { return $this->core_wechat_serve_service->jssdkConfig($url); } - /** * 扫码登录 * @return array @@ -207,11 +215,29 @@ class WechatAuthService extends BaseApiService $data = array( 'channel' => $this->channel, ); - $key = (new CoreScanService())->scan(ScanDict::WECHAT_LOGIN, $data, 300); - $url = $this->core_wechat_serve_service->scan($key, 300)['url'] ?? ''; + $key = ( new CoreScanService() )->scan(ScanDict::WECHAT_LOGIN, $data, 300); + $url = $this->core_wechat_serve_service->scan($key, 300)[ 'url' ] ?? ''; return [ 'url' => $url, 'key' => $key ]; } + + /** + * 更新openid(用于账号密码或手机号注册时未正常获取到openid时再次获取) + * @param string $code + * @return true + */ + public function updateOpenid(string $code) + { + [ $avatar, $nickname, $openid, $unionid ] = $this->userFromCode($code); + $member_service = new MemberService(); + $member = $member_service->findMemberInfo([ 'wx_openid' => $openid ]); + if (!$member->isEmpty()) throw new AuthException('MEMBER_OPENID_EXIST');//openid已存在 + + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id ]); + if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在 + $member_service->editByFind($member_info, [ 'wx_openid' => $openid ]); + return true; + } } diff --git a/niucloud/app/service/api/wechat/WechatServeService.php b/niucloud/app/service/api/wechat/WechatServeService.php index 390c2630e..60b748fd1 100644 --- a/niucloud/app/service/api/wechat/WechatServeService.php +++ b/niucloud/app/service/api/wechat/WechatServeService.php @@ -15,8 +15,6 @@ use app\service\core\wechat\CoreWechatServeService; use core\base\BaseApiService; use EasyWeChat\Kernel\Exceptions\BadRequestException; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; -use EasyWeChat\Kernel\Exceptions\RuntimeException; -use Psr\Http\Message\ResponseInterface; use ReflectionException; use Symfony\Component\HttpFoundation\Response; use Throwable; diff --git a/niucloud/app/service/core/addon/CoreAddonDevelopBuildService.php b/niucloud/app/service/core/addon/CoreAddonDevelopBuildService.php index 795c8a371..aa3ee400b 100644 --- a/niucloud/app/service/core/addon/CoreAddonDevelopBuildService.php +++ b/niucloud/app/service/core/addon/CoreAddonDevelopBuildService.php @@ -13,7 +13,6 @@ namespace app\service\core\addon; use app\dict\sys\MenuDict; use app\model\sys\SysMenu; -use app\service\admin\sys\MenuService; use core\base\BaseCoreService; use core\exception\AddonException; diff --git a/niucloud/app/service/core/addon/CoreAddonService.php b/niucloud/app/service/core/addon/CoreAddonService.php index 3bb0a8a14..17f1cf524 100644 --- a/niucloud/app/service/core/addon/CoreAddonService.php +++ b/niucloud/app/service/core/addon/CoreAddonService.php @@ -280,7 +280,7 @@ class CoreAddonService extends CoreAddonBaseService $data = $core_addon_service->getAddonConfig($key); if (isset($data['key'])) { $data['icon'] = is_file($data['icon']) ? image_to_base64($data['icon']) : ''; - $data['cover'] = is_file($data['icon']) ? image_to_base64($data['cover']) : ''; + $data['cover'] = is_file($data['cover']) ? image_to_base64($data['cover']) : ''; $data['type_name'] = empty($data['type']) ? '' : AddonDict::getType()[$data['type']] ?? ''; } if(isset($data['support_app']) && !empty($data['support_app'])) diff --git a/niucloud/app/service/core/addon/WapTrait.php b/niucloud/app/service/core/addon/WapTrait.php index cb029caec..c1d8120cb 100644 --- a/niucloud/app/service/core/addon/WapTrait.php +++ b/niucloud/app/service/core/addon/WapTrait.php @@ -32,13 +32,13 @@ trait WapTrait { $content = "\n"; @@ -140,168 +128,30 @@ trait WapTrait $content .= " import topTabbar from '@/components/top-tabbar/top-tabbar.vue'\n"; $content .= " import useDiyStore from '@/app/stores/diy';\n"; - $content .= " import { ref, onMounted, nextTick, computed, watch } from 'vue';\n"; - $content .= " import { useRouter } from 'vue-router';\n"; - $content .= " import { getLocation } from '@/utils/common';\n"; - $content .= " import Sortable from 'sortablejs';\n"; - $content .= " import { range } from 'lodash-es';\n"; - $content .= " import { onPageScroll } from '@dcloudio/uni-app'\n"; - $content .= " import useConfigStore from '@/stores/config'\n\n"; + $content .= " import { useDiyGroup } from './useDiyGroup';\n"; + $content .= " import { ref } from 'vue';\n\n"; $content .= " const props = defineProps(['data','pullDownRefreshCount']);\n"; + $content .= " const topTabbarRef = ref(null);\n"; $content .= " const diyStore = useDiyStore();\n"; - $content .= " const router = useRouter();\n\n"; - - $content .= " const data = computed(() => {\n"; - $content .= " if (diyStore.mode == 'decorate') {\n"; - $content .= " return diyStore;\n"; - $content .= " } else {\n"; - $content .= " return props.data;\n"; - $content .= " }\n"; - $content .= " })\n\n"; - - $content .= " let carouselSearchRef = ref(null)\n"; - $content .= " let carouselSearchScrollValue = 0\n"; - $content .= " let topTabbarRef = ref(null);\n"; - $content .= " let topTabbarScrollValue = 0\n\n"; - - $content .= " // 兼容轮播搜索组件-切换分类时,导致个人中心白屏 - start\n"; - $content .= " // #ifdef H5\n"; - $content .= " watch(() => router.currentRoute.value, (newRoute) => {\n"; - $content .= " if(newRoute.path != \"/addon/shop/pages/index\"){\n"; - $content .= " diyStore.topFixedStatus = 'home'\n"; - $content .= " }\n"; - $content .= " });\n\n"; - - $content .= " // #endif\n\n"; - - $content .= " // #ifdef MP\n"; - $content .= " wx.onAppRoute(function(res) {\n"; - $content .= " if(res.path != \"addon/shop/pages/index\"){\n"; - $content .= " diyStore.topFixedStatus = 'home'\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 .= " });\n"; - $content .= " // #endif\n"; - $content .= " // 兼容轮播搜索组件-切换分类时,导致个人中心白屏 - end\n\n"; + $content .= " const data = ref(diyGroup.data);\n\n"; - $content .= " const tabbarAddonName = computed(() => {\n"; - $content .= " return useConfigStore().addon;\n"; - $content .= " })\n\n"; + $content .= " // 监听页面加载完成\n"; + $content .= " diyGroup.onMounted();\n\n"; - $content .= " const positionFixed = ref(['fixed', 'top_fixed','right_fixed','bottom_fixed','left_fixed']);\n\n"; - - $content .= " const getComponentClass = (index:any,component:any) => {\n\n"; - $content .= " let obj: any = {\n\n"; - $content .= " relative: true,\n\n"; - $content .= " selected: diyStore.currentIndex == index,\n\n"; - $content .= " decorate: diyStore.mode == 'decorate'\n\n"; - $content .= " }\n\n"; - $content .= " obj['top-fixed-' + diyStore.topFixedStatus] = true;\n\n"; - $content .= " if (component.position && positionFixed.value.indexOf(component.position) != -1) {\n\n"; - $content .= " // 找出置顶组件,设置禁止拖动\n\n"; - $content .= " obj['ignore-draggable-element'] = true;\n\n"; - $content .= " } else {\n\n"; - $content .= " obj['draggable-element'] = true;\n\n"; - $content .= " }\n\n"; - $content .= " return obj;\n\n"; - $content .= " }\n\n"; - - $content .= " onMounted(() => {\n"; - $content .= " // #ifdef H5\n"; - $content .= " if (diyStore.mode == 'decorate') {\n"; - $content .= " var el = document.getElementById('componentList');\n"; - $content .= " const sortable = Sortable.create(el, {\n"; - $content .= " draggable: '.draggable-element',\n"; - $content .= " animation: 200,\n"; - $content .= " // 结束拖拽\n"; - $content .= " onEnd: event => {\n"; - $content .= " let temp = diyStore.value[event.oldIndex!];\n"; - $content .= " diyStore.value.splice(event.oldIndex!, 1);\n"; - $content .= " diyStore.value.splice(event.newIndex!, 0, temp);\n\n"; - - $content .= " nextTick(() => {\n"; - $content .= " sortable.sort(range(diyStore.value.length).map(value => {\n"; - $content .= " return value.toString();\n"; - $content .= " }));\n\n"; - - $content .= " diyStore.postMessage(event.newIndex, diyStore.value[event.newIndex]);\n"; - $content .= " });\n"; - $content .= " }\n"; - $content .= " });\n"; - $content .= " }\n"; - $content .= " // #endif\n\n"; - - $content .= " nextTick(() => {\n"; - $content .= " setTimeout(() => {\n"; - $content .= " if (data.value.global && data.value.global.topStatusBar && data.value.global.topStatusBar.style == 'style-4') {\n"; - $content .= " // 第一次获取经纬度\n"; - $content .= " getLocation()\n"; - $content .= " }\n"; - $content .= " // 获取轮播搜索的滚动值\n"; - $content .= " carouselSearchScrollValue = carouselSearchRef.value ? carouselSearchRef.value[0].scrollValue : 0;\n"; - $content .= " // 获取top-tabbar的滚动值\n"; - $content .= " topTabbarScrollValue = topTabbarRef.value ? topTabbarRef.value.scrollValue : 0;\n"; - $content .= " }, 500)\n"; - $content .= " });\n\n"; - - $content .= " });\n\n"; - - $content .= " // 是否显示占位区域,用于禁止选中负上边距的内容\n"; - $content .= " const isShowPlaceHolder = (index: any, component: any) => {\n"; - $content .= " // #ifdef H5\n"; - $content .= " if (diyStore.mode == 'decorate') {\n"; - $content .= " let el: any = document.getElementById('componentList');\n"; - $content .= " if (el && el.children.length && el.children[index]) {\n"; - $content .= " let height = el.children[index].offsetHeight;\n"; - $content .= " let top = 0;\n"; - $content .= " if (component.margin.top < 0) {\n"; - $content .= " top = component.margin.top * 2 * -1;\n"; - $content .= " // 若负上边距大于组件的高度,则允许选中进行装修\n"; - $content .= " if (top > height) {\n"; - $content .= " return false;\n"; - $content .= " }\n"; - $content .= " }\n"; - $content .= " }\n"; - $content .= " return true;\n"; - $content .= " }\n"; - $content .= " // #endif\n"; - $content .= " return false;\n"; - $content .= " }\n"; - - $content .= " // 空函数,禁止选中\n"; - $content .= " const placeholderEvent = ()=>{}\n\n"; - - $content .= " // 页面onShow调用时,也会触发改方法\n"; - $content .= " const refresh = ()=>{\n"; - $content .= " nextTick(()=>{\n"; - $content .= " topTabbarRef.value?.refresh();\n"; - $content .= " });\n"; - $content .= " }\n\n"; - - $content .= " // 当页面滚动值超出轮播搜索滚动值时,carouselSearchScrollBool会变成true,触发相对应变化\n"; - $content .= " let carouselSearchScrollBool = ref(false)\n"; - $content .= " // 当页面滚动值超出轮播搜索滚动值时,top-tabbar会变成true,触发相对应变化\n"; - $content .= " let topTabbarScrollBool = ref(false)\n\n"; - - $content .= " onPageScroll((e)=>{\n"; - - $content .= " // 轮播搜索\n"; - $content .= " if(e.scrollTop > carouselSearchScrollValue){\n"; - $content .= " carouselSearchScrollBool.value = true\n"; - $content .= " }else{\n"; - $content .= " carouselSearchScrollBool.value = false\n"; - $content .= " }\n"; - - $content .= " // top-tabbar\n"; - $content .= " if(e.scrollTop > topTabbarScrollValue){\n"; - $content .= " topTabbarScrollBool.value = true\n"; - $content .= " }else{\n"; - $content .= " topTabbarScrollBool.value = false\n"; - $content .= " }\n"; - $content .= " })\n\n"; + $content .= " // 监听滚动事件\n"; + $content .= " diyGroup.onPageScroll();\n"; $content .= " defineExpose({\n"; - $content .= " refresh\n"; + $content .= " refresh: diyGroup.refresh\n"; $content .= " })\n"; $content .= "\n"; diff --git a/niucloud/app/service/core/diy/CoreDiyConfigService.php b/niucloud/app/service/core/diy/CoreDiyConfigService.php index 5e067042c..a669f56c2 100644 --- a/niucloud/app/service/core/diy/CoreDiyConfigService.php +++ b/niucloud/app/service/core/diy/CoreDiyConfigService.php @@ -27,17 +27,20 @@ class CoreDiyConfigService extends BaseCoreService public function getBottomList($params = []) { $list = array_values(array_filter(event('BottomNavigation', $params))); - $app_bottom_nav_config = []; - foreach ($list as $k => &$v) { - // 将系统底部导航放到第一个位置 - if ($v[ 'key' ] == 'app') { - $app_bottom_nav_config = $v; - unset($list[ $k ]); + if (count($list) > 1) { + foreach ($list as $k => &$v) { + + // 将系统底部导航放到第一个位置 + if ($v[ 'key' ] == 'app') { + $app_bottom_nav_config = $v; + unset($list[ $k ]); + } } + $list = array_values($list); } - $list = array_values($list); + if (!empty($app_bottom_nav_config)) { array_unshift($list, $app_bottom_nav_config); } @@ -52,10 +55,12 @@ class CoreDiyConfigService extends BaseCoreService public function getBottomConfig(string $key = 'app') { $default_config = $this->getBottomList([ 'key' => $key ])[ 0 ] ?? []; + if (empty($default_config)) { + $default_config = $this->getBottomList([ 'key' => 'app' ])[ 0 ] ?? []; + } $config_key = ConfigKeyDict::DIY_BOTTOM . '_' . $key; $info = ( new CoreConfigService() )->getConfig($config_key)[ 'value' ] ?? []; - if (!empty($default_config)) { if (!empty($info)) { $value = $info; diff --git a/niucloud/app/service/core/diy/CoreDiyService.php b/niucloud/app/service/core/diy/CoreDiyService.php index 14fae5003..c8adb301e 100644 --- a/niucloud/app/service/core/diy/CoreDiyService.php +++ b/niucloud/app/service/core/diy/CoreDiyService.php @@ -11,12 +11,8 @@ namespace app\service\core\diy; -use app\dict\sys\ConfigKeyDict; use app\model\diy\Diy; -use app\model\sys\SysConfig; -use app\service\core\sys\CoreConfigService; use core\base\BaseCoreService; -use think\Model; /** * 自定义页面相关 diff --git a/niucloud/app/service/core/member/CoreMemberAccountService.php b/niucloud/app/service/core/member/CoreMemberAccountService.php index 558cb4667..cde59914b 100644 --- a/niucloud/app/service/core/member/CoreMemberAccountService.php +++ b/niucloud/app/service/core/member/CoreMemberAccountService.php @@ -11,6 +11,8 @@ namespace app\service\core\member; +use app\dict\member\MemberAccountChangeTypeDict; +use app\dict\member\MemberAccountTypeDict; use app\model\member\Member; use app\model\member\MemberAccountLog; use core\base\BaseCoreService; @@ -33,15 +35,15 @@ class CoreMemberAccountService extends BaseCoreService //账户检测 $member_info = $member_model->where([ [ 'member_id', '=', $member_id ], - ])->field($account_type .','.$account_type."_get" .', username, mobile, nickname')->lock(true)->find(); - if(empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST'); + ])->field($account_type . ',' . $account_type . "_get" . ', username, mobile, nickname')->lock(true)->find(); + if (empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST'); $account_new_data = round((float) $member_info[ $account_type ] + (float) $account_data, 2); if ($account_new_data < 0) { throw new CommonException('ACCOUNT_INSUFFICIENT'); } - $data = array ( + $data = array( 'member_id' => $member_id, 'account_type' => $account_type, 'account_data' => $account_data, @@ -51,7 +53,7 @@ class CoreMemberAccountService extends BaseCoreService 'nickname' => $member_info[ 'nickname' ], 'mobile' => $member_info[ 'mobile' ], 'memo' => $memo, - 'related_id'=>$related_id, + 'related_id' => $related_id, ); Db::startTrans(); @@ -59,27 +61,36 @@ class CoreMemberAccountService extends BaseCoreService $res = $member_account_log_model->create($data); //账户更新 - if($account_data > 0) - { - $account_type_get = $member_info[ $account_type."_get" ] + $account_data; - }else{ - $account_type_get = $member_info[ $account_type."_get" ]; + if ($account_data > 0) { + if ($account_type == MemberAccountTypeDict::GROWTH) { + $account_type_get = $member_info[ $account_type . "_get" ] + $account_data; + } else { + $from_type_arr = MemberAccountChangeTypeDict::getType($account_type)[ $from_type ]; + $is_change_get = $from_type_arr[ 'is_change_get' ] ?? 1; + if ($is_change_get) { + $account_type_get = $member_info[ $account_type . "_get" ] + $account_data; + } else { + $account_type_get = $member_info[ $account_type . "_get" ]; + } + } + } else { + $account_type_get = $member_info[ $account_type . "_get" ]; } $member_model->update([ $account_type => $account_new_data, - $account_type."_get" => $account_type_get + $account_type . "_get" => $account_type_get ], [ 'member_id' => $member_id ]); //账户变化事件 $data[] = [ $account_type => $account_new_data, - $account_type."_get" => $account_type_get + $account_type . "_get" => $account_type_get ]; event("MemberAccount", $data); Db::commit(); return $res->id; - } catch ( Exception $e) { + } catch (Exception $e) { Db::rollback(); throw new CommonException($e->getMessage()); } diff --git a/niucloud/app/service/core/member/CoreMemberConfigService.php b/niucloud/app/service/core/member/CoreMemberConfigService.php index a629f50f7..bd47a5672 100644 --- a/niucloud/app/service/core/member/CoreMemberConfigService.php +++ b/niucloud/app/service/core/member/CoreMemberConfigService.php @@ -30,14 +30,15 @@ class CoreMemberConfigService extends BaseCoreService * 获取注册与登录设置 * @return array */ - public function getLoginConfig(){ - $info = (new CoreConfigService())->getConfig('LOGIN')['value'] ?? []; + public function getLoginConfig() + { + $info = ( new CoreConfigService() )->getConfig('LOGIN')[ 'value' ] ?? []; return [ - 'is_username' => $info['is_username'] ?? 1,//是否用户名密码登录 - 'is_mobile' => $info['is_mobile'] ?? 0,//是否手机验证码登录 - 'is_auth_register' => $info['is_auth_register'] ?? 1,//是否第三方自动注册 - 'is_bind_mobile' => $info['is_bind_mobile'] ?? 0,//是否强制绑定手机 - 'agreement_show' => $info['agreement_show'] ?? 0 // 政策协议是否展示 + 'is_username' => $info[ 'is_username' ] ?? 1,//是否用户名密码登录 + 'is_mobile' => $info[ 'is_mobile' ] ?? 0,//是否手机验证码登录 + 'is_auth_register' => $info[ 'is_auth_register' ] ?? 1,//是否第三方自动注册 + 'is_bind_mobile' => $info[ 'is_bind_mobile' ] ?? 0,//是否强制绑定手机 + 'agreement_show' => $info[ 'agreement_show' ] ?? 0 // 政策协议是否展示 ]; } @@ -46,15 +47,16 @@ class CoreMemberConfigService extends BaseCoreService * @param array $data * @return true */ - public function setLoginConfig(array $data){ + public function setLoginConfig(array $data) + { $config = [ - 'is_username' => $data['is_username'] ?? 1,//是否用户名密码登录 - 'is_mobile' => $data['is_mobile'] ?? 0,//是否手机验证码登录 - 'is_auth_register' => $data['is_auth_register'] ?? 1,//是否第三方自动注册 - 'is_bind_mobile' => $data['is_bind_mobile'] ?? 0,//是否强制绑定手机 - 'agreement_show' => $data['agreement_show'] ?? 0 // 政策协议是否展示 + 'is_username' => $data[ 'is_username' ] ?? 1,//是否用户名密码登录 + 'is_mobile' => $data[ 'is_mobile' ] ?? 0,//是否手机验证码登录 + 'is_auth_register' => $data[ 'is_auth_register' ] ?? 1,//是否第三方自动注册 + 'is_bind_mobile' => $data[ 'is_bind_mobile' ] ?? 0,//是否强制绑定手机 + 'agreement_show' => $data[ 'agreement_show' ] ?? 0 // 政策协议是否展示 ]; - (new CoreConfigService())->setConfig('LOGIN', $config); + ( new CoreConfigService() )->setConfig('LOGIN', $config); return true; } @@ -62,11 +64,12 @@ class CoreMemberConfigService extends BaseCoreService * 获取会员设置 * @return array */ - public function getMemberConfig(){ - $info = (new CoreConfigService())->getConfig('MEMBER')['value'] ?? []; + public function getMemberConfig() + { + $info = ( new CoreConfigService() )->getConfig('MEMBER')[ 'value' ] ?? []; return [ - 'prefix' => $info['prefix'] ?? '',// 会员编码前缀 - 'length' => $info['length'] ?? 4, // 会员编码长度 + 'prefix' => $info[ 'prefix' ] ?? '',// 会员编码前缀 + 'length' => $info[ 'length' ] ?? 4, // 会员编码长度 ]; } @@ -75,12 +78,13 @@ class CoreMemberConfigService extends BaseCoreService * @param array $data * @return true */ - public function setMemberConfig(array $data){ + public function setMemberConfig(array $data) + { $config = [ - 'prefix' => $data['prefix'] ?? '',// 会员编码前缀 - 'length' => $data['length'] ?? 4,// 会员编码长度 + 'prefix' => $data[ 'prefix' ] ?? '',// 会员编码前缀 + 'length' => $data[ 'length' ] ?? 4,// 会员编码长度 ]; - (new CoreConfigService())->setConfig('MEMBER', $config); + ( new CoreConfigService() )->setConfig('MEMBER', $config); return true; } @@ -88,8 +92,9 @@ class CoreMemberConfigService extends BaseCoreService * 获取成长值规则配置 * @return array */ - public function getGrowthRuleConfig(){ - return (new CoreConfigService())->getConfigValue('GROWTH_RULE'); + public function getGrowthRuleConfig() + { + return ( new CoreConfigService() )->getConfigValue('GROWTH_RULE'); } /** @@ -97,8 +102,9 @@ class CoreMemberConfigService extends BaseCoreService * @param array $data * @return true */ - public function setGrowthRuleConfig(array $data){ - (new CoreConfigService())->setConfig('GROWTH_RULE', $data); + public function setGrowthRuleConfig(array $data) + { + ( new CoreConfigService() )->setConfig('GROWTH_RULE', $data); return true; } @@ -106,8 +112,9 @@ class CoreMemberConfigService extends BaseCoreService * 获取积分规则配置 * @return array */ - public function getPointRuleConfig(){ - return (new CoreConfigService())->getConfigValue('POINT_RULE'); + public function getPointRuleConfig() + { + return ( new CoreConfigService() )->getConfigValue('POINT_RULE'); } /** @@ -115,8 +122,9 @@ class CoreMemberConfigService extends BaseCoreService * @param array $data * @return true */ - public function setPointRuleConfig(array $data){ - (new CoreConfigService())->setConfig('POINT_RULE', $data); + public function setPointRuleConfig(array $data) + { + ( new CoreConfigService() )->setConfig('POINT_RULE', $data); return true; } @@ -124,16 +132,17 @@ class CoreMemberConfigService extends BaseCoreService * 获取会员提现设置 * @return array */ - public function getCashOutConfig(){ - $config = (new CoreConfigService())->getConfig(ConfigKeyDict::MEMBER_CASH_OUT)['value'] ?? []; + public function getCashOutConfig() + { + $config = ( new CoreConfigService() )->getConfig(ConfigKeyDict::MEMBER_CASH_OUT)[ 'value' ] ?? []; return [ - 'is_open' => $config['is_open'] ?? '0',//是否启用提现 - 'transfer_type' => $config['transfer_type'] ?? [],//提现方式 - 'min' => $config['min'] ?? '0',//最低提现金额 + 'is_open' => $config[ 'is_open' ] ?? '0',//是否启用提现 + 'transfer_type' => $config[ 'transfer_type' ] ?? [],//提现方式 + 'min' => $config[ 'min' ] ?? '0',//最低提现金额 // 'max' => '0',//最高提现金额 - 'rate' => $config['rate'] ?? '0',//手续费比率 - 'is_auto_verify' => $config['is_auto_verify'] ?? '0', //是否自动审核 - 'is_auto_transfer' => $config['is_auto_transfer'] ?? '0', //是否自动转账 + 'rate' => $config[ 'rate' ] ?? '0',//手续费比率 + 'is_auto_verify' => $config[ 'is_auto_verify' ] ?? '0', //是否自动审核 + 'is_auto_transfer' => $config[ 'is_auto_transfer' ] ?? '0', //是否自动转账 ]; } @@ -142,20 +151,21 @@ class CoreMemberConfigService extends BaseCoreService * @param array $data * @return true */ - public function setCashOutConfig(array $data){ + public function setCashOutConfig(array $data) + { //校验转账方式是否合法 $transfer_type_list = array_keys(TransferDict::getTransferType()); - if(array_diff(array_diff($data['transfer_type'], $transfer_type_list), $transfer_type_list)) throw new CommonException('TRANSFER_TYPE_NOT_EXIST'); + if (array_diff(array_diff($data[ 'transfer_type' ], $transfer_type_list), $transfer_type_list)) throw new CommonException('TRANSFER_TYPE_NOT_EXIST'); $config = [ - 'is_open' => $data['is_open'],//是否启用提现 - 'transfer_type' => $data['transfer_type'] ?? [],//提现方式 - 'min' => $data['min'] ?? '',//最低提现金额 - 'is_auto_verify' => $data['is_auto_verify'] ?? 0, //是否自动审核 - 'is_auto_transfer' => $data['is_auto_transfer'] ?? 0, //是否自动转账 + 'is_open' => $data[ 'is_open' ],//是否启用提现 + 'transfer_type' => $data[ 'transfer_type' ] ?? [],//提现方式 + 'min' => $data[ 'min' ] ?? '',//最低提现金额 + 'is_auto_verify' => $data[ 'is_auto_verify' ] ?? 0, //是否自动审核 + 'is_auto_transfer' => $data[ 'is_auto_transfer' ] ?? 0, //是否自动转账 // 'max' => $data['max'] ?? '',//最高提现金额 - 'rate' => $data['rate'] ?? '',//手续费比率 + 'rate' => $data[ 'rate' ] ?? '',//手续费比率 ]; - (new CoreConfigService())->setConfig(ConfigKeyDict::MEMBER_CASH_OUT, $config); + ( new CoreConfigService() )->setConfig(ConfigKeyDict::MEMBER_CASH_OUT, $config); return true; } diff --git a/niucloud/app/service/core/member/CoreMemberService.php b/niucloud/app/service/core/member/CoreMemberService.php index d88f3a9e9..01f0f2198 100644 --- a/niucloud/app/service/core/member/CoreMemberService.php +++ b/niucloud/app/service/core/member/CoreMemberService.php @@ -109,10 +109,10 @@ class CoreMemberService extends BaseCoreService * @throws ModelNotFoundException */ public static function createMemberNo() { - $no = (new self())->getMemberNoConfig(); - $no += 1; $config = (new CoreMemberConfigService())->getMemberConfig(); + $no = (new self())->getMemberNoConfig(); + $no += 1; $member_no = $config['prefix'] . ( strlen($config['prefix']) > $config['length'] ? $no : str_pad($no, ($config['length'] - strlen($config['prefix'])), "0", STR_PAD_LEFT) ); $member = (new Member())->where([ ['member_no', '=', $member_no] ])->findOrEmpty(); @@ -135,10 +135,10 @@ class CoreMemberService extends BaseCoreService * @throws ModelNotFoundException */ public static function setMemberNo(int $member_id) { - $no = (new self())->getMemberNoConfig(); - $no += 1; $config = (new CoreMemberConfigService())->getMemberConfig(); + $no = (new self())->getMemberNoConfig(); + $no += 1; $member_no = $config['prefix'] . ( strlen($config['prefix']) > $config['length'] ? $no : str_pad($no, ($config['length'] - strlen($config['prefix'])), "0", STR_PAD_LEFT) ); $member = (new Member())->where([ ['member_no', '=', $member_no] ])->findOrEmpty(); @@ -268,7 +268,7 @@ class CoreMemberService extends BaseCoreService foreach ($gifts as $k => $item) { $gifts[$k]['content'] = null; - if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { + if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || empty($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { continue; } else { $content = $dict[$k]['content'][$scene]; @@ -292,7 +292,7 @@ class CoreMemberService extends BaseCoreService foreach ($benefits as $k => $item) { $benefits[$k]['content'] = null; - if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { + if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || empty($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { continue; } else { $content = $dict[$k]['content'][$scene]; @@ -316,7 +316,7 @@ class CoreMemberService extends BaseCoreService foreach ($config as $k => $item) { $config[$k]['content'] = null; - if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { + if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || empty($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { continue; } else { $content = $dict[$k]['content'][$scene]; @@ -340,7 +340,7 @@ class CoreMemberService extends BaseCoreService foreach ($config as $k => $item) { $config[$k]['content'] = null; - if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { + if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || empty($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { continue; } else { $content = $dict[$k]['content'][$scene]; @@ -364,7 +364,7 @@ class CoreMemberService extends BaseCoreService foreach ($config as $k => $item) { $config[$k]['content'] = null; - if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { + if (!isset($item['is_use']) || !$item['is_use'] || !isset($dict[$k]['content']) || empty($dict[$k]['content']) || !isset($dict[$k]['content'][$scene])) { continue; } else { $content = $dict[$k]['content'][$scene]; diff --git a/niucloud/app/service/core/niucloud/CoreAuthService.php b/niucloud/app/service/core/niucloud/CoreAuthService.php index 2b2d30ae4..bfc61c9ff 100644 --- a/niucloud/app/service/core/niucloud/CoreAuthService.php +++ b/niucloud/app/service/core/niucloud/CoreAuthService.php @@ -11,12 +11,10 @@ namespace app\service\core\niucloud; -use app\service\admin\niucloud\NiucloudService; use core\util\niucloud\BaseNiucloudClient; use core\util\niucloud\http\Response; use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\ResponseInterface; -use RuntimeException; /** * 官网授权管理服务层 diff --git a/niucloud/app/service/core/niucloud/CoreCloudBaseService.php b/niucloud/app/service/core/niucloud/CoreCloudBaseService.php index 958da8169..daf32f7cd 100644 --- a/niucloud/app/service/core/niucloud/CoreCloudBaseService.php +++ b/niucloud/app/service/core/niucloud/CoreCloudBaseService.php @@ -13,7 +13,6 @@ namespace app\service\core\niucloud; use core\base\BaseCoreService; use core\exception\CommonException; -use core\util\niucloud\http\Response; /** * 云服务层 diff --git a/niucloud/app/service/core/niucloud/CoreCloudBuildService.php b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php index 993b55869..74e409214 100644 --- a/niucloud/app/service/core/niucloud/CoreCloudBuildService.php +++ b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php @@ -14,7 +14,6 @@ namespace app\service\core\niucloud; use app\model\addon\Addon; use app\service\core\addon\CoreAddonBaseService; use app\service\core\addon\CoreAddonDevelopDownloadService; -use app\service\core\addon\CoreAddonInstallService; use core\base\BaseCoreService; use core\exception\CommonException; use core\util\niucloud\BaseNiucloudClient; diff --git a/niucloud/app/service/core/niucloud/CoreModuleService.php b/niucloud/app/service/core/niucloud/CoreModuleService.php index 69a100146..4bfd7d9b4 100644 --- a/niucloud/app/service/core/niucloud/CoreModuleService.php +++ b/niucloud/app/service/core/niucloud/CoreModuleService.php @@ -12,7 +12,6 @@ namespace app\service\core\niucloud; use app\dict\sys\ConfigKeyDict; -use app\service\admin\niucloud\NiucloudService; use app\service\core\sys\CoreConfigService; use core\util\niucloud\BaseNiucloudClient; use core\util\niucloud\http\Response; diff --git a/niucloud/app/service/core/niucloud/CoreNotifyService.php b/niucloud/app/service/core/niucloud/CoreNotifyService.php index 0669349bd..371b49a5b 100644 --- a/niucloud/app/service/core/niucloud/CoreNotifyService.php +++ b/niucloud/app/service/core/niucloud/CoreNotifyService.php @@ -11,11 +11,7 @@ namespace app\service\core\niucloud; -use app\service\admin\niucloud\NiucloudService; use core\util\niucloud\BaseNiucloudClient; -use core\util\niucloud\http\Response; -use GuzzleHttp\Exception\GuzzleException; -use Psr\Http\Message\ResponseInterface; /** * 官网授权管理服务层 @@ -40,6 +36,4 @@ class CoreNotifyService extends BaseNiucloudClient return success(); } - - } diff --git a/niucloud/app/service/core/pay/CoreAccountService.php b/niucloud/app/service/core/pay/CoreAccountService.php index ca9ebe5bb..3a7ffc4ea 100644 --- a/niucloud/app/service/core/pay/CoreAccountService.php +++ b/niucloud/app/service/core/pay/CoreAccountService.php @@ -1,6 +1,6 @@ channel = $channel; $this->type = $type; - $this->config = (new CorePayChannelService())->getConfigByChannelAndType($this->channel, $this->type); + $this->config = ( new CorePayChannelService() )->getConfigByChannelAndType($this->channel, $this->type); return $this; } @@ -65,8 +65,8 @@ class CorePayEventService extends BaseCoreService */ public function app(string $action = 'query') { - $notify_url = (string)url("/api/pay/notify/$this->channel/$this->type/$action", [], '', true);//异步回调通知地址 - $this->config['notify_url'] = $notify_url; + $notify_url = (string) url("/api/pay/notify/$this->channel/$this->type/$action", [], '', true);//异步回调通知地址 + $this->config[ 'notify_url' ] = $notify_url; return new PayLoader($this->type, $this->config); } @@ -87,8 +87,8 @@ class CorePayEventService extends BaseCoreService { $pay_fun = ''; - if(mb_strlen($body, 'UTF-8') > 15){ - $body = mb_substr($body, 0, 15, 'UTF-8').'...'; + if (mb_strlen($body, 'UTF-8') > 15) { + $body = mb_substr($body, 0, 15, 'UTF-8') . '...'; } $params = array( 'out_trade_no' => $out_trade_no, @@ -103,7 +103,7 @@ class CorePayEventService extends BaseCoreService ); switch ($this->type) { case PayDict::WECHATPAY: - $params['money'] = (int)bcmul($params['money'], 100); + $params[ 'money' ] = (int) bcmul($params[ 'money' ], 100); switch ($this->channel) { case ChannelDict::H5://h5 $pay_fun = 'wap'; @@ -169,7 +169,7 @@ class CorePayEventService extends BaseCoreService $transfer_type = TransferDict::getPayTypeByTransfer($this->type); switch ($transfer_type) { case PayDict::WECHATPAY: - $money *= 100; + $money = (int) bcmul($money, 100); break; case PayDict::ALIPAY: break; @@ -213,8 +213,8 @@ class CorePayEventService extends BaseCoreService public function refund(string $out_trade_no, float $money, float $total, string $refund_no, $voucher = '') { if ($this->type == PayDict::WECHATPAY) { - $money *= 100; - $total *= 100; + $money = (int) bcmul($money, 100); + $total = (int) bcmul($total, 100); } return $this->app('refund')->refund([ 'out_trade_no' => $out_trade_no, @@ -247,7 +247,7 @@ class CorePayEventService extends BaseCoreService */ public function getOrder(string $out_trade_no) { - return $this->app()->getOrder(['out_trade_no' => $out_trade_no]); + return $this->app()->getOrder([ 'out_trade_no' => $out_trade_no ]); } /** diff --git a/niucloud/app/service/core/pay/CorePayService.php b/niucloud/app/service/core/pay/CorePayService.php index f28eff79b..e738b67dc 100644 --- a/niucloud/app/service/core/pay/CorePayService.php +++ b/niucloud/app/service/core/pay/CorePayService.php @@ -77,11 +77,11 @@ class CorePayService extends BaseCoreService public function findPayInfoByTrade(string $trade_type, int $trade_id) { $where = array( - ['trade_type', '=', $trade_type], - ['trade_id', '=', $trade_id], - ['status', '<>', PayDict::STATUS_CANCLE],///不查询已取消的单据 + [ 'trade_type', '=', $trade_type ], + [ 'trade_id', '=', $trade_id ], + [ 'status', '<>', PayDict::STATUS_CANCLE ],///不查询已取消的单据 ); - return $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty(); + return $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty(); } /** @@ -92,9 +92,9 @@ class CorePayService extends BaseCoreService public function findPayInfoByOutTradeNo(string $out_trade_no) { $where = array( - ['out_trade_no', '=', $out_trade_no] + [ 'out_trade_no', '=', $out_trade_no ] ); - return $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty(); + return $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty(); } /** @@ -109,12 +109,12 @@ class CorePayService extends BaseCoreService public function getInfoByOutTradeNo(string $out_trade_no, string $channel) { $where = array( - ['out_trade_no', '=', $out_trade_no] + [ 'out_trade_no', '=', $out_trade_no ] ); - $pay = $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty()->toArray(); + $pay = $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty()->toArray(); if (!empty($pay)) { //todo 校验场景控制支付方式 - $pay['pay_type_list'] = array_values((new CorePayChannelService())->getAllowPayTypeByChannel($channel, $pay['trade_type'])); + $pay[ 'pay_type_list' ] = array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($channel, $pay[ 'trade_type' ])); } return $pay; } @@ -136,12 +136,12 @@ class CorePayService extends BaseCoreService //创建新的支付单据 $pay = $this->createByTrade($trade_type, $trade_id); } - if(!is_array($pay)){ + if (!is_array($pay)) { $pay = $pay->toArray(); } if (!empty($pay)) { //todo 校验场景控制支付方式 - $pay['pay_type_list'] = array_values((new CorePayChannelService())->getAllowPayTypeByChannel($channel, $pay['trade_type'])); + $pay[ 'pay_type_list' ] = array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($channel, $pay[ 'trade_type' ])); } return $pay; } @@ -158,7 +158,7 @@ class CorePayService extends BaseCoreService public function getPayTypeByTrade(string $trade_type, string $channel) { //todo 校验场景控制支付方式 - return array_values((new CorePayChannelService())->getAllowPayTypeByChannel($channel, $trade_type)); + return array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($channel, $trade_type)); } /** @@ -180,14 +180,14 @@ class CorePayService extends BaseCoreService { //检测并创建支付单据 $pay = $this->checkOrCreate($trade_type, $trade_id); - $out_trade_no = $pay['out_trade_no']; - $money = $pay['money']; - $body = $pay['body']; - $trade_type = $pay['trade_type']; - if (!in_array($type, array_column((new CorePayChannelService())->getAllowPayTypeByChannel($channel, $trade_type), 'key'))) throw new PayException('PAYMENT_METHOD_NOT_SCENE');//场景不支持 + $out_trade_no = $pay[ 'out_trade_no' ]; + $money = $pay[ 'money' ]; + $body = $pay[ 'body' ]; + $trade_type = $pay[ 'trade_type' ]; + if (!in_array($type, array_column(( new CorePayChannelService() )->getAllowPayTypeByChannel($channel, $trade_type), 'key'))) throw new PayException('PAYMENT_METHOD_NOT_SCENE');//场景不支持 $pay_result = $this->pay_event->init($channel, $type)->pay($out_trade_no, $money, $body, $return_url, $quit_url, $buyer_id, $openid ?? '', $voucher); //todo 特殊支付方式会直接返回支付状态,状态如果为已支付会直接支付 - if (!empty($pay_result['status']) && $pay_result['status'] == PayDict::STATUS_FINISH) { + if (!empty($pay_result[ 'status' ]) && $pay_result[ 'status' ] == PayDict::STATUS_FINISH) { $pay->save([ 'channel' => $channel ]); $this->paySuccess([ 'status' => PayDict::STATUS_FINISH, @@ -221,8 +221,8 @@ class CorePayService extends BaseCoreService 'channel' => $channel ] ); - if(env('queue.state', true) ){ - PayReturnTo::dispatch(['out_trade_no' => $out_trade_no], secs: 15); + if (env('queue.state', true)) { + PayReturnTo::dispatch([ 'out_trade_no' => $out_trade_no ], secs: 15); } } return $pay_result; @@ -241,10 +241,10 @@ class CorePayService extends BaseCoreService //创建新的支付单据 $pay = $this->createByTrade($trade_type, $trade_id); } - if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS'); + if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS'); // if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE'); - if ($pay['status'] == PayDict::STATUS_ING || $pay['status'] == PayDict::STATUS_CANCLE) { - if($pay['status'] == PayDict::STATUS_ING ){ + if ($pay[ 'status' ] == PayDict::STATUS_ING || $pay[ 'status' ] == PayDict::STATUS_CANCLE) { + if ($pay[ 'status' ] == PayDict::STATUS_ING) { //尝试关闭原有的支付单据 $this->close($pay->out_trade_no); } @@ -260,19 +260,20 @@ class CorePayService extends BaseCoreService * @param $trade_id * @return Pay|array|mixed|Model */ - public function createByTrade($trade_type, $trade_id){ + public function createByTrade($trade_type, $trade_id) + { //创建新的支付单据 - $data = array_values(array_filter(event('PayCreate', ['trade_type' => $trade_type, 'trade_id' => $trade_id])))[0] ?? []; - if(empty($data)) throw new PayException('PAY_NOT_FOUND_TRADE');//找不到可支付的交易 + $data = array_values(array_filter(event('PayCreate', [ 'trade_type' => $trade_type, 'trade_id' => $trade_id ])))[ 0 ] ?? []; + if (empty($data)) throw new PayException('PAY_NOT_FOUND_TRADE');//找不到可支付的交易 - if(isset($data['status']) && $data['money'] == 0){ - $data['status'] = PayDict::STATUS_FINISH; - $data['status_name'] = PayDict::getStatus()[$data['status']] ?? ''; - $data['type'] = PayDict::BALANCEPAY; - $data['type_name'] = PayDict::getPayType()[$data['type']]['name'] ?? ''; + if (isset($data[ 'status' ]) && $data[ 'money' ] == 0) { + $data[ 'status' ] = PayDict::STATUS_FINISH; + $data[ 'status_name' ] = PayDict::getStatus()[ $data[ 'status' ] ] ?? ''; + $data[ 'type' ] = PayDict::BALANCEPAY; + $data[ 'type_name' ] = PayDict::getPayType()[ $data[ 'type' ] ][ 'name' ] ?? ''; return $data; - }else{ - $out_trade_no = $this->create($data['main_type'], $data['main_id'], $data['money'], $data['trade_type'], $data['trade_id'], $data['body']); + } else { + $out_trade_no = $this->create($data[ 'main_type' ], $data[ 'main_id' ], $data[ 'money' ], $data[ 'trade_type' ], $data[ 'trade_id' ], $data[ 'body' ]); return $this->findPayInfoByOutTradeNo($out_trade_no); } } @@ -292,12 +293,12 @@ class CorePayService extends BaseCoreService $pay = $this->findPayInfoByOutTradeNo($out_trade_no); } if ($pay->isEmpty()) return true; - if ($pay['status'] != PayDict::STATUS_ING) return true; + if ($pay[ 'status' ] != PayDict::STATUS_ING) return true; if (empty($pay->type)) return true; //尝试取消或关闭第三方支付 try { $close = $this->close($out_trade_no); - } catch ( Throwable $e ) { + } catch (Throwable $e) { $close = false; } return $close; @@ -312,20 +313,20 @@ class CorePayService extends BaseCoreService { $pay = $this->findPayInfoByOutTradeNo($out_trade_no); if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST'); - if($pay['status'] == PayDict::STATUS_CANCLE) return true; + if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) return true; - if (!in_array($pay['status'], [ + if (!in_array($pay[ 'status' ], [ PayDict::STATUS_WAIT, PayDict::STATUS_ING ])) throw new PayException('TREAT_PAYMENT_IS_OPEN'); - if ($pay['status'] == PayDict::STATUS_ING) { + if ($pay[ 'status' ] == PayDict::STATUS_ING) { if (!empty($pay->type)) { //尝试取消或关闭第三方支付 $close = $this->pay_event->init($pay->channel, $pay->type)->close($out_trade_no); if (!$close) {//有问题查询第三方订单详情 $order = $this->pay_event->init($pay->channel, $pay->type)->getOrder($out_trade_no); if (!empty($order)) { - if ($order['status'] == OnlinePayDict::SUCCESS) {//如果已支付,就将支付调整为已支付 + if ($order[ 'status' ] == OnlinePayDict::SUCCESS) {//如果已支付,就将支付调整为已支付 $this->paySuccess([ 'out_trade_no' => $out_trade_no, 'type' => $pay->type @@ -355,11 +356,11 @@ class CorePayService extends BaseCoreService // if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST'); if ($pay->isEmpty()) return true; // if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID');//当前单据已支付 - if (!in_array($pay['status'], [ + if (!in_array($pay[ 'status' ], [ PayDict::STATUS_WAIT, PayDict::STATUS_ING ])) throw new PayException('IS_PAY_REMOVE_NOT_RESETTING');//只有待支付可以关闭支付 - if (!$this->close($pay['out_trade_no'])) { + if (!$this->close($pay[ 'out_trade_no' ])) { throw new PayException('DOCUMENT_IS_PAY_REMOVE'); } return true; @@ -377,15 +378,15 @@ class CorePayService extends BaseCoreService $pay = $this->findPayInfoByOutTradeNo($out_trade_no); if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST'); - if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID'); - if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE'); - $status = $params['status']; + if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID'); + if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE'); + $status = $params[ 'status' ]; switch ($status) { case OnlinePayDict::SUCCESS://支付成功 - $this->paySuccess([ + $this->paySuccess(array_merge([ 'out_trade_no' => $out_trade_no, 'type' => $type - ]); + ], $params)); break; case OnlinePayDict::CLOSED://支付关闭 $this->payClose([ @@ -414,19 +415,19 @@ class CorePayService extends BaseCoreService */ public function notify(string $channel, string $type, string $action) { - $callback = function ($out_trade_no, $params) use ($type, $action) { + $callback = function($out_trade_no, $params) use ($type, $action) { try { switch ($action) { case 'pay'://支付结果通知 return $this->payNotify($out_trade_no, $type, $params); break; case 'refund': - return (new CoreRefundService())->refundNotify($out_trade_no, $type, $params); + return ( new CoreRefundService() )->refundNotify($out_trade_no, $type, $params); break; } //找不到对应的业务 return true; - } catch ( PayException $e ) { + } catch (PayException $e) { return false; } }; @@ -440,17 +441,17 @@ class CorePayService extends BaseCoreService */ public function check(array $data) { - $out_trade_no = $data['out_trade_no']; + $out_trade_no = $data[ 'out_trade_no' ]; $pay = $this->findPayInfoByOutTradeNo($out_trade_no); if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST'); - if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');//单据已支付 - if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');//单据已取消 + if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');//单据已支付 + if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');//单据已取消 //查询第三方支付单据 $pay_info = $this->pay_event->init($pay->channel, $pay->type)->getOrder($out_trade_no); - $type = $pay['type']; + $type = $pay[ 'type' ]; if (empty($pay_info)) return false; - $status = $pay_info['status']; + $status = $pay_info[ 'status' ]; switch ($status) { case OnlinePayDict::SUCCESS://支付成功 $this->paySuccess([ @@ -482,27 +483,27 @@ class CorePayService extends BaseCoreService */ public function paySuccess($params) { - $out_trade_no = $params['out_trade_no']; + $out_trade_no = $params[ 'out_trade_no' ]; $pay = $this->findPayInfoByOutTradeNo($out_trade_no); - $type = $params['type']; + $type = $params[ 'type' ]; $trade_type = $pay->trade_type; $trade_id = $pay->trade_id; $data = array( 'pay_time' => time(), 'status' => PayDict::STATUS_FINISH, 'type' => $type, - 'trade_no' => $params['trade_no'] ?? '', - 'voucher' => $params['voucher'] ?? '', - 'mch_id' => $params['mch_id'] ?? '', + 'trade_no' => $params[ 'trade_no' ] ?? '', + 'voucher' => $params[ 'voucher' ] ?? '', + 'mch_id' => $params[ 'mch_id' ] ?? '', ); //允许修改的值 - $allow_field = array('trade_no', 'voucher', 'status', 'pay_time', 'type', 'mch_id'); + $allow_field = array( 'trade_no', 'voucher', 'status', 'pay_time', 'type', 'mch_id' ); // 启动事务 Db::startTrans(); try { $pay->allowField($allow_field)->save($data); - $result = event('PaySuccess', ['out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'trade_id' => $trade_id]); + $result = event('PaySuccess', [ 'out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'trade_id' => $trade_id ]); // if (!check_event_result($result)) { // Db::rollback(); // return false; @@ -510,10 +511,10 @@ class CorePayService extends BaseCoreService // 提交事务 Db::commit(); return true; - } catch ( Throwable $e ) { + } catch (Throwable $e) { // 回滚事务 Db::rollback(); - throw new PayException($e->getMessage().$e->getFile().$e->getLine()); + throw new PayException($e->getMessage() . $e->getFile() . $e->getLine()); } return true; } @@ -525,17 +526,17 @@ class CorePayService extends BaseCoreService */ public function payClose($data) { - $out_trade_no = $data['out_trade_no']; + $out_trade_no = $data[ 'out_trade_no' ]; Db::startTrans(); try { $pay = $this->findPayInfoByOutTradeNo($out_trade_no); $pay->save([ 'status' => PayDict::STATUS_CANCLE, - 'fail_reason' => $data['reason'] ?? '' + 'fail_reason' => $data[ 'reason' ] ?? '' ]); - $result = event('PayClose', ['out_trade_no' => $out_trade_no, 'trade_type' => $pay->trade_type, 'trade_id' => $pay->trade_id ]); + $result = event('PayClose', [ 'out_trade_no' => $out_trade_no, 'trade_type' => $pay->trade_type, 'trade_id' => $pay->trade_id ]); if (!check_event_result($result)) { Db::rollback(); return false; @@ -543,10 +544,10 @@ class CorePayService extends BaseCoreService // 提交事务 Db::commit(); return true; - } catch ( Throwable $e ) { + } catch (Throwable $e) { // 回滚事务 Db::rollback(); - throw new PayException($e->getMessage().$e->getFile().$e->getLine()); + throw new PayException($e->getMessage() . $e->getFile() . $e->getLine()); } } diff --git a/niucloud/app/service/core/poster/CorePosterService.php b/niucloud/app/service/core/poster/CorePosterService.php index 527354bb1..6032e7755 100644 --- a/niucloud/app/service/core/poster/CorePosterService.php +++ b/niucloud/app/service/core/poster/CorePosterService.php @@ -40,16 +40,6 @@ class CorePosterService extends BaseCoreService return true; } - /** - * 删除自定义海报 - * @param $condition - * @return bool - */ - public function del($condition) - { - return ( new Poster() )->where($condition)->delete(); - } - /** * 海报类型 * @param string $type @@ -139,10 +129,11 @@ class CorePosterService extends BaseCoreService $dir = 'upload/poster'; $temp1 = md5(json_encode($poster)); $temp2 = md5(json_encode($poster_data)); - $file_path = 'poster' . $temp1 . '_' . $temp2 .'_'.$channel. '.png'; + $file_path = 'poster' . $temp1 . '_' . $temp2 . '_' . $channel . '.png'; $path = $dir . '/' . $file_path; //判断当前海报是否存在,存在直接返回地址,不存在的话则创建 + if (is_file($path)) { return $path; } else { @@ -174,7 +165,7 @@ class CorePosterService extends BaseCoreService if ($poster[ 'global' ][ 'bgType' ] == 'url') { if (!empty($poster[ 'global' ][ 'bgUrl' ]) && str_contains($poster[ 'global' ][ 'bgUrl' ], 'http://') || str_contains($poster[ 'global' ][ 'bgUrl' ], 'https://')) { //判断是否是是远程图片,远程图片需要本地化 - $temp_dir = 'file/image/' . date('Ym') . '/' . date('d'); + $temp_dir = 'file/' . 'image' . '/' . date('Ym') . '/' . date('d'); try { $poster[ 'global' ][ 'bgUrl' ] = $core_upload_service->image($poster[ 'global' ][ 'bgUrl' ], $temp_dir, FileDict::LOCAL)[ 'url' ] ?? ''; } catch (\Exception $e) { @@ -195,7 +186,7 @@ class CorePosterService extends BaseCoreService } else if ($v[ 'type' ] == 'image') {//校验图片文件是否是远程文件 if (str_contains($v[ 'value' ], 'http://') || str_contains($v[ 'value' ], 'https://')) { //判断是否是是远程图片,远程图片需要本地化 - $temp_dir = 'file/image/' . date('Ym') . '/' . date('d'); + $temp_dir = 'file/' . 'image' . '/' . date('Ym') . '/' . date('d'); try { $v[ 'value' ] = $core_upload_service->image($v[ 'value' ], $temp_dir, FileDict::LOCAL)[ 'url' ] ?? ''; } catch (\Exception $e) { @@ -216,4 +207,4 @@ class CorePosterService extends BaseCoreService return $this->driver('poster')->createPoster($poster, $dir, $file_path); } -} +} \ No newline at end of file diff --git a/niucloud/app/service/core/printer/CorePrinterService.php b/niucloud/app/service/core/printer/CorePrinterService.php new file mode 100644 index 000000000..dbe6cb90a --- /dev/null +++ b/niucloud/app/service/core/printer/CorePrinterService.php @@ -0,0 +1,321 @@ +where($where)->field($field)->order($order)->append([ 'brand_name' ])->select()->toArray(); + } + + /** + * 获取小票打印模板类型 + * @return array|null + */ + public function getType() + { + $data = PrinterDict::getType(); + array_multisort(array_column($data, 'sort'), SORT_ASC, $data); // 根据 sort 排序 + return $data; + } + + /** + * 获取设备品牌 + * @param string $brand + * @return array|mixed|string + */ + public function getBrand($brand = '') + { + return PrinterDict::getBrandName($brand); + } + + /** + * 设置易联云小票打印token + * @param $data + * @return \app\model\sys\SysConfig|bool|\think\Model + */ + public function setYlyTokenConfig($data) + { + return ( new ConfigService() )->setConfig('PRINTER_YLY_TOKEN', $data); + } + + /** + * 获取易联云配置 + * @return array|mixed + */ + public function getYlyTokenConfig() + { + $info = ( new ConfigService() )->getConfig('PRINTER_YLY_TOKEN'); + if (empty($info)) { + $info = []; + $info[ 'value' ] = [ + 'access_token' => '', + 'end_time' => '0' // token有效期 + ]; + } + return $info[ 'value' ]; + } + + /** + * 获取易联云token + * @param $yly_config + * @param bool $refresh 是否主动刷新token + * @return mixed + */ + public function getYlyToken($yly_config, $refresh = false) + { + // token 配置 + $config = $this->getYlyTokenConfig(); + + if ($config[ 'end_time' ] == 0 || $config[ 'end_time' ] < time() || $refresh) { + $client = new YlyOauthClient($yly_config); + $token = $client->getToken(); // 若是开放型应用请传授权码code + $access_token = $token->access_token; // 调用API凭证AccessToken + + // 更新token + $expires_in = $token->expires_in; + $end_time = time() + $expires_in; + $token_data = [ + 'access_token' => $token->access_token, + 'end_time' => $end_time + ]; + $this->setYlyTokenConfig($token_data); + } else { + $access_token = $config[ 'access_token' ]; + } + return $access_token; + } + + /** + * 添加易联云打印机授权 + * @param $params + * @return mixed + */ + public function addPrinterYly($params) + { + $yly_config = new YlyConfig($params[ 'open_id' ], $params[ 'apikey' ]); + $access_token = $this->getYlyToken($yly_config); + + $printer = new PrinterServiceApi($access_token, $yly_config); + $api_data = $printer->addPrinter($params[ 'printer_code' ], $params[ 'printer_key' ]); + + $res = [ + 'code' => $api_data->error, + 'message' => $api_data->error_description + ]; + + if (!empty($api_data->body) && gettype($api_data->body) == 'string') { + $res[ 'message' ] .= ',' . $api_data->body; + } + + return $res; + } + + /** + * 删除易联云打印机授权 + * @param $params + * @return mixed + */ + public function deletePrinterYly($params) + { + $yly_config = new YlyConfig($params[ 'open_id' ], $params[ 'apikey' ]); + $access_token = $this->getYlyToken($yly_config); + + $printer = new PrinterServiceApi($access_token, $yly_config); + $res = $printer->deletePrinter($params[ 'printer_code' ]); + return [ + 'code' => $res->error, + 'message' => $res->error_description + ]; + } + + /** + * 重新获取易联云token + * @param $printer_id + * @return mixed + */ + public function refreshToken($printer_id) + { + $field = 'open_id,apikey'; + $info = ( new SysPrinter() )->field($field)->where([ [ 'printer_id', "=", $printer_id ] ])->findOrEmpty()->toArray(); + if (empty($info)) { + throw new CommonException('PRINTER_NOT_EXIST'); + } + + $yly_config = new YlyConfig($info[ 'open_id' ], $info[ 'apikey' ]); + $access_token = $this->getYlyToken($yly_config, true); + return $access_token; + } + + /** + * 测试打印 + * @param $printer_id + * @return mixed + */ + public function testPrint($printer_id) + { + $field = 'printer_id,brand,printer_code,open_id,apikey'; + $info = ( new SysPrinter() )->field($field)->where([ [ 'printer_id', "=", $printer_id ] ])->findOrEmpty()->toArray(); + if (empty($info)) { + throw new CommonException('PRINTER_NOT_EXIST'); + } + + // 易联云打印机 + if ($info[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $res = $this->testYlyPrint($info); + return $res; + } + + } + + /** + * 测试易联云打印 + * @param $printer + */ + public function testYlyPrint($printer) + { + $origin_id = date('YmdHis') . rand(1, 999); // 内部订单号(32位以内) + + $content = "" . 1 . ""; + + $content .= "
小票名称
"; + $content .= str_repeat('.', 32); + $content .= "
商城名称
"; + $content .= str_repeat('.', 32); + + $content .= "订单时间:" . date("Y-m-d H:i") . "\n"; + $content .= "订单编号:" . $origin_id . "\n"; + + $content .= str_repeat('.', 32); + $content .= ""; + $content .= ""; + $content .= "
商品名称数量金额
"; + $content .= str_repeat('.', 32); + + $content .= ""; + $content .= ""; + $content .= ""; + $content .= ""; + $content .= "
烤土豆(超级辣)x35
烤豆干(超级辣)x210
烤鸡翅(超级辣)x315
"; + $content .= str_repeat('.', 32); + + $content .= "商品总额:¥30 \n"; + $content .= "订单共8件商品,总计: ¥30 \n"; + $content .= str_repeat('.', 32); + + $content .= "买家留言:微辣,多放孜然\n"; + $content .= str_repeat('.', 32); + + $content .= "
谢谢惠顾,欢迎下次光临
"; + + try { + $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]); + $access_token = $this->getYlyToken($config); + $machine_code = $printer[ 'printer_code' ]; // 商户授权机器码 + $print = new PrintService($access_token, $config); + $res = $print->index($machine_code, $content, $origin_id); + if ($res->error != 0) { + throw new CommonException($res->error_description); + } + } catch (\Exception $e) { + throw new CommonException($e->getMessage()); + } + } + + /** + * 打印小票内容 + * @param $params + * @return array + */ + public function printTicket($params) + { + $item = array_values(array_filter(event('PrinterContent', $params))); + + $result = [ + 'code' => 0, + 'message' => '' + ]; + $list = []; + foreach ($item as $k => $v) { + if ($v[ 'code' ] == 0) { + $list = array_merge($list, $v[ 'data' ]); + } else { + $result[ 'code' ] = $v[ 'code' ]; + $result[ 'message' ] = $v[ 'message' ]; + break; + } + } + + if ($result[ 'code' ] != 0) { + return $result; + } + + if (empty($list)) { + return [ + 'code' => -1, + 'message' => '未找到小票模板内容' + ]; + } + + try { + + foreach ($list as $k => $v) { + + switch ($v[ 'printer_info' ][ 'brand' ]) { + // 易联云打印机 + case PrinterDict::YI_LIAN_YUN: + $config = new YlyConfig($v[ 'printer_info' ][ 'open_id' ], $v[ 'printer_info' ][ 'apikey' ]); + $access_token = $this->getYlyToken($config); + $machine_code = $v[ 'printer_info' ][ 'printer_code' ]; // 商户授权机器码 + + $print = new PrintService($access_token, $config); + $res = $print->index($machine_code, $v[ 'content' ], $v[ 'origin_id' ]); + if ($res->error != 0) { + $result[ 'code' ] = $res->error; + $result[ 'message' ] = $res->error_description; + } + break; + } + + } + } catch (\Exception $e) { + $result[ 'code' ] = -1; + $result[ 'message' ] = $e->getMessage(); + } + + return $result; + } + +} \ No newline at end of file diff --git a/niucloud/app/service/core/schedule/CoreScheduleService.php b/niucloud/app/service/core/schedule/CoreScheduleService.php index 81bd3ae68..2f13c15f4 100644 --- a/niucloud/app/service/core/schedule/CoreScheduleService.php +++ b/niucloud/app/service/core/schedule/CoreScheduleService.php @@ -69,11 +69,15 @@ class CoreScheduleService extends BaseCoreService $template_list = array_column($this->getTemplateList(), null, 'key'); return $this->pageQuery($search_model, function ($item, $key) use($template_list){ $item['crontab_content'] = $this->getCrontabContent($item['time']); - foreach($template_list[$item['key']] as $k => $v){ - if($k != 'time'){ - $item->$k = $v; + $temp = $template_list[$item['key']] ?? []; + if(!empty($temp)){ + foreach($template_list[$item['key']] as $k => $v){ + if($k != 'time'){ + $item->$k = $v; + } } } + }); } @@ -225,4 +229,4 @@ class CoreScheduleService extends BaseCoreService } return true; } -} +} \ No newline at end of file diff --git a/niucloud/app/service/core/weapp/CoreWeappAuthService.php b/niucloud/app/service/core/weapp/CoreWeappAuthService.php index 7e57b92a3..0a174de54 100644 --- a/niucloud/app/service/core/weapp/CoreWeappAuthService.php +++ b/niucloud/app/service/core/weapp/CoreWeappAuthService.php @@ -11,7 +11,6 @@ namespace app\service\core\weapp; -use app\service\core\wxoplatform\CoreOplatformService; use core\base\BaseCoreService; use EasyWeChat\Kernel\Exceptions\DecryptException; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; @@ -24,7 +23,6 @@ use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; class CoreWeappAuthService extends BaseCoreService { - /** * 网页授权 * @param string|null $code @@ -39,13 +37,8 @@ class CoreWeappAuthService extends BaseCoreService */ public function session(?string $code) { - $config = (new CoreWeappConfigService())->getWeappConfig(); - if ($config['is_authorization']) { - return CoreOplatformService::codeToSession($code); - } else { - $utils = CoreWeappService::app()->getUtils(); - return $utils->codeToSession($code); - } + $utils = CoreWeappService::app()->getUtils(); + return $utils->codeToSession($code); } /** @@ -57,23 +50,24 @@ class CoreWeappAuthService extends BaseCoreService * @throws DecryptException * @throws InvalidArgumentException */ - public function decryptData(string $session, string $iv, string $encrypted_data){ - + public function decryptData(string $session, string $iv, string $encrypted_data) + { $utils = CoreWeappService::app()->getUtils(); return $utils->decryptSession($session, $iv, $encrypted_data); } /** - * v + * 获取用户手机号 * @param string $code * @return \EasyWeChat\Kernel\HttpClient\Response|\Symfony\Contracts\HttpClient\ResponseInterface * @throws InvalidArgumentException * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ - public function getUserPhoneNumber(string $code){ + public function getUserPhoneNumber(string $code) + { $api = CoreWeappService::appApiClient(); return $api->postJson('wxa/business/getuserphonenumber', [ - 'code' => (string)$code + 'code' => (string) $code ]); } } diff --git a/niucloud/app/service/core/weapp/CoreWeappConfigService.php b/niucloud/app/service/core/weapp/CoreWeappConfigService.php index 9bb4bcad4..7218e7c2e 100644 --- a/niucloud/app/service/core/weapp/CoreWeappConfigService.php +++ b/niucloud/app/service/core/weapp/CoreWeappConfigService.php @@ -28,41 +28,44 @@ class CoreWeappConfigService extends BaseCoreService * 获取微信小程序设置 * @return array */ - public function getWeappConfig(){ - $info = (new CoreConfigService())->getConfig(ConfigKeyDict::WEAPP)['value'] ?? []; + public function getWeappConfig() + { + $info = ( new CoreConfigService() )->getConfig(ConfigKeyDict::WEAPP)[ 'value' ] ?? []; return [ - 'weapp_name' => $info['weapp_name'] ?? '',//小程序名称 - 'weapp_original' => $info['weapp_original'] ?? '',//原始ID - 'app_id' => $info['app_id'] ?? '',//AppID - 'app_secret' => $info['app_secret'] ?? '',//AppSecret - 'qr_code' => $info['qr_code'] ?? '',//小程序二维码 - 'token' => $info['token'] ?? '', - 'encoding_aes_key' => $info['encoding_aes_key'] ?? '', - 'encryption_type' => $info['encryption_type'] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 - 'upload_private_key'=> $info['upload_private_key'] ?? '', - 'is_authorization' => $info['is_authorization'] ?? 0 + 'weapp_name' => $info[ 'weapp_name' ] ?? '',//小程序名称 + 'weapp_original' => $info[ 'weapp_original' ] ?? '',//原始ID + 'app_id' => $info[ 'app_id' ] ?? '',//AppID + 'app_secret' => $info[ 'app_secret' ] ?? '',//AppSecret + 'qr_code' => $info[ 'qr_code' ] ?? '',//小程序二维码 + 'token' => $info[ 'token' ] ?? '', + 'encoding_aes_key' => $info[ 'encoding_aes_key' ] ?? '', + 'encryption_type' => $info[ 'encryption_type' ] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 + 'upload_private_key' => $info[ 'upload_private_key' ] ?? '', + 'is_authorization' => $info[ 'is_authorization' ] ?? 0 ]; } /** * 微信小程序配置 + * @param * @param array $data * @return SysConfig|bool|Model */ - public function setWeappConfig(array $data){ + public function setWeappConfig(array $data) + { $old = $this->getWeappConfig(); $config = [ - 'weapp_name' => $data['weapp_name'] ?? '',//小程序名称 - 'weapp_original' => $data['weapp_original'] ?? '',//原始ID - 'app_id' => $data['app_id'] ?? '',//AppID - 'app_secret' => $data['app_secret'] ?? '',//AppSecret - 'qr_code' => $data['qr_code'] ?? '',//小程序二维码 - 'token' => $data['token'] ?? '', - 'encoding_aes_key' => $data['encoding_aes_key'] ?? '', - 'encryption_type' => $data['encryption_type'] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 - 'upload_private_key'=> $data['upload_private_key'] ?? '', - 'is_authorization' => $data['is_authorization'] ?? $old['is_authorization'] + 'weapp_name' => $data[ 'weapp_name' ] ?? '',//小程序名称 + 'weapp_original' => $data[ 'weapp_original' ] ?? '',//原始ID + 'app_id' => $data[ 'app_id' ] ?? '',//AppID + 'app_secret' => $data[ 'app_secret' ] ?? '',//AppSecret + 'qr_code' => $data[ 'qr_code' ] ?? '',//小程序二维码 + 'token' => $data[ 'token' ] ?? '', + 'encoding_aes_key' => $data[ 'encoding_aes_key' ] ?? '', + 'encryption_type' => $data[ 'encryption_type' ] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 + 'upload_private_key' => $data[ 'upload_private_key' ] ?? '', + 'is_authorization' => $data[ 'is_authorization' ] ?? $old[ 'is_authorization' ] ]; - return (new CoreConfigService())->setConfig(ConfigKeyDict::WEAPP, $config); + return ( new CoreConfigService() )->setConfig(ConfigKeyDict::WEAPP, $config); } } diff --git a/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php b/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php index d128874ce..ee0f760d0 100644 --- a/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php +++ b/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php @@ -109,6 +109,7 @@ class CoreWeappDeliveryService extends BaseCoreService return $result; } catch (\Exception $e) { + Log::write('uploadShippingInfo,报错:' . $e->getMessage() . ",File:" . $e->getFile() . ",line:" . $e->getLine()); return $e->getMessage() . ",File:" . $e->getFile() . ",line:" . $e->getLine(); } } @@ -166,12 +167,13 @@ class CoreWeappDeliveryService extends BaseCoreService * 1、如设置为空路径或小程序中不存在的路径,将仍然跳转平台默认的确认收货页面,不会进入你的小程序。 * 2、平台会在路径后面增加支付单的 transaction_id、merchant_id、merchant_trade_no 作为query参数,如果存在二级商户号则还会再增加 sub_merchant_id 参数,开发者可以在小程序中通过onLaunch等方式获取。 * 3、如你需要在path中携带自定义的query参数,请注意与上面的参数进行区分 + * @param int $type * @return mixed * @throws InvalidArgumentException */ - public function setMsgJumpPath() + public function setMsgJumpPath($type) { - $config_data = $this->getConfig(); + $config_data = $this->getConfig($type); if (true || empty($config_data) || ( !empty($config_data[ 'value' ]) && empty($config_data[ 'value' ][ 'path' ]) )) { try { $path = 'app/pages/weapp/order_shipping'; @@ -181,7 +183,7 @@ class CoreWeappDeliveryService extends BaseCoreService $data = [ 'path' => $path ]; - $this->setConfig($data); + $this->setConfig($type, $data); } return $result; @@ -239,25 +241,27 @@ class CoreWeappDeliveryService extends BaseCoreService /** * 获取配置信息 + * @param string $type * @return array */ - public function getConfig() + public function getConfig($type) { $config_service = new CoreConfigService(); - $res = $config_service->getConfig('WEAPP_ORDER_SHIPPING_CONFIG'); + $res = $config_service->getConfig('WEAPP_ORDER_SHIPPING_CONFIG_' . $type); return $res; } /** * 设置配置 + * @param string $type * @param array $value * @return SysConfig|bool|Model */ - public function setConfig(array $value) + public function setConfig($type, array $value) { $config_service = new CoreConfigService(); - $res = $config_service->setConfig('WEAPP_ORDER_SHIPPING_CONFIG', $value); + $res = $config_service->setConfig('WEAPP_ORDER_SHIPPING_CONFIG_' . $type, $value); return $res; } -} +} \ No newline at end of file diff --git a/niucloud/app/service/core/weapp/CoreWeappService.php b/niucloud/app/service/core/weapp/CoreWeappService.php index 223efb1b3..cf02263c0 100644 --- a/niucloud/app/service/core/weapp/CoreWeappService.php +++ b/niucloud/app/service/core/weapp/CoreWeappService.php @@ -35,15 +35,15 @@ class CoreWeappService extends BaseCoreService $core_weapp_service = new CoreWeappConfigService(); $weapp_config = $core_weapp_service->getWeappConfig(); - if(empty($weapp_config['app_id']) || empty($weapp_config['app_secret'])) throw new WechatException('WEAPP_NOT_EXIST');//公众号未配置 + if (empty($weapp_config[ 'app_id' ]) || empty($weapp_config[ 'app_secret' ])) throw new WechatException('WEAPP_NOT_EXIST');//公众号未配置 $config = array( - 'app_id' => $weapp_config['app_id'], - 'secret' => $weapp_config['app_secret'], - 'token' => $weapp_config['token'], - 'aes_key' => $weapp_config['encryption_type'] == 'not_encrypt' ? '' :$weapp_config['encoding_aes_key'],// 明文模式请勿填写 EncodingAESKey + 'app_id' => $weapp_config[ 'app_id' ], + 'secret' => $weapp_config[ 'app_secret' ], + 'token' => $weapp_config[ 'token' ], + 'aes_key' => $weapp_config[ 'encryption_type' ] == 'not_encrypt' ? '' : $weapp_config[ 'encoding_aes_key' ],// 明文模式请勿填写 EncodingAESKey 'http' => [ - 'throw' => true, // 状态码非 200、300 时是否抛出异常,默认为开启 + 'throw' => true, // 状态码非 200、300 时是否抛出异常,默认为开启 'timeout' => 5.0, 'retry' => true, // 使用默认重试配置 ], @@ -71,10 +71,11 @@ class CoreWeappService extends BaseCoreService * @return mixed * @throws InvalidArgumentException */ - public function qrcode($page, $data, $filepath, $width = 430){ + public function qrcode($page, $data, $filepath, $width = 430) + { $scene = []; - foreach($data as $v){ - $scene[] = $v['key'].'-'.$v['value']; + foreach ($data as $v) { + $scene[] = $v[ 'key' ] . '-' . $v[ 'value' ]; } $response = self::appApiClient()->postJson('/wxa/getwxacodeunlimit', [ 'scene' => implode('&', $scene), @@ -95,7 +96,8 @@ class CoreWeappService extends BaseCoreService * 获取小程序体验码 * @return void */ - public function getWeappPreviewImage() { + public function getWeappPreviewImage() + { $app = self::appApiClient(); $response = $app->get('/wxa/get_qrcode'); if ($response->isFailed()) { @@ -104,7 +106,7 @@ class CoreWeappService extends BaseCoreService } $dir = public_path() . "qrcode/"; mkdirs_or_notexist($dir); - $filepath = $dir . time().'.png'; + $filepath = $dir . time() . '.png'; file_put_contents($filepath, $response->getContent()); return $filepath; } diff --git a/niucloud/app/service/core/wechat/CoreWechatApiService.php b/niucloud/app/service/core/wechat/CoreWechatApiService.php index f27f96a9b..f56edef53 100644 --- a/niucloud/app/service/core/wechat/CoreWechatApiService.php +++ b/niucloud/app/service/core/wechat/CoreWechatApiService.php @@ -44,12 +44,12 @@ class CoreWechatApiService extends BaseCoreService public function userInfoBatchget(array $openids, string $lang = 'zh_CN') { return CoreWechatService::appApiClient()->postJson('/cgi-bin/user/info/batchget', [ - 'user_list' => array_map(function ($openid) use ($lang) { - return [ - 'openid' => $openid, - 'lang' => $lang, - ]; - }, $openids) + 'user_list' => array_map(function($openid) use ($lang) { + return [ + 'openid' => $openid, + 'lang' => $lang, + ]; + }, $openids) ] ); } @@ -60,10 +60,9 @@ class CoreWechatApiService extends BaseCoreService public function userGet(?string $next_openid = '') { $api = CoreWechatService::appApiClient(); - return $api->get('/cgi-bin/user/get', ['next_openid' => $next_openid]); + return $api->get('/cgi-bin/user/get', [ 'next_openid' => $next_openid ]); } - /** * 创建菜单按钮接口 * @param array $buttons @@ -82,8 +81,7 @@ class CoreWechatApiService extends BaseCoreService ]); } - return $api->postJson('cgi-bin/menu/create', ['button' => $buttons]); + return $api->postJson('cgi-bin/menu/create', [ 'button' => $buttons ]); } - -} +} \ No newline at end of file diff --git a/niucloud/app/service/core/wechat/CoreWechatConfigService.php b/niucloud/app/service/core/wechat/CoreWechatConfigService.php index cdeea8672..9b09b9f61 100644 --- a/niucloud/app/service/core/wechat/CoreWechatConfigService.php +++ b/niucloud/app/service/core/wechat/CoreWechatConfigService.php @@ -30,18 +30,19 @@ class CoreWechatConfigService extends BaseCoreService * 获取微信公众号配置 * @return array */ - public function getWechatConfig(){ - $info = (new CoreConfigService())->getConfig(ConfigKeyDict::WECHAT)['value'] ?? []; + public function getWechatConfig() + { + $info = ( new CoreConfigService() )->getConfig(ConfigKeyDict::WECHAT)[ 'value' ] ?? []; return [ - 'wechat_name' => $info['wechat_name'] ?? '',//公众号名称 - 'wechat_original' => $info['wechat_original'] ?? '',//原始ID - 'app_id' => $info['app_id'] ?? '',//AppID - 'app_secret' => $info['app_secret'] ?? '',//AppSecret - 'qr_code' => $info['qr_code'] ?? '',//公众号二维码 - 'token' => $info['token'] ?? '', - 'encoding_aes_key' => $info['encoding_aes_key'] ?? '', - 'encryption_type' => $info['encryption_type'] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 - 'is_authorization' => $info['is_authorization'] ?? 0 + 'wechat_name' => $info[ 'wechat_name' ] ?? '',//公众号名称 + 'wechat_original' => $info[ 'wechat_original' ] ?? '',//原始ID + 'app_id' => $info[ 'app_id' ] ?? '',//AppID + 'app_secret' => $info[ 'app_secret' ] ?? '',//AppSecret + 'qr_code' => $info[ 'qr_code' ] ?? '',//公众号二维码 + 'token' => $info[ 'token' ] ?? '', + 'encoding_aes_key' => $info[ 'encoding_aes_key' ] ?? '', + 'encryption_type' => $info[ 'encryption_type' ] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全 + 'is_authorization' => $info[ 'is_authorization' ] ?? 0 ]; } @@ -50,34 +51,35 @@ class CoreWechatConfigService extends BaseCoreService * @param array $data * @return SysConfig|bool|Model */ - public function setWechatConfig(array $data){ + public function setWechatConfig(array $data) + { $old = $this->getWechatConfig(); $config = [ - 'wechat_name' => $data['wechat_name'] ?? '',//公众号名称 - 'wechat_original' => $data['wechat_original'] ?? '',//原始ID - 'app_id' => $data['app_id'] ?? '',//AppID - 'app_secret' => $data['app_secret'] ?? '',//AppSecret - 'qr_code' => $data['qr_code'] ?? '',//公众号二维码 - 'token' => $data['token'] ?? '', - 'encoding_aes_key' => $data['encoding_aes_key'] ?? '', - 'encryption_type' => $data['encryption_type'] ?? '', - 'is_authorization' => $data['is_authorization'] ?? $old['is_authorization'] + 'wechat_name' => $data[ 'wechat_name' ] ?? '',//公众号名称 + 'wechat_original' => $data[ 'wechat_original' ] ?? '',//原始ID + 'app_id' => $data[ 'app_id' ] ?? '',//AppID + 'app_secret' => $data[ 'app_secret' ] ?? '',//AppSecret + 'qr_code' => $data[ 'qr_code' ] ?? '',//公众号二维码 + 'token' => $data[ 'token' ] ?? '', + 'encoding_aes_key' => $data[ 'encoding_aes_key' ] ?? '', + 'encryption_type' => $data[ 'encryption_type' ] ?? '', + 'is_authorization' => $data[ 'is_authorization' ] ?? $old[ 'is_authorization' ] ]; - return (new CoreConfigService())->setConfig(ConfigKeyDict::WECHAT, $config); + return ( new CoreConfigService() )->setConfig(ConfigKeyDict::WECHAT, $config); } - /** - *查询微信需要的静态信息 + * 查询微信需要的静态信息 * @return array */ - public function getWechatStaticInfo(){ - $wap_domain = (new CoreSysConfigService())->getSceneDomain()['wap_url'] ?? ''; + public function getWechatStaticInfo() + { + $wap_domain = ( new CoreSysConfigService() )->getSceneDomain()[ 'wap_url' ] ?? ''; return [ - 'serve_url' => (string)url('/api/wechat/serve', [],'',true), - 'business_domain' => $wap_domain, - 'js_secure_domain' => $wap_domain, - 'web_auth_domain' => $wap_domain, + 'serve_url' => (string) url('/api/wechat/serve/', [], '', true), + 'business_domain' => $wap_domain, + 'js_secure_domain' => $wap_domain, + 'web_auth_domain' => $wap_domain, 'encryption_type' => WechatDict::getEncryptionType() ]; } diff --git a/niucloud/app/service/core/wechat/CoreWechatMediaService.php b/niucloud/app/service/core/wechat/CoreWechatMediaService.php index b236206e3..127b78c31 100644 --- a/niucloud/app/service/core/wechat/CoreWechatMediaService.php +++ b/niucloud/app/service/core/wechat/CoreWechatMediaService.php @@ -42,12 +42,13 @@ class CoreWechatMediaService extends BaseCoreService 'media' => File::fromPath($data['file_path']) ]; if ($data['type'] == WechatMediaDict::VIDEO) { - $field['json'] = [ - 'description' => [ - 'title' => time(), - 'introduction' => time() - ] - ]; +// $field['json'] = [ +// 'description' => [ +// 'title' => time(), +// 'introduction' => time() +// ] +// ]; + $field['description'] = json_encode(['title' => time(), 'introduction' => time()]); } $options = Form::create($field)->toArray(); $add_res = CoreWechatService::appApiClient()->post("/cgi-bin/material/add_material?type={$data['type']}", $options); diff --git a/niucloud/app/service/core/wechat/CoreWechatService.php b/niucloud/app/service/core/wechat/CoreWechatService.php index 035482f9c..29eec5c0a 100644 --- a/niucloud/app/service/core/wechat/CoreWechatService.php +++ b/niucloud/app/service/core/wechat/CoreWechatService.php @@ -33,13 +33,13 @@ class CoreWechatService extends BaseCoreService $core_wechat_service = new CoreWechatConfigService(); $wechat_config = $core_wechat_service->getWechatConfig(); - if (empty($wechat_config['app_id']) || empty($wechat_config['app_secret'])) throw new WechatException('WECHAT_NOT_EXIST');//公众号未配置 + if (empty($wechat_config[ 'app_id' ]) || empty($wechat_config[ 'app_secret' ])) throw new WechatException('WECHAT_NOT_EXIST');//公众号未配置 $config = array( - 'app_id' => $wechat_config['app_id'], - 'secret' => $wechat_config['app_secret'], - 'token' => $wechat_config['token'], - 'aes_key' => $wechat_config['encryption_type'] == 'not_encrypt' ? '' :$wechat_config['encoding_aes_key'],// 明文模式请勿填写 EncodingAESKey + 'app_id' => $wechat_config[ 'app_id' ], + 'secret' => $wechat_config[ 'app_secret' ], + 'token' => $wechat_config[ 'token' ], + 'aes_key' => $wechat_config[ 'encryption_type' ] == 'not_encrypt' ? '' : $wechat_config[ 'encoding_aes_key' ],// 明文模式请勿填写 EncodingAESKey 'http' => [ 'timeout' => 5.0, 'retry' => true, // 使用默认重试配置 @@ -110,14 +110,14 @@ class CoreWechatService extends BaseCoreService 'MsgType' => 'MsgType', ]; if (is_array($title)) { - if (isset($title[0]) && is_array($title[0])) { + if (isset($title[ 0 ]) && is_array($title[ 0 ])) { $newsList = []; foreach ($title as $news) { $newsList[] = self::newsMessage($news); } return $newsList; } else { - $data = [$title]; + $data = [ $title ]; } } else { $data = [ @@ -129,8 +129,8 @@ class CoreWechatService extends BaseCoreService ] ]; } - $message['MsgType'] = count($data); - $message['Articles'] = $data; + $message[ 'MsgType' ] = count($data); + $message[ 'Articles' ] = $data; return $message; } } diff --git a/niucloud/app/upgrade/v130/upgrade.sql b/niucloud/app/upgrade/v130/upgrade.sql index cbb2c3aa3..7b35c3758 100644 --- a/niucloud/app/upgrade/v130/upgrade.sql +++ b/niucloud/app/upgrade/v130/upgrade.sql @@ -99,10 +99,6 @@ ALTER TABLE `diy_page` CHANGE COLUMN `title` `title` VARCHAR(255) NOT NULL DEFAU ALTER TABLE `diy_page` ADD COLUMN `page_title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '页面名称(用于后台展示)'; -ALTER TABLE `weapp_version` ADD COLUMN `from_type` VARCHAR(255) NOT NULL DEFAULT 'cloud_build'; - -ALTER TABLE `weapp_version` ADD COLUMN `auditid` VARCHAR(255) NOT NULL DEFAULT ''; - ALTER TABLE `member_address` DROP COLUMN `type`; UPDATE `diy_page` SET `page_title`=`title` WHERE `page_title`=''; diff --git a/niucloud/app/upgrade/v140/Upgrade.php b/niucloud/app/upgrade/v140/Upgrade.php new file mode 100644 index 000000000..265964748 --- /dev/null +++ b/niucloud/app/upgrade/v140/Upgrade.php @@ -0,0 +1,69 @@ +handleDiyData(); + } + + /** + * 处理自定义数据 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + private function handleDiyData() + { + $diy_model = new Diy(); + $where = [ + [ 'value', '<>', '' ] + ]; + $field = 'id,name,title,template,value'; + $list = $diy_model->where($where)->field($field)->select()->toArray(); + + if (!empty($list)) { + foreach ($list as $k => $v) { + $diy_data = json_decode($v[ 'value' ], true); + + if (in_array($diy_data[ 'global' ][ 'topStatusBar' ][ 'style' ], [ 'style-1', 'style-2', 'style-3', 'style-4' ])) { + + $diy_data[ 'global' ][ 'topStatusBar' ][ 'bgColor' ] = '#ffffff'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'styleName' ] = '风格1'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollBgColor' ] = '#ffffff'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollTextColor' ] = '#333333'; + + } elseif ($diy_data[ 'global' ][ 'topStatusBar' ][ 'style' ] == 'style-5') { + + $diy_data[ 'global' ][ 'topStatusBar' ][ 'bgColor' ] = ''; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollBgColor' ] = ''; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'styleName' ] = '风格1'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollTextColor' ] = '#ffffff'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'textColor' ] = '#333333'; + + } elseif ($diy_data[ 'global' ][ 'topStatusBar' ][ 'style' ] == 'style-6') { + + $diy_data[ 'global' ][ 'topStatusBar' ][ 'isShow' ] = false; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'styleName' ] = '风格1'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollBgColor' ] = '#ffffff'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'rollTextColor' ] = '#333333'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'bgColor' ] = '#ffffff'; + $diy_data[ 'global' ][ 'topStatusBar' ][ 'textColor' ] = '#333333'; + + } + + unset($diy_data[ 'global' ][ 'topStatusBar' ][ 'isTransparent' ]); + + $diy_data = json_encode($diy_data); + $diy_model->where([ [ 'id', '=', $v[ 'id' ] ] ])->update([ 'value' => $diy_data ]); + } + } + + } + +} \ No newline at end of file diff --git a/niucloud/app/upgrade/v140/upgrade.sql b/niucloud/app/upgrade/v140/upgrade.sql new file mode 100644 index 000000000..ced196e01 --- /dev/null +++ b/niucloud/app/upgrade/v140/upgrade.sql @@ -0,0 +1,49 @@ + +ALTER TABLE `member_cash_out` CHANGE COLUMN `remark` `remark` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '备注'; + +ALTER TABLE `member_cash_out` CHANGE COLUMN `refuse_reason` `refuse_reason` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '拒绝理由'; + +DROP TABLE IF EXISTS `sys_printer`; +CREATE TABLE `sys_printer` ( + `printer_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `printer_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机名称', + `brand` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '设备品牌(易联云,365,飞鹅)', + `printer_code` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机编号', + `printer_key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '打印机秘钥', + `open_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开发者id', + `apikey` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开发者密钥', + `template_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '小票打印模板类型,多个逗号隔开', + `trigger` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '触发打印时机', + `value` LONGTEXT DEFAULT NULL COMMENT '打印模板数据,json格式', + `print_width` VARCHAR(255) NOT NULL DEFAULT '58mm' COMMENT '纸张宽度', + `status` TINYINT(4) NOT NULL DEFAULT 1 COMMENT '状态(0,关闭,1:开启)', + `create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`printer_id`) +) +ENGINE = INNODB, +CHARACTER SET utf8mb4, +COLLATE utf8mb4_general_ci, +COMMENT = '小票打印机'; + + +DROP TABLE IF EXISTS `sys_printer_template`; +CREATE TABLE `sys_printer_template` ( + `template_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `template_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板名称', + `template_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板类型', + `value` LONGTEXT DEFAULT NULL COMMENT '模板数据,json格式', + `create_time` INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` INT(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`template_id`) +) +ENGINE = INNODB, +CHARACTER SET utf8mb4, +COLLATE utf8mb4_general_ci, +COMMENT = '小票打印模板'; + +ALTER TABLE `member` CHANGE COLUMN `nickname` `nickname` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '会员昵称'; + +ALTER TABLE `diy_page` CHANGE COLUMN `template` `template` VARCHAR(255) DEFAULT '' COMMENT '模板名称'; + +ALTER TABLE `diy_page` MODIFY `page_title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '页面名称(用于后台展示)' AFTER `id`; diff --git a/niucloud/app/validate/channel/Weapp.php b/niucloud/app/validate/channel/Weapp.php index 3f6af57e9..33e765d86 100644 --- a/niucloud/app/validate/channel/Weapp.php +++ b/niucloud/app/validate/channel/Weapp.php @@ -1,6 +1,6 @@ 'require', - 'mobile' => 'require', - 'province_id' => 'require', - 'city_id' => 'require', - 'district_id' => 'require', - 'address' => 'require', - 'full_address' => 'require', - ]; + protected $rule = [ + 'name' => 'require', + 'mobile' => 'require', + 'province_id' => 'require', + 'city_id' => 'require', + 'district_id' => 'require', + 'address' => 'require', + 'full_address' => 'require', + ]; - protected $message = [ - 'name.require' => ['common_validate.require', ['name']], - 'mobile.require' => ['common_validate.require', ['mobile']], - 'address.require' => ['common_validate.require', ['address']], - 'full_address.require' => ['common_validate.require', ['full_address']], - ]; + protected $message = [ + 'name.require' => [ 'common_validate.require', [ 'name' ] ], + 'mobile.require' => [ 'common_validate.require', [ 'mobile' ] ], + 'address.require' => [ 'common_validate.require', [ 'address' ] ], + 'full_address.require' => [ 'common_validate.require', [ 'full_address' ] ], + ]; - protected $scene = [ - "add" => ['name', 'mobile', 'address', 'full_address', 'lng', 'lat'], - "edit" => ['name', 'mobile', 'address', 'full_address', 'lng', 'lat'] - ]; + protected $scene = [ + "add" => [ 'name', 'mobile', 'address', 'full_address', 'lng', 'lat' ], + "edit" => [ 'name', 'mobile', 'address', 'full_address', 'lng', 'lat' ] + ]; } diff --git a/niucloud/app/validate/sys/Printer.php b/niucloud/app/validate/sys/Printer.php new file mode 100644 index 000000000..18f0f374b --- /dev/null +++ b/niucloud/app/validate/sys/Printer.php @@ -0,0 +1,49 @@ + 'require', + 'printer_name' => 'require', + 'printer_code' => 'require', + 'printer_key' => 'require', + 'open_id' => 'require', + 'apikey' => 'require', + 'print_width' => 'require', + ]; + + protected $message = [ + 'brand.require' => [ 'common_validate.require', [ 'brand' ] ], + 'printer_name.require' => [ 'common_validate.require', [ 'printer_name' ] ], + 'printer_code.require' => [ 'common_validate.require', [ 'printer_code' ] ], + 'printer_key.require' => [ 'common_validate.require', [ 'printer_key' ] ], + 'open_id.require' => [ 'common_validate.require', [ 'open_id' ] ], + 'apikey.require' => [ 'common_validate.require', [ 'apikey' ] ], + 'print_width.require' => [ 'common_validate.require', [ 'print_width' ] ], + ]; + + protected $scene = [ + "add" => [ 'brand', 'printer_name', 'printer_code', 'printer_key', 'open_id', 'apikey', 'value', 'print_width' ], + "edit" => [ 'brand', 'printer_name', 'printer_code', 'printer_key', 'open_id', 'apikey', 'value', 'print_width' ] + ]; + +} diff --git a/niucloud/app/validate/sys/PrinterTemplate.php b/niucloud/app/validate/sys/PrinterTemplate.php new file mode 100644 index 000000000..cce639710 --- /dev/null +++ b/niucloud/app/validate/sys/PrinterTemplate.php @@ -0,0 +1,39 @@ + 'require', + 'template_name' => 'require', + ]; + + protected $message = [ + 'template_type.require' => [ 'common_validate.require', [ 'template_type' ] ], + 'template_name.require' => [ 'common_validate.require', [ 'template_name' ] ], + ]; + + protected $scene = [ + "add" => [ 'template_type', 'template_name', 'value' ], + "edit" => [ 'template_type', 'template_name', 'value' ] + ]; + +} diff --git a/niucloud/config/install.php b/niucloud/config/install.php index f60aeb558..2c6420c75 100644 --- a/niucloud/config/install.php +++ b/niucloud/config/install.php @@ -73,7 +73,7 @@ return [ // 站点名称 'admin_site_name' => 'NIUCLOUD ADMIN', // admin 端登录页默认图 - 'admin_login_bg' => 'install/img/niucloud_login_index_left.jpg', + 'admin_login_bg' => 'install/img/niushop_login_index_left.jpg', // admin 端默认logo 'admin_logo' => 'install/img/logo.jpg' ]; diff --git a/niucloud/config/niucloud.php b/niucloud/config/niucloud.php index b811532a0..1d15de694 100644 --- a/niucloud/config/niucloud.php +++ b/niucloud/config/niucloud.php @@ -7,7 +7,7 @@ return [ ], 'http' => [ 'max_retries' => 1,// 重试次数,默认 1,指定当 http 请求失败时重试的次数。 - 'retry_delay' => 500,//重试延迟间隔(单位:ms),默认 500 + 'retry_delay' => 1000,//重试延迟间隔(单位:ms),默认 500 'timeout' => 5.0,//最大运行时间(超时) 'verify' => false,//请求时验证SSL证书行为。设置成 true 启用SSL证书验证,默认使用操作系统提供的CA包。设置成 false 禁用证书验证(这是不安全的!)。设置成字符串启用验证,并使用该字符串作为自定义证书CA包的路径。 ], diff --git a/niucloud/config/upload.php b/niucloud/config/upload.php index 7c828cbb2..a26034809 100644 --- a/niucloud/config/upload.php +++ b/niucloud/config/upload.php @@ -65,17 +65,25 @@ $system = [ 'application/x-zip-compressed' ], 'size' => 2097152 + ], + 'excel' => [ + 'ext' => ['xls', 'xlsx'], + 'mime' => [ + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + ], + 'size' => 10485760 ] ], 'thumb' => [ 'thumb_type' => [ 'big' => [ - 'width' => 800, - 'height' => 800, + 'width' => 1200, + 'height' => 1200, ], 'mid' => [ - 'width' => 400, - 'height' => 400, + 'width' => 800, + 'height' => 800, ], 'small' => [ 'width' => 200, diff --git a/niucloud/config/version.php b/niucloud/config/version.php index e45856fd1..3b0f9dbc1 100644 --- a/niucloud/config/version.php +++ b/niucloud/config/version.php @@ -1,6 +1,6 @@ '1.3.0', - 'code' => '202406240001' + 'version' => '1.4.0', + 'code' => '202408060001' ]; diff --git a/niucloud/core/base/BaseModel.php b/niucloud/core/base/BaseModel.php index 5a2e61f41..30c81b045 100644 --- a/niucloud/core/base/BaseModel.php +++ b/niucloud/core/base/BaseModel.php @@ -35,4 +35,14 @@ class BaseModel extends Model $table_name = str_replace($tablePrefix, '', $table_info['Name']); return Db::name($table_name)->getFields(); } + + /** + * 处理搜索条件特殊字符(%、_) + * @param $value + */ + public function handelSpecialCharacter($value) + { + $value = str_replace('%', '\%', str_replace('_', '\_', $value)); + return $value; + } } diff --git a/niucloud/core/dict/Printer.php b/niucloud/core/dict/Printer.php new file mode 100644 index 000000000..6e209edc9 --- /dev/null +++ b/niucloud/core/dict/Printer.php @@ -0,0 +1,40 @@ +getLocalAddons(); + $types_files = []; + + foreach ($addons as $v) { + $types_path = $this->getAddonDictPath($v) . "printer" . DIRECTORY_SEPARATOR . "type.php"; + if (is_file($types_path)) { + $types_files[] = $types_path; + } + } + $types_files_data = $this->loadFiles($types_files); + $types = $data; + foreach ($types_files_data as $file_data) { + $types = empty($types) ? $file_data : array_merge2($types, $file_data); + } + return $types; + } +} diff --git a/niucloud/core/exception/HomeException.php b/niucloud/core/exception/HomeException.php deleted file mode 100644 index 435215c80..000000000 --- a/niucloud/core/exception/HomeException.php +++ /dev/null @@ -1,18 +0,0 @@ -open($bg_image, $poster_data[ 'global' ][ 'bgUrl' ]); - $editor->resizeFill($bg_image, $poster_data[ 'global' ][ 'width' ], $poster_data[ 'global' ][ 'height' ]); + $instance = PosterInstance::extension('gd')->config([ 'path' => realpath($dir) . DIRECTORY_SEPARATOR . $file_path ]); + $bg_width = $poster_data[ 'global' ][ 'width' ]; + $bg_height = $poster_data[ 'global' ][ 'height' ]; + if ($bg_type == 'url' && !empty($poster_data[ 'global' ][ 'bgUrl' ]) && is_file($poster_data[ 'global' ][ 'bgUrl' ])) { + $im = $instance->buildIm($bg_width, $bg_height)->buildImage([ + 'src' => $poster_data[ 'global' ][ 'bgUrl' ], +// 'angle' => 80 + ], 0, 0, 0, 0, $bg_width, $bg_height); } else { - $bg_image = Grafika::createBlankImage($poster_data[ 'global' ][ 'width' ], $poster_data[ 'global' ][ 'height' ]); - //填充背景色 - $editor->fill($bg_image, new Color($poster_data[ 'global' ][ 'bgColor' ])); + $im = $instance->buildIm($bg_width, $bg_height, $this->getRgbColor($poster_data[ 'global' ][ 'bgColor' ])); } + $align_array = [ + 'center', 'left', 'right', 'top', 'bottom' + ]; foreach ($poster_data[ 'value' ] as $k => $v) { $type = $v[ 'type' ]; switch ($type) { case 'text': + $font_size = ceil($v[ 'fontSize' ]); $default_font = 'static' . DIRECTORY_SEPARATOR . 'font' . DIRECTORY_SEPARATOR . 'SourceHanSansCN-Regular.ttf'; - $editor->text($bg_image, $v[ 'value' ], round($v[ 'fontSize' ]*(4/3)), round($v[ 'x' ] * 2), round($v[ 'y' ] * 2), new Color($v[ 'fontColor' ]), $v[ 'fontFamily' ] ? : $default_font, $v[ 'angle' ]); + $font = $v[ 'fontFamily' ] ? : $default_font; + $content_list = $this->getText($v[ 'value' ], $font_size, $font, $v[ 'space' ] ?? 0, $v[ 'width' ], $v[ 'height' ], $v[ 'lineHeight' ] + $font_size); + $base_y = $this->getX($v[ 'y' ]); + if (is_array($base_y)) { + $diff_height = count($content_list) * ( $v[ 'lineHeight' ] + $font_size ); + $again_y = $base_y[ 0 ]; + if ($again_y == 'center') { + $base_y_num = ( $bg_height - $diff_height ) > 0 ? ( $bg_height - $diff_height ) / 2 : 0; + } else if ($again_y == 'top') { + $base_y_num = 0; + } else { + $base_y_num = $bg_height - $v[ 'height' ]; + } + + } else { + $base_y_num = $base_y; + } +// if(in_array($base_y, $align_array)){ +// $diff_height = count($content_list)*($v[ 'lineHeight' ]+$font_size); +// $base_y_num = ($bg_height-$diff_height) > 0 ? ($bg_height-$diff_height)/2 : 0; +// }else{ +// $base_y_num = $base_y[0]; +// } + foreach ($content_list as $ck => $content) { + if ($ck == 0) { + if ($v[ 'lineHeight' ] > 0) { + $item_line = $v[ 'lineHeight' ] / 2; + } else { + $item_line = 0; + } + } else { + $item_line = $v[ 'lineHeight' ] + $font_size; + } + $base_y_num += $item_line; + //计算文本框宽度 + $im = $im->buildText($content, $this->getX($v[ 'x' ]), $base_y_num, $font_size, $this->getRgbColor($v[ 'fontColor' ]), $v[ 'width' ], $font, $v[ 'weight' ] ? 10 : null); # 合成文字 + } break; case 'image': - $image_name = 'image' . $k; - $$image_name = null; if (is_file($v[ 'value' ])) { - $editor->open($$image_name, $v[ 'value' ]); - $editor->resizeFill($$image_name, $v[ 'width' ] * 2, $v[ 'height' ] * 2); - $editor->blend($bg_image, $$image_name, 'normal', 0, 'top-left', $v[ 'x' ] * 2, $v[ 'y' ] * 2); + $im = $im->buildImage($v[ 'value' ], $this->getX($v[ 'x' ]), $this->getY($v[ 'y' ]), 0, 0, $v[ 'width' ], $v[ 'height' ], false, $v[ 'shape' ] ?? 'normal'); # 合成图片 } break; case 'draw': - $draw_name = 'draw' . $k; - $$draw_name = Grafika::createDrawingObject($v[ 'drawType' ], $v[ 'points' ], 1, NULL, new Color($v[ 'bgColor' ])); - // 在图像上绘制上面创建的绘制对象 - $editor->draw($bg_image, $$draw_name); + if (!empty($v[ 'draw_type' ]) && $v[ 'draw_type' ] == 'Polygon') { + $points = $v[ 'points' ]; + $im = $im->buildLine($points[ 0 ][ 0 ], $points[ 0 ][ 1 ], $points[ 2 ][ 0 ], $points[ 2 ][ 1 ], $this->getRgbColor($v[ 'bgColor' ]), 'filled_rectangle'); + } break; } } - $editor->save($bg_image, $dir . '/' . $file_path); - return $dir . '/' . $file_path; + + $path = $im->getPoster(); + + return str_replace(DIRECTORY_SEPARATOR, '/', str_replace(realpath(''), '', $path[ 'url' ])); } -} + + public function getX($dst_x) + { + if (is_int($dst_x)) { + return $dst_x; + } else { + return [ $dst_x, 0 ]; + } + } + + public function getY($dst_y) + { + if (is_int($dst_y)) { + return $dst_y; + } else { + return [ $dst_y, 0 ]; + } + } + + public function getRgbColor($color) + { + $color = $color ? : '#FFFFFF'; + if (!str_contains($color, '#')) { + $color = str_replace('rgba(', '', $color); + $color = str_replace(')', '', $color); + list($r, $g, $b) = explode(',', $color); + list($r, $g, $b) = array_map(function($v) { return (int) $v; }, [ $r, $g, $b ]); + } else { + list($r, $g, $b) = sscanf($color, "#%02x%02x%02x"); + } + return [ $r, $g, $b, 1 ]; + } + + /** + * 获取高度限制过后的文本 + * @param $content + * @param $fontSize + * @param $font + * @param $space + * @param $max_ws + * @param $max_hs + * @param $line_height + * @return mixed + */ + public function getText($content, $fontSize, $font, $space, $max_ws, $max_hs, $line_height) + { + $calcSpace = $space > $fontSize ? ( $space - $fontSize ) : 0; // 获取间距计算值 + + $fontSize = ( $fontSize * 3 ) / 4; // px 转化为 pt + + mb_internal_encoding('UTF-8'); // 设置编码 + // 这几个变量分别是 字体大小, 角度, 字体名称, 字符串, 预设宽度 + $contents = ''; + $contentsArr = []; + $letter = []; + $line = 1; + $calcSpaceRes = 0; + // 将字符串拆分成一个个单字 保存到数组 letter 中 + for ($i = 0; $i < mb_strlen($content); $i++) { + $letter[] = mb_substr($content, $i, 1); + } + $textWidthArr = []; + $contentStr = ''; + $line_num = 1; + $total_width = 0; + $content_list = []; + foreach ($letter as $l) { + $textStr = $contentStr . $l; + $fontBox = imagettfbbox($fontSize, 0, $font, $textStr); + $textWidth = abs($fontBox[ 2 ]) + $calcSpaceRes; + $textWidthArr[ $line ] = $textWidth; + // 判断拼接后的字符串是否超过预设的宽度 + if (( $textWidth > $max_ws ) && ( $contents !== '' )) { + $line_num++; + if (( $line_num * $line_height ) > $max_hs) { + break; + } + $contents .= "\n"; + $contentStr = ""; + $line++; + } + if (empty($content_list[ $line_num - 1 ])) $content_list[ $line_num - 1 ] = ''; + $content_list[ $line_num - 1 ] .= $l; + $contents .= $l; + $contentStr .= $l; + $line === 1 && $calcSpaceRes += $calcSpace; + $text_width = max(array_values($textWidthArr)); + } + return $content_list; + } +} \ No newline at end of file diff --git a/niucloud/core/poster/PosterLoader.php b/niucloud/core/poster/PosterLoader.php index b0dbc5989..82265b019 100644 --- a/niucloud/core/poster/PosterLoader.php +++ b/niucloud/core/poster/PosterLoader.php @@ -12,7 +12,6 @@ namespace core\poster; use core\loader\Loader; -use core\sms\BaseSms; /** * @see PosterLoader diff --git a/niucloud/app/adminapi/controller/stat/Stat.php b/niucloud/core/printer/BasePrinter.php similarity index 60% rename from niucloud/app/adminapi/controller/stat/Stat.php rename to niucloud/core/printer/BasePrinter.php index b4007807e..e892997ee 100644 --- a/niucloud/app/adminapi/controller/stat/Stat.php +++ b/niucloud/core/printer/BasePrinter.php @@ -9,27 +9,31 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\adminapi\controller\stat; +namespace core\printer; -use app\service\admin\stat\StatService; -use core\base\BaseAdminController; -use think\Response; +use core\loader\Storage; /** - * 统计数据 - * Class Stat - * @package app\adminapi\controller\stat + * Class BasePrinter + * @package core\printer */ -class Stat extends BaseAdminController +abstract class BasePrinter extends Storage { /** - * 首页数据 - * @return Response + * 初始化 + * @param array $config + * @return void */ - public function index() + protected function initialize(array $config = []) { - $data = (new StatService())->getIndexData(); - return success($data); } + + /** + * 打印小票 + * @param array $data + * @return mixed + */ + abstract protected function printTicket(array $data); + } diff --git a/niucloud/app/adminapi/controller/stat/SiteStat.php b/niucloud/core/printer/KdniaoPrinter.php similarity index 59% rename from niucloud/app/adminapi/controller/stat/SiteStat.php rename to niucloud/core/printer/KdniaoPrinter.php index ab3e342c4..64787fc5e 100644 --- a/niucloud/app/adminapi/controller/stat/SiteStat.php +++ b/niucloud/core/printer/KdniaoPrinter.php @@ -8,28 +8,30 @@ // +---------------------------------------------------------------------- // | Author: Niucloud Team // +---------------------------------------------------------------------- +namespace core\printer; -namespace app\adminapi\controller\stat; -use app\service\admin\stat\SiteStatService; -use core\base\BaseAdminController; -use think\Response; - -/** - * 统计数据 - * Class Stat - * @package app\adminapi\controller\stat - */ -class SiteStat extends BaseAdminController +class KdniaoPrinter extends BasePrinter { - /** - * 首页数据 - * @return Response - */ - public function index() - { - $data = (new SiteStatService())->getIndexData(); - return success($data); + protected $config; + + /** + * @param array $config + * @return void + */ + protected function initialize(array $config = []) + { + parent::initialize($config); + $this->config = $config; } -} + + /** + * 打印小票 + * @param array $data + * @return mixed|void + */ + public function printTicket(array $data) + { + } +} \ No newline at end of file diff --git a/niucloud/app/listener/system/SiteIndexListener.php b/niucloud/core/printer/PrinterLoader.php similarity index 60% rename from niucloud/app/listener/system/SiteIndexListener.php rename to niucloud/core/printer/PrinterLoader.php index 57b6e5fcf..28c2f9c82 100644 --- a/niucloud/app/listener/system/SiteIndexListener.php +++ b/niucloud/core/printer/PrinterLoader.php @@ -9,22 +9,31 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\listener\system; +namespace core\printer; + +use core\loader\Loader; /** - * 站点首页加载事件 - * Class AppInit - * @package app\listener\system + * Class PrinterLoader + * @package core\printer */ -class SiteIndexListener +class PrinterLoader extends Loader { - public function handle() + + /** + * 空间名 + * @var string + */ + protected $namespace = '\\core\\printer\\'; + + protected $config_name = 'printer'; + + /** + * 默认驱动 + * @return mixed + */ + protected function getDefault() { - return [ - [ - "name" => get_lang("dict_site_index.system"), - "view_path" => "index/site_index" - ] - ]; + return 'kdbird'; } -} +} \ No newline at end of file diff --git a/niucloud/core/printer/sdk/yilianyun/Autoloader.php b/niucloud/core/printer/sdk/yilianyun/Autoloader.php new file mode 100644 index 000000000..0bd49dcda --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/Autoloader.php @@ -0,0 +1,32 @@ +client->call('expressprint/index', array('machine_code' => $machineCode, 'content' => $content, 'origin_id' => $originId, 'sandbox' => $sandbox)); + } + + /** + * 面单取消接口 + * + * @param $machineCode + * @param $content + * @return mixed + * @throws \Exception + */ + public function cancel($machineCode, $content) + { + return $this->client->call('expressprint/cancel', array('machine_code' => $machineCode, 'content' => $content)); + } + +} diff --git a/niucloud/core/printer/sdk/yilianyun/api/OauthService.php b/niucloud/core/printer/sdk/yilianyun/api/OauthService.php new file mode 100644 index 000000000..c712be220 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/OauthService.php @@ -0,0 +1,22 @@ +client->call('oauth/setpushurl', array('cmd' => $cmd, 'url' => $url, 'status' => $status)); + } +} + + diff --git a/niucloud/core/printer/sdk/yilianyun/api/PicturePrintService.php b/niucloud/core/printer/sdk/yilianyun/api/PicturePrintService.php new file mode 100644 index 000000000..dfb4b4c46 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/PicturePrintService.php @@ -0,0 +1,22 @@ +client->call('pictureprint/index', array('machine_code' => $machineCode, 'picture_url' => $pictureUrl, 'origin_id' => $originId, $idempotence => $idempotence)); + } +} diff --git a/niucloud/core/printer/sdk/yilianyun/api/PrintMenuService.php b/niucloud/core/printer/sdk/yilianyun/api/PrintMenuService.php new file mode 100644 index 000000000..6f4a5ede8 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/PrintMenuService.php @@ -0,0 +1,19 @@ +client->call('printmenu/addprintmenu', array('machine_code' => $machineCode, 'content' => $content)); + } + +} \ No newline at end of file diff --git a/niucloud/core/printer/sdk/yilianyun/api/PrintService.php b/niucloud/core/printer/sdk/yilianyun/api/PrintService.php new file mode 100644 index 000000000..7ff2309ec --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/PrintService.php @@ -0,0 +1,20 @@ +client->call('print/index', array('machine_code' => $machineCode, 'content' => $content, 'origin_id' => $originId, 'idempotence' => $idempotence)); + } +} diff --git a/niucloud/core/printer/sdk/yilianyun/api/PrinterService.php b/niucloud/core/printer/sdk/yilianyun/api/PrinterService.php new file mode 100644 index 000000000..d7b6bd66e --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/PrinterService.php @@ -0,0 +1,313 @@ + $machineCode, + 'msign' => $mSign, + ); + if (!empty($phone)) { + $params['phone'] = $phone; + } + if (!empty($printName)) { + $params['print_name'] = $printName; + } + return $this->client->call('printer/addprinter', $params); + } + + + /** + * 设置内置语音接口 + * 注意: 仅支持K4-WA、K4-GAD、K4-WGEAD型号 + * + * @param $machineCode string 机器码 + * @param $content string 在线语音地址链接 or 自定义语音内容 + * @param bool $isFile true or false + * @param string $aid int 0~9 , 定义需设置的语音编号,若不提交,默认升序 + * @return mixed + */ + public function setVoice($machineCode, $content, $isFile = false, $aid = '') + { + $params = array( + 'machine_code' => $machineCode, + 'content' => $content, + 'is_file' => $isFile, + ); + if (!empty($aid)){ + $params ['aid'] = $aid; + } + return $this->client->call('printer/setvoice', $params); + } + + + /** + * 删除内置语音接口 + * 注意: 仅支持K4-WA、K4-GAD、K4-WGEAD型号 + * + * @param $machineCode string 机器码 + * @param $aid int 0 ~ 9 编号 + * @return mixed + */ + public function deleteVoice($machineCode, $aid) + { + return $this->client->call('printer/deletevoice', array('machine_code' => $machineCode, 'aid' => $aid)); + } + + + /** + * 删除终端授权接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function deletePrinter($machineCode) + { + return $this->client->call('printer/deleteprinter', array('machine_code' => $machineCode)); + } + + + /** + * 关机重启接口 + * + * @param $machineCode string 机器码 + * @param $responseType string restart or shutdown + * @return mixed + */ + public function shutdownRestart($machineCode, $responseType) + { + return $this->client->call('printer/shutdownrestart', array('machine_code' => $machineCode, 'response_type' => $responseType)); + } + + + /** + * 声音调节接口 + * + * @param $machineCode string 机器码 + * @param $voice string 音量 0 or 1 or 2 or 3 + * @param $responseType string buzzer (蜂鸣器) or horn (喇叭) + * @return mixed + */ + public function setsound($machineCode, $voice, $responseType) + { + return $this->client->call('printer/setsound', array('machine_code' => $machineCode, 'voice' => $voice, 'response_type' => $responseType)); + } + + + /** + * 获取机型打印宽度接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function printInfo($machineCode) + { + return $this->client->call('printer/printinfo', array('machine_code' => $machineCode)); + } + + + /** + * 获取机型软硬件版本接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function getVersion($machineCode) + { + return $this->client->call('printer/getversion', array('machine_code' => $machineCode)); + } + + + /** + * 取消所有未打印订单接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function cancelAll($machineCode) + { + return $this->client->call('printer/cancelall', array('machine_code' => $machineCode)); + } + + + /** + * 取消单条未打印订单接口 + * + * @param $machineCode string 机器码 + * @param $orderId string 未打印的易联云ID + * @return mixed + */ + public function cancelOne($machineCode, $orderId) + { + return $this->client->call('printer/cancelone', array('machine_code' => $machineCode, 'order_id' => $orderId)); + } + + + /** + * 设置logo接口 + * + * @param $machineCode string 机器码 + * @param $imgUrl string logo链接地址 + * @return mixed + */ + public function setIcon($machineCode, $imgUrl) + { + return $this->client->call('printer/seticon', array('machine_code' => $machineCode, 'img_url' => $imgUrl)); + } + + + /** + * 取消logo接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function deleteIcon($machineCode) + { + return $this->client->call('printer/deleteicon', array('machine_code' => $machineCode)); + } + + + /** + * 打印方式接口 + * + * @param $machineCode string 机器码 + * @param $responseType string btnopen or btnclose + * @return mixed + */ + public function btnPrint($machineCode, $responseType) + { + return $this->client->call('printer/btnprint', array('machine_code' => $machineCode, 'response_type' => $responseType)); + } + + + /** + * 接单拒单设置接口 + * + * @param $machineCode string 机器码 + * @param $responseType string open or close + * @return mixed + */ + public function getOrder($machineCode, $responseType) + { + return $this->client->call('printer/getorder', array('machine_code' => $machineCode, 'response_type' => $responseType)); + } + + + /** + * 获取订单状态接口 + * + * @param $machineCode string 机器码 + * @param $orderId string 易联云订单id + * @return mixed + */ + public function getOrderStatus($machineCode, $orderId) + { + return $this->client->call('printer/getorderstatus', array('machine_code' => $machineCode, 'order_id' => $orderId)); + } + + + /** + * 获取订单列表接口 + * + * @param $machineCode string 机器码 + * @param $pageIndex int 第几页 + * @param $pageSize int 查询条数 + * @return mixed + */ + public function getOrderPagingList($machineCode, $pageIndex = 1 , $pageSize = 10) + { + return $this->client->call('printer/getorderpaginglist', array('machine_code' => $machineCode, 'page_index' => $pageIndex, 'page_size' => $pageSize)); + } + + /** + * 获取终端状态接口 + * + * @param $machineCode string 机器码 + * @return mixed + */ + public function getPrintStatus($machineCode) + { + return $this->client->call('printer/getprintstatus', array('machine_code' => $machineCode)); + } + + /** + * 订单重打(单订单) + * + * @param $machineCode + * @param $orderId + * @return mixed + * @throws \Exception + */ + public function reprintOrder($machineCode, $orderId) + { + return $this->client->call('printer/reprintorder', array('machine_code' => $machineCode, 'order_id' => $orderId)); + } + + /** + * K8 推送开关设置 + * + * @param $machineCode + * @param $status + * @param $mode + * @return mixed + * @throws \Exception + */ + public function pushSwitch($machineCode, $status, $mode = 1) + { + return $this->client->call('printer/pushswitch', array('machine_code' => $machineCode, 'status' => $status, $mode)); + } + + /** + * K8 关键词设置接口 + * + * @param $machineCode + * @param $keys + * @param $type + * @param $content + * @return mixed + * @throws \Exception + */ + public function setKeyWords($machineCode, $keys, $type, $content) + { + return $this->client->call('printer/setkeywords', array('machine_code' => $machineCode, 'keys' => $keys, 'type' => $type, 'content' => $content)); + } + + /** + * K8 高级设置接口 + * + * @param $machineCode + * @param null $usbPrintMode + * @param null $usbInputMode + * @param null $cameraDecodeTxMode + * @return mixed + * @throws \Exception + */ + public function setting($machineCode, $usbPrintMode = null, $usbInputMode = null, $cameraDecodeTxMode = null) + { + $params = array('machine_code' => $machineCode); + if (!is_null($usbPrintMode) && in_array($usbPrintMode, [0, 1])) { + $params['usb_print_mode'] = (int)$usbInputMode; + } + if (!is_null($usbInputMode) && in_array($usbInputMode, [0, 1])) { + $params['usb_input_mode'] = (int)$usbInputMode; + } + if (!is_null($cameraDecodeTxMode) && in_array($cameraDecodeTxMode, [0, 1])) { + $params['camera_decode_tx_mode'] = (int)$cameraDecodeTxMode; + } + return $this->client->call('printer/setting', $params); + } + +} diff --git a/niucloud/core/printer/sdk/yilianyun/api/RpcService.php b/niucloud/core/printer/sdk/yilianyun/api/RpcService.php new file mode 100644 index 000000000..22596e684 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/api/RpcService.php @@ -0,0 +1,19 @@ +client = new YlyRpcClient($token, $config); + } + +} \ No newline at end of file diff --git a/niucloud/core/printer/sdk/yilianyun/config/YlyConfig.php b/niucloud/core/printer/sdk/yilianyun/config/YlyConfig.php new file mode 100644 index 000000000..cdf00b9ed --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/config/YlyConfig.php @@ -0,0 +1,68 @@ +clientId = $clientId; + $this->clientSecret = $clientSecret; + } + + public function getClientId() + { + return $this->clientId; + } + + + public function getClientSecret() + { + return $this->clientSecret; + } + + public function getRequestUrl() + { + return $this->requestUrl; + } + + public function setRequestUrl($requestUrl) + { + $this->requestUrl = $requestUrl; + } + + public function getLog() + { + return $this->log; + } + + public function setLog($log) + { + if (!method_exists($log, "info")) { + throw new InvalidArgumentException("logger need have method 'info(\$message)'"); + } + if (!method_exists($log, "error")) { + throw new InvalidArgumentException("logger need have method 'error(\$message)'"); + } + $this->log = $log; + } + +} diff --git a/niucloud/core/printer/sdk/yilianyun/demo/authorization_code_mode/callback.php b/niucloud/core/printer/sdk/yilianyun/demo/authorization_code_mode/callback.php new file mode 100644 index 000000000..aa8786c36 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/demo/authorization_code_mode/callback.php @@ -0,0 +1,141 @@ +getToken($code); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; + print_r(json_decode($e->getMessage(), true)); + return; +} + +$access_token = $token->access_token; //调用API凭证AccessToken +$refresh_token = $token->refresh_token; //刷新AccessToken凭证 失效时间35天 +$machine_code = $token->machine_code; //商户授权机器码 +$expires_in = $token->expires_in; //AccessToken失效时间30天 +$refresh_expires_in = $token->refresh_expires_in; //RefreshToken失效时间35天 +$origin_id = ''; //内部订单号(32位以内) + + +if (empty($machine_code)) { + echo 'The machine_code cannot be empty'; + return; +} + +if (empty($origin_id)) { + echo 'The origin_id cannot be empty'; + return; +} + +/**文本接口开始**/ +$print = new PrintService($access_token, $config); +//58mm排版 排版指令详情请看 http://doc2.10ss.net/332006 +$content = "
**#1 美团**
"; +$content .= str_repeat('.', 32); +$content .= "
--在线支付--
"; +$content .= "
张周兄弟烧烤
"; +$content .= "订单时间:" . date("Y-m-d H:i") . "\n"; +$content .= "订单编号:40807050607030\n"; +$content .= str_repeat('*', 14) . "商品" . str_repeat("*", 14); +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= "
烤土豆(超级辣)x35.96
烤豆干(超级辣)x23.88
烤鸡翅(超级辣)x317.96
烤排骨(香辣)x312.44
烤韭菜(超级辣)x38.96
"; +$content .= str_repeat('.', 32); +$content .= "这是二维码内容"; +$content .= "小计:¥82\n"; +$content .= "折扣:¥4 \n"; +$content .= str_repeat('*', 32); +$content .= "订单总价:¥78 \n"; +$content .= "
**#1 完**
"; + +try { + var_dump($print->index($machine_code, $content, $origin_id)); +} catch (Exception $e) { + echo $e->getMessage(); +} +/**文本接口结束**/ + + +///**图形接口开始**/ +//$picturePrint = new PicturePrintService($access_token, $config); +//$content = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497000905083&di=7c3cffef1dd40edffbd0a37c4eabb277&imgtype=0&src=http://img1.touxiang.cn/uploads/20131114/14-054929_462.jpg"; +//try{ +// var_dump($picturePrint->index($machine_code, $content, $origin_id)); +//}catch (Exception $e) { +// echo $e->getMessage(); +//} +///**图形接口结束**/ + + +///**面单接口开始**/ //打印机型必须为k5; +//$expressPrint = new ExpressPrintService($access_token, $config); +//$content = array( +// "OrderCode"=> "0126578665784971", +// "ShipperCode"=> "SF", //SF YZPY HTKY YD +// "PayType"=> 1, +// "ExpType"=> 1, +// "Cost"=>6.0, +// "OtherCost"=> 7.0, +// "CustomerName" => '1264546', +// "CustomerPwd" => '4545454', +// "MonthCode" => '', +// "Sender"=> array( +// "Company" => "5645645", +// "Name" => "Taylor", +// "Mobile" => "15018442396", +// "ProvinceName" => "上海", +// "CityName" => "上海", +// "PostCode" => '61000', +// "ExpAreaName" => "青浦区", +// "Address" => "明珠路73号" +// ), +// "Receiver"=> array( +// "Company"=> "789789", +// "Name"=> "Yann", +// "Mobile"=> "15018442396", +// "ProvinceName"=> "北京", +// "CityName"=> "北京", +// "PostCode" => '61000', +// "ExpAreaName"=> "朝阳区", +// "Address"=> "三里屯街道雅秀大厦" +// ), +// "Commodity" => array( +// array( +// "GoodsName"=> "鞋子", +// ) +// ), +// "AddService"=> array( +// array( +// "Name"=> "COD", +// "Value"=> "1020", +// "CustomerID" => "44564" +// ) +// ), +// "StartDate" => date("y-M-d H:i:s",time() + 7200), +// "Weight"=> 1.0, +// "Quantity"=> 1, +// "Volume"=> 0.0, +// "Remark"=> "小心轻放", +//); +// +//try{ +// var_dump($expressPrint->index($machine_code, $content, $origin_id)); +//}catch (Exception $e) { +// echo $e->getMessage(); +//} +///**面单接口结束**/ diff --git a/niucloud/core/printer/sdk/yilianyun/demo/client_mode/callback.php b/niucloud/core/printer/sdk/yilianyun/demo/client_mode/callback.php new file mode 100644 index 000000000..bba4a61e8 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/demo/client_mode/callback.php @@ -0,0 +1,136 @@ +getToken(); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; + print_r(json_decode($e->getMessage(), true)); + return; +} + +$access_token = $token->access_token; //调用API凭证AccessToken 永久有效,请妥善保存. +$refresh_token = $token->refresh_token; //刷新AccessToken凭证 失效时间35天 +$expires_in = $token->expires_in; //自有型应用可忽略此回调参数, AccessToken失效时间30天 +$refresh_expires_in = $token->refresh_expires_in; //自有型应用可忽略此回调参数, RefreshToken失效时间35天 +$machine_code = ''; //机器码 +$origin_id = ''; //内部订单号(32位以内) + +if (empty($machine_code)) { + echo 'The machine_code cannot be empty'; + return; +} + +if (empty($origin_id)) { + echo 'The origin_id cannot be empty'; + return; +} + + +/**文本接口开始**/ +$print = new PrintService($access_token, $config); +//58mm排版 排版指令详情请看 http://doc2.10ss.net/332006 +$content = "
**#1 美团**
"; +$content .= str_repeat('.', 32); +$content .= "
--在线支付--
"; +$content .= "
张周兄弟烧烤
"; +$content .= "订单时间:" . date("Y-m-d H:i") . "\n"; +$content .= "订单编号:40807050607030\n"; +$content .= str_repeat('*', 14) . "商品" . str_repeat("*", 14); +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= ""; +$content .= "
烤土豆(超级辣)x35.96
烤豆干(超级辣)x23.88
烤鸡翅(超级辣)x317.96
烤排骨(香辣)x312.44
烤韭菜(超级辣)x38.96
"; +$content .= str_repeat('.', 32); +$content .= "这是二维码内容"; +$content .= "小计:¥82\n"; +$content .= "折扣:¥4 \n"; +$content .= str_repeat('*', 32); +$content .= "订单总价:¥78 \n"; +$content .= "
**#1 完**
"; + +try { + var_dump($print->index($machine_code, $content, $origin_id)); +} catch (Exception $e) { + echo $e->getMessage(); +} +/**文本接口结束**/ + + +///**图形接口开始**/ +//$picturePrint = new PicturePrintService($access_token, $config); +//$content = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497000905083&di=7c3cffef1dd40edffbd0a37c4eabb277&imgtype=0&src=http://img1.touxiang.cn/uploads/20131114/14-054929_462.jpg"; +//try{ +// var_dump($picturePrint->index($machine_code, $content, $origin_id)); +//}catch (Exception $e) { +// echo $e->getMessage(); +//} +///**图形接口结束**/ + + +///**面单接口开始**/ //打印机型必须为k5; +//$expressPrint = new ExpressPrintService($access_token, $config); +//$content = array( +// "OrderCode"=> "0126578665784971", +// "ShipperCode"=> "SF", //SF YZPY HTKY YD +// "PayType"=> 1, +// "ExpType"=> 1, +// "Cost"=>6.0, +// "OtherCost"=> 7.0, +// "CustomerName" => '1264546', +// "CustomerPwd" => '4545454', +// "MonthCode" => '', +// "Sender"=> array( +// "Company" => "5645645", +// "Name" => "Taylor", +// "Mobile" => "15018442396", +// "ProvinceName" => "上海", +// "CityName" => "上海", +// "PostCode" => '61000', +// "ExpAreaName" => "青浦区", +// "Address" => "明珠路73号" +// ), +// "Receiver"=> array( +// "Company"=> "789789", +// "Name"=> "Yann", +// "Mobile"=> "15018442396", +// "ProvinceName"=> "北京", +// "CityName"=> "北京", +// "PostCode" => '61000', +// "ExpAreaName"=> "朝阳区", +// "Address"=> "三里屯街道雅秀大厦" +// ), +// "Commodity" => array( +// array( +// "GoodsName"=> "鞋子", +// ) +// ), +// "AddService"=> array( +// array( +// "Name"=> "COD", +// "Value"=> "1020", +// "CustomerID" => "44564" +// ) +// ), +// "StartDate" => date("y-M-d H:i:s",time() + 7200), +// "Weight"=> 1.0, +// "Quantity"=> 1, +// "Volume"=> 0.0, +// "Remark"=> "小心轻放", +//); +// +//try{ +// var_dump($expressPrint->index($machine_code, $content, $origin_id)); +//}catch (Exception $e) { +// echo $e->getMessage(); +//} +///**面单接口结束**/ diff --git a/niucloud/core/printer/sdk/yilianyun/demo/index.php b/niucloud/core/printer/sdk/yilianyun/demo/index.php new file mode 100644 index 000000000..30cabdd08 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/demo/index.php @@ -0,0 +1,11 @@ +setRequestUrl('https://open-api.10ss.net/v2'); diff --git a/niucloud/core/printer/sdk/yilianyun/oauth/YlyOauthClient.php b/niucloud/core/printer/sdk/yilianyun/oauth/YlyOauthClient.php new file mode 100644 index 000000000..ffc8510dd --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/oauth/YlyOauthClient.php @@ -0,0 +1,152 @@ +clientId = $config->getClientId(); + $this->clientSecret = $config->getClientSecret(); + $this->requestUrl = $config->getRequestUrl(); + $this->log = $config->getLog(); + } + + + public function getToken($code = '') + { + $time = time(); + $params = array( + 'client_id' => $this->clientId, + 'timestamp' => $time, + 'sign' => $this->getSign($time), + 'id' => $this->uuid4(), + 'scope' => 'all' + ); + $params[ 'grant_type' ] = 'client_credentials'; + if (!empty($code)) { + $params[ 'code' ] = $code; + $params[ 'grant_type' ] = 'authorization_code'; + } + + $url = sprintf("%s/%s", $this->requestUrl, 'oauth/oauth'); + return $this->send($params, $url); + } + + + public function getTokenBySecret($machineCode, $secret, $secretType = 0) + { + $time = time(); + $params = array( + 'client_id' => $this->clientId, + 'timestamp' => $time, + 'sign' => $this->getSign($time), + 'id' => $this->uuid4(), + 'machine_code' => $machineCode, + 'scope' => 'all' + ); + if ($secretType == 1) { + $params[ 'qr_key' ] = $secret; + } else { + $params[ 'msign' ] = $secret; + } + + $url = sprintf("%s/%s", $this->requestUrl, 'oauth/scancodemodel'); + return $this->send($params, $url); + } + + public function refreshToken($refreshToken) + { + $time = time(); + $params = array( + 'client_id' => $this->clientId, + 'timestamp' => $time, + 'sign' => $this->getSign($time), + 'id' => $this->uuid4(), + 'scope' => 'all', + 'grant_type' => 'refresh_token', + 'refresh_token' => $refreshToken, + ); + + $url = sprintf("%s/%s", $this->requestUrl, 'oauth/oauth'); + return $this->send($params, $url); + } + + + public function getSign($timestamp) + { + return md5( + $this->clientId . + $timestamp . + $this->clientSecret + ); + } + + + public function uuid4() + { + mt_srand(mt_rand()); + $charid = strtolower(md5(uniqid(rand(), true))); + $hyphen = '-'; + $uuidV4 = + substr($charid, 0, 8) . $hyphen . + substr($charid, 8, 4) . $hyphen . + substr($charid, 12, 4) . $hyphen . + substr($charid, 16, 4) . $hyphen . + substr($charid, 20, 12); + return $uuidV4; + } + + + public function send($data, $url) + { + $requestInfo = http_build_query($data); + $log = $this->log; + if ($log != null) { + $log->info("request data: " . $requestInfo); + } + $curl = curl_init(); // 启动一个CURL会话 + curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检测 + curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Expect:' )); // 解决数据包大不能提交 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer + curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 + curl_setopt($curl, CURLOPT_POSTFIELDS, $requestInfo); // Post提交的数据包 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循 + curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 + $requestResponse = curl_exec($curl); // 执行操作 + $response = json_decode($requestResponse); + if (curl_errno($curl)) { + if ($log != null) { + $log->error("error: " . curl_error($curl)); + } + throw new Exception(curl_error($curl)); + } + if (is_null($response)) { + throw new Exception("illegal response :" . $requestResponse); + } + + if ($response->error != 0 && $response->error_description != 'success') { + throw new Exception($response->error_description); + } + if ($this->log != null) { + $this->log->info("response: " . json_encode($response)); + } + curl_close($curl); // 关键CURL会话 + return $response->body; // 返回数据 + } + + +} diff --git a/niucloud/core/printer/sdk/yilianyun/protocol/YlyRpcClient.php b/niucloud/core/printer/sdk/yilianyun/protocol/YlyRpcClient.php new file mode 100644 index 000000000..4099af9b2 --- /dev/null +++ b/niucloud/core/printer/sdk/yilianyun/protocol/YlyRpcClient.php @@ -0,0 +1,104 @@ +clientId = $config->getClientId(); + $this->clientSecret = $config->getClientSecret(); + $this->requestUrl = $config->getRequestUrl(); + $this->log = $config->getLog(); + $this->token = $token; + } + + + public function call($action, array $params) + { + $time = time(); + $params = array_merge(array( + 'client_id' => $this->clientId, + 'timestamp' => $time, + 'sign' => $this->getSign($time), + 'id' => $this->uuid4(), + 'access_token' => $this->token, + ), $params); + + $result = $this->send($params, $this->requestUrl . '/' . $action); + $response = json_decode($result, false, 512, JSON_BIGINT_AS_STRING); + + return $response; + } + + + public function getSign($timestamp) + { + return md5( + $this->clientId . + $timestamp . + $this->clientSecret + ); + } + + + public function uuid4() + { + mt_srand(mt_rand()); + $charid = strtolower(md5(uniqid(rand(), true))); + $hyphen = '-'; + $uuidV4 = + substr($charid, 0, 8) . $hyphen . + substr($charid, 8, 4) . $hyphen . + substr($charid, 12, 4) . $hyphen . + substr($charid, 16, 4) . $hyphen . + substr($charid, 20, 12); + return $uuidV4; + } + + + public function send($data, $url) + { + $requestInfo = http_build_query($data); + $log = $this->log; + if ($log != null) { + $log->info("request data: " . $requestInfo); + } + $curl = curl_init(); // 启动一个CURL会话 + curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检测 + curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Expect:' )); // 解决数据包大不能提交 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer + curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 + curl_setopt($curl, CURLOPT_POSTFIELDS, $requestInfo); // Post提交的数据包 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循 + curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 + $response = curl_exec($curl); // 执行操作 + if (curl_errno($curl)) { + if ($log != null) { + $log->error("error: " . curl_error($curl)); + } + throw new Exception(curl_error($curl)); + } + if ($log != null) { + $log->info("response: " . $response); + } + curl_close($curl); // 关键CURL会话 + return $response; // 返回数据 + } + + +} diff --git a/niucloud/core/sms/Aliyun.php b/niucloud/core/sms/Aliyun.php index 85cb66816..dc66a8ef1 100644 --- a/niucloud/core/sms/Aliyun.php +++ b/niucloud/core/sms/Aliyun.php @@ -29,9 +29,9 @@ class Aliyun extends BaseSms protected function initialize(array $config = []) { parent::initialize($config); - $this->app_key = $config['app_key'] ?? ''; - $this->secret_key = $config['secret_key'] ?? ''; - $this->sign = $config['sign'] ?? ''; + $this->app_key = $config[ 'app_key' ] ?? ''; + $this->secret_key = $config[ 'secret_key' ] ?? ''; + $this->sign = $config[ 'sign' ] ?? ''; } @@ -66,17 +66,17 @@ class Aliyun extends BaseSms ->request(); $res = $result->toArray(); - if (isset($res['Code']) && $res['Code'] == 'OK') { + if (isset($res[ 'Code' ]) && $res[ 'Code' ] == 'OK') { return $res; } - $message = $res['Message'] ?? $res; + $message = $res[ 'Message' ] ?? $res; throw new NoticeException($message); - } catch ( Exception $e ) { + } catch (Exception $e) { throw new NoticeException($e->getMessage()); } } - public function modify(string $sign = null, string $mobile, string $code) + public function modify(string $sign, string $mobile, string $code) { } @@ -95,4 +95,4 @@ class Aliyun extends BaseSms public function record($id) { } -} +} \ No newline at end of file diff --git a/niucloud/core/sms/BaseSms.php b/niucloud/core/sms/BaseSms.php index 239a221dc..4559cf23e 100644 --- a/niucloud/core/sms/BaseSms.php +++ b/niucloud/core/sms/BaseSms.php @@ -42,7 +42,7 @@ abstract class BaseSms extends Storage * 编辑签名 * @return mixed */ - abstract public function modify(string $sign = null, string $mobile, string $code); + abstract public function modify(string $sign, string $mobile, string $code); /** * 短信模板 diff --git a/niucloud/core/sms/SmsLoader.php b/niucloud/core/sms/SmsLoader.php index d22551872..18b833dda 100644 --- a/niucloud/core/sms/SmsLoader.php +++ b/niucloud/core/sms/SmsLoader.php @@ -13,11 +13,11 @@ namespace core\sms; use core\loader\Loader; + /** - * @see SmsLoader - * @package think\facade - * @mixin BaseSms - * @method string|null send(string $mobile, string $template_id, array $data) 发送短信 + * Class SmsLoader + * @package core\sms + * @method string|null send( string $mobile, string $template_id, array $data ) 发送短信 */ class SmsLoader extends Loader { @@ -41,4 +41,4 @@ class SmsLoader extends Loader } -} +} \ No newline at end of file diff --git a/niucloud/core/sms/Tencent.php b/niucloud/core/sms/Tencent.php index 92c7f9e84..cf919198a 100644 --- a/niucloud/core/sms/Tencent.php +++ b/niucloud/core/sms/Tencent.php @@ -40,10 +40,10 @@ class Tencent extends BaseSms protected function initialize(array $config = []) { parent::initialize($config); - $this->secret_id = $config['secret_id'] ?? ''; - $this->secret_key = $config['secret_key'] ?? ''; - $this->sign = $config['sign'] ?? ''; - $this->app_id = $config['app_id'] ?? ''; + $this->secret_id = $config[ 'secret_id' ] ?? ''; + $this->secret_key = $config[ 'secret_key' ] ?? ''; + $this->sign = $config[ 'sign' ] ?? ''; + $this->app_id = $config[ 'app_id' ] ?? ''; } @@ -63,7 +63,7 @@ class Tencent extends BaseSms $client = new SmsClient($cred, 'ap-guangzhou', $clientProfile); $params = [ - 'PhoneNumberSet' => ['+86' . $mobile], + 'PhoneNumberSet' => [ '+86' . $mobile ], 'TemplateID' => $template_id, 'Sign' => $this->sign, 'TemplateParamSet' => $data, @@ -72,19 +72,19 @@ class Tencent extends BaseSms $req = new SendSmsRequest(); $req->fromJsonString(json_encode($params, JSON_THROW_ON_ERROR)); $resp = json_decode($client->SendSms($req)->toJsonString(), true, 512, JSON_THROW_ON_ERROR); - if (isset($resp['SendStatusSet']) && $resp['SendStatusSet'][0]['Code'] == 'Ok') { + if (isset($resp[ 'SendStatusSet' ]) && $resp[ 'SendStatusSet' ][ 0 ][ 'Code' ] == 'Ok') { return $resp; } else { - $message = $res['SendStatusSet'][0]['Message'] ?? json_encode($resp, JSON_THROW_ON_ERROR); + $message = $res[ 'SendStatusSet' ][ 0 ][ 'Message' ] ?? json_encode($resp, JSON_THROW_ON_ERROR); throw new CommonException($message); } - } catch ( Exception $e ) { + } catch (Exception $e) { throw new NoticeException($e->getMessage()); } } - public function modify(string $sign = null, string $mobile, string $code) + public function modify(string $sign, string $mobile, string $code) { } @@ -103,4 +103,4 @@ class Tencent extends BaseSms public function record($id) { } -} +} \ No newline at end of file diff --git a/niucloud/core/template/Weapp.php b/niucloud/core/template/Weapp.php index 1a510e1e1..815fc54fe 100644 --- a/niucloud/core/template/Weapp.php +++ b/niucloud/core/template/Weapp.php @@ -15,7 +15,6 @@ use app\service\core\weapp\CoreWeappService; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use EasyWeChat\Kernel\Support\Collection; -use EasyWeChat\MiniProgram\SubscribeMessage\Client; use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\ResponseInterface; diff --git a/niucloud/core/template/Wechat.php b/niucloud/core/template/Wechat.php index c808ff8c4..f9aea6f75 100644 --- a/niucloud/core/template/Wechat.php +++ b/niucloud/core/template/Wechat.php @@ -15,7 +15,6 @@ use app\service\core\wechat\CoreWechatService; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use EasyWeChat\Kernel\Support\Collection; -use EasyWeChat\OfficialAccount\TemplateMessage\Client; use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\ResponseInterface; diff --git a/niucloud/core/upload/Aliyun.php b/niucloud/core/upload/Aliyun.php index 3b154b816..238a4c97e 100644 --- a/niucloud/core/upload/Aliyun.php +++ b/niucloud/core/upload/Aliyun.php @@ -62,7 +62,7 @@ class Aliyun extends BaseUpload $bucket = $this->config['bucket']; try { $base64_file = base64_decode($base64_data); - if (!$base64_file) throw new UploadFileException('FILE_ERROE'); + if (!$base64_file) throw new UploadFileException('FILE_ERROR'); $this->client()->putObject( $bucket, $key, diff --git a/niucloud/core/upload/Qiniu.php b/niucloud/core/upload/Qiniu.php index 07d5081f2..ea3ecbdf0 100644 --- a/niucloud/core/upload/Qiniu.php +++ b/niucloud/core/upload/Qiniu.php @@ -101,7 +101,7 @@ class Qiniu extends BaseUpload $upload_mgr = new UploadManager(); //将 base64 编码的图片数据解码 $base64_file = base64_decode($base64_data); - if (!$base64_file) throw new UploadFileException('FILE_ERROE'); + if (!$base64_file) throw new UploadFileException('FILE_ERROR'); // 初始化 UpLoadManager 对象并进行文件的上传 list($ret, $err) = $upload_mgr->put($up_token, $key, $base64_file); if ($err !== null) throw new UploadFileException($err->message); diff --git a/niucloud/core/upload/Tencent.php b/niucloud/core/upload/Tencent.php index b08a7d31b..a5b03ceba 100644 --- a/niucloud/core/upload/Tencent.php +++ b/niucloud/core/upload/Tencent.php @@ -84,7 +84,7 @@ class Tencent extends BaseUpload $bucket = $this->config['bucket']; try { $base64_file = base64_decode($base64_data); - if (!$base64_file) throw new UploadFileException('FILE_ERROE'); + if (!$base64_file) throw new UploadFileException('FILE_ERROR'); $result = $this->client()->putObject(array( 'Bucket' => $bucket, //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucket 'Key' => $key, diff --git a/niucloud/core/util/Barcode.php b/niucloud/core/util/Barcode.php index b49915c19..09a4228e2 100644 --- a/niucloud/core/util/Barcode.php +++ b/niucloud/core/util/Barcode.php @@ -1,20 +1,24 @@ color_black = new \BCGColor(0, 0, 0); $this->color_white = new \BCGColor(255, 255, 255); $this->size = $size; @@ -22,9 +26,10 @@ class Barcode{ $this->font = new \BCGFontFile($this->fontPath, $this->size); $this->content = $content; } - + //生成条形码 - public function generateBarcode($path='', $scale = 2){ + public function generateBarcode($path = '', $scale = 2) + { try { $code = new \BCGcode128(); $code->setScale($scale); @@ -33,15 +38,15 @@ class Barcode{ $code->setBackgroundColor($this->color_white); // 空白间隙颜色 $code->setFont($this->font); // $code->parse($this->content); // 条形码需要的数据内容 - } catch(Exception $exception) { + } catch (Exception $exception) { $this->drawException = $exception; } - if($path == ''){ + if ($path == '') { $path = 'upload/barcode';//条形码存放路径 } - - if (! is_dir($path)) { + + if (!is_dir($path)) { $mode = intval('0777', 8); mkdir($path, $mode, true); chmod($path, $mode); @@ -50,10 +55,10 @@ class Barcode{ if (file_exists($path)) { unlink($path); } - + //根据以上条件绘制条形码 $drawing = new \BCGDrawing('', $this->color_white); - if($this->drawException) { + if ($this->drawException) { $drawing->drawException($this->drawException); } else { $drawing->setBarcode($code); @@ -65,4 +70,5 @@ class Barcode{ return $path; } } + ?> \ No newline at end of file diff --git a/niucloud/core/util/Queue.php b/niucloud/core/util/Queue.php index 7931a0fd8..912b4db17 100644 --- a/niucloud/core/util/Queue.php +++ b/niucloud/core/util/Queue.php @@ -12,10 +12,7 @@ namespace core\util; use Exception; -use think\cache\driver\Redis; -use think\facade\Cache; use think\facade\Log; -use think\facade\Queue as ThinkQueue; /** * Class Queue