diff --git a/app/data/controller/ShopOrder.php b/app/data/controller/ShopOrder.php index c870e74af..f22ab980a 100644 --- a/app/data/controller/ShopOrder.php +++ b/app/data/controller/ShopOrder.php @@ -5,7 +5,7 @@ namespace app\data\controller; use app\data\service\OrderService; use app\data\service\PaymentService; use app\data\service\ExpressService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; use think\exception\HttpResponseException; @@ -84,8 +84,8 @@ class ShopOrder extends Controller */ protected function _index_page_filter(array &$data) { - UserService::instance()->buildByUid($data); - UserService::instance()->buildByUid($data, 'puid1', 'fromer'); + UserAdminService::instance()->buildByUid($data); + UserAdminService::instance()->buildByUid($data, 'puid1', 'fromer'); OrderService::instance()->buildData($data); foreach ($data as &$vo) $vo['payment_name'] = PaymentService::name($vo['payment_type']); } diff --git a/app/data/controller/ShopPayment.php b/app/data/controller/ShopPayment.php index e8de38d52..09a96118b 100644 --- a/app/data/controller/ShopPayment.php +++ b/app/data/controller/ShopPayment.php @@ -3,7 +3,7 @@ namespace app\data\controller; use app\data\service\PaymentService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; use think\admin\extend\CodeExtend; @@ -81,8 +81,8 @@ class ShopPayment extends Controller $this->payments = []; foreach ($this->types as $k => $vo) { $allow = []; - foreach ($vo['bind'] as $api) if (isset(UserService::TYPES[$api])) { - $allow[$api] = UserService::TYPES[$api]['name']; + foreach ($vo['bind'] as $api) if (isset(UserAdminService::TYPES[$api])) { + $allow[$api] = UserAdminService::TYPES[$api]['name']; } if (count($allow)) { $this->payments[$k] = array_merge($vo, ['allow' => join('、', $allow)]); diff --git a/app/data/controller/User.php b/app/data/controller/User.php index 724c9132f..3f8f1a57e 100644 --- a/app/data/controller/User.php +++ b/app/data/controller/User.php @@ -2,7 +2,7 @@ namespace app\data\controller; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; /** @@ -40,7 +40,7 @@ class User extends Controller */ protected function _page_filter(array &$data) { - UserService::instance()->buildByUid($data, 'pid1', 'fromer'); + UserAdminService::instance()->buildByUid($data, 'pid1', 'fromer'); } /** diff --git a/app/data/controller/UserBalance.php b/app/data/controller/UserBalance.php index 346a7fe8d..61cd639b5 100644 --- a/app/data/controller/UserBalance.php +++ b/app/data/controller/UserBalance.php @@ -4,7 +4,7 @@ namespace app\data\controller; use app\data\service\UserBalanceService; use app\data\service\UserUpgradeService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; use think\admin\extend\CodeExtend; use think\admin\service\AdminService; @@ -47,7 +47,7 @@ class UserBalance extends Controller */ protected function _index_page_filter(array &$data) { - UserService::instance()->buildByUid($data); + UserAdminService::instance()->buildByUid($data); $uids = array_unique(array_column($data, 'create_by')); $users = $this->app->db->name('SystemUser')->whereIn('id', $uids)->column('username', 'id'); foreach ($data as &$vo) $vo['create_byname'] = $users[$vo['create_by']] ?? $vo['create_by']; diff --git a/app/data/controller/UserTransfer.php b/app/data/controller/UserTransfer.php index 3f279133b..90237a8e1 100644 --- a/app/data/controller/UserTransfer.php +++ b/app/data/controller/UserTransfer.php @@ -2,7 +2,7 @@ namespace app\data\controller; -use app\data\service\UserService; +use app\data\service\UserAdminService; use app\data\service\UserTransferService; use think\admin\Controller; use think\admin\extend\CodeExtend; @@ -91,7 +91,7 @@ class UserTransfer extends Controller */ protected function _page_filter(array &$data) { - UserService::instance()->buildByUid($data); + UserAdminService::instance()->buildByUid($data); } /** diff --git a/app/data/controller/api/Auth.php b/app/data/controller/api/Auth.php index f7b382abd..dcd842b1b 100644 --- a/app/data/controller/api/Auth.php +++ b/app/data/controller/api/Auth.php @@ -2,7 +2,7 @@ namespace app\data\controller\api; -use app\data\service\UserService; +use app\data\service\UserAdminService; use app\data\service\UserTokenService; use think\admin\Controller; use think\exception\HttpResponseException; @@ -46,7 +46,7 @@ abstract class Auth extends Controller // 接口数据类型 $this->type = $this->request->header('api-name') ?: input('api'); $this->type = $this->type ?: $this->request->header('api-type'); - if (empty($this->type) || empty(UserService::TYPES[$this->type])) { + if (empty($this->type) || empty(UserAdminService::TYPES[$this->type])) { $this->error("接口支付未定义!"); } // 获取用户数据 @@ -70,7 +70,7 @@ abstract class Auth extends Controller [$state, $info, $this->uuid] = UserTokenService::instance()->check($this->type, $token); if (empty($state)) $this->error($info, '{-null-}', 401); } - return UserService::instance()->get($this->uuid, $this->type); + return UserAdminService::instance()->get($this->uuid, $this->type); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { diff --git a/app/data/controller/api/Login.php b/app/data/controller/api/Login.php index 102082071..50b6e58a6 100644 --- a/app/data/controller/api/Login.php +++ b/app/data/controller/api/Login.php @@ -3,7 +3,7 @@ namespace app\data\controller\api; use app\data\service\MessageService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; /** @@ -30,8 +30,8 @@ class Login extends Controller */ protected function initialize() { - $this->type = input('api', UserService::API_TYPE_WAP); - if (empty(UserService::TYPES[$this->type])) { + $this->type = input('api', UserAdminService::API_TYPE_WAP); + if (empty(UserAdminService::TYPES[$this->type])) { $this->error("接口支付[{$this->type}]未定义规则!"); } } @@ -55,7 +55,7 @@ class Login extends Controller if (empty($user)) $this->error('该手机号还没有注册哦!'); if (empty($user['status'])) $this->error('该用户账号状态异常!'); if (md5($data['password']) === $user['password']) { - $this->success('手机登录成功!', UserService::instance()->set($map, [], $this->type, true)); + $this->success('手机登录成功!', UserAdminService::instance()->set($map, [], $this->type, true)); } else { $this->error('账号登录失败,请稍候再试!'); } @@ -88,7 +88,7 @@ class Login extends Controller $this->error('手机号已注册,请使用其它手机号!'); } $data['password'] = md5($data['password']); - $user = UserService::instance()->set($map, $data, $this->type, true); + $user = UserAdminService::instance()->set($map, $data, $this->type, true); empty($user) ? $this->error('手机注册失败!') : $this->success('用户注册成功!', $user); } diff --git a/app/data/controller/api/Wechat.php b/app/data/controller/api/Wechat.php index e56605239..822151431 100644 --- a/app/data/controller/api/Wechat.php +++ b/app/data/controller/api/Wechat.php @@ -2,7 +2,7 @@ namespace app\data\controller\api; -use app\data\service\UserService; +use app\data\service\UserAdminService; use app\wechat\service\WechatService; use think\admin\Controller; use think\Response; @@ -25,7 +25,7 @@ class Wechat extends Controller * 接口认证类型 * @var string */ - private $type = UserService::API_TYPE_WECHAT; + private $type = UserAdminService::API_TYPE_WECHAT; /** * 唯一绑定字段 @@ -39,10 +39,10 @@ class Wechat extends Controller */ protected function initialize(): Wechat { - if (empty(UserService::TYPES[$this->type]['auth'])) { + if (empty(UserAdminService::TYPES[$this->type]['auth'])) { $this->error("接口类型[{$this->type}]没有定义规则"); } else { - $this->field = UserService::TYPES[$this->type]['auth']; + $this->field = UserAdminService::TYPES[$this->type]['auth']; } return $this; } @@ -81,7 +81,7 @@ class Wechat extends Controller $data['base_sex'] = ['未知', '男', '女'][$data['sex']] ?? '未知'; if (isset($data['headimgurl'])) $data['headimg'] = $data['headimgurl']; $map = isset($data['unionid']) ? ['unionid' => $data['unionid']] : [$this->field => $result['openid']]; - $result['userinfo'] = UserService::instance()->set($map, array_merge($map, $data), $this->type, true); + $result['userinfo'] = UserAdminService::instance()->set($map, array_merge($map, $data), $this->type, true); $script[] = "window.WeChatOpenid='{$result['openid']}'"; $script[] = 'window.WeChatFansInfo=' . json_encode($result['fansinfo'], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); $script[] = 'window.WeChatUserInfo=' . json_encode($result['userinfo'], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); diff --git a/app/data/controller/api/Wxapp.php b/app/data/controller/api/Wxapp.php index 789f6151c..360fa4cb7 100644 --- a/app/data/controller/api/Wxapp.php +++ b/app/data/controller/api/Wxapp.php @@ -2,7 +2,7 @@ namespace app\data\controller\api; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Controller; use think\exception\HttpResponseException; use think\Response; @@ -21,7 +21,7 @@ class Wxapp extends Controller * 接口认证类型 * @var string */ - private $type = UserService::API_TYPE_WXAPP; + private $type = UserAdminService::API_TYPE_WXAPP; /** * 唯一绑定字段 @@ -48,10 +48,10 @@ class Wxapp extends Controller 'appsecret' => sysconf('data.wxapp_appkey'), 'cache_path' => $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'wechat', ]; - if (empty(UserService::TYPES[$this->type]['auth'])) { + if (empty(UserAdminService::TYPES[$this->type]['auth'])) { $this->error("接口类型[{$this->type}]没有定义规则"); } else { - $this->field = UserService::TYPES[$this->type]['auth']; + $this->field = UserAdminService::TYPES[$this->type]['auth']; } } @@ -66,7 +66,7 @@ class Wxapp extends Controller [$openid, $unionid, $sessionKey] = $this->_getSessionKey($input['code']); $map = empty($unionid) ? [$this->field => $openid] : ['unionid' => $unionid]; $data = array_merge($map, [$this->field => $openid, 'session_key' => $sessionKey]); - $this->success('授权换取成功!', UserService::instance()->set($map, $data, $this->type, true)); + $this->success('授权换取成功!', UserAdminService::instance()->set($map, $data, $this->type, true)); } /** @@ -91,7 +91,7 @@ class Wxapp extends Controller $sex = ['未知', '男', '女'][$result['gender']] ?? '未知'; $map = empty($result['unionId']) ? [$this->field => $result['openId']] : ['unionid' => $result['unionId']]; $data = [$this->field => $result['openId'], 'headimg' => $result['avatarUrl'], 'nickname' => $result['nickName'], 'base_sex' => $sex]; - $this->success('数据解密成功!', UserService::instance()->set($map, array_merge($map, $data), $this->type, true)); + $this->success('数据解密成功!', UserAdminService::instance()->set($map, array_merge($map, $data), $this->type, true)); } elseif (is_array($result) && isset($result['phoneNumber'])) { $this->success('数据解密成功!', $result); } else { diff --git a/app/data/controller/api/auth/Center.php b/app/data/controller/api/auth/Center.php index d6931c91a..6470da3d1 100644 --- a/app/data/controller/api/auth/Center.php +++ b/app/data/controller/api/auth/Center.php @@ -4,7 +4,7 @@ namespace app\data\controller\api\auth; use app\data\controller\api\Auth; use app\data\service\UserUpgradeService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\Storage; use think\exception\HttpResponseException; @@ -137,9 +137,9 @@ class Center extends Auth $data = $this->_vali(['from.require' => '邀请人不能为空']); [$state, $message] = UserUpgradeService::instance()->bindAgent($this->uuid, $data['from'], false); if ($state) { - $this->success($message, UserService::instance()->total($this->uuid)); + $this->success($message, UserAdminService::instance()->total($this->uuid)); } else { - $this->error($message, UserService::instance()->total($this->uuid)); + $this->error($message, UserAdminService::instance()->total($this->uuid)); } } } \ No newline at end of file diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index bf35f14b5..d11b319e1 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -7,7 +7,7 @@ use app\data\service\ExpressService; use app\data\service\GoodsService; use app\data\service\OrderService; use app\data\service\PaymentService; -use app\data\service\UserService; +use app\data\service\UserAdminService; use think\admin\extend\CodeExtend; use think\exception\HttpResponseException; @@ -317,8 +317,8 @@ class Order extends Auth if ($order['payment_status'] > 0) $this->error('已经完成支付'); try { $openid = ''; - if (in_array($this->type, [UserService::API_TYPE_WXAPP, UserService::API_TYPE_WECHAT])) { - $openid = $this->user[UserService::TYPES[$this->type]['auth']] ?? ''; + if (in_array($this->type, [UserAdminService::API_TYPE_WXAPP, UserAdminService::API_TYPE_WECHAT])) { + $openid = $this->user[UserAdminService::TYPES[$this->type]['auth']] ?? ''; if (empty($openid)) $this->error("发起支付失败"); } // 返回订单数据及支付发起参数 diff --git a/app/data/service/NewsService.php b/app/data/service/NewsService.php index 0361b71a2..ed5358dcf 100644 --- a/app/data/service/NewsService.php +++ b/app/data/service/NewsService.php @@ -45,7 +45,7 @@ class NewsService extends Service foreach ($list as &$vo) $vo['record'] = $items[$vo['code']] ?? []; /*! 绑定用户数据 */ $colls = 'id,phone,nickname,username,headimg,status'; - UserService::instance()->buildByUid($list, 'uid', 'user', $colls); + UserAdminService::instance()->buildByUid($list, 'uid', 'user', $colls); } return $list; } diff --git a/app/data/service/OrderService.php b/app/data/service/OrderService.php index 2f1445099..1eeffd921 100644 --- a/app/data/service/OrderService.php +++ b/app/data/service/OrderService.php @@ -114,8 +114,8 @@ class OrderService extends Service $items = $query->withoutField('id,uid,status,deleted,create_at')->whereIn('order_no', $nobs)->select()->toArray(); // 关联用户数据 $fields = 'phone,username,nickname,headimg,status'; - UserService::instance()->buildByUid($data, 'uid', 'user', $fields); - if ($fromer) UserService::instance()->buildByUid($data, 'puid1', 'fromer', $fields); + UserAdminService::instance()->buildByUid($data, 'uid', 'user', $fields); + if ($fromer) UserAdminService::instance()->buildByUid($data, 'puid1', 'fromer', $fields); foreach ($data as &$vo) { [$vo['sales'], $vo['truck'], $vo['items']] = [0, $trucks[$vo['order_no']] ?? [], []]; foreach ($items as $item) if ($vo['order_no'] === $item['order_no']) { diff --git a/app/data/service/PaymentService.php b/app/data/service/PaymentService.php index 0bb6e6581..a271155c5 100644 --- a/app/data/service/PaymentService.php +++ b/app/data/service/PaymentService.php @@ -53,71 +53,71 @@ abstract class PaymentService 'type' => 'BALANCE', 'name' => '账号余额支付', 'bind' => [ - UserService::API_TYPE_WAP, UserService::API_TYPE_WEB, - UserService::API_TYPE_WXAPP, UserService::API_TYPE_WECHAT, - UserService::API_TYPE_IOSAPP, UserService::API_TYPE_ANDROID, + UserAdminService::API_TYPE_WAP, UserAdminService::API_TYPE_WEB, + UserAdminService::API_TYPE_WXAPP, UserAdminService::API_TYPE_WECHAT, + UserAdminService::API_TYPE_IOSAPP, UserAdminService::API_TYPE_ANDROID, ], ], self::PAYMENT_VOUCHER => [ 'type' => 'VOUCHER', 'name' => '单据凭证支付', 'bind' => [ - UserService::API_TYPE_WAP, UserService::API_TYPE_WEB, - UserService::API_TYPE_WXAPP, UserService::API_TYPE_WECHAT, - UserService::API_TYPE_IOSAPP, UserService::API_TYPE_ANDROID, + UserAdminService::API_TYPE_WAP, UserAdminService::API_TYPE_WEB, + UserAdminService::API_TYPE_WXAPP, UserAdminService::API_TYPE_WECHAT, + UserAdminService::API_TYPE_IOSAPP, UserAdminService::API_TYPE_ANDROID, ], ], self::PAYMENT_WECHAT_WAP => [ 'type' => 'MWEB', 'name' => '微信WAP支付', - 'bind' => [UserService::API_TYPE_WAP], + 'bind' => [UserAdminService::API_TYPE_WAP], ], self::PAYMENT_WECHAT_APP => [ 'type' => 'APP', 'name' => '微信APP支付', - 'bind' => [UserService::API_TYPE_IOSAPP, UserService::API_TYPE_ANDROID], + 'bind' => [UserAdminService::API_TYPE_IOSAPP, UserAdminService::API_TYPE_ANDROID], ], self::PAYMENT_WECHAT_XCX => [ 'type' => 'JSAPI', 'name' => '微信小程序支付', - 'bind' => [UserService::API_TYPE_WXAPP], + 'bind' => [UserAdminService::API_TYPE_WXAPP], ], self::PAYMENT_WECHAT_GZH => [ 'type' => 'JSAPI', 'name' => '微信公众号支付', - 'bind' => [UserService::API_TYPE_WECHAT], + 'bind' => [UserAdminService::API_TYPE_WECHAT], ], self::PAYMENT_WECHAT_QRC => [ 'type' => 'NATIVE', 'name' => '微信二维码支付', - 'bind' => [UserService::API_TYPE_WEB], + 'bind' => [UserAdminService::API_TYPE_WEB], ], // 支付宝支持配置(不需要的直接注释) self::PAYMENT_ALIPAY_WAP => [ 'type' => '', 'name' => '支付宝WAP支付', - 'bind' => [UserService::API_TYPE_WAP], + 'bind' => [UserAdminService::API_TYPE_WAP], ], self::PAYMENT_ALIPAY_WEB => [ 'type' => '', 'name' => '支付宝WEB支付', - 'bind' => [UserService::API_TYPE_WEB], + 'bind' => [UserAdminService::API_TYPE_WEB], ], self::PAYMENT_ALIAPY_APP => [ 'type' => '', 'name' => '支付宝APP支付', - 'bind' => [UserService::API_TYPE_ANDROID, UserService::API_TYPE_IOSAPP], + 'bind' => [UserAdminService::API_TYPE_ANDROID, UserAdminService::API_TYPE_IOSAPP], ], // 汇聚支持配置(不需要的直接注释) self::PAYMENT_JOINPAY_XCX => [ 'type' => 'WEIXIN_XCX', 'name' => '汇聚小程序支付', - 'bind' => [UserService::API_TYPE_WXAPP], + 'bind' => [UserAdminService::API_TYPE_WXAPP], ], self::PAYMENT_JOINPAY_GZH => [ 'type' => 'WEIXIN_GZH', 'name' => '汇聚公众号支付', - 'bind' => [UserService::API_TYPE_WECHAT], + 'bind' => [UserAdminService::API_TYPE_WECHAT], ], ]; @@ -213,7 +213,7 @@ abstract class PaymentService { $types = []; foreach (self::TYPES as $k => $v) if (isset($v['bind'])) { - if (array_intersect($v['bind'], array_keys(UserService::TYPES))) { + if (array_intersect($v['bind'], array_keys(UserAdminService::TYPES))) { $types[$k] = $v; } } diff --git a/app/data/service/UserService.php b/app/data/service/UserAdminService.php similarity index 97% rename from app/data/service/UserService.php rename to app/data/service/UserAdminService.php index 688686f71..843715418 100644 --- a/app/data/service/UserService.php +++ b/app/data/service/UserAdminService.php @@ -7,11 +7,11 @@ use think\admin\Service; use think\db\exception\DbException; /** - * 用户数据服务 - * Class UserService + * 用户数据管理服务 + * Class UserAdminService * @package app\store\service */ -class UserService extends Service +class UserAdminService extends Service { const API_TYPE_WAP = 'wap'; const API_TYPE_WEB = 'web';