diff --git a/niucloud/app/Request.php b/niucloud/app/Request.php index 6920dc91b..d1dfe161a 100644 --- a/niucloud/app/Request.php +++ b/niucloud/app/Request.php @@ -60,7 +60,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..135828738 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; @@ -26,16 +25,16 @@ class AddonDevelop extends BaseAdminController public function lists() { $data = $this->request->params([ - ['search', ''] + [ 'search', '' ] ]); - return success((new AddonDevelopService())->getList($data['search'])); + return success(( new AddonDevelopService() )->getList($data[ 'search' ])); } - public function info($key) { - return success((new AddonDevelopService())->getInfo($key)); + return success(( new AddonDevelopService() )->getInfo($key)); } + /** * 开发插件新增 * @return Response @@ -43,19 +42,19 @@ class AddonDevelop extends BaseAdminController public function add(string $key) { $data = $this->request->params([ - ['title', ''], - ['desc', ''], - ['icon', ''], - ['cover', ''], - ['key', ''], - ['author', ''], - ['version', ''], - ['type', ''], - ['support_app', ''], + [ 'title', '' ], + [ 'desc', '' ], + [ 'icon', '' ], + [ 'cover', '' ], + [ 'key', '' ], + [ 'author', '' ], + [ 'version', '' ], + [ 'type', '' ], + [ 'support_app', '' ], ], false); - $data['key'] = $key; + $data[ 'key' ] = $key; $this->validate($data, 'app\validate\addon\AddonDevelop.add'); - (new AddonDevelopService())->add($key, $data); + ( new AddonDevelopService() )->add($key, $data); return success('ADD_SUCCESS'); } @@ -67,19 +66,19 @@ class AddonDevelop extends BaseAdminController public function edit(string $key) { $data = $this->request->params([ - ['title', ''], - ['desc', ''], - ['icon', ''], - ['cover', ''], - ['key', ''], - ['author', ''], - ['version', ''], - ['type', ''], - ['support_app', ''], + [ 'title', '' ], + [ 'desc', '' ], + [ 'icon', '' ], + [ 'cover', '' ], + [ 'key', '' ], + [ 'author', '' ], + [ 'version', '' ], + [ 'type', '' ], + [ 'support_app', '' ], ], false); - $data['key'] = $key; + $data[ 'key' ] = $key; $this->validate($data, 'app\validate\addon\AddonDevelop.edit'); - (new AddonDevelopService())->edit($key, $data); + ( new AddonDevelopService() )->edit($key, $data); return success('EDIT_SUCCESS'); } @@ -91,7 +90,7 @@ class AddonDevelop extends BaseAdminController */ public function del(string $key) { - (new AddonDevelopService())->del($key); + ( new AddonDevelopService() )->del($key); return success('DELETE_SUCCESS'); } @@ -100,8 +99,9 @@ class AddonDevelop extends BaseAdminController * @param $key * @return void */ - public function checkKey($key){ - return success(data:(new AddonDevelopService())->checkKey($key)); + public function checkKey($key) + { + return success(data:( new AddonDevelopService() )->checkKey($key)); } /** @@ -109,8 +109,9 @@ class AddonDevelop extends BaseAdminController * @param $key * @return Response */ - public function build($key){ - (new AddonDevelopService())->build($key); + public function build($key) + { + ( new AddonDevelopService() )->build($key); return success(); } @@ -119,16 +120,18 @@ class AddonDevelop extends BaseAdminController * @param $key * @return Response */ - public function download($key){ + public function download($key) + { - return success(data:(new AddonDevelopService())->download($key)); + return success(data:( new AddonDevelopService() )->download($key)); } /** * * @return Response */ - public function keyBlackList() { + public function keyBlackList() + { return success(AddonDict::ADDON_KEY_BLACK_LIST); } } diff --git a/niucloud/app/adminapi/controller/addon/Upgrade.php b/niucloud/app/adminapi/controller/addon/Upgrade.php index af6e860c9..b374ebdd7 100644 --- a/niucloud/app/adminapi/controller/addon/Upgrade.php +++ b/niucloud/app/adminapi/controller/addon/Upgrade.php @@ -22,8 +22,9 @@ class Upgrade extends BaseAdminController * @param $app_key * @return Response */ - public function upgrade($addon = ''){ - return success(data:(new UpgradeService())->upgrade($addon)); + public function upgrade($addon = '') + { + return success(data:( new UpgradeService() )->upgrade($addon)); } /** @@ -31,8 +32,9 @@ class Upgrade extends BaseAdminController * @param $app_key * @return Response */ - public function execute($addon = ''){ - return success(data:(new UpgradeService())->execute()); + public function execute($addon = '') + { + return success(data:( new UpgradeService() )->execute()); } /** @@ -40,16 +42,18 @@ class Upgrade extends BaseAdminController * @param $addon * @return Response */ - public function getUpgradeContent($addon = '') { - return success(data:(new UpgradeService())->getUpgradeContent($addon)); + public function getUpgradeContent($addon = '') + { + return success(data:( new UpgradeService() )->getUpgradeContent($addon)); } /** * 获取正在进行的升级任务 * @return Response */ - public function getUpgradeTask() { - return success(data:(new UpgradeService())->getUpgradeTask()); + public function getUpgradeTask() + { + return success(data:( new UpgradeService() )->getUpgradeTask()); } /** @@ -57,15 +61,17 @@ class Upgrade extends BaseAdminController * @param $addon * @return Response */ - public function upgradePreCheck($addon = '') { - return success(data:(new UpgradeService())->upgradePreCheck($addon)); + public function upgradePreCheck($addon = '') + { + return success(data:( new UpgradeService() )->upgradePreCheck($addon)); } /** * 清除 * @return Response */ - public function clearUpgradeTask() { - return success(data:(new UpgradeService())->clearUpgradeTask()); + public function clearUpgradeTask() + { + return success(data:( new UpgradeService() )->clearUpgradeTask()); } } diff --git a/niucloud/app/adminapi/controller/auth/Auth.php b/niucloud/app/adminapi/controller/auth/Auth.php index 66a4c5324..c0428ebf8 100644 --- a/niucloud/app/adminapi/controller/auth/Auth.php +++ b/niucloud/app/adminapi/controller/auth/Auth.php @@ -29,9 +29,9 @@ class Auth extends BaseAdminController public function authMenuList() { $data = $this->request->params([ - ['addon', 'all'], + [ 'addon', 'all' ], ]); - return success((new AuthService())->getAuthMenuList(1, $data['addon'])); + return success(( new AuthService() )->getAuthMenuList(1, $data[ 'addon' ])); } /** @@ -41,19 +41,20 @@ class Auth extends BaseAdminController * @throws DbException * @throws ModelNotFoundException */ - public function getAuthAddonList(){ - return success((new AuthSiteService())->getAuthAddonList()); + public function getAuthAddonList() + { + return success(( new AuthSiteService() )->getAuthAddonList()); } + /** * 获取登录用户信息 * @return Response */ public function get() { - return success((new AuthService())->getAuthInfo()); + return success(( new AuthService() )->getAuthInfo()); } - /** * 修改登录用户信息 * @param $field @@ -62,27 +63,26 @@ 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'); } - /** * 更新用户 */ 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'); } @@ -92,7 +92,7 @@ class Auth extends BaseAdminController */ public function site() { - return success((new AuthSiteService())->getSiteInfo()); + return success(( new AuthSiteService() )->getSiteInfo()); } /** @@ -104,6 +104,6 @@ class Auth extends BaseAdminController */ public function getShowMenuList() { - return success((new AuthSiteService())->getShowMenuList()); + return success(( new AuthSiteService() )->getShowMenuList()); } } diff --git a/niucloud/app/adminapi/controller/login/Config.php b/niucloud/app/adminapi/controller/login/Config.php index 1391d8007..68782788e 100644 --- a/niucloud/app/adminapi/controller/login/Config.php +++ b/niucloud/app/adminapi/controller/login/Config.php @@ -19,7 +19,6 @@ use think\Response; class Config extends BaseAdminController { - /** * 获取登录设置 * @return Response diff --git a/niucloud/app/adminapi/controller/login/Login.php b/niucloud/app/adminapi/controller/login/Login.php index a98daf929..a4f1408c4 100644 --- a/niucloud/app/adminapi/controller/login/Login.php +++ b/niucloud/app/adminapi/controller/login/Login.php @@ -11,18 +11,11 @@ namespace app\adminapi\controller\login; -use addon\vipcard\app\service\core\CoreOrderRefundService; -use app\dict\member\MemberAccountTypeDict; use app\service\admin\auth\ConfigService; use app\service\admin\auth\LoginService; -use app\service\admin\member\MemberService; use app\service\admin\upgrade\UpgradeService; -use app\service\core\addon\CoreAddonDevelopBuildService; use app\service\core\addon\WapTrait; -use app\service\core\menu\CoreMenuService; -use app\service\core\upload\CoreFileService; use core\base\BaseAdminController; -use think\facade\Db; use think\Response; class Login extends BaseAdminController @@ -37,12 +30,12 @@ class Login extends BaseAdminController { $data = $this->request->params([ - ['username', ''], - ['password', ''], + [ 'username', '' ], + [ 'password', '' ], ]); //参数验证 //验证码验证 - $result = (new LoginService())->login($data['username'], $data['password'], $app_type); + $result = ( new LoginService() )->login($data[ 'username' ], $data[ 'password' ], $app_type); if (!$result) { //账号密码错误...., 重置验证码 return fail('USER_ERROR'); @@ -57,26 +50,26 @@ class Login extends BaseAdminController */ public function logout() { - (new LoginService)->logout(); + ( new LoginService )->logout(); return success('LOGOUT'); } - /** * 获取登录设置 * @return Response */ public function getConfig() { - return success((new ConfigService())->getConfig()); + return success(( new ConfigService() )->getConfig()); } - public function test(){ - (new UpgradeService())->executeSql(root_path().'app/upgrade/v011/upgrade.sql'); + public function test() + { + ( new UpgradeService() )->executeSql(root_path() . 'app/upgrade/v011/upgrade.sql'); } public function geAddonPackagePath(string $addon) { - return root_path() . 'addon' .DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR . 'package' . DIRECTORY_SEPARATOR; + return root_path() . 'addon' . DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR . 'package' . DIRECTORY_SEPARATOR; } } diff --git a/niucloud/app/adminapi/controller/member/Account.php b/niucloud/app/adminapi/controller/member/Account.php index 8bcbb5bd8..861418da3 100644 --- a/niucloud/app/adminapi/controller/member/Account.php +++ b/niucloud/app/adminapi/controller/member/Account.php @@ -26,13 +26,13 @@ class Account extends BaseAdminController public function point() { $data = $this->request->params([ - ['member_id', ''], - ['from_type', ''], - ['create_time', []], - ['keywords', ''], + [ 'member_id', '' ], + [ 'from_type', '' ], + [ 'create_time', [] ], + [ 'keywords', '' ], ]); - $data['account_type'] = 'point'; - return success((new MemberAccountService())->getPage($data)); + $data[ 'account_type' ] = 'point'; + return success(( new MemberAccountService() )->getPage($data)); } /** @@ -41,22 +41,22 @@ class Account extends BaseAdminController public function sumPoint() { $data = $this->request->params([ - ['member_id', ''], + [ 'member_id', '' ], ]); $member_account_service = new MemberAccountService(); $member_service = new MemberService(); - if (empty($data['member_id'])) { + if (empty($data[ 'member_id' ])) { $commission_data = [ 'point_get' => $member_service->getSum('point_get'),//累计 'point_use' => abs($member_account_service->getExpensesSumAccount(MemberAccountTypeDict::POINT)), ]; return success($commission_data); } else { - $info = $member_account_service->getMemberAccountInfo($data['member_id']); + $info = $member_account_service->getMemberAccountInfo($data[ 'member_id' ]); $commission_data = [ - 'point_get' => $info['point_get'], - 'point_use' => abs($member_account_service->getExpensesSumAccount(MemberAccountTypeDict::POINT, $data['member_id'])), + 'point_get' => $info[ 'point_get' ], + 'point_use' => abs($member_account_service->getExpensesSumAccount(MemberAccountTypeDict::POINT, $data[ 'member_id' ])), ]; return success($commission_data); } @@ -69,13 +69,13 @@ class Account extends BaseAdminController public function balance() { $data = $this->request->params([ - ['member_id', ''], - ['from_type', ''], - ['create_time', []], - ['keywords', ''], + [ 'member_id', '' ], + [ 'from_type', '' ], + [ 'create_time', [] ], + [ 'keywords', '' ], ]); - $data['account_type'] = 'balance'; - return success((new MemberAccountService())->getPage($data)); + $data[ 'account_type' ] = 'balance'; + return success(( new MemberAccountService() )->getPage($data)); } /** @@ -85,28 +85,29 @@ class Account extends BaseAdminController public function money() { $data = $this->request->params([ - ['member_id', ''], - ['from_type', ''], - ['create_time', []], - ['keywords', ''], + [ 'member_id', '' ], + [ 'from_type', '' ], + [ 'create_time', [] ], + [ 'keywords', '' ], ]); - $data['account_type'] = 'money'; - return success((new MemberAccountService())->getPage($data)); + $data[ 'account_type' ] = 'money'; + return success(( new MemberAccountService() )->getPage($data)); } /** * 查询成长值 * @return Response */ - public function growth() { + public function growth() + { $data = $this->request->params([ - ['member_id', ''], - ['from_type', ''], - ['create_time', []], - ['keywords', ''], + [ 'member_id', '' ], + [ 'from_type', '' ], + [ 'create_time', [] ], + [ 'keywords', '' ], ]); - $data['account_type'] = 'growth'; - return success((new MemberAccountService())->getPage($data)); + $data[ 'account_type' ] = 'growth'; + return success(( new MemberAccountService() )->getPage($data)); } /** @@ -115,12 +116,12 @@ class Account extends BaseAdminController public function adjustPoint() { $data = $this->request->params([ - ['member_id', ''], - ['account_data', 0], - ['memo', ''], + [ 'member_id', '' ], + [ 'account_data', 0 ], + [ 'memo', '' ], ]); - $res = (new MemberAccountService())->adjustPoint($data); - return success('SUCCESS', ['id' => $res]); + $res = ( new MemberAccountService() )->adjustPoint($data); + return success('SUCCESS', [ 'id' => $res ]); } /** @@ -129,12 +130,12 @@ class Account extends BaseAdminController public function adjustBalance() { $data = $this->request->params([ - ['member_id', ''], - ['account_data', 0], - ['memo', ''], + [ 'member_id', '' ], + [ 'account_data', 0 ], + [ 'memo', '' ], ]); - $res = (new MemberAccountService())->adjustBalance($data); - return success('SUCCESS', ['id' => $res]); + $res = ( new MemberAccountService() )->adjustBalance($data); + return success('SUCCESS', [ 'id' => $res ]); } /** @@ -144,12 +145,12 @@ class Account extends BaseAdminController public function adjustMoney() { $data = $this->request->params([ - ['member_id', ''], - ['account_data', 0], - ['memo', ''], + [ 'member_id', '' ], + [ 'account_data', 0 ], + [ 'memo', '' ], ]); - $res = (new MemberAccountService())->adjustMoney($data); - return success('SUCCESS', ['id' => $res]); + $res = ( new MemberAccountService() )->adjustMoney($data); + return success('SUCCESS', [ 'id' => $res ]); } /** @@ -159,13 +160,13 @@ class Account extends BaseAdminController public function commission() { $data = $this->request->params([ - ['member_id', ''], - ['from_type', ''], - ['create_time', []], - ['keywords', ''], + [ 'member_id', '' ], + [ 'from_type', '' ], + [ 'create_time', [] ], + [ 'keywords', '' ], ]); - $data['account_type'] = 'commission'; - return success((new MemberAccountService())->getPage($data)); + $data[ 'account_type' ] = 'commission'; + return success(( new MemberAccountService() )->getPage($data)); } /** @@ -174,12 +175,12 @@ class Account extends BaseAdminController public function sumCommission() { $data = $this->request->params([ - ['member_id', ''], + [ 'member_id', '' ], ]); $member_account_service = new MemberAccountService(); $member_service = new MemberService(); - if (empty($data['member_id'])) { + if (empty($data[ 'member_id' ])) { $commission_data = [ 'total_commission' => $member_service->getSum('commission_get'),//累计 'commission' => $member_service->getSum('commission'),//未提现 @@ -188,12 +189,12 @@ class Account extends BaseAdminController ]; return success($commission_data); } else { - $info = $member_account_service->getMemberAccountInfo($data['member_id']); + $info = $member_account_service->getMemberAccountInfo($data[ 'member_id' ]); $commission_data = [ - 'commission' => $info['commission'], - 'commission_cash_outing' => $info['commission_cash_outing'], - 'withdrawn_commission' => $member_account_service->getWithdrawnCommission($data['member_id']),//已提现 - 'total_commission' => $info['commission_get'], + 'commission' => $info[ 'commission' ], + 'commission_cash_outing' => $info[ 'commission_cash_outing' ], + 'withdrawn_commission' => $member_account_service->getWithdrawnCommission($data[ 'member_id' ]),//已提现 + 'total_commission' => $info[ 'commission_get' ], ]; return success($commission_data); } @@ -205,10 +206,10 @@ class Account extends BaseAdminController public function sumBalance() { $data = $this->request->params([ - ['member_id', ''], + [ 'member_id', '' ], ]); $member_account_service = new MemberAccountService(); - if (empty($data['member_id'])) { + if (empty($data[ 'member_id' ])) { $balance_data = [ MemberAccountTypeDict::BALANCE => number_format($member_account_service->getSumAccount(MemberAccountTypeDict::BALANCE), 2, '.', ''), @@ -216,7 +217,7 @@ class Account extends BaseAdminController ]; return success($balance_data); } else { - return success($member_account_service->getMemberAccountInfo($data['member_id'])); + return success($member_account_service->getMemberAccountInfo($data[ 'member_id' ])); } } @@ -227,7 +228,7 @@ class Account extends BaseAdminController */ public function changeType(string $account_type) { - $res = (new MemberAccountService())->getFromType($account_type); + $res = ( new MemberAccountService() )->getFromType($account_type); return success($res); } @@ -239,5 +240,4 @@ class Account extends BaseAdminController return success(MemberAccountTypeDict::getType()); } - } diff --git a/niucloud/app/adminapi/controller/member/Member.php b/niucloud/app/adminapi/controller/member/Member.php index 00d6461ff..9b6e4929f 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/member/MemberLevel.php b/niucloud/app/adminapi/controller/member/MemberLevel.php index 765c64e89..9c75cb989 100644 --- a/niucloud/app/adminapi/controller/member/MemberLevel.php +++ b/niucloud/app/adminapi/controller/member/MemberLevel.php @@ -32,18 +32,6 @@ class MemberLevel extends BaseAdminController return success(( new MemberLevelService() )->getPage($data)); } - /** - * 会员等级列表 - * @return Response - */ - public function lists() - { - $data = $this->request->params([ - [ 'level_name', '' ], - ]); - return success(( new MemberLevelService() )->getList($data)); - } - /** * 会员等级详情 * @param int $id diff --git a/niucloud/app/adminapi/controller/pay/Pay.php b/niucloud/app/adminapi/controller/pay/Pay.php index 84beda237..53ca9070b 100644 --- a/niucloud/app/adminapi/controller/pay/Pay.php +++ b/niucloud/app/adminapi/controller/pay/Pay.php @@ -11,7 +11,6 @@ namespace app\adminapi\controller\pay; -use app\dict\pay\PayDict; use app\service\admin\pay\PayService; use core\base\BaseAdminController; diff --git a/niucloud/app/adminapi/controller/pay/PayChannel.php b/niucloud/app/adminapi/controller/pay/PayChannel.php index a8b666075..712157291 100644 --- a/niucloud/app/adminapi/controller/pay/PayChannel.php +++ b/niucloud/app/adminapi/controller/pay/PayChannel.php @@ -62,7 +62,6 @@ class PayChannel extends BaseAdminController return success((new PayChannelService())->getListByChannel($channel)); } - /** * 支付设置 * @return Response diff --git a/niucloud/app/adminapi/controller/site/SiteGroup.php b/niucloud/app/adminapi/controller/site/SiteGroup.php index f96274bf9..663ddfef3 100644 --- a/niucloud/app/adminapi/controller/site/SiteGroup.php +++ b/niucloud/app/adminapi/controller/site/SiteGroup.php @@ -87,7 +87,6 @@ class SiteGroup extends BaseAdminController */ public function del($group_id) { - (new SiteGroupService())->del($group_id); return success('DELETE_SUCCESS'); } diff --git a/niucloud/app/adminapi/controller/site/User.php b/niucloud/app/adminapi/controller/site/User.php index c7a699909..4e35b60d3 100644 --- a/niucloud/app/adminapi/controller/site/User.php +++ b/niucloud/app/adminapi/controller/site/User.php @@ -32,7 +32,6 @@ class User extends BaseAdminController ]); $list = (new SiteUserService())->getPage($data); return success($list); - } /** @@ -66,7 +65,6 @@ class User extends BaseAdminController return success('ADD_SUCCESS', ['uid' => $uid]); } - /** * 更新用户 */ diff --git a/niucloud/app/adminapi/controller/sys/Agreement.php b/niucloud/app/adminapi/controller/sys/Agreement.php index 722847510..154fb415d 100644 --- a/niucloud/app/adminapi/controller/sys/Agreement.php +++ b/niucloud/app/adminapi/controller/sys/Agreement.php @@ -59,5 +59,4 @@ class Agreement extends BaseAdminController return success('EDIT_SUCCESS'); } - } diff --git a/niucloud/app/adminapi/controller/sys/App.php b/niucloud/app/adminapi/controller/sys/App.php index 8dc6fadeb..ffefd8269 100644 --- a/niucloud/app/adminapi/controller/sys/App.php +++ b/niucloud/app/adminapi/controller/sys/App.php @@ -29,5 +29,4 @@ class App extends BaseAdminController return success((new AppService())->getAppList()); } - } diff --git a/niucloud/app/adminapi/controller/sys/Common.php b/niucloud/app/adminapi/controller/sys/Common.php index c14f08f77..2fb4ec6ca 100644 --- a/niucloud/app/adminapi/controller/sys/Common.php +++ b/niucloud/app/adminapi/controller/sys/Common.php @@ -38,5 +38,4 @@ class Common extends BaseAdminController return success((new DateDict())->getWeek()); } - } diff --git a/niucloud/app/adminapi/controller/sys/Config.php b/niucloud/app/adminapi/controller/sys/Config.php index c5d5da150..9b4964d6f 100644 --- a/niucloud/app/adminapi/controller/sys/Config.php +++ b/niucloud/app/adminapi/controller/sys/Config.php @@ -46,8 +46,6 @@ class Config extends BaseAdminController [ "full_address", "" ], [ "phone", "" ], [ "business_hours", "" ], - [ "site_name", "" ], - [ "logo", "" ], [ "front_end_name", "" ], [ "front_end_logo", "" ], [ "front_end_icon", "" ], @@ -135,26 +133,6 @@ class Config extends BaseAdminController return success(( new ConfigService() )->getMap()); } - /** - * 设置快捷菜单 - */ - 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/Menu.php b/niucloud/app/adminapi/controller/sys/Menu.php index 1171de334..5bb9e3307 100644 --- a/niucloud/app/adminapi/controller/sys/Menu.php +++ b/niucloud/app/adminapi/controller/sys/Menu.php @@ -28,8 +28,7 @@ class Menu extends BaseAdminController */ public function lists($app_type) { - - return success((new MenuService())->getAllMenuList($app_type, 'all', 1)); + return success(( new MenuService() )->getAllMenuList($app_type, 'all', 1)); } /** @@ -39,7 +38,7 @@ class Menu extends BaseAdminController */ public function info($app_type, $menu_key) { - return success((new MenuService())->get($app_type, $menu_key)); + return success(( new MenuService() )->get($app_type, $menu_key)); } /** @@ -49,24 +48,24 @@ class Menu extends BaseAdminController public function add() { $data = $this->request->params([ - ['app_type', ''], - ['menu_name', ''], - ['menu_type', 0], - ['menu_key', ''], - ['parent_key', ''], - ['icon', ''], - ['api_url', ''], - ['view_path', ''], - ['router_path', ''], - ['methods', ''], - ['sort', 0], - ['status', MenuDict::ON], - ['is_show', 0], - ['addon', ''], - ['menu_short_name',''] + [ 'app_type', '' ], + [ 'menu_name', '' ], + [ 'menu_type', 0 ], + [ 'menu_key', '' ], + [ 'parent_key', '' ], + [ 'icon', '' ], + [ 'api_url', '' ], + [ 'view_path', '' ], + [ 'router_path', '' ], + [ 'methods', '' ], + [ 'sort', 0 ], + [ 'status', MenuDict::ON ], + [ 'is_show', 0 ], + [ 'addon', '' ], + [ 'menu_short_name', '' ] ]); $this->validate($data, 'app\validate\sys\Menu.add'); - (new MenuService())->add($data); + ( new MenuService() )->add($data); return success('ADD_SUCCESS'); } @@ -76,22 +75,22 @@ class Menu extends BaseAdminController public function edit($app_type, $menu_key) { $data = $this->request->params([ - ['menu_name', ''], - ['parent_key', ''], - ['menu_type', 0], - ['icon', ''], - ['api_url', ''], - ['router_path', ''], - ['view_path', ''], - ['methods', ''], - ['sort', 0], - ['status', MenuDict::ON], - ['is_show', 0], - ['addon', ''], - ['menu_short_name',''] + [ 'menu_name', '' ], + [ 'parent_key', '' ], + [ 'menu_type', 0 ], + [ 'icon', '' ], + [ 'api_url', '' ], + [ 'router_path', '' ], + [ 'view_path', '' ], + [ 'methods', '' ], + [ 'sort', 0 ], + [ 'status', MenuDict::ON ], + [ 'is_show', 0 ], + [ 'addon', '' ], + [ 'menu_short_name', '' ] ]); $this->validate($data, 'app\validate\sys\Menu.edit'); - (new MenuService())->edit($app_type, $menu_key, $data); + ( new MenuService() )->edit($app_type, $menu_key, $data); return success('EDIT_SUCCESS'); } @@ -121,13 +120,13 @@ class Menu extends BaseAdminController */ public function del($app_type, $menu_key) { - (new MenuService())->del($app_type, $menu_key); + ( new MenuService() )->del($app_type, $menu_key); return success('DELETE_SUCCESS'); } public function refreshMenu() { - (new InstallSystemService())->install(); + ( new InstallSystemService() )->install(); return success('SUCCESS'); } @@ -136,7 +135,7 @@ class Menu extends BaseAdminController */ public function getSystem() { - return success( (new MenuService())->getSystemMenu('all', 1)); + return success(( new MenuService() )->getSystemMenu('all', 1)); } /** @@ -144,7 +143,7 @@ class Menu extends BaseAdminController */ public function getAddonMenu($app_key) { - return success( (new MenuService())->getAddonMenu($app_key,'all', 1)); + return success(( new MenuService() )->getAddonMenu($app_key, 'all', 1)); } /** @@ -152,7 +151,8 @@ class Menu extends BaseAdminController * @param $addon * @return Response */ - public function getMenuByTypeDir($addon = 'system') { - return success( (new MenuService())->getMenuByTypeDir($addon)); + public function getMenuByTypeDir($addon = 'system') + { + return success(( new MenuService() )->getMenuByTypeDir($addon)); } } 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 f13b58ea6..97db5f002 100644 --- a/niucloud/app/adminapi/controller/user/User.php +++ b/niucloud/app/adminapi/controller/user/User.php @@ -51,6 +51,15 @@ class User extends BaseAdminController return success($list); } + public function getUserSelect() + { + $data = $this->request->params([ + ['username', ''] + ]); + $list = (new UserService())->getUserSelect($data); + return success($list); + } + public function checkUserIsExist() { $data = $this->request->params([ ['username', ''], diff --git a/niucloud/app/adminapi/controller/weapp/Config.php b/niucloud/app/adminapi/controller/weapp/Config.php index 58fb4ae7e..65109cd1d 100644 --- a/niucloud/app/adminapi/controller/weapp/Config.php +++ b/niucloud/app/adminapi/controller/weapp/Config.php @@ -48,5 +48,4 @@ class Config extends BaseAdminController return success('SET_SUCCESS'); } - } diff --git a/niucloud/app/adminapi/controller/weapp/Delivery.php b/niucloud/app/adminapi/controller/weapp/Delivery.php index 51eee4a90..2c2a3b996 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/Template.php b/niucloud/app/adminapi/controller/weapp/Template.php index 216c2342d..fb52d7818 100644 --- a/niucloud/app/adminapi/controller/weapp/Template.php +++ b/niucloud/app/adminapi/controller/weapp/Template.php @@ -31,7 +31,6 @@ class Template extends BaseAdminController return success($wechat_template_service->getList()); } - /** * 菜单信息 * @return 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/controller/wechat/Reply.php b/niucloud/app/adminapi/controller/wechat/Reply.php index 676bbe0db..491ae7145 100644 --- a/niucloud/app/adminapi/controller/wechat/Reply.php +++ b/niucloud/app/adminapi/controller/wechat/Reply.php @@ -34,8 +34,8 @@ class Reply extends BaseAdminController public function getKeywordLists() { $data = $this->request->params([ - ['keyword', ''], - ['name', ''] + [ 'keyword', '' ], + [ 'name', '' ] ]); $wechat_reply_service = new WechatReplyService(); return success($wechat_reply_service->getKeywordPage($data)); @@ -49,12 +49,12 @@ class Reply extends BaseAdminController { $wechat_reply_service = new WechatReplyService(); $data = $this->request->params([ - ['name', ''], - ['keyword', ''], - ['matching_type', '', false], - ['reply_method', ''], - ['content', ''], - ['sort', ''], + [ 'name', '' ], + [ 'keyword', '' ], + [ 'matching_type', '', false ], + [ 'reply_method', '' ], + [ 'content', '' ], + [ 'sort', '' ], ]); $wechat_reply_service->addKeyword($data); return success('ADD_SUCCESS'); @@ -68,12 +68,12 @@ class Reply extends BaseAdminController { $wechat_reply_service = new WechatReplyService(); $data = $this->request->params([ - ['name', ''], - ['keyword', ''], - ['matching_type', '', false], - ['reply_method', ''], - ['content', ''], - ['sort', ''], + [ 'name', '' ], + [ 'keyword', '' ], + [ 'matching_type', '', false ], + [ 'reply_method', '' ], + [ 'content', '' ], + [ 'sort', '' ], ]); $wechat_reply_service->editKeyword($id, $data); return success('EDIT_SUCCESS'); @@ -107,7 +107,7 @@ class Reply extends BaseAdminController public function editDefault() { $data = $this->request->params([ - ['content', ''], + [ 'content', '' ], ]); $wechat_reply_service = new WechatReplyService(); $wechat_reply_service->editDefault($data); @@ -131,12 +131,11 @@ class Reply extends BaseAdminController public function editSubscribe() { $data = $this->request->params([ - ['content', ''], + [ 'content', '' ], ]); $wechat_reply_service = new WechatReplyService(); $wechat_reply_service->editSubscribe($data); return success('SET_SUCCESS'); } - } diff --git a/niucloud/app/adminapi/controller/wechat/Template.php b/niucloud/app/adminapi/controller/wechat/Template.php index d450591b3..c8aa42c69 100644 --- a/niucloud/app/adminapi/controller/wechat/Template.php +++ b/niucloud/app/adminapi/controller/wechat/Template.php @@ -28,10 +28,10 @@ class Template extends BaseAdminController public function sync() { $data = $this->request->params([ - ['keys', []] + [ 'keys', [] ] ]); $wechat_template_service = new WechatTemplateService(); - return success(data:$wechat_template_service->syncAll($data['keys'])); + return success(data:$wechat_template_service->syncAll($data[ 'keys' ])); } /** @@ -44,5 +44,4 @@ class Template extends BaseAdminController return success($wechat_template_service->getList()); } - } diff --git a/niucloud/app/adminapi/controller/wxoplatform/Config.php b/niucloud/app/adminapi/controller/wxoplatform/Config.php index 23acdb103..11d651e6c 100644 --- a/niucloud/app/adminapi/controller/wxoplatform/Config.php +++ b/niucloud/app/adminapi/controller/wxoplatform/Config.php @@ -11,7 +11,6 @@ namespace app\adminapi\controller\wxoplatform; -use app\service\admin\wechat\WechatConfigService; use app\service\admin\wxoplatform\OplatformConfigService; use core\base\BaseAdminController; use think\Response; 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 a2259be9d..c19f77cf2 100644 --- a/niucloud/app/adminapi/route/member.php +++ b/niucloud/app/adminapi/route/member.php @@ -46,6 +46,14 @@ Route::group('member', function () { Route::get('status/list', 'member.Member/getStatusList'); //会员设置状态 Route::put('setstatus/:status', 'member.Member/setStatus'); + // 获取会员权益字典 + Route::get('dict/benefits', 'member.Member/getMemberBenefitsDict'); + // 获取会员礼包字典 + Route::get('dict/gift', 'member.Member/getMemberGiftDict'); + // 获取成长值规则字典 + Route::get('dict/growth_rule', 'member.Member/getGrowthRuleDict'); + // 获取积分规则字典 + Route::get('dict/point_rule', 'member.Member/getPointRuleDict'); /***************************************************** 会员标签 ****************************************************/ //会员标签列表 Route::get('label', 'member.MemberLabel/lists'); @@ -101,6 +109,10 @@ Route::group('member', function () { Route::get('config/point_rule', 'member.Config/getPointRuleConfig'); //设置积分规则 Route::post('config/point_rule', 'member.Config/setPointRuleConfig'); + //获取注册与登录设置 + Route::get('config/member', 'member.Config/getMemberConfig'); + //更新注册与登录设置 + Route::post('config/member', 'member.Config/setMemberConfig'); /***************************************************** 会员体现**************************************************/ //会员提现列表 Route::get('cash_out', 'member.CashOut/lists'); @@ -116,23 +128,9 @@ Route::group('member', function () { Route::get('cash_out/status', 'member.CashOut/getStatusList'); //提现统计信息 Route::get('cash_out/stat', 'member.CashOut/stat'); - //获取注册与登录设置 - Route::get('config/member', 'member.Config/getMemberConfig'); - //更新注册与登录设置 - Route::post('config/member', 'member.Config/setMemberConfig'); - // 获取会员权益字典 - Route::get('dict/benefits', 'member.Member/getMemberBenefitsDict'); - // 获取会员礼包字典 - Route::get('dict/gift', 'member.Member/getMemberGiftDict'); - // 获取成长值规则字典 - Route::get('dict/growth_rule', 'member.Member/getGrowthRuleDict'); - // 获取积分规则字典 - Route::get('dict/point_rule', 'member.Member/getPointRuleDict'); /***************************************************** 会员等级 ****************************************************/ //会员等级分页列表 Route::get('level', 'member.MemberLevel/pages'); - //会员等级列表 - Route::get('level/list', 'member.MemberLevel/lists'); //会员等级详情 Route::get('level/:id', 'member.MemberLevel/info'); //会员等级添加 diff --git a/niucloud/app/adminapi/route/sys.php b/niucloud/app/adminapi/route/sys.php index 31e336ec7..8898f87e0 100644 --- a/niucloud/app/adminapi/route/sys.php +++ b/niucloud/app/adminapi/route/sys.php @@ -78,24 +78,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'); //登录注册设置 @@ -273,6 +255,62 @@ Route::group('sys', function() { // 百度编辑器文件上传 Route::post('ueditor', 'sys.Ueditor/upload'); + /***************************************************** 小票打印管理 ****************************************************/ + + // 小票打印机分页列表 + 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 a69c0618f..fe67d49f1 100644 --- a/niucloud/app/adminapi/route/user.php +++ b/niucloud/app/adminapi/route/user.php @@ -24,6 +24,8 @@ Route::group('user', function () { Route::get('user', 'user.User/lists'); //全部用户列表 Route::get('user_all', 'user.User/getUserAll'); + //添加站点可选用户列表 + Route::get('user_select', 'user.User/getUserSelect'); //用户详情 Route::get('user/:uid', 'user.User/info'); // 查询账号是否存在 diff --git a/niucloud/app/api/controller/agreement/Agreement.php b/niucloud/app/api/controller/agreement/Agreement.php index f3407c427..ca9c2e9be 100644 --- a/niucloud/app/api/controller/agreement/Agreement.php +++ b/niucloud/app/api/controller/agreement/Agreement.php @@ -16,7 +16,7 @@ use core\base\BaseApiController; /** * 协议控制器 - * Class Article + * Class Agreement * @package app\api\controller\agreement */ class Agreement extends BaseApiController diff --git a/niucloud/app/api/controller/article/Article.php b/niucloud/app/api/controller/article/Article.php deleted file mode 100644 index 7631382d8..000000000 --- a/niucloud/app/api/controller/article/Article.php +++ /dev/null @@ -1,57 +0,0 @@ -request->params([ - ['title', ''], - ['category_id', ''], - ]); - return success((new ArticleService())->getPage($data)); - } - - public function all(){ - $data = $this->request->params([ - ['title', ''], - ['category_id', ''], - ['ids', []], - ['limit', 0] - ]); - return success((new ArticleService())->getAll($data, $data['limit'])); - } - - /** - * 文章详情 - * @param int $id - * @return Response - */ - public function info(int $id){ - return success((new ArticleService())->getInfo($id)); - } - - -} diff --git a/niucloud/app/api/controller/article/ArticleCategory.php b/niucloud/app/api/controller/article/ArticleCategory.php deleted file mode 100644 index 2e550f9b9..000000000 --- a/niucloud/app/api/controller/article/ArticleCategory.php +++ /dev/null @@ -1,47 +0,0 @@ -request->params([ - ['name', ''], - ]); - return success((new ArticleCategoryService())->getPage($data)); - } - - /** - * 文章分类详情 - * @param int $id - * @return Response - */ - public function info(int $id){ - return success((new ArticleCategoryService())->getInfo($id)); - } - - - -} diff --git a/niucloud/app/api/controller/login/Config.php b/niucloud/app/api/controller/login/Config.php index 182ddcf44..22115b543 100644 --- a/niucloud/app/api/controller/login/Config.php +++ b/niucloud/app/api/controller/login/Config.php @@ -23,9 +23,7 @@ class Config extends BaseController */ public function getLoginConfig() { - - return success((new MemberConfigService())->getLoginConfig()); + return success(( new MemberConfigService() )->getLoginConfig()); } - } diff --git a/niucloud/app/api/controller/login/Login.php b/niucloud/app/api/controller/login/Login.php index 3f4dd3734..ea355839e 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 f8681ef47..ad76a1545 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 9d8221206..8495a6024 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,10 @@ class Account extends BaseApiController public function balanceList(): Response { $data = $this->request->params([ - ['from_type', ''] + ['from_type', ''], + ['create_time', []] ]); - return success((new MemberAccountService())->getPages($data)); + return success((new MemberAccountService())->getBalancePage($data)); } /** @@ -98,9 +101,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 aab444afb..bdb468d06 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 9bf177f30..fce8e9933 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 d6bc314d7..fcf515789 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 b332dccd4..100b14d0a 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/article.php b/niucloud/app/api/route/article.php deleted file mode 100644 index ee4cd0b94..000000000 --- a/niucloud/app/api/route/article.php +++ /dev/null @@ -1,38 +0,0 @@ -middleware(ApiChannel::class) - ->middleware(ApiCheckToken::class, false) - ->middleware(ApiLog::class); \ No newline at end of file diff --git a/niucloud/app/api/route/member.php b/niucloud/app/api/route/member.php index b4fcc1926..83e7fb005 100644 --- a/niucloud/app/api/route/member.php +++ b/niucloud/app/api/route/member.php @@ -91,9 +91,6 @@ Route::group('member', function () { //删除会员收货地址 Route::delete('address/:id', 'member.Address/del'); - /***************************************************** 会员等级 **************************************************/ - Route::get('level', 'member.Level/lists'); - /***************************************************** 会员签到 **************************************************/ //会员签到记录 Route::get('sign', 'member.MemberSign/lists'); @@ -118,6 +115,9 @@ Route::group('member', function () { /***************************************************** 会员管理 ****************************************************/ //会员日志 Route::post('log', 'member.Member/log'); + + /***************************************************** 会员等级 **************************************************/ + Route::get('level', 'member.Level/lists'); })->middleware(ApiChannel::class) ->middleware(ApiCheckToken::class) ->middleware(ApiLog::class); diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 61586c583..de7faa7d2 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -144,5 +144,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/WorkerCommand.php b/niucloud/app/command/WorkerCommand.php index fe5dda152..9e5813582 100644 --- a/niucloud/app/command/WorkerCommand.php +++ b/niucloud/app/command/WorkerCommand.php @@ -11,11 +11,8 @@ namespace app\command; -use core\exception\CommonException; -use core\job\Dispatch; use think\console\Input; use think\console\Output; -use think\queue\Job; /** * worker 兼容think自定义指令 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 9ab98a22b..44cb08985 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..5035fe981 100644 --- a/niucloud/app/dict/diy/ComponentDict.php +++ b/niucloud/app/dict/diy/ComponentDict.php @@ -550,8 +550,10 @@ class ComponentDict 'sort' => 10014, 'position' => 'fixed', 'value' => [ - "imageSize" => 40, + "imageSize" => 80, "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 f03195ea4..c978989ff 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'], diff --git a/niucloud/app/dict/member/MemberRegisterChannelDict.php b/niucloud/app/dict/member/MemberRegisterChannelDict.php index fc5489c2e..f5f17cd93 100644 --- a/niucloud/app/dict/member/MemberRegisterChannelDict.php +++ b/niucloud/app/dict/member/MemberRegisterChannelDict.php @@ -24,7 +24,6 @@ class MemberRegisterChannelDict extends ChannelDict public static function getType($type = '') { - $data = ChannelDict::getType($type); $data[self::MANUAL] = get_lang('dict_member.register_manual');//手动添加 if (empty($type)) { 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/site.php b/niucloud/app/dict/menu/site.php index 9f026e23a..45657c5cc 100644 --- a/niucloud/app/dict/menu/site.php +++ b/niucloud/app/dict/menu/site.php @@ -2172,7 +2172,7 @@ return [ 'router_path' => 'setting/agreement', 'view_path' => 'setting/agreement', 'methods' => 'get', - 'sort' => '80', + 'sort' => '100', 'status' => '1', 'is_show' => '1', ], @@ -2260,7 +2260,7 @@ return [ 'router_path' => 'setting/storage', 'view_path' => 'setting/storage', 'methods' => 'get', - 'sort' => '30', + 'sort' => '98', 'status' => '1', 'is_show' => '1', 'children' => [ @@ -2304,7 +2304,7 @@ return [ 'router_path' => 'setting/export', 'view_path' => 'setting/export', 'methods' => 'get', - 'sort' => '30', + 'sort' => '98', 'status' => '1', 'is_show' => '1', 'children' => [ @@ -2323,7 +2323,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/sys/FileDict.php b/niucloud/app/dict/sys/FileDict.php index 67cfe0c31..8b8210cda 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导入 ]; } diff --git a/niucloud/app/dict/sys/PrinterDict.php b/niucloud/app/dict/sys/PrinterDict.php new file mode 100644 index 000000000..a2b4be8d8 --- /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/install/controller/Index.php b/niucloud/app/install/controller/Index.php index a4fd7f7a2..003dfb288 100644 --- a/niucloud/app/install/controller/Index.php +++ b/niucloud/app/install/controller/Index.php @@ -152,16 +152,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); diff --git a/niucloud/app/install/source/database.sql b/niucloud/app/install/source/database.sql index c7c802490..33f32f75d 100644 --- a/niucloud/app/install/source/database.sql +++ b/niucloud/app/install/source/database.sql @@ -22,6 +22,7 @@ CREATE TABLE `addon` ( 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` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -33,6 +34,7 @@ CREATE TABLE `addon_log` ( 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 '主键', @@ -44,6 +46,7 @@ CREATE TABLE `applet_site_version` ( 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 '主键', @@ -63,6 +66,7 @@ CREATE TABLE `applet_version` ( 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` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -81,7 +85,8 @@ CREATE TABLE `diy_page` ( `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 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 `diy_route`; CREATE TABLE `diy_route` ( @@ -96,6 +101,7 @@ CREATE TABLE `diy_route` ( 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', @@ -125,6 +131,7 @@ CREATE TABLE `generate_column` ( 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` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -142,6 +149,7 @@ CREATE TABLE `generate_table` ( 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, @@ -154,6 +162,7 @@ CREATE TABLE `jobs` ( 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` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -165,6 +174,7 @@ CREATE TABLE `jobs_failed` ( 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 '主键', @@ -174,7 +184,7 @@ CREATE TABLE `member` ( `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_label` varchar(255) NOT NULL DEFAULT '' COMMENT '会员标签', @@ -221,6 +231,7 @@ CREATE TABLE `member` ( 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, @@ -236,31 +247,29 @@ CREATE TABLE `member_account_log` ( 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 UNSIGNED NOT NULL AUTO_INCREMENT, - member_id int NOT NULL DEFAULT 0 COMMENT '会员id', - site_id int NOT NULL DEFAULT 0 COMMENT '站点id', - 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 = '会员收货地址'; + `id` int UNSIGNED NOT NULL AUTO_INCREMENT, + `member_id` int NOT NULL DEFAULT 0 COMMENT '会员id', + `site_id` int NOT NULL DEFAULT 0 COMMENT '站点id', + `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, @@ -282,9 +291,9 @@ CREATE TABLE `member_cash_out` ( `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 '备注', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '申请时间', - `refuse_reason` varchar(100) NOT NULL DEFAULT '' 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 '取消时间', @@ -292,6 +301,7 @@ CREATE TABLE `member_cash_out` ( 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, @@ -306,6 +316,7 @@ CREATE TABLE `member_cash_out_account` ( 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', @@ -319,6 +330,7 @@ CREATE TABLE `member_label` ( 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` ( `level_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '会员等级', @@ -332,7 +344,8 @@ CREATE TABLE `member_level` ( `level_benefits` text COMMENT '等级权益', `level_gifts` text COMMENT '等级礼包', PRIMARY KEY (`level_id`) USING BTREE -) 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 `member_sign`; CREATE TABLE `member_sign` ( @@ -347,7 +360,8 @@ 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` ( @@ -374,6 +388,7 @@ CREATE TABLE `pay` ( 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` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -388,6 +403,7 @@ CREATE TABLE `pay_channel` ( 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` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -411,7 +427,8 @@ CREATE TABLE `pay_refund` ( `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; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '退款记录表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `pay_transfer`; CREATE TABLE `pay_transfer` ( @@ -440,6 +457,7 @@ CREATE TABLE `pay_transfer` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '转账表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `recharge_order`; CREATE TABLE `recharge_order` ( `order_id` int(11) NOT NULL AUTO_INCREMENT, @@ -467,6 +485,7 @@ CREATE TABLE `recharge_order` ( PRIMARY KEY (`order_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `recharge_order_item`; CREATE TABLE `recharge_order_item` ( `order_item_id` int(11) NOT NULL AUTO_INCREMENT, @@ -487,6 +506,7 @@ CREATE TABLE `recharge_order_item` ( PRIMARY KEY (`order_item_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单商品表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `recharge_order_item_refund`; CREATE TABLE `recharge_order_item_refund` ( `refund_id` int(11) NOT NULL AUTO_INCREMENT, @@ -506,6 +526,7 @@ CREATE TABLE `recharge_order_item_refund` ( PRIMARY KEY (`refund_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单退款表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `recharge_order_log`; CREATE TABLE `recharge_order_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -521,6 +542,7 @@ CREATE TABLE `recharge_order_log` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单操作记录表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `site`; CREATE TABLE `site` ( `site_id` int(11) NOT NULL AUTO_INCREMENT, @@ -547,13 +569,14 @@ CREATE TABLE `site` ( `front_end_icon` varchar(255) NOT NULL DEFAULT '' COMMENT '前台icon', `icon` varchar(255) NOT NULL DEFAULT '' COMMENT '网站图标', `member_no` varchar(255) NOT NULL DEFAULT '0' COMMENT '最大会员码值', - `app` text NOT NULL COMMENT '站点主应用', + `app` text NOT NULL COMMENT '站点应用', `addons` text NOT NULL COMMENT '站点包含的插件', `initalled_addon` text DEFAULT NULL COMMENT '站点已执行初始化方法的插件', `site_domain` varchar(255) NOT NULL DEFAULT '' COMMENT '站点域名', PRIMARY KEY (`site_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 10000 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '站点表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `site_account_log`; CREATE TABLE `site_account_log` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -565,6 +588,7 @@ CREATE TABLE `site_account_log` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '站点账单记录' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `site_group`; CREATE TABLE `site_group` ( `group_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '分组ID', @@ -577,6 +601,7 @@ CREATE TABLE `site_group` ( PRIMARY KEY (`group_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` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, @@ -614,7 +639,7 @@ 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` ( @@ -628,6 +653,7 @@ CREATE TABLE `sys_agreement` ( 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, @@ -642,6 +668,7 @@ CREATE TABLE `sys_area` ( 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, @@ -660,6 +687,7 @@ CREATE TABLE `sys_attachment` ( 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, @@ -673,6 +701,7 @@ CREATE TABLE `sys_attachment_category` ( 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 '主键', @@ -686,6 +715,7 @@ CREATE TABLE `sys_config` ( 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, @@ -708,6 +738,7 @@ CREATE TABLE `sys_cron_task` ( 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', @@ -718,7 +749,8 @@ CREATE TABLE `sys_dict` ( `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; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `sys_export`; CREATE TABLE `sys_export` ( @@ -732,7 +764,8 @@ CREATE TABLE `sys_export` ( `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; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '导出报表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `verifier`; CREATE TABLE `verifier` ( @@ -743,7 +776,8 @@ CREATE TABLE `verifier` ( `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; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '核销员表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `verify`; CREATE TABLE `verify` ( @@ -758,7 +792,8 @@ CREATE TABLE `verify` ( `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; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '核销记录' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `sys_menu`; CREATE TABLE `sys_menu` ( @@ -785,6 +820,7 @@ CREATE TABLE `sys_menu` ( 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, @@ -803,6 +839,7 @@ CREATE TABLE `sys_notice` ( 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', @@ -823,6 +860,7 @@ CREATE TABLE `sys_notice_log` ( 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', @@ -842,6 +880,7 @@ CREATE TABLE `sys_notice_sms_log` ( 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', @@ -854,6 +893,7 @@ CREATE TABLE `sys_role` ( 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 UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -868,7 +908,42 @@ CREATE TABLE `sys_poster` ( `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='海报表' ROW_FORMAT=DYNAMIC; +) 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, + `site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id', + `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, + `site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id', + `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` ( @@ -888,6 +963,7 @@ CREATE TABLE `sys_schedule` ( 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', @@ -907,6 +983,7 @@ CREATE TABLE `sys_user` ( 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', @@ -921,6 +998,7 @@ CREATE TABLE `sys_user_log` ( 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, @@ -933,6 +1011,7 @@ CREATE TABLE `sys_user_role` ( 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, @@ -948,7 +1027,8 @@ CREATE TABLE `weapp_version` ( `from_type` VARCHAR(255) NOT NULL DEFAULT 'cloud_build', `auditid` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '小程序版本' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `wechat_fans`; CREATE TABLE `wechat_fans` ( @@ -975,6 +1055,7 @@ CREATE TABLE `wechat_fans` ( 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, @@ -987,6 +1068,7 @@ CREATE TABLE `wechat_media` ( 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 UNSIGNED NOT NULL AUTO_INCREMENT, @@ -1004,6 +1086,7 @@ CREATE TABLE `wechat_reply` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '公众号消息回调表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `wx_oplatfrom_weapp_version`; CREATE TABLE `wx_oplatfrom_weapp_version` ( `id` INT(11) NOT NULL AUTO_INCREMENT, @@ -1018,10 +1101,8 @@ CREATE TABLE `wx_oplatfrom_weapp_version` ( `create_time` INT(11) NOT NULL DEFAULT 0, `update_time` INT(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) -ENGINE = INNODB, -CHARACTER SET utf8mb4, -COLLATE utf8mb4_general_ci; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信小程序开发平台版本表' ROW_FORMAT = Dynamic; + DROP TABLE IF EXISTS `user_create_site_limit`; CREATE TABLE `user_create_site_limit` ( @@ -1031,17 +1112,14 @@ CREATE TABLE `user_create_site_limit` ( `num` INT(11) NOT NULL DEFAULT 0, `month` INT(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) -ENGINE = INNODB, -CHARACTER SET utf8mb4, -COLLATE utf8mb4_general_ci; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户站点创建限制表' ROW_FORMAT = Dynamic; INSERT INTO `site`(site_id, site_name, group_id, keywords, app_type, logo, `desc`, status, latitude, longitude, province_id, city_id, district_id, address, full_address, phone, business_hours, create_time, expire_time, front_end_name, front_end_logo, front_end_icon, icon, member_no, app, addons, initalled_addon, site_domain) VALUES (1, 'niucloud-admin', 0, '', 'admin', '', '', 1, '', '', 0, 0, 0, '', '', '', '', 0, 0, '', '', '', '', '0', '', '', '', ''); UPDATE `site` SET site_id = 0 WHERE site_id = 1; -INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0'); +-- INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0'); INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1', '1'); diff --git a/niucloud/app/job/member/SetMemberNoJob.php b/niucloud/app/job/member/SetMemberNoJob.php new file mode 100644 index 000000000..c393d3532 --- /dev/null +++ b/niucloud/app/job/member/SetMemberNoJob.php @@ -0,0 +1,27 @@ + '用户不存在', 'NO_SITE_USER_ROLE' => '用户不存在关联权限', 'ADMIN_NOT_ALLOW_EDIT_ROLE' => '超级管理员不允许改动权限', - 'USERNAME_REPEAT' => '用户名重复', + 'USERNAME_REPEAT' => '账号重复', 'SITE_USER_EXIST' => '该用户已存在', //角色管理 @@ -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..f721c7f87 100644 --- a/niucloud/app/lang/zh-cn/dict.php +++ b/niucloud/app/lang/zh-cn/dict.php @@ -232,6 +232,7 @@ return [ 'member_my_level' => '会员等级', 'member_my_sign_in' => '我的签到', 'member_verify_index' => '核销台', + 'member_contact' => '客服', 'diy_page' => '自定义页面', 'diy_link' => '自定义链接', @@ -239,7 +240,7 @@ return [ 'diy_make_phone_call' => '拨打电话' ], // 自定义海报 - 'dict_diy_poster'=>[ + 'dict_diy_poster' => [ 'component_type_basic' => '基础组件', ], //短信相关 @@ -379,4 +380,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 cc3325ae5..047d75657 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/MemberRegisterListener.php b/niucloud/app/listener/member/MemberRegisterListener.php index 8f52c90f7..522487f55 100644 --- a/niucloud/app/listener/member/MemberRegisterListener.php +++ b/niucloud/app/listener/member/MemberRegisterListener.php @@ -15,7 +15,7 @@ use app\service\core\member\CoreMemberService; /** * 会员注册成功事件 - * Class MemberRegister + * Class MemberRegisterListener * @package app\listener\member */ class MemberRegisterListener diff --git a/niucloud/app/listener/system/Poster.php b/niucloud/app/listener/system/Poster.php index 22201120a..0a67e710c 100644 --- a/niucloud/app/listener/system/Poster.php +++ b/niucloud/app/listener/system/Poster.php @@ -40,7 +40,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 69ad3f550..2803d1f44 100644 --- a/niucloud/app/model/addon/Addon.php +++ b/niucloud/app/model/addon/Addon.php @@ -76,7 +76,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..25dca1927 100644 --- a/niucloud/app/model/dict/Dict.php +++ b/niucloud/app/model/dict/Dict.php @@ -54,7 +54,7 @@ class Dict extends BaseModel */ public function searchNameAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where("name", $value); } } @@ -66,7 +66,7 @@ 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 92c6e4c38..7edb19ba4 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 66a627b8e..afa6cd793 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 2f7469794..7f9017c65 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 a03818c21..0daa209b9 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 7ff6afe59..323d03fad 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 c40fe2aeb..9039d4219 100644 --- a/niucloud/app/model/member/MemberLevel.php +++ b/niucloud/app/model/member/MemberLevel.php @@ -63,7 +63,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/site/Site.php b/niucloud/app/model/site/Site.php index d1f2527a2..876d214d7 100644 --- a/niucloud/app/model/site/Site.php +++ b/niucloud/app/model/site/Site.php @@ -72,8 +72,8 @@ class Site extends BaseModel */ public function searchKeywordsAttr($query, $value, $data) { - if ($value) { - $query->where('site_name|keywords', 'like', '%' . $value . '%'); + if ($value != '') { + $query->where('site_name|keywords', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } @@ -86,8 +86,8 @@ class Site extends BaseModel */ public function searchSiteDomainAttr($query, $value, $data) { - if ($value) { - $query->where('site_domain', 'like', '%' . $value . '%'); + if ($value != '') { + $query->where('site_domain', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } @@ -99,7 +99,7 @@ class Site extends BaseModel */ public function searchAppAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where('app', 'like', '%"' . $value . '"%'); } } diff --git a/niucloud/app/model/site/SiteAccountLog.php b/niucloud/app/model/site/SiteAccountLog.php index b87b5f242..a514a46e8 100644 --- a/niucloud/app/model/site/SiteAccountLog.php +++ b/niucloud/app/model/site/SiteAccountLog.php @@ -97,7 +97,7 @@ class SiteAccountLog extends BaseModel public function searchTradeNoAttr($query, $value, $data) { - if ($value) { + if ($value != '') { $query->where('trade_no', 'like', "%$value%"); } } diff --git a/niucloud/app/model/site/SiteGroup.php b/niucloud/app/model/site/SiteGroup.php index 5a3b50aca..6885527cf 100644 --- a/niucloud/app/model/site/SiteGroup.php +++ b/niucloud/app/model/site/SiteGroup.php @@ -77,8 +77,8 @@ class SiteGroup extends BaseModel */ public function searchKeywordsAttr($query, $value, $data) { - if ($value) { - $query->where('group_name', 'like', '%' . $value . '%'); + if ($value != '') { + $query->where('group_name', 'like', '%' . $this->handelSpecialCharacter($value) . '%'); } } diff --git a/niucloud/app/model/sys/Poster.php b/niucloud/app/model/sys/Poster.php index dfd692ea6..025c99645 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 2e541b0ef..3d78fba9e 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 41a48e6da..9a2cf1f9f 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 19205e4b4..928ddd5e4 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..4ec10d75c --- /dev/null +++ b/niucloud/app/model/sys/SysPrinterTemplate.php @@ -0,0 +1,97 @@ +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/SysUser.php b/niucloud/app/model/sys/SysUser.php index 72b28b604..e52fef2fe 100644 --- a/niucloud/app/model/sys/SysUser.php +++ b/niucloud/app/model/sys/SysUser.php @@ -80,8 +80,8 @@ class SysUser extends BaseModel */ public function searchUsernameAttr($query, $value) { - if ($value) { - $query->whereLike('username', '%' . $value . '%'); + if ($value != '') { + $query->whereLike('username', '%' . $this->handelSpecialCharacter($value) . '%'); } } @@ -93,7 +93,7 @@ class SysUser extends BaseModel */ public function searchRealnameAttr($query, $value) { - if ($value) { + if ($value != '') { $query->whereLike('real_name', '%' . $value . '%'); } diff --git a/niucloud/app/model/sys/SysUserLog.php b/niucloud/app/model/sys/SysUserLog.php index 9eb831866..6defc7fee 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/sys/WxOplatfromWeappVersion.php b/niucloud/app/model/sys/WxOplatfromWeappVersion.php index b4dc8423b..8bae91dac 100644 --- a/niucloud/app/model/sys/WxOplatfromWeappVersion.php +++ b/niucloud/app/model/sys/WxOplatfromWeappVersion.php @@ -45,7 +45,7 @@ class WxOplatfromWeappVersion extends BaseModel */ public function getStatusNameAttr($value, $data) { - if (!isset($data['status']) || empty($data['status'])) return ''; + if (!isset($data['status'])) return ''; return CloudDict::getAppletUploadSatus($data['status']); } } diff --git a/niucloud/app/model/verify/Verify.php b/niucloud/app/model/verify/Verify.php index 2edf89930..c6dd1a650 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/model/wechat/WechatReply.php b/niucloud/app/model/wechat/WechatReply.php index 62213f1be..f5acf8b2a 100644 --- a/niucloud/app/model/wechat/WechatReply.php +++ b/niucloud/app/model/wechat/WechatReply.php @@ -11,7 +11,6 @@ namespace app\model\wechat; -use app\dict\channel\ReplyDict; use core\base\BaseModel; /** diff --git a/niucloud/app/service/admin/addon/AddonDevelopService.php b/niucloud/app/service/admin/addon/AddonDevelopService.php index 92d3e728c..4f23fb3f8 100644 --- a/niucloud/app/service/admin/addon/AddonDevelopService.php +++ b/niucloud/app/service/admin/addon/AddonDevelopService.php @@ -13,10 +13,8 @@ namespace app\service\admin\addon; use app\service\core\addon\CoreAddonDevelopBuildService; -use app\service\core\addon\CoreAddonDevelopDownloadService; use app\service\core\addon\CoreAddonDevelopService; use app\service\core\addon\CoreAddonService; -use app\service\core\niucloud\CoreAppService; use app\service\core\niucloud\CoreModuleService; use core\base\BaseAdminService; diff --git a/niucloud/app/service/admin/diy/DiyConfigService.php b/niucloud/app/service/admin/diy/DiyConfigService.php index 4cdc13bfe..36db928fe 100644 --- a/niucloud/app/service/admin/diy/DiyConfigService.php +++ b/niucloud/app/service/admin/diy/DiyConfigService.php @@ -37,7 +37,7 @@ class DiyConfigService extends BaseAdminService $site_addon = ( new CoreSiteService() )->getSiteCache($this->site_id); // 单应用,排除 系统 底部导航设置 - if (count($site_addon[ 'apps' ]) == 1) { + if (count($list) > 1 && count($site_addon[ '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 4ebe1e1ae..e6b15b2ff 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/vm/site_service.vm b/niucloud/app/service/admin/generator/vm/site_service.vm index b2ceef6ff..0d7b5d91c 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/install/InstallArticleService.php b/niucloud/app/service/admin/install/InstallArticleService.php deleted file mode 100644 index ba77f92e2..000000000 --- a/niucloud/app/service/admin/install/InstallArticleService.php +++ /dev/null @@ -1,81 +0,0 @@ -installArticle($params); - return true; - } - - /** - * 安装数据 - */ - public function installArticle(array $params = []) - { - $article_category = new ArticleCategory(); - $category = [ - 'site_id' => $params[ 'site_id' ], - 'name' => '资讯', - 'is_show' => 1, - 'create_time' => time() - ]; - $category_id = $article_category->insert($category); - - $article = new Article(); - $article_list = [ - [ - 'category_id' => $category_id, - 'site_id' => $params[ 'site_id' ], - 'title' => 'NiuCloud-admin介绍', - 'intro' => '', - 'summary' => '', - 'image' => 'static/resource/images/article/niucloud_admin_frame.png', - 'author' => 'NiuCloud', - 'content' => '

Niucloud-admin特点介绍


1.采用的技术栈

1.1 后台php采用thinkphp6+php8+mysql,支持composer快速安装扩展,支持redis缓存以及消息队列,支持多语言设计开发,同时开发采用严格的restful的api设计开发。

1.2 后台前后端分离采用element-plus、vue3.0、typescript、vite、pina等前端技术,同时使用i18n支持国际化多语言开发。

1.3 手机端采用uniapp前后端分离,同时使用uview、vue3.0、typescript、vite、pina等前端技术,同时使用i18n支持国际化多语言开发,可以灵活编译成h5,微信小程序,支付宝小程序,抖音小程序等使用场景。


2.技术特点

2.1niucloud-admin采用多租户的saas系统设计,能够提供企业级软件服务运营 ,同时满足用户多站点,多商户,多门店等系统开发需求。

2.2niucloud-admin结合当前市面上很多框架结构不规范,导致基础结构不稳定等情况,严格定义了分层设计的开发规范,同时api接口严格采用restful的开发规范,能够满足大型业务系统或者微服务的开发需求。

2.3 niucloud-admin前端以及后端采用严格的多语言开发规范,包括前端展示,api接口返回,数据验证,错误返回等全部使用多语言设计规范,使开发者能够真生意义上实现多语言的开发需求。

2.4 Niucloud-admin已经搭建好常规系统的开发底层,具体的底层功能包括:管理员管理,权限管理,网站设置,计划任务管理,素材管理,会员管理,会员账户管理,微信公众号以及小程序管理,支付管理,第三方登录管理,消息管理,短信管理,文章管理,前端装修等全面的基础功能,这样开发者不需要开发基础的结构而专心开发业务。

2.5 niucloud-admin系统内置支持微信/支付宝支付,微信公众号/小程序/短信消息管理,阿里云/腾讯云短信,七牛云/阿里云存储等基础的功能扩展,后续会根据实际业务不断扩展基础组件。

2.6 niucloud-admin结合系统结构特点专门开发了代码生成器,这样开发者根据数据表就可以一键生成基础的业务代码,包括:后台php业务代码以及对应的前端vue代码。

2.7 前端采用标准的element-plus,开发者不需要详细了解前端,只需要用标准的element组件就可以。

2.8  手机端设计开发了自定义装修,同时提供了基础的开发组件,方便开发者设计开发手机自定义页面装修的开发需求。

2.9  手机端使用uniapp ,同时使用uview页面展示,可以开发出丰富的手机样式,同时不需要专门学习小程序,app等开发语言,只需要通过uniapp编译就可以。

', - 'is_show' => 1, - 'create_time' => time() - ], - [ - 'category_id' => $category_id, - 'site_id' => $params[ 'site_id' ], - 'title' => 'NiuCloud-admin 开发者联盟', - 'intro' => 'Niucloud-admin 开发者联盟招募', - 'summary' => '', - 'image' => 'static/resource/images/article/niucloud_admin_developer.png', - 'author' => 'NiuCloud', - 'content' => '

Niucloud-admin 开发者联盟招募

近几年,我们看到很多企业都在做自己的研发,有的是企业和内部使用,有的是帮助别人定制开发,也有的已经成功走向商业化,对软件开发的学习和钻研成为了行业圈内发展很有前景的方向。同时我们也看到,大家的开发之路都多多少少遇到了各自的瓶颈。或者是接触不到真实项目需求、只能闭门造车;或者是产品研发出来,没有变现的销路;或者技术遇到了瓶颈,没办法走的更深入;或者几个人自己钻研,水平提升很慢。无论属于哪种,亲爱的开发者,如果你也正在为自己怀才不遇无处施展,或者感觉优质的技术内容没有让更多的人知道而苦恼,那么现在,机会来啦~~niucloud-admin框架为你提供优质平台,公开招募开发爱好者。今天,大牛哥把一大波福利搬来,希望可以在学习、交流和市场拓展等方面帮助大家。在针对那些想提高技术水平的个人或团队,想要基于niucloud-admin框架开发自己的产品的伙伴 ,联盟会免费提供一些列的培训或辅导答疑。针对那些渴望交流、认识同路人的小伙伴,会有线上交流会让大家互通想法、互相引荐高人。

说了这么多,那么niucloud-admin到底是什么呢?且听小编来介绍~

Niucloud-admin是一款快速开发通用管理后台框架,前端采用最新的技术栈Vite+TypeScript+Vue3+ElementPlus最流行技术架构,后台结合PHP8、Java SDK、Python等主流后端语言搭建,内置集成用户权限、代码生成器、表单设计、云存储、短信发送、素材中心、微信及公众号、Api模块一系列开箱即用功能,是一款快速可以开发企业级应用的软件系统。

听完介绍是不是都有点马上可以从小白变成大牛的感觉了,“开箱即用”,那不是小白都可以开发出属于自己的插件了吗?对,你没听错~ 具体怎么生成,那就赶快加入niucloud-admin开发者联盟来亲身体验下吧~~

有态度,有深度,niucloud-admin咱们下次见~

', - 'is_show' => 1, - 'create_time' => time() - ] - ]; - $article->insertAll($article_list); - - return true; - } - -} \ No newline at end of file diff --git a/niucloud/app/service/admin/member/MemberAccountService.php b/niucloud/app/service/admin/member/MemberAccountService.php index 9334e763e..4695815ff 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.site_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->where([ [ 'member_account_log.site_id', '=', $this->site_id ] ])->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/MemberCashOutConfigService.php b/niucloud/app/service/admin/member/MemberCashOutConfigService.php deleted file mode 100644 index c10d26de8..000000000 --- a/niucloud/app/service/admin/member/MemberCashOutConfigService.php +++ /dev/null @@ -1,38 +0,0 @@ -model = new MemberCashOut(); - } - - - public function getConfig(){ - return (new CoreMemberCashOutConfigService())->getMemberCashOutConfig($this->site_id); - } - - public function setConfig(array $data){ - (new CoreMemberCashOutConfigService())->setMemberCashOutConfig($this->site_id, $data); - return true; - } -} \ No newline at end of file diff --git a/niucloud/app/service/admin/member/MemberService.php b/niucloud/app/service/admin/member/MemberService.php index 40a65f4c4..cf73d0e32 100644 --- a/niucloud/app/service/admin/member/MemberService.php +++ b/niucloud/app/service/admin/member/MemberService.php @@ -116,7 +116,7 @@ class MemberService extends BaseAdminService $password_hash = create_password($data['password']); $data['password'] = $password_hash; $data['register_type'] = MemberRegisterTypeDict::MANUAL; - $data['register_channel'] = MemberRegisterChannelDict::MANUAL;//todo 公共化渠道 + $data['register_channel'] = MemberRegisterChannelDict::MANUAL; // todo 公共化渠道 $member = $this->model->create($data); $data['member_id'] = $member->member_id; diff --git a/niucloud/app/service/admin/member/MemberSignService.php b/niucloud/app/service/admin/member/MemberSignService.php index f69738958..b2868761b 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.site_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)->where([['member_sign.site_id', '=', $this->site_id]])->withJoin(["member" => ['member_no', 'mobile', 'nickname', 'headimg']])->field($field)->append(['is_sign_name'])->order('member_sign.create_time desc'); diff --git a/niucloud/app/service/admin/notice/SmsService.php b/niucloud/app/service/admin/notice/SmsService.php index 1aef65c5a..7ade5e2b6 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 c4cce8d3a..ceacc70fa 100644 --- a/niucloud/app/service/admin/pay/PayChannelService.php +++ b/niucloud/app/service/admin/pay/PayChannelService.php @@ -156,6 +156,8 @@ class PayChannelService extends BaseAdminService 'collection_desc' => $data[ 'collection_desc' ] ?? '',// 必填-转账说明 ]; break; + default: + $config = $data; } return $config; } diff --git a/niucloud/app/service/admin/site/SiteUserService.php b/niucloud/app/service/admin/site/SiteUserService.php index 84ba4b12c..ba16d51a8 100644 --- a/niucloud/app/service/admin/site/SiteUserService.php +++ b/niucloud/app/service/admin/site/SiteUserService.php @@ -49,9 +49,9 @@ class SiteUserService extends BaseAdminService ->with('userinfo')->append(['status_name']) ->hasWhere('userinfo', function ($query) use ($where) { $condition = []; - if (!empty($where['username'])) $condition[] = ['username', 'like', "%{$where['username']}%"]; + if (isset($where['username']) && $where['username'] !== '') $condition[] = ['username', 'like', "%{$this->model->handelSpecialCharacter($where['username'])}%"]; $query->where($condition); - })->where([ ['SysUserRole.site_id', '=', $this->site_id ] ]); + })->where([ ['SysUserRole.site_id', '=', $this->site_id ], ['is_admin', '=', 0 ] ]); return $this->pageQuery($search_model, function ($item){ if (!empty($item['role_ids'])) { $item['role_array'] = (new SysRole())->where([ ['role_id', 'in', $item['role_ids'] ] ])->column('role_name'); diff --git a/niucloud/app/service/admin/sys/AttachmentService.php b/niucloud/app/service/admin/sys/AttachmentService.php index 4a4498228..0388f4137 100644 --- a/niucloud/app/service/admin/sys/AttachmentService.php +++ b/niucloud/app/service/admin/sys/AttachmentService.php @@ -243,8 +243,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(); } @@ -259,7 +259,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 ]); } } diff --git a/niucloud/app/service/admin/sys/ConfigService.php b/niucloud/app/service/admin/sys/ConfigService.php index af02b537e..c68a0f53a 100644 --- a/niucloud/app/service/admin/sys/ConfigService.php +++ b/niucloud/app/service/admin/sys/ConfigService.php @@ -165,42 +165,6 @@ class ConfigService extends BaseAdminService return $info[ 'value' ]; } - /** - * 设置站点快捷菜单 - * @param $data - * @return bool - */ - public function setShortcutMenu($data) - { - ( new CoreConfigService() )->setConfig($this->site_id, 'shortcut_menu', $data); - return true; - } - - /** - * 获取站点快捷菜单 - * @return array|mixed - */ - public function getShortcutMenu() - { - $config = ( new CoreConfigService() )->getConfig($this->site_id, '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; - } - /** * 获取手机端首页列表 * @param $data diff --git a/niucloud/app/service/admin/sys/PrinterService.php b/niucloud/app/service/admin/sys/PrinterService.php new file mode 100644 index 000000000..aa3d30d8d --- /dev/null +++ b/niucloud/app/service/admin/sys/PrinterService.php @@ -0,0 +1,253 @@ +model = new SysPrinter(); + } + + /** + * 获取小票打印机分页列表 + * @param array $where + * @return array + * @throws \think\db\exception\DbException + */ + public function getPage(array $where = []) + { + $field = 'printer_id,site_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([ [ 'site_id', "=", $this->site_id ] ])->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,site_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,site_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(); + + $data[ 'site_id' ] = $this->site_id; + $res = $this->model->create($data); + + // 绑定易联云设备授权 + if ($data[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $result = ( new CorePrinterService() )->addPrinterYly($this->site_id, $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($this->site_id, $data); + if ($result[ 'code' ] != 0) { + Db::rollback(); + throw new CommonException($result[ 'message' ]); + } + } + + $this->model->where([ [ 'printer_id', '=', $id ], [ 'site_id', '=', $this->site_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' ] ], + [ 'site_id', '=', $this->site_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([ [ 'site_id', '=', $this->site_id ], [ 'printer_id', "=", $printer_id ] ])->findOrEmpty()->toArray(); + + // 删除易联云打印机授权 + if ($printer_info[ 'brand' ] == PrinterDict::YI_LIAN_YUN) { + $result = ( new CorePrinterService() )->deletePrinterYly($this->site_id, $printer_info); + if ($result[ 'code' ] != 0) { + Db::rollback(); + throw new CommonException($result[ 'message' ]); + } + } + + $model = $this->model->where([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $this->site_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($this->site_id, $data); + } + + /** + * 获取易联云配置 + * @return array + */ + public function getYlyTokenConfig() + { + return ( new CorePrinterService() )->getYlyTokenConfig($this->site_id); + } + + /** + * 重新获取易联云token + * @param $printer_id + * @return mixed + */ + public function refreshToken($printer_id) + { + return ( new CorePrinterService() )->refreshToken($this->site_id, $printer_id); + } + + /** + * 测试打印 + * @param $printer_id + * @return array + */ + public function testPrint($printer_id) + { + return ( new CorePrinterService() )->testPrint($this->site_id, $printer_id); + } + + /** + * 打印小票内容 + * @param $params + */ + public function printTicket($params) + { + $params[ 'site_id' ] = $this->site_id; + 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..9770b9c95 --- /dev/null +++ b/niucloud/app/service/admin/sys/PrinterTemplateService.php @@ -0,0 +1,136 @@ +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([ [ 'site_id', "=", $this->site_id ] ])->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([ [ 'site_id', "=", $this->site_id ] ])->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,site_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) + { + $data[ 'site_id' ] = $this->site_id; + $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 ], [ 'site_id', '=', $this->site_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([ + [ 'site_id', '=', $this->site_id ], + [ '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 ], [ 'site_id', '=', $this->site_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 b09ae5801..44d21e175 100644 --- a/niucloud/app/service/admin/sys/RoleService.php +++ b/niucloud/app/service/admin/sys/RoleService.php @@ -14,6 +14,7 @@ namespace app\service\admin\sys; use app\dict\sys\RoleStatusDict; use app\model\sys\SysRole; use app\model\sys\SysUserRole; +use app\service\admin\auth\AuthService; use app\service\admin\site\SiteService; use core\base\BaseAdminService; use core\exception\AdminException; @@ -44,8 +45,8 @@ class RoleService extends BaseAdminService public function getPage(array $data) { $where = [['site_id', '=', $this->site_id]]; - 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']); @@ -73,7 +74,33 @@ class RoleService extends BaseAdminService ['site_id', '=', $this->site_id], ['status', '=', 1] ); - return $this->model->where($where)->field('role_id,role_name,status,create_time')->select()->toArray(); + $site_role_all = $this->model->where($where)->field('role_id,role_name,rules,status,create_time')->select()->toArray(); + foreach ($site_role_all as $key => $value) { + $site_role_all[$key]['disabled'] = false; + } + if (AuthService::isSuperAdmin()) { + $is_admin = 1; + } else { + $user_role_info = (new AuthService())->getAuthRole($this->site_id); + if(empty($user_role_info)) + return []; + $is_admin = $user_role_info['is_admin'];//是否是超级管理员组 + } + + if (!$is_admin) { + $user_role_ids = $user_role_info['role_ids']; + $role_service = new RoleService(); + $menu_keys = $role_service->getMenuIdsByRoleIds($this->site_id, $user_role_ids); + foreach ($site_role_all as $key => $value) { + if (!empty(array_diff($value['rules'], $menu_keys))) { + $site_role_all[$key]['disabled'] = true; + } + } + } + foreach ($site_role_all as &$value) { + unset($value['rules']); + } + return $site_role_all; } /** diff --git a/niucloud/app/service/admin/upgrade/BackupService.php b/niucloud/app/service/admin/upgrade/BackupService.php index 5417f9217..b265e4aeb 100644 --- a/niucloud/app/service/admin/upgrade/BackupService.php +++ b/niucloud/app/service/admin/upgrade/BackupService.php @@ -14,7 +14,6 @@ namespace app\service\admin\upgrade; use app\dict\addon\AddonDict; use app\service\admin\generator\GenerateService; use core\util\DbBackup; -use core\util\niucloud\BaseNiucloudClient; /** * 框架及插件升级备份 diff --git a/niucloud/app/service/admin/user/UserService.php b/niucloud/app/service/admin/user/UserService.php index 03dbe4b1f..cc3863d78 100644 --- a/niucloud/app/service/admin/user/UserService.php +++ b/niucloud/app/service/admin/user/UserService.php @@ -14,6 +14,7 @@ namespace app\service\admin\user; use app\dict\sys\AppTypeDict; use app\dict\sys\UserDict; +use app\model\sys\SysRole; use app\model\sys\SysUser; use app\model\sys\SysUserRole; use app\model\sys\UserCreateSiteLimit; @@ -282,6 +283,29 @@ class UserService extends BaseAdminService ->toArray(); } + /** + * 获取可选站点管理员(用于站点添加) + * @param array $where + * @return array + */ + public function getUserSelect(array $where) + { + $field = 'SysUser.uid, username, head_img'; + $all_uid = array_column($this->getUserAll($where), 'uid'); + $all_role_uid = (new SysUserRole())->distinct(true)->order('id desc')->select()->column('uid'); + $data = $this->model->distinct(true)->hasWhere('userrole', function ($query) { + $query->where([['is_admin', '=', 1]])->whereOr([['site_id', '=', 0]]); + })->withSearch(['username', 'realname', 'create_time'], $where) + ->field($field) + ->order('SysUser.uid desc') + ->select() + ->toArray(); + $uids = array_diff($all_uid, $all_role_uid); + $diff_users = $this->model->where([['uid', 'in', $uids]])->withSearch(['username', 'realname', 'create_time'], $where) + ->field('uid, username, head_img')->order('uid desc')->select()->toArray(); + return array_merge($diff_users, $data); + } + /** * 获取用户站点创建限制 * @param int $uid diff --git a/niucloud/app/service/admin/weapp/WeappDeliveryService.php b/niucloud/app/service/admin/weapp/WeappDeliveryService.php index 6782ab350..29b9725c8 100644 --- a/niucloud/app/service/admin/weapp/WeappDeliveryService.php +++ b/niucloud/app/service/admin/weapp/WeappDeliveryService.php @@ -11,17 +11,9 @@ namespace app\service\admin\weapp; -use app\dict\notice\NoticeTypeDict; -use app\service\admin\notice\NoticeService; -use app\service\core\notice\CoreNoticeService; use app\service\core\weapp\CoreWeappDeliveryService; use core\base\BaseAdminService; -use core\exception\NoticeException; -use core\template\TemplateLoader; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; -use think\db\exception\DataNotFoundException; -use think\db\exception\DbException; -use think\db\exception\ModelNotFoundException; /** * 小程序发货信息管理服务 diff --git a/niucloud/app/service/admin/weapp/WeappVersionService.php b/niucloud/app/service/admin/weapp/WeappVersionService.php index eb3e30636..586e11456 100644 --- a/niucloud/app/service/admin/weapp/WeappVersionService.php +++ b/niucloud/app/service/admin/weapp/WeappVersionService.php @@ -12,14 +12,11 @@ namespace app\service\admin\weapp; use app\dict\sys\CloudDict; -use app\dict\sys\FileDict; use app\service\core\site\CoreSiteService; use app\service\core\weapp\CoreWeappCloudService; use app\service\core\weapp\CoreWeappConfigService; use app\service\core\weapp\CoreWeappService; use core\base\BaseAdminService; -use app\dict\sys\StorageDict; -use app\service\core\upload\CoreUploadService; use app\model\weapp\WeappVersion; use core\exception\CommonException; @@ -94,7 +91,7 @@ class WeappVersionService extends BaseAdminService public function getPage(array $where = []) { $field = 'id, version, version_no, desc, create_time, status, fail_reason, task_key'; - $order = 'version_no desc'; + $order = 'create_time desc'; $where[] = ['site_id', '=', $this->site_id]; $search_model = $this->model->where($where)->field($field)->order($order)->append(['status_name']); return $this->pageQuery($search_model); diff --git a/niucloud/app/service/api/diy/DiyConfigService.php b/niucloud/app/service/api/diy/DiyConfigService.php index fae00cd3a..e7ddbf8ae 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 $site_addon = ( new CoreSiteService() )->getSiteCache($this->site_id); // 单应用,排除 系统 底部导航设置 - if (count($site_addon[ 'apps' ]) == 1) { + if (count($list) > 1 && count($site_addon[ 'apps' ]) == 1) { foreach ($list as $k => $v) { if ($v[ 'key' ] = 'app') { unset($list[ $k ]); @@ -44,7 +44,12 @@ class DiyConfigService extends BaseApiService } $list = array_values($list); } - return $list; + + $res = []; + foreach ($list as $k => $v) { + $res[] = $this->getBottomConfig($v[ 'key' ]); + } + return $res; } /** diff --git a/niucloud/app/service/api/login/AuthService.php b/niucloud/app/service/api/login/AuthService.php index 730ba029a..0071d92c1 100644 --- a/niucloud/app/service/api/login/AuthService.php +++ b/niucloud/app/service/api/login/AuthService.php @@ -26,8 +26,8 @@ use core\exception\AuthException; /** * 登录服务层 - * Class BaseService - * @package app\service + * Class AuthService + * @package app\service\api\login */ class AuthService extends BaseApiService { @@ -38,13 +38,15 @@ class AuthService extends BaseApiService $this->model = new Member(); } - public function checkSiteAuth(Request $request){ + public function checkSiteAuth(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, 'site_id' => $this->site_id]); - if($member_info->isEmpty()) + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id, 'site_id' => $this->site_id ]); + if ($member_info->isEmpty()) { throw new AuthException('MEMBER_NOT_EXIST', 401); + } } return true; } @@ -54,17 +56,18 @@ class AuthService extends BaseApiService * @param Request $request * @return void */ - public function checkChannel(Request $request) { + public function checkChannel(Request $request) + { $channel = $request->getChannel(); $site_id = $request->apiSiteId(); switch ($channel) { case ChannelDict::H5: - $is_open = (int)(new CoreH5Service())->getH5($site_id)['is_open']; + $is_open = (int) ( new CoreH5Service() )->getH5($site_id)[ 'is_open' ]; if (!$is_open) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); break; case ChannelDict::PC: - $is_open = (int)(new CorePcService())->getPc($site_id)['is_open']; + $is_open = (int) ( new CorePcService() )->getPc($site_id)[ 'is_open' ]; if (!$is_open) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); break; } @@ -75,13 +78,14 @@ class AuthService extends BaseApiService * @param Request $request * @return true */ - public function checkSite(Request $request){ + public function checkSite(Request $request) + { $site_id = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id - $site_info = (new CoreSiteService())->getSiteCache($site_id); - if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST', 403); + $site_info = ( new CoreSiteService() )->getSiteCache($site_id); + if (empty($site_info)) throw new AuthException('SITE_NOT_EXIST', 403); $rule = strtolower(trim($request->rule()->getRule())); - if($rule != 'site'){ - if ($site_info['status'] == SiteDict::CLOSE || $site_info['expire_time'] < time()) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); + if ($rule != 'site') { + if ($site_info[ 'status' ] == SiteDict::CLOSE || $site_info[ 'expire_time' ] < time()) throw new AuthException('SITE_CLOSE_NOT_ALLOW', 402); } $request->siteId($site_id); return true; @@ -93,28 +97,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($this->site_id, $mobile_code); - if(empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); + if (empty($mobile)) { + $result = ( new CoreWeappAuthService() )->getUserPhoneNumber($this->site_id, $mobile_code); + if (empty($result)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); if ($result[ 'errcode' ] != 0) throw new ApiException($result[ 'errmsg' ]); - $phone_info = $result['phone_info']; - $mobile = $phone_info['purePhoneNumber']; - if(empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); - }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, 'site_id' => $this->site_id]); - if($member->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST'); + $member = $member_service->findMemberInfo([ 'member_id' => $this->member_id, 'site_id' => $this->site_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, 'site_id' => $this->site_id]); - if(!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST'); + $mobile_member = $member_service->findMemberInfo([ 'mobile' => $mobile, 'site_id' => $this->site_id ]); + if (!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST'); // if(empty($mobile)) throw new AuthException('MOBILE_NEEDED');//必须填写 $member->save([ @@ -123,5 +128,4 @@ class AuthService extends BaseApiService return true; } - } diff --git a/niucloud/app/service/api/login/ConfigService.php b/niucloud/app/service/api/login/ConfigService.php new file mode 100644 index 000000000..5217fa1d2 --- /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 7bb1e6305..126ffbd24 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, 'site_id' => $this->site_id]); - 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 8ed2fa624..c1ecd55db 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; @@ -79,10 +79,10 @@ class RegisterService extends BaseApiService $member_id = ( new MemberService() )->add($data); $data[ 'member_id' ] = $member_id; event('MemberRegister', $data); - CoreMemberService::setMemberNo($this->site_id, $member_id); + SetMemberNoJob::dispatch([ 'site_id' => $this->site_id, 'member_id' => $member_id ]); } $member_info = $member_service->findMemberInfo([ 'member_id' => $member_id, 'site_id' => $this->site_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); } @@ -96,7 +96,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; @@ -125,7 +125,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, ); @@ -142,13 +142,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, 'site_id' => $this->site_id ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在 - $data = array ( + $data = array( 'mobile' => $mobile, ); return $this->register($mobile, $data, MemberRegisterTypeDict::MOBILE); @@ -185,13 +186,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, 'site_id' => $this->site_id ]); if (!$member->isEmpty()) { @@ -206,11 +210,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 617cff5bf..a11b86ad1 100644 --- a/niucloud/app/service/api/member/MemberAccountService.php +++ b/niucloud/app/service/api/member/MemberAccountService.php @@ -11,6 +11,7 @@ namespace app\service\api\member; +use app\dict\member\MemberAccountChangeTypeDict; use app\dict\member\MemberAccountTypeDict; use app\model\member\Member; use app\model\member\MemberAccountLog; @@ -40,16 +41,46 @@ class MemberAccountService extends BaseApiService { $where['member_id'] = $this->member_id; $field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo'; - $search_model = $this->model->where([['site_id', '=', $this->site_id]])->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([['site_id', '=', $this->site_id]])->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 = []) + { + $type_where = []; + switch ($where['amount_type']){ + case 'income': + $type_where = [ + ['account_data', '>', 0 ], + ]; + break; + case 'disburse': + $type_where = [ + ['account_data', '<', 0 ], + ]; + break; + default: + break; + } + $where['member_id'] = $this->member_id; + $field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo'; + $search_model = $this->model->where([['site_id', '=', $this->site_id]])->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['from_type']){ @@ -83,6 +114,7 @@ class MemberAccountService extends BaseApiService $where['member_id'] = $this->member_id; + $where['create_time'] = $data['create_time']; $field = 'id, member_id, site_id, account_type, account_data, account_sum, from_type, related_id, create_time, memo'; $search_model = $this->model->where([['site_id', '=', $this->site_id]])->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); @@ -136,4 +168,40 @@ class MemberAccountService extends BaseApiService 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 61de81ffb..84247dfbd 100644 --- a/niucloud/app/service/api/member/MemberLevelService.php +++ b/niucloud/app/service/api/member/MemberLevelService.php @@ -59,7 +59,7 @@ class MemberLevelService extends BaseApiService } } - $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/MemberSignService.php b/niucloud/app/service/api/member/MemberSignService.php index 9898a93c4..9289796d2 100644 --- a/niucloud/app/service/api/member/MemberSignService.php +++ b/niucloud/app/service/api/member/MemberSignService.php @@ -255,6 +255,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(); @@ -275,25 +276,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; } } @@ -302,6 +307,15 @@ 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([['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id]])->whereDay('create_time', $time)->findOrEmpty()->toArray(); @@ -315,7 +329,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' => [], + ]; + } } /** @@ -339,12 +365,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; diff --git a/niucloud/app/service/api/verify/VerifyService.php b/niucloud/app/service/api/verify/VerifyService.php index f553a5022..e7f6de380 100644 --- a/niucloud/app/service/api/verify/VerifyService.php +++ b/niucloud/app/service/api/verify/VerifyService.php @@ -82,7 +82,7 @@ class VerifyService extends BaseApiService ['site_id', '=', $this->site_id], ['verifier_member_id', '=', $this->member_id] ]) - ->withSearch(['code', 'type', 'create_time', 'relate_tag'], $data) + ->withSearch(['code', 'type', 'create_time', 'relate_tag', 'keyword'], $data) ->with([ 'member' => function($query){ $query->field('member_id, nickname, mobile, headimg'); diff --git a/niucloud/app/service/api/weapp/WeappAuthService.php b/niucloud/app/service/api/weapp/WeappAuthService.php index 1afeb7f5b..680dd9a09 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($this->site_id, $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, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'weapp_openid' => $openid, 'site_id' => $this->site_id ]); if ($member_info->isEmpty() && !empty($unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $unionid, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $unionid, 'site_id' => $this->site_id ]); 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($this->site_id, $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, 'site_id' => $this->site_id]); - if(!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 + $member_info = $member_service->findMemberInfo([ 'weapp_openid' => $openid, 'site_id' => $this->site_id ]); + if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 if (!empty($wx_unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $wx_unionid, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $wx_unionid, 'site_id' => $this->site_id ]); 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, 'site_id' => $this->site_id ]); + if (!$member->isEmpty()) throw new AuthException('MEMBER_OPENID_EXIST');//openid已存在 + + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id, 'site_id' => $this->site_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 c06a7adf8..05c4cca05 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($this->site_id, $url, $scopes)]; + return [ 'url' => $this->core_wechat_serve_service->authorization($this->site_id, $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, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid, 'site_id' => $this->site_id ]); if ($member_info->isEmpty() && !empty($unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $unionid, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $unionid, 'site_id' => $this->site_id ]); 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($this->site_id, $openid, ['avatar' => $avatar, 'nickname' => $nickname]); + $core_wechat_fans_service->edit($this->site_id, $openid, [ 'avatar' => $avatar, 'nickname' => $nickname ]); $member_service = new MemberService(); - $member_info = $member_service->findMemberInfo(['wx_openid' => $openid, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid, 'site_id' => $this->site_id ]); 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, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_openid' => $openid, 'site_id' => $this->site_id ]); if (!$member_info->isEmpty()) throw new AuthException('MEMBER_IS_EXIST');//账号已存在, 不能在注册 if (!empty($wx_unionid)) { - $member_info = $member_service->findMemberInfo(['wx_unionid' => $wx_unionid, 'site_id' => $this->site_id]); + $member_info = $member_service->findMemberInfo([ 'wx_unionid' => $wx_unionid, 'site_id' => $this->site_id ]); 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($this->site_id, $url); } - /** * 扫码登录 * @return array @@ -207,11 +215,29 @@ class WechatAuthService extends BaseApiService $data = array( 'channel' => $this->channel, ); - $key = (new CoreScanService())->scan($this->site_id, ScanDict::WECHAT_LOGIN, $data, 300); - $url = $this->core_wechat_serve_service->scan($this->site_id, $key, 300)['url'] ?? ''; + $key = ( new CoreScanService() )->scan($this->site_id, ScanDict::WECHAT_LOGIN, $data, 300); + $url = $this->core_wechat_serve_service->scan($this->site_id, $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, 'site_id' => $this->site_id ]); + if (!$member->isEmpty()) throw new AuthException('MEMBER_OPENID_EXIST');//openid已存在 + + $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id, 'site_id' => $this->site_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/core/addon/CoreAddonCloudService.php b/niucloud/app/service/core/addon/CoreAddonCloudService.php index e6b835a8a..58a68fdc5 100644 --- a/niucloud/app/service/core/addon/CoreAddonCloudService.php +++ b/niucloud/app/service/core/addon/CoreAddonCloudService.php @@ -224,10 +224,6 @@ class CoreAddonCloudService extends CoreCloudBaseService */ public function downloadAddon(string $addon, string $version) { $action_token = (new CoreModuleService())->getActionToken('download', ['data' => ['app_key' => $addon, 'version' => $version, 'product_key' => BaseNiucloudClient::PRODUCT ]]); - if (isset($action_token['code']) && $action_token['code'] != 1) { - if ($action_token['code'] == 401) $action_token = (new CoreModuleService())->getActionToken('download', ['data' => ['app_key' => $addon, 'version' => $version, 'product_key' => BaseNiucloudClient::PRODUCT]]); - if ($action_token['code'] != 1) throw new CommonException($action_token['msg']); - } $query = [ 'authorize_code' => $this->auth_code, @@ -265,10 +261,6 @@ class CoreAddonCloudService extends CoreCloudBaseService */ public function upgradeAddon(array $data = []) { $action_token = (new CoreModuleService())->getActionToken('upgrade', ['data' => $data ]); - if (isset($action_token['code']) && $action_token['code'] != 1) { - if ($action_token['code'] == 401) $action_token = (new CoreModuleService())->getActionToken('upgrade', ['data' => $data ]); - if ($action_token['code'] != 1) throw new CommonException($action_token['msg']); - } $query = [ 'authorize_code' => $this->auth_code, diff --git a/niucloud/app/service/core/addon/WapTrait.php b/niucloud/app/service/core/addon/WapTrait.php index 80bf6810c..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"; @@ -128,144 +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 .= " // 兼容轮播搜索组件-切换分类时,导致个人中心白屏 - 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 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 .= " // 监听页面加载完成\n"; + $content .= " diyGroup.onMounted();\n\n"; - $content .= " const tabbarAddonName = computed(() => {\n"; - $content .= " return useConfigStore().addon;\n"; - $content .= " })\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 .= " }, 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 .= " let topTabbarRef = ref(null);\n\n"; - - $content .= " // 页面onShow调用时,也会触发改方法\n"; - $content .= " const refresh = ()=>{\n"; - $content .= " nextTick(()=>{\n"; - $content .= " topTabbarRef.value?.refresh();\n"; - $content .= " });\n"; - $content .= " }\n\n"; - - $content .= " let scrollTop = ref(0)\n"; - $content .= " onPageScroll((e)=>{\n"; - $content .= " scrollTop.value = e.scrollTop;\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 f6b33b30a..e829947e4 100644 --- a/niucloud/app/service/core/diy/CoreDiyConfigService.php +++ b/niucloud/app/service/core/diy/CoreDiyConfigService.php @@ -28,15 +28,19 @@ class CoreDiyConfigService extends BaseCoreService { $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 +56,12 @@ class CoreDiyConfigService extends BaseCoreService public function getBottomConfig(int $site_id, 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($site_id, $config_key)[ 'value' ] ?? []; - if (!empty($default_config)) { if (!empty($info)) { $value = $info; diff --git a/niucloud/app/service/core/member/CoreMemberAccountService.php b/niucloud/app/service/core/member/CoreMemberAccountService.php index ca44c3733..6f19db7fd 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; @@ -63,7 +65,17 @@ class CoreMemberAccountService extends BaseCoreService //账户更新 if($account_data > 0) { - $account_type_get = $member_info[ $account_type."_get" ] + $account_data; + 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" ]; } diff --git a/niucloud/app/service/core/member/CoreMemberService.php b/niucloud/app/service/core/member/CoreMemberService.php index 5e0dcd32d..70ced5911 100644 --- a/niucloud/app/service/core/member/CoreMemberService.php +++ b/niucloud/app/service/core/member/CoreMemberService.php @@ -174,7 +174,7 @@ class CoreMemberService extends BaseCoreService */ public static function sendGrowth(int $site_id, int $member_id, string $key, array $param = []) { $config = (new CoreMemberConfigService())->getGrowthRuleConfig($site_id); - if (!isset($config[$key]) || !$config[$key]['is_use']) return true; + if (!isset($config[$key]) || empty($config[$key]) || !$config[$key]['is_use']) return true; $config = $config[$key]; @@ -208,7 +208,7 @@ class CoreMemberService extends BaseCoreService */ public static function sendPoint(int $site_id, int $member_id, string $key, array $param = []) { $config = (new CoreMemberConfigService())->getPointRuleConfig($site_id)['grant'] ?? []; - if (!isset($config[$key]) || !$config[$key]['is_use']) return true; + if (!isset($config[$key]) || empty($config[$key]) || !$config[$key]['is_use']) return true; $config = $config[$key]; @@ -276,7 +276,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]; @@ -301,7 +301,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]; @@ -326,7 +326,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]; @@ -351,7 +351,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]; @@ -376,7 +376,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/CoreCloudBuildService.php b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php index 76d203db4..571042476 100644 --- a/niucloud/app/service/core/niucloud/CoreCloudBuildService.php +++ b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php @@ -17,6 +17,7 @@ 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; use core\util\niucloud\CloudService; use think\facade\Cache; @@ -97,6 +98,8 @@ class CoreCloudBuildService extends BaseCoreService public function cloudBuild() { if ($this->build_task) throw new CommonException('CLOUD_BUILD_TASK_EXIST'); + $action_token = (new CoreModuleService())->getActionToken('cloudbuild', ['data' => [ 'product_key' => BaseNiucloudClient::PRODUCT ]]); + // 上传任务key $task_key = uniqid(); // 此次上传任务临时目录 @@ -129,7 +132,8 @@ class CoreCloudBuildService extends BaseCoreService $query = [ 'authorize_code' => $this->auth_code, - 'timestamp' => time() + 'timestamp' => time(), + 'token' => $action_token['data']['token'] ?? '' ]; $response = (new CloudService())->httpPost('cloud/build?' . http_build_query($query), [ 'multipart' => [ diff --git a/niucloud/app/service/core/pay/CorePayService.php b/niucloud/app/service/core/pay/CorePayService.php index 5eb1f710a..9196ed2a8 100644 --- a/niucloud/app/service/core/pay/CorePayService.php +++ b/niucloud/app/service/core/pay/CorePayService.php @@ -400,10 +400,10 @@ class CorePayService extends BaseCoreService $status = $params['status']; switch ($status) { case OnlinePayDict::SUCCESS://支付成功 - $this->paySuccess($site_id, [ + $this->paySuccess($site_id, array_merge([ 'out_trade_no' => $out_trade_no, 'type' => $type - ]); + ], $params)); break; case OnlinePayDict::CLOSED://支付关闭 $this->payClose($site_id, [ diff --git a/niucloud/app/service/core/poster/CorePosterService.php b/niucloud/app/service/core/poster/CorePosterService.php index 2e17ac1ad..737fa977b 100644 --- a/niucloud/app/service/core/poster/CorePosterService.php +++ b/niucloud/app/service/core/poster/CorePosterService.php @@ -139,6 +139,7 @@ class CorePosterService extends BaseCoreService $path = $dir . '/' . $file_path; //判断当前海报是否存在,存在直接返回地址,不存在的话则创建 + if (is_file($path)) { return $path; } else { diff --git a/niucloud/app/service/core/printer/CorePrinterService.php b/niucloud/app/service/core/printer/CorePrinterService.php new file mode 100644 index 000000000..f530c10ba --- /dev/null +++ b/niucloud/app/service/core/printer/CorePrinterService.php @@ -0,0 +1,329 @@ +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 + * @param $site_id + * @return \app\model\sys\SysConfig|bool|\think\Model + */ + public function setYlyTokenConfig($site_id, $data) + { + return ( new ConfigService() )->setConfig($site_id, 'PRINTER_YLY_TOKEN', $data); + } + + /** + * 获取易联云配置 + * @param $site_id + * @return array|mixed + */ + public function getYlyTokenConfig($site_id) + { + $info = ( new ConfigService() )->getConfig($site_id, 'PRINTER_YLY_TOKEN'); + if (empty($info)) { + $info = []; + $info[ 'value' ] = [ + 'access_token' => '', + 'end_time' => '0' // token有效期 + ]; + } + return $info[ 'value' ]; + } + + /** + * 获取易联云token + * @param $site_id + * @param $yly_config + * @param bool $refresh 是否主动刷新token + * @return mixed + */ + public function getYlyToken($site_id, $yly_config, $refresh = false) + { + // token 配置 + $config = $this->getYlyTokenConfig($site_id); + + 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($site_id, $token_data); + } else { + $access_token = $config[ 'access_token' ]; + } + return $access_token; + } + + /** + * 添加易联云打印机授权 + * @param $site_id + * @param $params + * @return mixed + */ + public function addPrinterYly($site_id, $params) + { + $yly_config = new YlyConfig($params[ 'open_id' ], $params[ 'apikey' ]); + $access_token = $this->getYlyToken($site_id, $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 $site_id + * @param $params + * @return mixed + */ + public function deletePrinterYly($site_id, $params) + { + $yly_config = new YlyConfig($params[ 'open_id' ], $params[ 'apikey' ]); + $access_token = $this->getYlyToken($site_id, $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 $site_id + * @param $printer_id + * @return mixed + */ + public function refreshToken($site_id, $printer_id) + { + $field = 'open_id,apikey'; + $info = ( new SysPrinter() )->field($field)->where([ [ 'site_id', '=', $site_id ], [ '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($site_id, $yly_config, true); + return $access_token; + } + + /** + * 测试打印 + * @param $site_id + * @param $printer_id + * @return mixed + */ + public function testPrint($site_id, $printer_id) + { + $field = 'printer_id,brand,printer_code,open_id,apikey'; + $info = ( new SysPrinter() )->field($field)->where([ [ 'site_id', '=', $site_id ], [ '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($site_id, $info); + return $res; + } + + } + + /** + * 测试易联云打印 + * @param $site_id + * @param $printer + */ + public function testYlyPrint($site_id, $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($site_id, $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($params[ 'site_id' ], $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 429879b55..4615bd2ed 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; + } } } + }); } diff --git a/niucloud/app/service/core/sys/CoreConfigService.php b/niucloud/app/service/core/sys/CoreConfigService.php index 6bd5dd6ff..332673a34 100644 --- a/niucloud/app/service/core/sys/CoreConfigService.php +++ b/niucloud/app/service/core/sys/CoreConfigService.php @@ -27,6 +27,7 @@ class CoreConfigService extends BaseCoreService parent::__construct(); $this->model = new SysConfig(); } + /** * 获取配置信息 * @param int $site_id @@ -36,8 +37,8 @@ class CoreConfigService extends BaseCoreService public function getConfig(int $site_id, string $key) { $where = array( - ['config_key', '=', $key], - ['site_id', '=', $site_id] + [ 'config_key', '=', $key ], + [ 'site_id', '=', $site_id ] ); return $this->model->where($where)->field('id,site_id,config_key,value,status,create_time,update_time')->findOrEmpty()->toArray(); } @@ -52,8 +53,8 @@ class CoreConfigService extends BaseCoreService public function setConfig(int $site_id, string $key, array $value) { $where = array( - ['config_key', '=', $key], - ['site_id', '=', $site_id] + [ 'config_key', '=', $key ], + [ 'site_id', '=', $site_id ] ); $data = array( 'site_id' => $site_id, @@ -61,11 +62,11 @@ class CoreConfigService extends BaseCoreService 'value' => $value, ); $info = $this->getConfig($site_id, $key); - if(empty($info)){ - $data['create_time'] = time(); + if (empty($info)) { + $data[ 'create_time' ] = time(); $res = $this->model->create($data); - }else{ - $data['update_time'] = time(); + } else { + $data[ 'update_time' ] = time(); $res = $this->model->where($where)->save($data); } @@ -82,8 +83,8 @@ class CoreConfigService extends BaseCoreService public function modifyStatus(int $site_id, int $status, string $key) { $where = array( - ['config_key', '=', $key], - ['site_id', '=', $site_id] + [ 'config_key', '=', $key ], + [ 'site_id', '=', $site_id ] ); $data = array( 'status' => $status, @@ -93,16 +94,16 @@ class CoreConfigService extends BaseCoreService /** * 返回config信息 + * @param int $site_id * @param string $key * @return array|mixed */ - public function getConfigValue(int $site_id, string $key) + public function getConfigValue(int $site_id, string $key) { $config_info = $this->getConfig($site_id, $key); - if(empty($config_info)) - { + if (empty($config_info)) { return []; } - return $config_info['value']; + return $config_info[ 'value' ]; } } diff --git a/niucloud/app/service/core/weapp/CoreWeappAuthService.php b/niucloud/app/service/core/weapp/CoreWeappAuthService.php index 9d34a4df1..ecae42c56 100644 --- a/niucloud/app/service/core/weapp/CoreWeappAuthService.php +++ b/niucloud/app/service/core/weapp/CoreWeappAuthService.php @@ -24,7 +24,6 @@ use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; class CoreWeappAuthService extends BaseCoreService { - /** * 网页授权 * @param int $site_id @@ -40,8 +39,8 @@ class CoreWeappAuthService extends BaseCoreService */ public function session(int $site_id, ?string $code) { - $config = (new CoreWeappConfigService())->getWeappConfig($site_id); - if ($config['is_authorization']) { + $config = ( new CoreWeappConfigService() )->getWeappConfig($site_id); + if ($config[ 'is_authorization' ]) { return CoreOplatformService::codeToSession($site_id, $code); } else { $utils = CoreWeappService::app($site_id)->getUtils(); @@ -59,24 +58,25 @@ class CoreWeappAuthService extends BaseCoreService * @throws DecryptException * @throws InvalidArgumentException */ - public function decryptData(int $site_id, string $session, string $iv, string $encrypted_data){ - + public function decryptData(int $site_id, string $session, string $iv, string $encrypted_data) + { $utils = CoreWeappService::app($site_id)->getUtils(); return $utils->decryptSession($session, $iv, $encrypted_data); } /** - * v + * 获取用户手机号 * @param int $site_id * @param string $code * @return \EasyWeChat\Kernel\HttpClient\Response|\Symfony\Contracts\HttpClient\ResponseInterface * @throws InvalidArgumentException * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ - public function getUserPhoneNumber(int $site_id,string $code){ + public function getUserPhoneNumber(int $site_id, string $code) + { $api = CoreWeappService::appApiClient($site_id); return $api->postJson('wxa/business/getuserphonenumber', [ - 'code' => (string)$code + 'code' => (string) $code ]); } } diff --git a/niucloud/app/service/core/weapp/CoreWeappCloudService.php b/niucloud/app/service/core/weapp/CoreWeappCloudService.php index 2b192ac2d..34fec1d88 100644 --- a/niucloud/app/service/core/weapp/CoreWeappCloudService.php +++ b/niucloud/app/service/core/weapp/CoreWeappCloudService.php @@ -12,14 +12,13 @@ namespace app\service\core\weapp; use app\dict\addon\AddonDict; -use app\dict\sys\CloudDict; use app\model\addon\Addon; -use app\model\weapp\WeappVersion; use app\service\core\addon\CoreAddonDevelopDownloadService; use app\service\core\addon\WapTrait; use app\service\core\niucloud\CoreCloudBaseService; -use app\service\core\site\CoreSiteService; +use app\service\core\niucloud\CoreModuleService; use core\exception\CommonException; +use core\util\niucloud\BaseNiucloudClient; use core\util\niucloud\CloudService; /** @@ -44,32 +43,36 @@ class CoreWeappCloudService extends CoreCloudBaseService use WapTrait; - public function __construct() - { - parent::__construct(); - $this->root_path = dirname(root_path()) . DIRECTORY_SEPARATOR; - $this->addon_path = root_path() . 'addon' . DIRECTORY_SEPARATOR; - $this->config['base_url'] = (string)url('/', [], '', true); - } + public function __construct() + { + parent::__construct(); + $this->root_path = dirname(root_path()) . DIRECTORY_SEPARATOR; + $this->addon_path = root_path() . 'addon' . DIRECTORY_SEPARATOR; + $this->config[ 'base_url' ] = (string) url('/', [], '', true); + } - public function setConfig($function) { - $this->config = array_merge($this->config, $function()); - return $this; - } + public function setConfig($function) + { + $this->config = array_merge($this->config, $function()); + return $this; + } /** * 上传小程序 * @param $addon */ - public function uploadWeapp(array $data) { - if (strpos($this->config['base_url'], 'https://') === false) throw new CommonException('CURR_SITE_IS_NOT_OPEN_SSL'); - $this->site_id = $data['site_id'] ?? 0; + public function uploadWeapp(array $data) + { + if (strpos($this->config[ 'base_url' ], 'https://') === false) throw new CommonException('CURR_SITE_IS_NOT_OPEN_SSL'); + $this->site_id = $data[ 'site_id' ] ?? 0; - if (empty($this->config['app_id'])) throw new CommonException('WEAPP_APPID_EMPTY'); - if (empty($this->config['upload_private_key'])) throw new CommonException('UPLOAD_KEY_EMPTY'); - if (!file_exists($this->config['upload_private_key'])) throw new CommonException('UPLOAD_KEY_NOT_EXIST'); + if (empty($this->config[ 'app_id' ])) throw new CommonException('WEAPP_APPID_EMPTY'); + if (empty($this->config[ 'upload_private_key' ])) throw new CommonException('UPLOAD_KEY_EMPTY'); + if (!file_exists($this->config[ 'upload_private_key' ])) throw new CommonException('UPLOAD_KEY_NOT_EXIST'); - $compile_addon = (new Addon())->where([ ['compile', 'like', "%weapp%"] ])->field('key')->findOrEmpty(); + $action_token = ( new CoreModuleService() )->getActionToken('weappbuild', [ 'data' => [ 'product_key' => BaseNiucloudClient::PRODUCT ] ]); + + $compile_addon = ( new Addon() )->where([ [ 'compile', 'like', "%weapp%" ] ])->field('key')->findOrEmpty(); // 上传任务key $task_key = uniqid(); // 此次上传任务临时目录 @@ -81,7 +84,7 @@ class CoreWeappCloudService extends CoreCloudBaseService // 如果不存在编译版小程序 if ($compile_addon->isEmpty()) { - dir_copy($this->root_path . 'uni-app', $uni_dir, exclude_dirs:['node_modules', 'unpackage', 'dist']); + dir_copy($this->root_path . 'uni-app', $uni_dir, exclude_dirs:[ 'node_modules', 'unpackage', 'dist' ]); $this->handleUniapp($uni_dir); // 替换env文件 $this->weappEnvReplace($uni_dir . DIRECTORY_SEPARATOR . '.env.production'); @@ -91,25 +94,26 @@ class CoreWeappCloudService extends CoreCloudBaseService dir_copy($compile_dir, $uni_dir); $this->weappCompileReplace($uni_dir); } - file_put_contents($package_dir . 'private.key', file_get_contents($this->config['upload_private_key'])); + file_put_contents($package_dir . 'private.key', file_get_contents($this->config[ 'upload_private_key' ])); // 将临时目录下文件生成压缩包 $zip_file = $temp_dir . DIRECTORY_SEPARATOR . 'weapp.zip'; - (new CoreAddonDevelopDownloadService(''))->compressToZip($package_dir, $zip_file); + ( new CoreAddonDevelopDownloadService('') )->compressToZip($package_dir, $zip_file); $query = [ 'compile' => $compile_addon->isEmpty() ? 0 : 1, 'authorize_code' => $this->auth_code, - 'appid' => $this->config['app_id'], - 'version' => $data['version'] ?? '', - 'desc' => $data['desc'] ?? '', + 'appid' => $this->config[ 'app_id' ], + 'version' => $data[ 'version' ] ?? '', + 'desc' => $data[ 'desc' ] ?? '', 'do' => 1, - 'timestamp' => time() + 'timestamp' => time(), + 'token' => $action_token[ 'data' ][ 'token' ] ?? '' ]; - $response = (new CloudService())->httpPost('cloud/weapp?' . http_build_query($query), [ + $response = ( new CloudService() )->httpPost('cloud/weapp?' . http_build_query($query), [ 'multipart' => [ [ - 'name' => 'file', + 'name' => 'file', 'contents' => fopen($zip_file, 'r'), 'filename' => 'weapp.zip' ] @@ -119,9 +123,9 @@ class CoreWeappCloudService extends CoreCloudBaseService // 删除临时文件 del_target_dir(runtime_path() . 'backup' . DIRECTORY_SEPARATOR . 'weapp', true); - if (isset($response['code']) && $response['code'] == 0) throw new CommonException($response['msg']); + if (isset($response[ 'code' ]) && $response[ 'code' ] == 0) throw new CommonException($response[ 'msg' ]); - return ['key' => $query['timestamp'] ]; + return [ 'key' => $query[ 'timestamp' ] ]; } /** @@ -129,18 +133,19 @@ class CoreWeappCloudService extends CoreCloudBaseService * @param string $dir * @return void */ - private function handleUniapp(string $dir) { - $site_addon = $this->config['addon']; - $local_addon = (new Addon())->where([['status', '=', AddonDict::ON]])->column('key'); + private function handleUniapp(string $dir) + { + $site_addon = $this->config[ 'addon' ]; + $local_addon = ( new Addon() )->where([ [ 'status', '=', AddonDict::ON ] ])->column('key'); // 移除uniapp中该站点没有的插件 - $diff_addon = array_filter(array_map(function ($key) use ($site_addon) { + $diff_addon = array_filter(array_map(function($key) use ($site_addon) { if (!in_array($key, $site_addon)) return $key; }, $local_addon)); $this->handlePageCode($dir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $site_addon); - if (!empty($diff_addon) ) { + if (!empty($diff_addon)) { foreach ($diff_addon as $addon) { $this->addon = $addon; @@ -162,7 +167,8 @@ class CoreWeappCloudService extends CoreCloudBaseService } } - private function handlePageCode($compile_path, $addon_arr) { + private function handlePageCode($compile_path, $addon_arr) + { $pages = []; foreach ($addon_arr as $addon) { if (!file_exists($this->geAddonPackagePath($addon) . 'uni-app-pages.php')) continue; @@ -173,8 +179,8 @@ class CoreWeappCloudService extends CoreCloudBaseService $page_end = strtoupper($addon) . '_PAGE_END'; // 对0.2.0之前的版本做处理 - $uniapp_pages[ 'pages' ] = preg_replace_callback('/(.*)(\\r\\n.*\/\/ PAGE_END.*)/s', function ($match){ - return $match[1] . (substr($match[1], -1) == ',' ? '' : ',') .$match[2]; + $uniapp_pages[ 'pages' ] = preg_replace_callback('/(.*)(\\r\\n.*\/\/ PAGE_END.*)/s', function($match) { + return $match[ 1 ] . ( substr($match[ 1 ], -1) == ',' ? '' : ',' ) . $match[ 2 ]; }, $uniapp_pages[ 'pages' ]); $uniapp_pages[ 'pages' ] = str_replace('PAGE_BEGIN', $page_begin, $uniapp_pages[ 'pages' ]); @@ -185,8 +191,8 @@ class CoreWeappCloudService extends CoreCloudBaseService } $content = @file_get_contents($compile_path . "pages.json"); - $content = preg_replace_callback('/(.*\/\/ \{\{ PAGE_BEGAIN \}\})(.*)(\/\/ \{\{ PAGE_END \}\}.*)/s', function ($match) use ($pages) { - return $match[1] . PHP_EOL . implode(PHP_EOL, $pages) . PHP_EOL . $match[3]; + $content = preg_replace_callback('/(.*\/\/ \{\{ PAGE_BEGAIN \}\})(.*)(\/\/ \{\{ PAGE_END \}\}.*)/s', function($match) use ($pages) { + return $match[ 1 ] . PHP_EOL . implode(PHP_EOL, $pages) . PHP_EOL . $match[ 3 ]; }, $content); // 找到页面路由文件 pages.json,写入内容 @@ -198,10 +204,11 @@ class CoreWeappCloudService extends CoreCloudBaseService * @param string $env_file * @return void */ - private function weappEnvReplace(string $env_file) { + private function weappEnvReplace(string $env_file) + { $env = file_get_contents($env_file); - $env = str_replace("VITE_APP_BASE_URL=''", "VITE_APP_BASE_URL='" . $this->config['base_url'] . 'api/' . "'", $env); - $env = str_replace("VITE_IMG_DOMAIN=''", "VITE_IMG_DOMAIN='" . $this->config['base_url'] . "'", $env); + $env = str_replace("VITE_APP_BASE_URL=''", "VITE_APP_BASE_URL='" . $this->config[ 'base_url' ] . 'api/' . "'", $env); + $env = str_replace("VITE_IMG_DOMAIN=''", "VITE_IMG_DOMAIN='" . $this->config[ 'base_url' ] . "'", $env); $env = str_replace("VITE_SITE_ID = ''", "VITE_SITE_ID='" . $this->site_id . "'", $env); file_put_contents($env_file, $env); } @@ -211,18 +218,19 @@ class CoreWeappCloudService extends CoreCloudBaseService * @param string $vendor_file * @return void */ - private function weappCompileReplace(string $path) { + private function weappCompileReplace(string $path) + { // 替换request.js $request_file = $path . DIRECTORY_SEPARATOR . 'utils' . DIRECTORY_SEPARATOR . 'request.js'; $content = file_get_contents($request_file); - $content = str_replace('{{$baseUrl}}', $this->config['base_url'] . 'api/', $content); - $content = str_replace('{{$siteId}}', $this->site_id, $content); + $content = str_replace('{{$baseUrl}}', $this->config[ 'base_url' ] . 'api/', $content); + $content = str_replace('{{$siteId}}', $this->site_id, $content); file_put_contents($request_file, $content); // 替换common.js $common_file = $path . DIRECTORY_SEPARATOR . 'utils' . DIRECTORY_SEPARATOR . 'common.js'; $content = file_get_contents($common_file); - $content = str_replace('{{$imgUrl}}', $this->config['base_url'], $content); + $content = str_replace('{{$imgUrl}}', $this->config[ 'base_url' ], $content); file_put_contents($common_file, $content); } @@ -230,11 +238,12 @@ class CoreWeappCloudService extends CoreCloudBaseService * 获取微信小程序预览码 * @return void */ - public function getWeappPreviewImage() { + public function getWeappPreviewImage() + { $query = [ 'authorize_code' => $this->auth_code, ]; - $preview_url = (new CloudService())->getUrl('cloud/get_weapp_preview?' . http_build_query($query)); + $preview_url = ( new CloudService() )->getUrl('cloud/get_weapp_preview?' . http_build_query($query)); try { $path = runtime_path() . uniqid() . '.jpg'; @@ -250,12 +259,13 @@ class CoreWeappCloudService extends CoreCloudBaseService * @param string $timestamp * @return void */ - public function getWeappCompileLog(string $timestamp) { + public function getWeappCompileLog(string $timestamp) + { $query = [ 'authorize_code' => $this->auth_code, 'timestamp' => $timestamp ]; - return (new CloudService())->httpGet('cloud/get_weapp_logs?' . http_build_query($query)); + return ( new CloudService() )->httpGet('cloud/get_weapp_logs?' . http_build_query($query)); } /** diff --git a/niucloud/app/service/core/weapp/CoreWeappConfigService.php b/niucloud/app/service/core/weapp/CoreWeappConfigService.php index 99e83861b..961e9a3a9 100644 --- a/niucloud/app/service/core/weapp/CoreWeappConfigService.php +++ b/niucloud/app/service/core/weapp/CoreWeappConfigService.php @@ -29,19 +29,20 @@ class CoreWeappConfigService extends BaseCoreService * @param int $site_id * @return array */ - public function getWeappConfig(int $site_id){ - $info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::WEAPP)['value'] ?? []; + public function getWeappConfig(int $site_id) + { + $info = ( new CoreConfigService() )->getConfig($site_id, 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 ]; } @@ -51,21 +52,22 @@ class CoreWeappConfigService extends BaseCoreService * @param array $data * @return SysConfig|bool|Model */ - public function setWeappConfig(int $site_id, array $data){ + public function setWeappConfig(int $site_id, array $data) + { $old = $this->getWeappConfig($site_id); $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($site_id, ConfigKeyDict::WEAPP, $config); + return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::WEAPP, $config); } /** @@ -73,8 +75,9 @@ class CoreWeappConfigService extends BaseCoreService * @param int $site_id * @return mixed */ - public function getWeappAuthorizationInfo(int $site_id) { - return (new CoreConfigService())->getConfigValue($site_id, ConfigKeyDict::WEAPP_AUTHORIZATION_INFO); + public function getWeappAuthorizationInfo(int $site_id) + { + return ( new CoreConfigService() )->getConfigValue($site_id, ConfigKeyDict::WEAPP_AUTHORIZATION_INFO); } /** @@ -83,7 +86,8 @@ class CoreWeappConfigService extends BaseCoreService * @param array $config * @return SysConfig|bool|Model */ - public function setWeappAuthorizationInfo(int $site_id, array $config) { - return (new CoreConfigService())->setConfig($site_id, ConfigKeyDict::WEAPP_AUTHORIZATION_INFO, $config); + public function setWeappAuthorizationInfo(int $site_id, array $config) + { + return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::WEAPP_AUTHORIZATION_INFO, $config); } } diff --git a/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php b/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php index e46c737f9..68cd9f7ef 100644 --- a/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php +++ b/niucloud/app/service/core/weapp/CoreWeappDeliveryService.php @@ -111,6 +111,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(); } } diff --git a/niucloud/app/service/core/wechat/CoreWechatApiService.php b/niucloud/app/service/core/wechat/CoreWechatApiService.php index 3d2d5a380..c27ec73b5 100644 --- a/niucloud/app/service/core/wechat/CoreWechatApiService.php +++ b/niucloud/app/service/core/wechat/CoreWechatApiService.php @@ -45,26 +45,25 @@ class CoreWechatApiService extends BaseCoreService public function userInfoBatchget(int $site_id, array $openids, string $lang = 'zh_CN') { return CoreWechatService::appApiClient($site_id)->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) ] ); } - + /** * 用户列表(可以再外部设计一个递归查询全部的函数) 返回的是 openid */ public function userGet(int $site_id, ?string $next_openid = '') { $api = CoreWechatService::appApiClient($site_id); - return $api->get('/cgi-bin/user/get', ['next_openid' => $next_openid]); + return $api->get('/cgi-bin/user/get', [ 'next_openid' => $next_openid ]); } - /** * 创建菜单按钮接口 * @param int $site_id @@ -84,8 +83,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 e8c5a7f7b..fb991052b 100644 --- a/niucloud/app/service/core/wechat/CoreWechatConfigService.php +++ b/niucloud/app/service/core/wechat/CoreWechatConfigService.php @@ -31,18 +31,19 @@ class CoreWechatConfigService extends BaseCoreService * @param int $site_id * @return array */ - public function getWechatConfig(int $site_id){ - $info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::WECHAT)['value'] ?? []; + public function getWechatConfig(int $site_id) + { + $info = ( new CoreConfigService() )->getConfig($site_id, 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 ]; } @@ -52,34 +53,35 @@ class CoreWechatConfigService extends BaseCoreService * @param array $data * @return SysConfig|bool|Model */ - public function setWechatConfig(int $site_id, array $data){ + public function setWechatConfig(int $site_id, array $data) + { $old = $this->getWechatConfig($site_id); $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($site_id, ConfigKeyDict::WECHAT, $config); + return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::WECHAT, $config); } - /** - *查询微信需要的静态信息 + * 查询微信需要的静态信息 * @return array */ - public function getWechatStaticInfo($site_id){ - $wap_domain = (new CoreSysConfigService())->getSceneDomain($site_id)['wap_url'] ?? ''; + public function getWechatStaticInfo($site_id) + { + $wap_domain = ( new CoreSysConfigService() )->getSceneDomain($site_id)[ 'wap_url' ] ?? ''; return [ - 'serve_url' => (string)url('/api/wechat/serve/'.$site_id, [],'',true), - 'business_domain' => $wap_domain, - 'js_secure_domain' => $wap_domain, - 'web_auth_domain' => $wap_domain, + 'serve_url' => (string) url('/api/wechat/serve/' . $site_id, [], '', true), + 'business_domain' => $wap_domain, + 'js_secure_domain' => $wap_domain, + 'web_auth_domain' => $wap_domain, 'encryption_type' => WechatDict::getEncryptionType() ]; } @@ -89,8 +91,9 @@ class CoreWechatConfigService extends BaseCoreService * @param int $site_id * @return mixed */ - public function getWechatAuthorizationInfo(int $site_id) { - return (new CoreConfigService())->getConfigValue($site_id, ConfigKeyDict::WECHAT_AUTHORIZATION_INFO); + public function getWechatAuthorizationInfo(int $site_id) + { + return ( new CoreConfigService() )->getConfigValue($site_id, ConfigKeyDict::WECHAT_AUTHORIZATION_INFO); } /** @@ -99,7 +102,8 @@ class CoreWechatConfigService extends BaseCoreService * @param array $config * @return SysConfig|bool|Model */ - public function setWechatAuthorizationInfo(int $site_id, array $config) { - return (new CoreConfigService())->setConfig($site_id, ConfigKeyDict::WECHAT_AUTHORIZATION_INFO, $config); + public function setWechatAuthorizationInfo(int $site_id, array $config) + { + return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::WECHAT_AUTHORIZATION_INFO, $config); } } diff --git a/niucloud/app/service/core/wechat/CoreWechatFansService.php b/niucloud/app/service/core/wechat/CoreWechatFansService.php index 757a23cd0..2df7f33f4 100644 --- a/niucloud/app/service/core/wechat/CoreWechatFansService.php +++ b/niucloud/app/service/core/wechat/CoreWechatFansService.php @@ -39,13 +39,11 @@ class CoreWechatFansService extends BaseCoreService */ public function add(int $site_id, array $data) { - $fans = $this->model->create($data); return $fans->fans_id; } - - public function find(array|string $where) + public function find($where) { return $this->model->where($where)->findOrEmpty(); } @@ -60,8 +58,8 @@ class CoreWechatFansService extends BaseCoreService public function edit(int $site_id, string $open_id, array $data) { $condition = [ - ['site_id', '=', $site_id], - ['openid', '=', $open_id] + [ 'site_id', '=', $site_id ], + [ 'openid', '=', $open_id ] ]; $fans = $this->find($condition); $core_wechat_api_service = new CoreWechatApiService(); @@ -71,34 +69,34 @@ class CoreWechatFansService extends BaseCoreService $save_data = array( 'site_id' => $site_id, - 'subscribe' => $userinfo['subscribe'],//用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。 + 'subscribe' => $userinfo[ 'subscribe' ],//用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。 ); //用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息 - if ($userinfo['subscribe'] == 1) { + if ($userinfo[ 'subscribe' ] == 1) { $save_data = array_merge($save_data, [ - 'language' => $userinfo['language'] ?? '',//用户的语言,简体中文为zh_CN - 'subscribe_time' => $userinfo['subscribe_time'] ?? '',//用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 - 'unionid' => $userinfo['unionid'] ?? '',//只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。 - 'remark' => $userinfo['remark'] ?? '',//公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 - 'groupid' => $userinfo['groupid'] ?? '',//用户所在的分组ID(兼容旧的用户分组接口) - 'subscribe_scene' => $userinfo['subscribe_scene'] ?? '',//返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_REPRINT 他人转载 ,ADD_SCENE_LIVESTREAM 视频号直播, ADD_SCENE_CHANNELS 视频号, ADD_SCENE_OTHERS 其他 + 'language' => $userinfo[ 'language' ] ?? '',//用户的语言,简体中文为zh_CN + 'subscribe_time' => $userinfo[ 'subscribe_time' ] ?? '',//用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 + 'unionid' => $userinfo[ 'unionid' ] ?? '',//只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。 + 'remark' => $userinfo[ 'remark' ] ?? '',//公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 + 'groupid' => $userinfo[ 'groupid' ] ?? '',//用户所在的分组ID(兼容旧的用户分组接口) + 'subscribe_scene' => $userinfo[ 'subscribe_scene' ] ?? '',//返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_REPRINT 他人转载 ,ADD_SCENE_LIVESTREAM 视频号直播, ADD_SCENE_CHANNELS 视频号, ADD_SCENE_OTHERS 其他 'update_time' => time(), // 'tagid_list' => $userinfo['tagid_list'],//用户被打上的标签ID列表 , 数据库字段为json ] ); } //头像 - if (!empty($data['avatar'])) { - $save_data['avatar'] = $data['avatar']; + if (!empty($data[ 'avatar' ])) { + $save_data[ 'avatar' ] = $data[ 'avatar' ]; } //昵称 - if (!empty($data['nickname'])) { - $save_data['nickname'] = $data['nickname']; + if (!empty($data[ 'nickname' ])) { + $save_data[ 'nickname' ] = $data[ 'nickname' ]; } //取消关注时间 - if (!empty($data['unsubscribe_time'])) { - $save_data['unsubscribe_time'] = $data['unsubscribe_time']; + if (!empty($data[ 'unsubscribe_time' ])) { + $save_data[ 'unsubscribe_time' ] = $data[ 'unsubscribe_time' ]; } // todo qr_scene qr_scene_str 这两个二维码自定义开发功能 if (!$fans->isEmpty()) { @@ -126,10 +124,10 @@ class CoreWechatFansService extends BaseCoreService 'app_id' => $app_id, 'openid' => $from_user_name, 'subscribe' => 1, - 'nickname' => $user_info['remark'], - 'subscribe_time' => $user_info['subscribe_time'], - 'subscribe_scene' => $user_info['subscribe_scene'], - 'language' => $user_info['language'], + 'nickname' => $user_info[ 'remark' ], + 'subscribe_time' => $user_info[ 'subscribe_time' ], + 'subscribe_scene' => $user_info[ 'subscribe_scene' ], + 'language' => $user_info[ 'language' ], ); $this->edit($site_id, $from_user_name, $data); return true; diff --git a/niucloud/app/service/core/wechat/CoreWechatMediaService.php b/niucloud/app/service/core/wechat/CoreWechatMediaService.php index 7ce0f6ae6..4d1e7837a 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($data['site_id'])->post("/cgi-bin/material/add_material?type={$data['type']}", $options); diff --git a/niucloud/app/service/core/wechat/CoreWechatMessageService.php b/niucloud/app/service/core/wechat/CoreWechatMessageService.php index 18776a981..ddb70cc20 100644 --- a/niucloud/app/service/core/wechat/CoreWechatMessageService.php +++ b/niucloud/app/service/core/wechat/CoreWechatMessageService.php @@ -41,12 +41,12 @@ class CoreWechatMessageService extends BaseCoreService switch ($message['MsgType']) { case WechatDict::MESSAGE_TYPE_EVENT: return $this->event($site_id, $message); - return '收到事件消息'; +// return '收到事件消息'; break; case WechatDict::MESSAGE_TYPE_TEXT: //调用文本回复 return $this->text($site_id, $message); - return '收到文字消息'; +// return '收到文字消息'; break; case WechatDict::MESSAGE_TYPE_IMAGE: return '收到图片消息'; diff --git a/niucloud/app/service/core/wechat/CoreWechatServeService.php b/niucloud/app/service/core/wechat/CoreWechatServeService.php index aab826d3f..f6a76dc1e 100644 --- a/niucloud/app/service/core/wechat/CoreWechatServeService.php +++ b/niucloud/app/service/core/wechat/CoreWechatServeService.php @@ -12,6 +12,7 @@ namespace app\service\core\wechat; use core\base\BaseCoreService; +use core\exception\CommonException; use EasyWeChat\Kernel\Exceptions\BadRequestException; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; @@ -49,8 +50,12 @@ class CoreWechatServeService extends BaseCoreService */ public function userFromCode(int $site_id, string $code) { - $oauth = CoreWechatService::app($site_id)->getOauth(); - return $oauth->userFromCode($code); + try { + $oauth = CoreWechatService::app($site_id)->getOauth(); + return $oauth->userFromCode($code); + } catch (\Exception $e) { + throw new CommonException($e->getCode()); + } } public function getUser($user) diff --git a/niucloud/app/service/core/wxoplatform/CoreOplatformService.php b/niucloud/app/service/core/wxoplatform/CoreOplatformService.php index 1abf1a176..a9d640cef 100644 --- a/niucloud/app/service/core/wxoplatform/CoreOplatformService.php +++ b/niucloud/app/service/core/wxoplatform/CoreOplatformService.php @@ -213,7 +213,7 @@ class CoreOplatformService extends BaseCoreService */ public static function releaseWeapp($site_id) { $app = CoreWeappService::app($site_id); - return $app->getClient()->post('/wxa/release')->toArray(); + return $app->getClient()->post('/wxa/release', ['json' => []])->toArray(); } /** diff --git a/niucloud/app/upgrade/v050/Upgrade.php b/niucloud/app/upgrade/v050/Upgrade.php new file mode 100644 index 000000000..2290959ae --- /dev/null +++ b/niucloud/app/upgrade/v050/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,site_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/v050/upgrade.sql b/niucloud/app/upgrade/v050/upgrade.sql new file mode 100644 index 000000000..fe744c333 --- /dev/null +++ b/niucloud/app/upgrade/v050/upgrade.sql @@ -0,0 +1,47 @@ + +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, + `site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id', + `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, + `site_id` INT(11) NOT NULL DEFAULT 0 COMMENT '站点id', + `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 '会员昵称'; 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/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 251801150..e9d690852 100644 --- a/niucloud/config/version.php +++ b/niucloud/config/version.php @@ -1,6 +1,6 @@ '0.4.0', - 'code' => '202406150001' + 'version' => '0.5.0', + 'code' => '202407250001' ]; diff --git a/niucloud/core/base/BaseModel.php b/niucloud/core/base/BaseModel.php index 240d4cb94..7d9ede1f4 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/Config.php b/niucloud/core/dict/Config.php index c96062001..de2da3eb0 100644 --- a/niucloud/core/dict/Config.php +++ b/niucloud/core/dict/Config.php @@ -34,8 +34,8 @@ class Config extends BaseDict { $system_config = empty($system_config) ? $file_data : array_merge2($system_config, $file_data); } - } + return $system_config; } } diff --git a/niucloud/core/dict/Printer.php b/niucloud/core/dict/Printer.php new file mode 100644 index 000000000..27099e940 --- /dev/null +++ b/niucloud/core/dict/Printer.php @@ -0,0 +1,41 @@ +getAddonKeysBySiteId(); + $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/AddonException.php b/niucloud/core/exception/AddonException.php index f10b15459..34a085214 100644 --- a/niucloud/core/exception/AddonException.php +++ b/niucloud/core/exception/AddonException.php @@ -12,7 +12,6 @@ class AddonException extends RuntimeException { public function __construct($message = "", $code = 0, Throwable $previous = null) { - parent::__construct($message, $code, $previous); } } diff --git a/niucloud/core/exception/AdminException.php b/niucloud/core/exception/AdminException.php index 4725e0226..8a286c020 100644 --- a/niucloud/core/exception/AdminException.php +++ b/niucloud/core/exception/AdminException.php @@ -12,7 +12,6 @@ class AdminException extends RuntimeException { public function __construct($message = "", $code = 0, Throwable $previous = null) { - parent::__construct($message, $code, $previous); } } diff --git a/niucloud/core/pay/Wechatpay.php b/niucloud/core/pay/Wechatpay.php index 8671fc7ec..5aa7595cd 100644 --- a/niucloud/core/pay/Wechatpay.php +++ b/niucloud/core/pay/Wechatpay.php @@ -14,7 +14,6 @@ use Yansongda\Pay\Exception\ContainerException; use Yansongda\Pay\Exception\InvalidParamsException; use Yansongda\Pay\Exception\ServiceNotFoundException; use Yansongda\Pay\Pay; -use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryOutBatchNoPlugin; use Yansongda\Supports\Collection; diff --git a/niucloud/core/poster/Poster.php b/niucloud/core/poster/Poster.php index 306242e3d..0dfe65a34 100644 --- a/niucloud/core/poster/Poster.php +++ b/niucloud/core/poster/Poster.php @@ -10,9 +10,7 @@ // +---------------------------------------------------------------------- namespace core\poster; -use Grafika\Color; -use Grafika\Grafika; - +use Kkokk\Poster\Facades\Poster as PosterInstance; class Poster extends BasePoster { @@ -37,41 +35,171 @@ class Poster extends BasePoster public function createPoster(array $poster_data, string $dir, string $file_path) { $bg_type = $poster_data[ 'global' ][ 'bgType' ]; - $editor = Grafika::createEditor(); - if ($bg_type == 'url' && !empty($poster_data[ 'global' ][ 'bgUrl' ])) { - $editor->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 2a67d6873..8c078af53 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/core/printer/BasePrinter.php b/niucloud/core/printer/BasePrinter.php new file mode 100644 index 000000000..03db1b1b0 --- /dev/null +++ b/niucloud/core/printer/BasePrinter.php @@ -0,0 +1,39 @@ +config = $config; + } + + /** + * 打印小票 + * @param array $data + * @return mixed|void + */ + public function printTicket(array $data) + { + } +} \ No newline at end of file diff --git a/niucloud/core/printer/PrinterLoader.php b/niucloud/core/printer/PrinterLoader.php new file mode 100644 index 000000000..28c2f9c82 --- /dev/null +++ b/niucloud/core/printer/PrinterLoader.php @@ -0,0 +1,39 @@ +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 b0ee853d5..561998333 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) { } diff --git a/niucloud/core/sms/BaseSms.php b/niucloud/core/sms/BaseSms.php index 1b89a6ccd..98ad7ceb7 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 3c0e615d5..0a031101a 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 { diff --git a/niucloud/core/sms/Tencent.php b/niucloud/core/sms/Tencent.php index 7c0a32f11..0bd9d0aac 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) { } diff --git a/niucloud/core/template/BaseTemplate.php b/niucloud/core/template/BaseTemplate.php index 064e7ad1b..4811992dc 100644 --- a/niucloud/core/template/BaseTemplate.php +++ b/niucloud/core/template/BaseTemplate.php @@ -29,27 +29,6 @@ abstract class BaseTemplate extends Storage } - - /** - * 发送模板消息 - * @return mixed - */ - abstract protected function send(array $data); - - /** - * 增加模板消息 - * @param array $data - * @return mixed - */ - abstract protected function addTemplate(array $data); - - /** - * 删除消息模板 - * @param array $data - * @return mixed - */ - abstract protected function delete(array $data); - /** * 获取消息模板列表 * @return mixed 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