Browse Source

[更新]同步framework代码

Anyon 5 năm trước cách đây
mục cha
commit
5990690c9f

+ 6 - 6
application/service/controller/Index.php

@@ -14,8 +14,8 @@
 
 namespace app\service\controller;
 
-use app\service\service\Build;
-use app\service\service\Wechat;
+use app\service\service\BuildService;
+use app\service\service\WechatService;
 use library\Controller;
 use think\Db;
 
@@ -57,7 +57,7 @@ class Index extends Controller
     public function clearQuota()
     {
         $appid = input('appid');
-        $result = Wechat::WeChatLimit($appid)->clearQuota();
+        $result = WechatService::WeChatLimit($appid)->clearQuota();
         if (empty($result['errcode']) && $result['errmsg'] === 'ok') {
             $this->success('接口调用次数清零成功!');
         } elseif (isset($result['errmsg'])) {
@@ -77,7 +77,7 @@ class Index extends Controller
             $where = ['authorizer_appid' => $appid, 'is_deleted' => '0', 'status' => '1'];
             $author = Db::name('WechatServiceConfig')->where($where)->find();
             empty($author) && $this->error('无效的授权信息,请同步其它公众号!');
-            $data = Build::filter(Wechat::service()->getAuthorizerInfo($appid));
+            $data = BuildService::filter(WechatService::service()->getAuthorizerInfo($appid));
             $data['authorizer_appid'] = $appid;
             $where = ['authorizer_appid' => $data['authorizer_appid']];
             $appkey = Db::name('WechatServiceConfig')->where($where)->value('appkey');
@@ -98,10 +98,10 @@ class Index extends Controller
     public function syncall()
     {
         try {
-            $wechat = Wechat::service();
+            $wechat = WechatService::service();
             $result = $wechat->getAuthorizerList();
             foreach ($result['list'] as $item) if (!empty($item['refresh_token']) && !empty($item['auth_time'])) {
-                $data = Build::filter($wechat->getAuthorizerInfo($item['authorizer_appid']));
+                $data = BuildService::filter($wechat->getAuthorizerInfo($item['authorizer_appid']));
                 $data['is_deleted'] = '0';
                 $data['authorizer_appid'] = $item['authorizer_appid'];
                 $data['authorizer_refresh_token'] = $item['refresh_token'];

+ 5 - 5
application/service/controller/api/Client.php

@@ -14,7 +14,7 @@
 
 namespace app\service\controller\api;
 
-use app\service\service\Wechat;
+use app\service\service\WechatService;
 use think\Controller;
 use think\Db;
 
@@ -104,13 +104,13 @@ class Client extends Controller
             $weminiClassName = 'Account,Basic,Code,Domain,Tester,User,Crypt,Plugs,Poi,Qrcode,Template,Total';
             $wechatClassName = 'Card,Custom,Limit,Media,Menu,Oauth,Pay,Product,Qrcode,Receive,Scan,Script,Shake,Tags,Template,User,Wifi';
             if ($this->type === 'wechat' && stripos($wechatClassName, $this->name) !== false) {
-                $instance = Wechat::instance($this->name, $this->appid, 'WeChat');
+                $instance = WechatService::instance($this->name, $this->appid, 'WeChat');
             } elseif ($this->type === 'wemini' && stripos($weminiClassName, $this->name) !== false) {
-                $instance = Wechat::instance($this->name, $this->appid, 'WeMini');
+                $instance = WechatService::instance($this->name, $this->appid, 'WeMini');
             } elseif (stripos('Service,MiniApp', $this->name) !== false) {
-                $instance = Wechat::instance($this->name, $this->appid, 'WeOpen');
+                $instance = WechatService::instance($this->name, $this->appid, 'WeOpen');
             } elseif (stripos('Wechat,Config,Handler', $this->name) !== false) {
-                $className = "\\app\\service\\handler\\Wechat";
+                $className = "\\app\\service\\handler\\WechatHandler";
                 $instance = new $className($this->config);
             }
             if (!empty($instance)) return $instance;

+ 11 - 10
application/service/controller/api/Push.php

@@ -14,8 +14,8 @@
 
 namespace app\service\controller\api;
 
-use app\service\service\Build;
-use app\service\service\Wechat;
+use app\service\service\BuildService;
+use app\service\service\WechatService;
 use library\Controller;
 use think\Db;
 
@@ -41,12 +41,13 @@ class Push extends Controller
      */
     public function notify($appid)
     {
-        /* 全网发布接口测试 */
         if ($appid === 'wx570bc396a51b8ff8') {
-            return \app\service\handler\Publish::handler($appid);
+            # 全网发布接口测试
+            return \app\service\handler\PublishHandler::handler($appid);
+        } else {
+            # 接口类正常服务
+            return \app\service\handler\ReceiveHandler::handler($appid);
         }
-        /* 接口类正常服务 */
-        return \app\service\handler\Receive::handler($appid);
     }
 
     /**
@@ -61,7 +62,7 @@ class Push extends Controller
     public function ticket()
     {
         try {
-            $server = Wechat::service();
+            $server = WechatService::service();
             if (!($data = $server->getComonentTicket())) {
                 return "Ticket event handling failed.";
             }
@@ -98,7 +99,7 @@ class Push extends Controller
             $this->request->get('mode'), $this->request->get('state'),
             $this->request->get('enurl'), $this->request->get('sessid'),
         ];
-        $service = Wechat::service();
+        $service = WechatService::service();
         $result = $service->getOauthAccessToken($appid);
         if (empty($result['openid'])) throw new \think\Exception('网页授权失败, 无法进一步操作!');
         cache("{$appid}_{$sessid}_openid", $result['openid'], 3600);
@@ -127,7 +128,7 @@ class Push extends Controller
             return '请传入回跳Redirect参数 ( 请使用ENCODE加密 )';
         }
         # 预授权码不为空,则表示可以进行授权处理
-        $service = Wechat::service();
+        $service = WechatService::service();
         if (($auth_code = $this->request->get('auth_code'))) {
             return $this->applyAuth($service, $fromRedirect);
         }
@@ -164,7 +165,7 @@ class Push extends Controller
             return '获取授权数据失败, 请稍候再试!';
         }
         // 生成公众号授权参数
-        $update = array_merge(Build::filter($update), [
+        $update = array_merge(BuildService::filter($update), [
             'status' => '1', 'is_deleted' => '0', 'expires_in' => time() + 7000, 'create_at' => date('y-m-d H:i:s'),
         ]);
         // 微信接口APPKEY处理与更新

+ 0 - 67
application/service/handler/Publish.php

@@ -1,67 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\service\handler;
-
-use app\service\service\Wechat;
-
-/**
- * 第三方平台测试上线
- *
- * @author Anyon <zoujingli@qq.com>
- * @date 2016/10/27 14:14
- */
-class Publish
-{
-
-    /**
-     * 当前微信APPID
-     * @var string
-     */
-    protected static $appid;
-
-    /**
-     * 事件初始化
-     * @param string $appid
-     * @return string
-     * @throws \WeChat\Exceptions\InvalidDecryptException
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function handler($appid)
-    {
-        try {
-            $wechat = Wechat::WeChatReceive($appid);
-        } catch (\Exception $e) {
-            return "Wechat message handling failed, {$e->getMessage()}";
-        }
-        /* 分别执行对应类型的操作 */
-        switch (strtolower($wechat->getMsgType())) {
-            case 'text':
-                $receive = $wechat->getReceive();
-                if ($receive['Content'] === 'TESTCOMPONENT_MSG_TYPE_TEXT') {
-                    return $wechat->text('TESTCOMPONENT_MSG_TYPE_TEXT_callback')->reply([], true);
-                }
-                $key = str_replace("QUERY_AUTH_CODE:", '', $receive['Content']);
-                Wechat::instance('Service')->getQueryAuthorizerInfo($key);
-                return $wechat->text("{$key}_from_api")->reply([], true);
-            case 'event':
-                $receive = $wechat->getReceive();
-                return $wechat->text("{$receive['Event']}from_callback")->reply([], true);
-            default:
-                return 'success';
-        }
-    }
-
-}

+ 0 - 64
application/service/handler/Receive.php

@@ -1,64 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\service\handler;
-
-use app\service\service\Wechat;
-use think\Db;
-
-/**
- * 微信推送消息处理
- *
- * @author Anyon <zoujingli@qq.com>
- * @date 2016/10/27 14:14
- */
-class Receive
-{
-
-    /**
-     * 事件初始化
-     * @param string $appid
-     * @return string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\Exception
-     */
-    public static function handler($appid)
-    {
-        try {
-            $service = Wechat::WeChatReceive($appid);
-        } catch (\Exception $e) {
-            return "Wechat message handling failed, {$e->getMessage()}";
-        }
-        // 验证微信配置信息
-        $config = Db::name('WechatServiceConfig')->where(['authorizer_appid' => $appid])->find();
-        if (empty($config) || empty($config['appuri'])) {
-            \think\facade\Log::error(($message = "微信{$appid}授权配置验证无效"));
-            return $message;
-        }
-        try {
-            list($data, $openid) = [$service->getReceive(), $service->getOpenid()];
-            if (isset($data['EventKey']) && is_object($data['EventKey'])) $data['EventKey'] = (array)$data['EventKey'];
-            $input = ['openid' => $openid, 'appid' => $appid, 'receive' => serialize($data), 'encrypt' => intval($service->isEncrypt())];
-            if (is_string($result = http_post($config['appuri'], $input, ['timeout' => 30]))) {
-                return $result;
-            }
-        } catch (\Exception $e) {
-            \think\facade\Log::error("微信{$appid}接口调用异常,{$e->getMessage()}");
-        }
-        return 'success';
-    }
-
-}

+ 0 - 160
application/service/handler/Wechat.php

@@ -1,160 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\service\handler;
-
-use app\service\service\Wechat as WechatLogic;
-use think\Db;
-
-/**
- * 微信网页授权接口
- * Class WechatHandler
- * @package app\wechat\handler
- * @author Anyon <zoujingli@qq.com>
- */
-class Wechat
-{
-    /**
-     * 当前微信APPID
-     * @var string
-     */
-    protected $appid;
-
-    /**
-     * 当前微信配置
-     * @var array
-     */
-    protected $config;
-
-    /**
-     * 错误消息
-     * @var string
-     */
-    protected $message;
-
-    /**
-     * Wechat constructor.
-     * @param array $config
-     */
-    public function __construct($config = [])
-    {
-        $this->config = $config;
-        $this->appid = isset($config['authorizer_appid']) ? $config['authorizer_appid'] : '';
-    }
-
-    /**
-     * 检查微信配置服务初始化状态
-     * @return boolean
-     * @throws \think\Exception
-     */
-    private function checkInit()
-    {
-        if (!empty($this->config)) return true;
-        throw new \think\Exception('Wechat Please bind Wechat first');
-    }
-
-    /**
-     * 获取当前公众号配置
-     * @return array|boolean
-     * @throws \think\Exception
-     */
-    public function getConfig()
-    {
-        $this->checkInit();
-        $info = Db::name('WechatServiceConfig')->where(['authorizer_appid' => $this->appid])->find();
-        if (empty($info)) return false;
-        if (isset($info['id'])) unset($info['id']);
-        return $info;
-    }
-
-    /**
-     * 设置微信接口通知URL地址
-     * @param string $notifyUri 接口通知URL地址
-     * @return boolean
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public function setApiNotifyUri($notifyUri)
-    {
-        $this->checkInit();
-        if (empty($notifyUri)) throw new \think\Exception('请传入微信通知URL');
-        list($where, $data) = [['authorizer_appid' => $this->appid], ['appuri' => $notifyUri]];
-        return Db::name('WechatServiceConfig')->where($where)->update($data) !== false;
-    }
-
-    /**
-     * 更新接口Appkey(成功返回新的Appkey)
-     * @return bool|string
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public function updateApiAppkey()
-    {
-        $this->checkInit();
-        $data = ['appkey' => md5(uniqid())];
-        Db::name('WechatServiceConfig')->where(['authorizer_appid' => $this->appid])->update($data);
-        return $data['appkey'];
-    }
-
-    /**
-     * 获取公众号的配置参数
-     * @param string $name 参数名称
-     * @return array|string
-     * @throws \think\Exception
-     */
-    public function config($name = null)
-    {
-        $this->checkInit();
-        return WechatLogic::WeChatScript($this->appid)->config->get($name);
-    }
-
-    /**
-     * 微信网页授权
-     * @param string $sessid 当前会话id(可用session_id()获取)
-     * @param string $selfUrl 当前会话URL地址(需包含域名的完整URL地址)
-     * @param int $fullMode 网页授权模式(0静默模式,1高级授权)
-     * @return array|bool
-     * @throws \think\Exception
-     */
-    public function oauth($sessid, $selfUrl, $fullMode = 0)
-    {
-        $this->checkInit();
-        $fans = cache("{$this->appid}_{$sessid}_fans");
-        $openid = cache("{$this->appid}_{$sessid}_openid");
-        if (!empty($openid) && (empty($fullMode) || !empty($fans))) {
-            return ['openid' => $openid, 'fans' => $fans, 'url' => ''];
-        }
-        $service = WechatLogic::service();
-        $mode = empty($fullMode) ? 'snsapi_base' : 'snsapi_userinfo';
-        $url = url('@service/api.push/oauth', '', true, true);
-        $params = ['mode' => $fullMode, 'sessid' => $sessid, 'enurl' => encode($selfUrl)];
-        $authurl = $service->getOauthRedirect($this->appid, $url . '?' . http_build_query($params), $mode);
-        return ['openid' => $openid, 'fans' => $fans, 'url' => $authurl];
-    }
-
-    /**
-     * 微信网页JS签名
-     * @param string $url 当前会话URL地址(需包含域名的完整URL地址)
-     * @return array|boolean
-     * @throws \WeChat\Exceptions\InvalidResponseException
-     * @throws \WeChat\Exceptions\LocalCacheException
-     * @throws \think\Exception
-     */
-    public function jsSign($url)
-    {
-        $this->checkInit();
-        return WechatLogic::WeChatScript($this->appid)->getJsSign($url);
-    }
-
-}

+ 0 - 52
application/service/service/Build.php

@@ -1,52 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\service\service;
-
-/**
- * 授权数据处理
- * Class Build
- * @package app\service\service
- */
-class Build
-{
-
-    /**
-     * 授权数据过滤转换处理
-     * @param array $info
-     * @return mixed
-     */
-    public static function filter(array $info)
-    {
-        if (isset($info['func_info'])) $info['func_info'] = join(',', array_map(function ($tmp) {
-            return $tmp['funcscope_category']['id'];
-        }, $info['func_info']));
-        $info['verify_type_info'] = join(',', $info['verify_type_info']);
-        $info['service_type_info'] = join(',', $info['service_type_info']);
-        $info['business_info'] = json_encode($info['business_info'], JSON_UNESCAPED_UNICODE);
-        // 微信类型:  0 代表订阅号, 2 代表服务号, 3 代表小程序
-        $info['service_type'] = intval($info['service_type_info']) === 2 ? 2 : 0;
-        if (!empty($info['MiniProgramInfo'])) {
-            // 微信类型:  0 代表订阅号, 2 代表服务号, 3 代表小程序
-            $info['service_type'] = 3;
-            // 小程序信息
-            $info['miniprograminfo'] = json_encode($info['MiniProgramInfo'], JSON_UNESCAPED_UNICODE);
-        }
-        unset($info['MiniProgramInfo']);
-        // 微信认证: -1 代表未认证, 0 代表微信认证
-        $info['verify_type'] = intval($info['verify_type_info']) !== 0 ? -1 : 0;
-        return $info;
-    }
-
-}

+ 0 - 150
application/service/service/Wechat.php

@@ -1,150 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\service\service;
-
-use think\Db;
-
-/**
- * 微信数据服务
- * Class Wechat
- * @package app\service\service
- * @method \WeChat\Card WeChatCard($appid) static 微信卡券管理
- * @method \WeChat\Custom WeChatCustom($appid) static 微信客服消息
- * @method \WeChat\Limit WeChatLimit($appid) static 接口调用频次限制
- * @method \WeChat\Media WeChatMedia($appid) static 微信素材管理
- * @method \WeChat\Menu WeChatMenu($appid) static 微信菜单管理
- * @method \WeChat\Oauth WeChatOauth($appid) static 微信网页授权
- * @method \WeChat\Pay WeChatPay($appid) static 微信支付商户
- * @method \WeChat\Product WeChatProduct($appid) static 微信商店管理
- * @method \WeChat\Qrcode WeChatQrcode($appid) static 微信二维码管理
- * @method \WeChat\Receive WeChatReceive($appid) static 微信推送管理
- * @method \WeChat\Scan WeChatScan($appid) static 微信扫一扫接入管理
- * @method \WeChat\Script WeChatScript($appid) static 微信前端支持
- * @method \WeChat\Shake WeChatShake($appid) static 微信揺一揺周边
- * @method \WeChat\Tags WeChatTags($appid) static 微信用户标签管理
- * @method \WeChat\Template WeChatTemplate($appid) static 微信模板消息
- * @method \WeChat\User WeChatUser($appid) static 微信粉丝管理
- * @method \WeChat\Wifi WeChatWifi($appid) static 微信门店WIFI管理
- *
- * ----- WeMini -----
- * @method \WeMini\Account WeMiniAccount($appid) static 小程序账号管理
- * @method \WeMini\Basic WeMiniBasic($appid) static 小程序基础信息设置
- * @method \WeMini\Code WeMiniCode($appid) static 小程序代码管理
- * @method \WeMini\Domain WeMiniDomain($appid) static 小程序域名管理
- * @method \WeMini\Tester WeMinitester($appid) static 小程序成员管理
- * @method \WeMini\User WeMiniUser($appid) static 小程序帐号管理
- * --------------------
- * @method \WeMini\Crypt WeMiniCrypt($appid) static 小程序数据加密处理
- * @method \WeMini\Plugs WeMiniPlugs($appid) static 小程序插件管理
- * @method \WeMini\Poi WeMiniPoi($appid) static 小程序地址管理
- * @method \WeMini\Qrcode WeMiniQrcode($appid) static 小程序二维码管理
- * @method \WeMini\Template WeMiniTemplate($appid) static 小程序模板消息支持
- * @method \WeMini\Total WeMiniTotal($appid) static 小程序数据接口
- *
- * ----- WePay -----
- * @method \WePay\Bill WePayBill($appid) static 微信商户账单及评论
- * @method \WePay\Order WePayOrder($appid) static 微信商户订单
- * @method \WePay\Refund WePayRefund($appid) static 微信商户退款
- * @method \WePay\Coupon WePayCoupon($appid) static 微信商户代金券
- * @method \WePay\Redpack WePayRedpack($appid) static 微信红包支持
- * @method \WePay\Transfers WePayTransfers($appid) static 微信商户打款到零钱
- * @method \WePay\TransfersBank WePayTransfersBank($appid) static 微信商户打款到银行卡
- *
- * ----- WeOpen -----
- * @method \WeOpen\Login login() static 第三方微信登录
- * @method \WeOpen\Service service() static 第三方服务
- *
- * ----- ThinkService -----
- * @method mixed wechat() static 第三方微信工具
- * @method mixed config() static 第三方配置工具
- */
-class Wechat
-{
-
-    /**
-     * 接口类型模式
-     * @var string
-     */
-    private static $type = 'WeChat';
-
-    /**
-     * 实例微信对象
-     * @param string $name
-     * @param string $appid 授权公众号APPID
-     * @param string $type 将要获取SDK类型
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function instance($name, $appid = '', $type = null)
-    {
-        $config = [
-            'cache_path'               => env('runtime_path') . 'wechat',
-            'component_appid'          => sysconf('component_appid'),
-            'component_token'          => sysconf('component_token'),
-            'component_appsecret'      => sysconf('component_appsecret'),
-            'component_encodingaeskey' => sysconf('component_encodingaeskey'),
-        ];
-        // 注册授权公众号 AccessToken 处理
-        $config['GetAccessTokenCallback'] = function ($authorizerAppid) use ($config) {
-            $where = ['authorizer_appid' => $authorizerAppid];
-            if (!($refreshToken = Db::name('WechatServiceConfig')->where($where)->value('authorizer_refresh_token'))) {
-                throw new \think\Exception('The WeChat information is not configured.', '404');
-            }
-            $open = new \WeOpen\MiniApp($config);
-            $result = $open->refreshAccessToken($authorizerAppid, $refreshToken);
-            if (empty($result['authorizer_access_token']) || empty($result['authorizer_refresh_token'])) {
-                throw new \think\Exception($result['errmsg'], '0');
-            }
-            Db::name('WechatServiceConfig')->where($where)->update([
-                'authorizer_access_token'  => $result['authorizer_access_token'],
-                'authorizer_refresh_token' => $result['authorizer_refresh_token'],
-            ]);
-            return $result['authorizer_access_token'];
-        };
-        $app = new \WeOpen\MiniApp($config);
-        if (in_array(strtolower($name), ['service', 'miniapp'])) {
-            return $app;
-        }
-        if (!in_array($type, ['WeChat', 'WeMini'])) {
-            $type = self::$type;
-        }
-        return $app->instance($name, $appid, $type);
-    }
-
-    /**
-     * 静态初始化对象
-     * @param string $name
-     * @param array $arguments
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function __callStatic($name, $arguments)
-    {
-        if (substr($name, 0, 6) === 'WeMini') {
-            self::$type = 'WeMini';
-            $name = substr($name, 6);
-        } elseif (substr($name, 0, 6) === 'WeChat') {
-            self::$type = 'WeChat';
-            $name = substr($name, 6);
-        } elseif (substr($name, 0, 5) === 'WePay') {
-            self::$type = 'WePay';
-            $name = substr($name, 5);
-        }
-        return self::instance($name, isset($arguments[0]) ? $arguments[0] : '', self::$type);
-    }
-
-}

+ 85 - 79
application/service/view/config/index.html

@@ -1,94 +1,100 @@
 {extend name="admin@main"}
 
 {block name="content"}
-<div class="nowrap" style="width:1295px">
-    <div class="layui-code margin-top-0 margin-bottom-20 think-box-shadow" style="border-left-width:1px">
-        强烈建议安装 YAR 扩展来实现接口通信,SOAP 不能正常显示接口的异常信息。
+<div class="relative">
+
+    <div class="think-box-shadow border-0 margin-bottom-20">
+        强烈建议安装 YAR 扩展来实现接口通信,SOAP 不能正常显示接口的异常信息
     </div>
-    <fieldset class="margin-bottom-15 margin-right-10 pull-left think-box-shadow wechat-box">
-        <legend class="layui-bg-cyan">授权参数</legend>
-        <form onsubmit="return false;" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
-            <div class="layui-form-item">
-                <label class="relative block">
-                    <span class="color-green">开放平台服务 AppID</span>
-                    <input name="component_appid" required pattern="^.{18}$" maxlength="18" placeholder="请输入18位开放平台服务AppID" value="{:sysconf('component_appid')}" class="layui-input">
-                </label>
-                <p class="help-block">开放平台服务 AppID,需要在微信开放平台获取。</p>
-            </div>
-            <div class="layui-form-item">
-                <label class="relative block">
-                    <span class="color-green">开放平台服务 AppSecret</span>
-                    <input name="component_appsecret" required pattern="^.{32}$" maxlength="32" placeholder="请输入32位开放平台服务AppSecret" value="{:sysconf('component_appsecret')}" class="layui-input">
-                </label>
-                <p class="help-block">开放平台服务 AppSecret,需要在微信开放平台获取。</p>
-            </div>
-            <div class="layui-form-item">
-                <label class="relative block">
-                    <span class="color-green">开放平台消息校验 Token</span>
-                    <input name="component_token" required placeholder="请输入微信消息校验Token" value="{:sysconf('component_token')}" class="layui-input">
-                </label>
-                <p class="help-block">开发者在代替微信接收到消息时,用此 Token 来校验消息。</p>
-            </div>
-            <div class="layui-form-item">
-                <label class="relative block">
-                    <span class="color-green">开放平台消息加解密 AesKey</span>
-                    <input name="component_encodingaeskey" required pattern="^.{43}$" maxlength="43" placeholder="请输入43位微信消息加解密Key" value="{:sysconf('component_encodingaeskey')}" class="layui-input">
-                </label>
-                <p class="help-block">在代替微信收发消息过程中使用。必须是长度为43位的字符串,只能是字母和数字。</p>
-            </div>
-            <div class="hr-line-dashed"></div>
-            <div class="text-center padding-bottom-15 margin-bottom-20">
-                <button class="layui-btn" type="submit">保存配置</button>
-            </div>
-        </form>
-    </fieldset>
 
-    <fieldset class="margin-bottom-15 pull-left think-box-shadow wechat-box">
-        <legend class="layui-bg-cyan">对接信息</legend>
-        <div class="layui-form-item">
-            <p class="color-green">授权发起页域名</p>
-            <label class="relative block">
-                <input disabled class="layui-input layui-bg-gray" value="{:request()->host()}">
-                <a data-copy="{:request()->host()}" class="fa fa-copy right-btn"></a>
-            </label>
-            <p class="help-block">必须从本域名内网页跳转到登录授权页,才可完成登录授权。无需填写 http:// 等域名协议前缀</p>
-        </div>
-        <div class="layui-form-item">
-            <p class="color-green">授权事件接收 URL</p>
-            <label class="relative block">
-                <input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/ticket','',false,true)}">
-                <a data-copy="{:url('@service/api.push/ticket','',false,true)}" class="fa fa-copy right-btn"></a>
-            </label>
-            <p class="help-block">用于接收取消授权通知、授权成功通知、授权更新通知,也用于接收 ticket,ticket 是验证平台方的重要凭据</p>
-        </div>
-        <div class="layui-form-item">
-            <p class="color-green">微信消息与事件接收 URL</p>
-            <label class="relative block">
-                <input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/notify/\$APPID\$','',false,true)}">
-                <a data-copy="{:url('@service/api.push/notify/\$APPID\$','',false,true)}" class="fa fa-copy right-btn"></a>
-            </label>
-            <p class="help-block">通过该 URL 接收微信消息和事件推送,该参数按规则填写,实际接收消息时 $APPID$ 将被替换为微信 AppId</p>
-        </div>
-        <div class="layui-form-item">
-            <p class="color-green">客户端系统 Yar 模块接口</p>
-            <label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/yar/PARAM','',false,true)}"></label>
-            <p class="help-block">客户端系统 Yar 接口 URL,PARAM 由调用参数组成(AppName-AppId-AppKey-AppType)</p>
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-lg6">
+            <fieldset class="think-box-shadow">
+                <legend class="layui-bg-cyan">授权参数</legend>
+                <form onsubmit="return false;" data-auto="true" method="post" class='layui-form padding-left-20 padding-right-20' autocomplete="off">
+                    <div class="layui-form-item">
+                        <label class="relative block">
+                            <span class="color-green">开放平台服务 AppID</span>
+                            <input name="component_appid" required pattern="^.{18}$" maxlength="18" placeholder="请输入18位开放平台服务AppID" value="{:sysconf('component_appid')}" class="layui-input">
+                        </label>
+                        <p class="help-block">开放平台服务 AppID,需要在微信开放平台获取</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="relative block">
+                            <span class="color-green">开放平台服务 AppSecret</span>
+                            <input name="component_appsecret" required pattern="^.{32}$" maxlength="32" placeholder="请输入32位开放平台服务AppSecret" value="{:sysconf('component_appsecret')}" class="layui-input">
+                        </label>
+                        <p class="help-block">开放平台服务 AppSecret,需要在微信开放平台获取</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="relative block">
+                            <span class="color-green">开放平台消息校验 Token</span>
+                            <input name="component_token" required placeholder="请输入微信消息校验Token" value="{:sysconf('component_token')}" class="layui-input">
+                        </label>
+                        <p class="help-block">开发者在代替微信接收到消息时,用此 Token 来校验消息</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="relative block">
+                            <span class="color-green">开放平台消息加解密 AesKey</span>
+                            <input name="component_encodingaeskey" required pattern="^.{43}$" maxlength="43" placeholder="请输入43位微信消息加解密Key" value="{:sysconf('component_encodingaeskey')}" class="layui-input">
+                        </label>
+                        <p class="help-block">在代替微信收发消息时使用,必须是长度为43位字母和数字组合的字符串</p>
+                    </div>
+                    <div class="hr-line-dashed"></div>
+                    <div class="text-center padding-bottom-15 margin-bottom-20">
+                        <button class="layui-btn" type="submit">保存配置</button>
+                    </div>
+                </form>
+            </fieldset>
         </div>
-        <div class="layui-form-item">
-            <p class="color-green">客户端系统 Soap 模块接口</p>
-            <label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/soap/PARAM','',false,true)}"></label>
-            <p class="help-block">客户端系统 Soap 接口 URL,PARAM 由调用参数组成(AppName-AppId-AppKey-AppType)</p>
+        <div class="layui-col-lg6">
+            <fieldset class="think-box-shadow">
+                <legend class="layui-bg-cyan">对接信息</legend>
+                <div class="padding-right-20 padding-left-20">
+                    <div class="layui-form-item">
+                        <p class="color-green">授权发起页域名</p>
+                        <label class="relative block">
+                            <input disabled class="layui-input layui-bg-gray" value="{:request()->host()}">
+                            <a data-copy="{:request()->host()}" class="fa fa-copy right-btn"></a>
+                        </label>
+                        <p class="help-block">从本域名跳转到登录授权页才可以完成登录授权,无需填写域名协议前缀</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <p class="color-green">授权事件接收 URL</p>
+                        <label class="relative block">
+                            <input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/ticket','',false,true)}">
+                            <a data-copy="{:url('@service/api.push/ticket','',false,true)}" class="fa fa-copy right-btn"></a>
+                        </label>
+                        <p class="help-block">用于接收取消授权通知、授权成功通知、授权更新通知、接收 TICKET 凭据</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <p class="color-green">微信消息与事件接收 URL</p>
+                        <label class="relative block">
+                            <input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/notify/\$APPID\$','',false,true)}">
+                            <a data-copy="{:url('@service/api.push/notify/\$APPID\$','',false,true)}" class="fa fa-copy right-btn"></a>
+                        </label>
+                        <p class="help-block">通过该 URL 接收微信消息和事件推送,$APPID$ 将被替换为微信 AppId</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <p class="color-green">客户端系统 Yar 模块接口</p>
+                        <label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/yar/PARAM','',false,true)}"></label>
+                        <p class="help-block">客户端 Yar 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
+                    </div>
+                    <div class="layui-form-item">
+                        <p class="color-green">客户端系统 Soap 模块接口</p>
+                        <label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/soap/PARAM','',false,true)}"></label>
+                        <p class="help-block">客户端 Soap 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
+                    </div>
+                </div>
+            </fieldset>
         </div>
-    </fieldset>
+    </div>
+
 </div>
 {/block}
 
 {block name='style'}
 <style>
-    fieldset.wechat-box {
-        width: 600px
-    }
-
     .right-btn {
         top: 0;
         right: 0;

+ 7 - 7
application/wechat/command/Fans.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\command;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use think\console\Command;
 use think\console\Input;
 use think\console\Output;
@@ -61,8 +61,8 @@ class Fans extends Command
      */
     protected function _list($next = '', $index = 0)
     {
-        $appid = Wechat::getAppid();
-        $wechat = Wechat::WeChatUser();
+        $appid = WechatService::getAppid();
+        $wechat = WechatService::WeChatUser();
         $this->output->comment('preparing synchronize fans list ...');
         while (true) if (is_array($result = $wechat->getUserList($next)) && !empty($result['data']['openid'])) {
             foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
@@ -70,7 +70,7 @@ class Fans extends Command
                     foreach ($list['user_info_list'] as $user) {
                         $indexString = str_pad(++$index, strlen($result['total']), '0', STR_PAD_LEFT);
                         $this->output->writeln("({$indexString}/{$result['total']}) updating wechat user {$user['openid']} {$user['nickname']}");
-                        \app\wechat\service\Fans::set($user, $appid);
+                        \app\wechat\service\FansService::set($user, $appid);
                     }
                 }
             }
@@ -91,7 +91,7 @@ class Fans extends Command
      */
     public function _black($next = '', $index = 0)
     {
-        $wechat = Wechat::WeChatUser();
+        $wechat = WechatService::WeChatUser();
         $this->output->comment('prepare synchronize fans black ...');
         while (true) if (is_array($result = $wechat->getBlackList($next)) && !empty($result['data']['openid'])) {
             foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
@@ -118,8 +118,8 @@ class Fans extends Command
      */
     public function _tags($index = 0)
     {
-        $appid = Wechat::getAppid();
-        $wechat = Wechat::WeChatTags();
+        $appid = WechatService::getAppid();
+        $wechat = WechatService::WeChatTags();
         $this->output->comment('prepare synchronize fans tags ...');
         if (is_array($list = $wechat->getTags()) && !empty($list['tags'])) {
             $count = count($list['tags']);

+ 4 - 4
application/wechat/controller/Config.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use library\Controller;
 use library\File;
 
@@ -45,10 +45,10 @@ class Config extends Controller
                 sysconf('wechat_type', 'thr');
                 sysconf('wechat_thr_appid', input('appid'));
                 sysconf('wechat_thr_appkey', input('appkey'));
-                Wechat::wechat()->setApiNotifyUri($this->thrNotify);
+                WechatService::wechat()->setApiNotifyUri($this->thrNotify);
             }
             try {
-                $this->wechat = Wechat::wechat()->getConfig();
+                $this->wechat = WechatService::wechat()->getConfig();
             } catch (\Exception $e) {
                 $this->wechat = [];
             }
@@ -56,7 +56,7 @@ class Config extends Controller
         } else {
             foreach ($this->request->post() as $k => $v) sysconf($k, $v);
             if ($this->request->post('wechat_type') === 'thr') {
-                Wechat::wechat()->setApiNotifyUri($this->thrNotify);
+                WechatService::wechat()->setApiNotifyUri($this->thrNotify);
             }
             $uri = url('wechat/config/options');
             $this->success('公众号参数获取成功!', url('@admin') . "#{$uri}");

+ 6 - 6
application/wechat/controller/Fans.php

@@ -14,9 +14,9 @@
 
 namespace app\wechat\controller;
 
-use app\admin\service\Queue;
-use app\wechat\queue\Jobs;
-use app\wechat\service\Wechat;
+use app\admin\service\QueueService;
+use app\wechat\queue\WechatQueue;
+use app\wechat\service\WechatService;
 use library\Controller;
 use think\Db;
 use think\exception\HttpResponseException;
@@ -75,7 +75,7 @@ class Fans extends Controller
         $this->applyCsrfToken();
         try {
             foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
-                Wechat::WeChatUser()->batchBlackList($openids);
+                WechatService::WeChatUser()->batchBlackList($openids);
                 Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '1']);
             }
             $this->success('拉黑粉丝信息成功!');
@@ -94,7 +94,7 @@ class Fans extends Controller
         $this->applyCsrfToken();
         try {
             foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
-                Wechat::WeChatUser()->batchUnblackList($openids);
+                WechatService::WeChatUser()->batchUnblackList($openids);
                 Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '0']);
             }
             $this->success('取消拉黑粉丝信息成功!');
@@ -111,7 +111,7 @@ class Fans extends Controller
     public function sync()
     {
         try {
-            Queue::add('同步粉丝列表', Jobs::URI, 0, [], 0);
+            QueueService::add('同步粉丝列表', WechatQueue::URI, 0, [], 0);
             $this->success('创建同步粉丝任务成功,需要时间来完成。<br>请到系统任务管理查看进度!');
         } catch (HttpResponseException $exception) {
             throw $exception;

+ 2 - 2
application/wechat/controller/Keys.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use library\Controller;
 use think\Db;
 
@@ -54,7 +54,7 @@ class Keys extends Controller
         // 关键字二维码生成
         if ($this->request->get('action') === 'qrc') {
             try {
-                $wechat = Wechat::WeChatQrcode();
+                $wechat = WechatService::WeChatQrcode();
                 $result = $wechat->create($this->request->get('keys', ''));
                 $this->success('生成二维码成功!', "javascript:$.previewImage('{$wechat->url($result['ticket'])}')");
             } catch (\think\exception\HttpResponseException $exception) {

+ 4 - 4
application/wechat/controller/Menu.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use library\Controller;
 use think\Db;
 
@@ -72,7 +72,7 @@ class Menu extends Controller
             $data = $this->request->post('data');
             if (empty($data)) { // 删除菜单
                 try {
-                    Wechat::WeChatMenu()->delete();
+                    WechatService::WeChatMenu()->delete();
                 } catch (\Exception $e) {
                     $this->error('删除微信菜单失败,请稍候再试!' . $e->getMessage());
                 }
@@ -80,7 +80,7 @@ class Menu extends Controller
             }
             try {
                 sysdata('menudata', $this->buildMenu($menudata = json_decode($data, true)));
-                Wechat::WeChatMenu()->create(['button' => sysdata('menudata')]);
+                WechatService::WeChatMenu()->create(['button' => sysdata('menudata')]);
             } catch (\Exception $e) {
                 $this->error("微信菜单发布失败,请稍候再试!<br> {$e->getMessage()}");
             }
@@ -142,7 +142,7 @@ class Menu extends Controller
     public function cancel()
     {
         try {
-            Wechat::WeChatMenu()->delete();
+            WechatService::WeChatMenu()->delete();
         } catch (\Exception $e) {
             $this->error("菜单取消失败,请稍候再试!<br> {$e->getMessage()}");
         }

+ 4 - 4
application/wechat/controller/News.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller;
 
-use app\wechat\service\Media;
+use app\wechat\service\MediaService;
 use library\Controller;
 use think\Db;
 
@@ -56,7 +56,7 @@ class News extends Controller
      */
     protected function _index_page_filter(&$data)
     {
-        foreach ($data as &$vo) $vo = Media::news($vo['id']);
+        foreach ($data as &$vo) $vo = MediaService::news($vo['id']);
     }
 
     /**
@@ -82,7 +82,7 @@ class News extends Controller
      */
     protected function _select_page_filter(&$data)
     {
-        foreach ($data as &$vo) $vo = Media::news($vo['id']);
+        foreach ($data as &$vo) $vo = MediaService::news($vo['id']);
     }
 
     /**
@@ -118,7 +118,7 @@ class News extends Controller
         if ($this->request->isGet()) {
             empty($id) && $this->error('参数错误,请稍候再试!');
             if ($this->request->get('output') === 'json') {
-                $this->success('获取数据成功!', Media::news($id));
+                $this->success('获取数据成功!', MediaService::news($id));
             }
             $this->fetch('form', ['title' => '编辑图文']);
         } else {

+ 3 - 3
application/wechat/controller/api/Js.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller\api;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use library\Controller;
 use think\facade\Response;
 
@@ -36,10 +36,10 @@ class Js extends Controller
     public function index()
     {
         $url = $this->request->server('http_referer', $this->request->url(true), null);
-        $wechat = Wechat::getWebOauthInfo($url, $this->request->get('mode', 1), false);
+        $wechat = WechatService::getWebOauthInfo($url, $this->request->get('mode', 1), false);
         $openid = isset($wechat['openid']) ? $wechat['openid'] : '';
         $unionid = empty($wechat['fansinfo']['unionid']) ? '' : $wechat['fansinfo']['unionid'];
-        $configJson = json_encode(Wechat::getWebJssdkSign($url), JSON_UNESCAPED_UNICODE);
+        $configJson = json_encode(WechatService::getWebJssdkSign($url), JSON_UNESCAPED_UNICODE);
         $fansinfoJson = json_encode(isset($wechat['fansinfo']) ? $wechat['fansinfo'] : [], JSON_UNESCAPED_UNICODE);
         $html = <<<EOF
 if(typeof wx==='object'){

+ 14 - 14
application/wechat/controller/api/Push.php

@@ -14,9 +14,9 @@
 
 namespace app\wechat\controller\api;
 
-use app\wechat\service\Fans;
-use app\wechat\service\Media;
-use app\wechat\service\Wechat;
+use app\wechat\service\FansService;
+use app\wechat\service\MediaService;
+use app\wechat\service\WechatService;
 use library\Controller;
 use think\Db;
 
@@ -87,8 +87,8 @@ class Push extends Controller
     public function index()
     {
         try {
-            $this->wechat = Wechat::WeChatReceive();
-            if ($this->request->has('receive', 'post') && Wechat::getType() === 'thr') {
+            $this->wechat = WechatService::WeChatReceive();
+            if ($this->request->has('receive', 'post') && WechatService::getType() === 'thr') {
                 $this->forceCustom = true;
                 $this->appid = $this->request->post('appid', '', null);
                 $this->openid = $this->request->post('openid', '', null);
@@ -99,7 +99,7 @@ class Push extends Controller
                 }
             } else {
                 $this->forceCustom = false;
-                $this->appid = Wechat::getAppid();
+                $this->appid = WechatService::getAppid();
                 $this->openid = $this->wechat->getOpenid();
                 $this->encrypt = $this->wechat->isEncrypt();
                 $this->receive = $this->toLower($this->wechat->getReceive());
@@ -217,13 +217,13 @@ class Push extends Controller
             case 'customservice':
                 return $this->sendMessage('customservice', ['content' => $data['content']], false);
             case 'voice':
-                if (empty($data['voice_url']) || !($mediaId = Media::upload($data['voice_url'], 'voice'))) return false;
+                if (empty($data['voice_url']) || !($mediaId = MediaService::upload($data['voice_url'], 'voice'))) return false;
                 return $this->sendMessage('voice', ['media_id' => $mediaId], $isCustom);
             case 'image':
-                if (empty($data['image_url']) || !($mediaId = Media::upload($data['image_url'], 'image'))) return false;
+                if (empty($data['image_url']) || !($mediaId = MediaService::upload($data['image_url'], 'image'))) return false;
                 return $this->sendMessage('image', ['media_id' => $mediaId], $isCustom);
             case 'news':
-                list($news, $articles) = [Media::news($data['news_id']), []];
+                list($news, $articles) = [MediaService::news($data['news_id']), []];
                 if (empty($news['articles'])) return false;
                 foreach ($news['articles'] as $vo) array_push($articles, [
                     'url'   => url("@wechat/api.review/view", '', false, true) . "?id={$vo['id']}",
@@ -233,14 +233,14 @@ class Push extends Controller
             case 'music':
                 if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) return false;
                 return $this->sendMessage('music', [
-                    'thumb_media_id' => empty($data['music_image']) ? '' : Media::upload($data['music_image'], 'image'),
+                    'thumb_media_id' => empty($data['music_image']) ? '' : MediaService::upload($data['music_image'], 'image'),
                     'description'    => $data['music_desc'], 'title' => $data['music_title'],
                     'hqmusicurl'     => $data['music_url'], 'musicurl' => $data['music_url'],
                 ], $isCustom);
             case 'video':
                 if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) return false;
                 $videoData = ['title' => $data['video_title'], 'introduction' => $data['video_desc']];
-                if (!($mediaId = Media::upload($data['video_url'], 'video', $videoData))) return false;
+                if (!($mediaId = MediaService::upload($data['video_url'], 'video', $videoData))) return false;
                 return $this->sendMessage('video', ['media_id' => $mediaId, 'title' => $data['video_title'], 'description' => $data['video_desc']], $isCustom);
             default:
                 return false;
@@ -262,7 +262,7 @@ class Push extends Controller
     private function sendMessage($type, $data, $isCustom = false)
     {
         if ($isCustom) {
-            Wechat::WeChatCustom()->send(['touser' => $this->openid, 'msgtype' => $type, "{$type}" => $data]);
+            WechatService::WeChatCustom()->send(['touser' => $this->openid, 'msgtype' => $type, "{$type}" => $data]);
         } else switch (strtolower($type)) {
             case 'text': // 发送文本消息
                 return $this->wechat->reply(['CreateTime' => time(), 'MsgType' => 'text', 'ToUserName' => $this->openid, 'FromUserName' => $this->fromOpenid, 'Content' => $data['content']], true, $this->encrypt);
@@ -311,8 +311,8 @@ class Push extends Controller
     {
         if ($subscribe) {
             try {
-                $user = Wechat::WeChatUser()->getUserInfo($this->openid);
-                return Fans::set(array_merge($user, ['subscribe' => '1']));
+                $user = WechatService::WeChatUser()->getUserInfo($this->openid);
+                return FansService::set(array_merge($user, ['subscribe' => '1']));
             } catch (\Exception $e) {
                 \think\facade\Log::error(__METHOD__ . " {$this->openid} 粉丝信息获取失败,{$e->getMessage()}");
                 return false;

+ 2 - 2
application/wechat/controller/api/Review.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller\api;
 
-use app\wechat\service\Media;
+use app\wechat\service\MediaService;
 use library\Controller;
 use think\Db;
 
@@ -35,7 +35,7 @@ class Review extends Controller
      */
     public function news($id = 0)
     {
-        $this->news = Media::news(empty($id) ? input('id') : $id);
+        $this->news = MediaService::news(empty($id) ? input('id') : $id);
         $this->fetch();
     }
 

+ 17 - 15
application/wechat/controller/api/Tools.php

@@ -14,7 +14,7 @@
 
 namespace app\wechat\controller\api;
 
-use app\wechat\service\Wechat;
+use app\wechat\service\WechatService;
 use library\Controller;
 
 /**
@@ -34,8 +34,9 @@ class Tools extends Controller
      */
     public function oauth()
     {
-        $this->fans = Wechat::getWebOauthInfo($this->request->url(true), 1);
-        return $this->fetch();
+        $this->url = $this->request->url(true);
+        $this->fans = WechatService::getWebOauthInfo($this->url, 1);
+        $this->fetch();
     }
 
     /**
@@ -61,7 +62,8 @@ class Tools extends Controller
      */
     public function jssdk()
     {
-        return $this->fetch('', ['options' => Wechat::getWebJssdkSign()]);
+        $this->options = WechatService::getWebJssdkSign();
+        $this->fetch();
     }
 
     /**
@@ -73,8 +75,8 @@ class Tools extends Controller
      */
     public function jssdk_qrc()
     {
-        $url = url('@wechat/api.tools/jssdk', '', true, true);
-        return $this->createQrc($url);
+        $this->url = url('@wechat/api.tools/jssdk', '', true, true);
+        return $this->createQrc($this->url);
     }
 
     /**
@@ -101,7 +103,7 @@ class Tools extends Controller
      */
     public function scanOneQrc()
     {
-        $pay = Wechat::WePayOrder();
+        $pay = WechatService::WePayOrder();
         $result = $pay->qrcParams('8888888');
         return $this->createQrc($result);
     }
@@ -114,7 +116,7 @@ class Tools extends Controller
      */
     public function scanOneNotify()
     {
-        $pay = Wechat::WePayOrder();
+        $pay = WechatService::WePayOrder();
         $notify = $pay->getNotify();
         p('======= 来自扫码支付1的数据 ======');
         p($notify);
@@ -159,7 +161,7 @@ class Tools extends Controller
      */
     public function scanQrc()
     {
-        $pay = Wechat::WePayOrder();
+        $pay = WechatService::WePayOrder();
         $result = $pay->create([
             'body'             => '测试商品',
             'out_trade_no'     => time(),
@@ -181,8 +183,8 @@ class Tools extends Controller
      */
     public function jsapiQrc()
     {
-        $url = url('@wechat/api.tools/jsapi', '', true, true);
-        return $this->createQrc($url);
+        $this->url = url('@wechat/api.tools/jsapi', '', true, true);
+        return $this->createQrc($this->url);
     }
 
     /**
@@ -195,8 +197,8 @@ class Tools extends Controller
      */
     public function jsapi()
     {
-        $pay = Wechat::WePayOrder();
-        $openid = Wechat::getWebOauthInfo(request()->url(true), 0)['openid'];
+        $pay = WechatService::WePayOrder();
+        $openid = WechatService::getWebOauthInfo(request()->url(true), 0)['openid'];
         $options = [
             'body'             => '测试商品',
             'out_trade_no'     => time(),
@@ -212,7 +214,7 @@ class Tools extends Controller
         $options = $pay->jsapiParams($result['prepay_id']);
         $optionJSON = json_encode($options, JSON_UNESCAPED_UNICODE);
         // JSSDK 签名配置
-        $configJSON = json_encode(Wechat::getWebJssdkSign(), JSON_UNESCAPED_UNICODE);
+        $configJSON = json_encode(WechatService::getWebJssdkSign(), JSON_UNESCAPED_UNICODE);
 
         echo '<pre>';
         echo "当前用户OPENID: {$openid}";
@@ -246,7 +248,7 @@ class Tools extends Controller
      */
     public function notify()
     {
-        $wechat = Wechat::WePayOrder();
+        $wechat = WechatService::WePayOrder();
         p($wechat->getNotify());
         return 'SUCCESS';
     }

+ 0 - 75
application/wechat/queue/Jobs.php

@@ -1,75 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\wechat\queue;
-
-use app\admin\queue\JobsBase;
-use app\wechat\service\Fans;
-use app\wechat\service\Wechat;
-use think\Db;
-
-/**
- * Class Jobs
- * @package app\wechat
- */
-class Jobs extends JobsBase
-{
-    /**
-     * 当前任务URI
-     */
-    const URI = self::class;
-
-    /**
-     * 执行任务
-     * @return boolean
-     */
-    public function execute()
-    {
-        try {
-            $appid = Wechat::getAppid();
-            $wechat = Wechat::WeChatUser();
-            $next = ''; // 获取远程粉丝
-            $this->output->writeln('Start synchronizing fans from the Wechat server');
-            while (is_array($result = $wechat->getUserList($next)) && !empty($result['data']['openid'])) {
-                foreach (array_chunk($result['data']['openid'], 100) as $chunk)
-                    if (is_array($list = $wechat->getBatchUserInfo($chunk)) && !empty($list['user_info_list']))
-                        foreach ($list['user_info_list'] as $user) Fans::set($user, $appid);
-                if (in_array($result['next_openid'], $result['data']['openid'])) break;
-                $next = $result['next_openid'];
-            }
-            $next = ''; // 同步粉丝黑名单
-            $this->output->writeln('Start synchronizing black from the Wechat server');
-            while (is_array($result = $wechat->getBlackList($next)) && !empty($result['data']['openid'])) {
-                foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
-                    $where = [['is_black', 'eq', '0'], ['openid', 'in', $chunk]];
-                    Db::name('WechatFans')->where($where)->update(['is_black' => '1']);
-                }
-                if (in_array($result['next_openid'], $result['data']['openid'])) break;
-                $next = $result['next_openid'];
-            }
-            // 同步粉丝标签列表
-            $this->output->writeln('Start synchronizing tags from the Wechat server');
-            if (is_array($list = Wechat::WeChatTags()->getTags()) && !empty($list['tags'])) {
-                foreach ($list['tags'] as &$tag) $tag['appid'] = $appid;
-                Db::name('WechatFansTags')->where('1=1')->delete();
-                Db::name('WechatFansTags')->insertAll($list['tags']);
-            }
-            return true;
-        } catch (\Exception $e) {
-            $this->statusDesc = $e->getMessage();
-            return false;
-        }
-    }
-
-}

+ 0 - 68
application/wechat/service/Fans.php

@@ -1,68 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\wechat\service;
-
-use think\Db;
-
-/**
- * 微信粉丝信息
- * Class Fans
- * @package app\wechat\service
- */
-class Fans
-{
-
-    /**
-     * 增加或更新粉丝信息
-     * @param array $user 粉丝信息
-     * @param string $appid 公众号APPID
-     * @return boolean
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function set(array $user, $appid = '')
-    {
-        if (!empty($user['subscribe_time'])) {
-            $user['subscribe_at'] = date('Y-m-d H:i:s', $user['subscribe_time']);
-        }
-        if (isset($user['tagid_list']) && is_array($user['tagid_list'])) {
-            $user['tagid_list'] = is_array($user['tagid_list']) ? join(',', $user['tagid_list']) : '';
-        }
-        foreach (['country', 'province', 'city', 'nickname', 'remark'] as $k) {
-            isset($user[$k]) && $user[$k] = emoji_encode($user[$k]);
-        }
-        if ($appid !== '') $user['appid'] = $appid;
-        unset($user['privilege'], $user['groupid']);
-        return data_save('WechatFans', $user, 'openid');
-    }
-
-    /**
-     * 获取粉丝信息
-     * @param string $openid
-     * @return array|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function get($openid)
-    {
-        $user = Db::name('WechatFans')->where(['openid' => $openid])->find();
-        foreach (['country', 'province', 'city', 'nickname', 'remark'] as $k) {
-            isset($user[$k]) && $user[$k] = emoji_decode($user[$k]);
-        }
-        return $user;
-    }
-
-}

+ 0 - 83
application/wechat/service/Media.php

@@ -1,83 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\wechat\service;
-
-use library\File;
-use think\Db;
-use WeChat\Contracts\MyCurlFile;
-
-/**
- * 微信素材管理
- * Class Media
- * @package app\wechat\service
- */
-class Media
-{
-    /**
-     * 通过图文ID读取图文信息
-     * @param integer $id 本地图文ID
-     * @param array $where 额外的查询条件
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function news($id, $where = [])
-    {
-        $data = Db::name('WechatNews')->where(['id' => $id])->where($where)->find();
-        list($data['articles'], $articleIds) = [[], explode(',', $data['article_id'])];
-        $articles = Db::name('WechatNewsArticle')->whereIn('id', $articleIds)->select();
-        foreach ($articleIds as $article_id) foreach ($articles as $article) {
-            if (intval($article['id']) === intval($article_id)) array_push($data['articles'], $article);
-            unset($article['create_by'], $article['create_at']);
-        }
-        return $data;
-    }
-
-    /**
-     * 上传图片永久素材,返回素材media_id
-     * @param string $url 文件URL地址
-     * @param string $type 文件类型
-     * @param array $videoInfo 视频信息
-     * @return string|null
-     * @throws \WeChat\Exceptions\InvalidResponseException
-     * @throws \WeChat\Exceptions\LocalCacheException
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function upload($url, $type = 'image', $videoInfo = [])
-    {
-        $where = ['md5' => md5($url), 'appid' => Wechat::getAppid()];
-        if (($mediaId = Db::name('WechatMedia')->where($where)->value('media_id'))) return $mediaId;
-        $result = Wechat::WeChatMedia()->addMaterial(self::getServerPath($url), $type, $videoInfo);
-        data_save('WechatMedia', [
-            'local_url' => $url, 'md5' => $where['md5'], 'appid' => Wechat::getAppid(), 'type' => $type,
-            'media_url' => isset($result['url']) ? $result['url'] : '', 'media_id' => $result['media_id'],
-        ], 'type', $where);
-        return $result['media_id'];
-    }
-
-    /**
-     * 文件位置处理
-     * @param string $local
-     * @return string
-     * @throws \WeChat\Exceptions\LocalCacheException
-     */
-    private static function getServerPath($local)
-    {
-        if (file_exists($local)) return new MyCurlFile($local);
-        return new MyCurlFile(File::down($local)['file']);
-    }
-}

+ 0 - 248
application/wechat/service/Wechat.php

@@ -1,248 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | framework
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://framework.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | github开源项目:https://github.com/zoujingli/framework
-// +----------------------------------------------------------------------
-
-namespace app\wechat\service;
-
-/**
- * 微信处理管理
- * Class Wechat
- * @package app\wechat\service
- *
- * ----- WeOpen for Open -----
- * @method \WeOpen\Login login() static 第三方微信登录
- * @method \WeOpen\Service service() static 第三方服务
- *
- * ----- WeMini for Open -----
- * @method \WeMini\Code WeMiniCode() static 小程序代码管理
- * @method \WeMini\User WeMiniUser() static 小程序帐号管理
- * @method \WeMini\Basic WeMiniBasic() static 小程序基础信息
- * @method \WeMini\Domain WeMiniDomain() static 小程序域名管理
- * @method \WeMini\Tester WeMiniTester() static 小程序成员管理
- * @method \WeMini\Account WeMiniAccount() static 小程序账号管理
- *
- * ----- ThinkService -----
- * @method mixed wechat() static 第三方微信工具
- */
-class Wechat extends \We
-{
-
-    /**
-     * 接口类型模式
-     * @var string
-     */
-    private static $type = 'WeChat';
-
-    /**
-     * 获取微信支付配置
-     * @param array|null $options
-     * @return array
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function config($options = null)
-    {
-        if (empty($options)) $options = [
-            // 微信功能必需参数
-            'appid'          => self::getAppid(),
-            'token'          => sysconf('wechat_token'),
-            'appsecret'      => sysconf('wechat_appsecret'),
-            'encodingaeskey' => sysconf('wechat_encodingaeskey'),
-            // 微信支付必要参数
-            'mch_id'         => sysconf('wechat_mch_id'),
-            'mch_key'        => sysconf('wechat_mch_key'),
-            'cache_path'     => env('runtime_path') . 'wechat' . DIRECTORY_SEPARATOR,
-        ];
-        if (sysconf('wechat_mch_ssl_type') === 'p12') {
-            $options['ssl_p12'] = self::_parseCertPath(sysconf('wechat_mch_ssl_p12'));
-        } else {
-            $options['ssl_key'] = self::_parseCertPath(sysconf('wechat_mch_ssl_key'));
-            $options['ssl_cer'] = self::_parseCertPath(sysconf('wechat_mch_ssl_cer'));
-        }
-        return parent::config($options);
-    }
-
-    /**
-     * 解析证书路径
-     * @param string $path
-     * @return mixed
-     * @throws \think\Exception
-     */
-    private static function _parseCertPath($path)
-    {
-        if (preg_match('|^[a-z0-9]{16,16}\/[a-z0-9]{16,16}\.|i', $path)) {
-            return \library\File::instance('local')->path($path, true);
-        }
-        return $path;
-    }
-
-    /**
-     * 静态魔术加载方法
-     * @param string $name 静态类名
-     * @param array $arguments 参数集合
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function __callStatic($name, $arguments)
-    {
-        $config = [];
-        if (is_array($arguments) && count($arguments) > 0) {
-            $option = array_shift($arguments);
-            $config = is_array($option) ? $option : self::config();
-        }
-        if (in_array($name, ['wechat'])) {
-            return self::instance(trim($name, '_'), 'WeChat', $config);
-        } elseif (substr($name, 0, 6) === 'WeChat') {
-            return self::instance(substr($name, 6), 'WeChat', $config);
-        } elseif (substr($name, 0, 6) === 'WeMini') {
-            return self::instance(substr($name, 6), 'WeMini', $config);
-        } elseif (substr($name, 0, 5) === 'WePay') {
-            return self::instance(substr($name, 5), 'WePay', $config);
-        } elseif (substr($name, 0, 6) === 'AliPay') {
-            return self::instance(substr($name, 6), 'AliPay', $config);
-        }
-        throw new \think\Exception("class {$name} not found");
-    }
-
-    /**
-     * 接口对象实例化
-     * @param string $name 接口名称
-     * @param string $type 接口类型
-     * @param array $config 微信配置
-     * @return mixed
-     * @throws \SoapFault
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function instance($name, $type = 'WeChat', $config = [])
-    {
-        if (!in_array($type, ['WeChat', 'WeMini', 'WePay', 'AliPay'])) $type = self::$type;
-        if (self::getType() === 'api' || in_array($type, ['WePay', 'AliPay'])) {
-            $class = "\\{$type}\\" . ucfirst(strtolower($name));
-            if (class_exists($class)) return new $class(empty($config) ? self::config() : $config);
-            throw new \think\Exception("Class '{$class}' not found");
-        }
-        set_time_limit(3600);
-        list($appid, $appkey) = [sysconf('wechat_thr_appid'), sysconf('wechat_thr_appkey')];
-        $token = strtolower("{$name}-{$appid}-{$appkey}-{$type}");
-        if (class_exists('Yar_Client')) {
-            return new \Yar_Client(config('wechat.service_url') . "/service/api.client/yar/{$token}");
-        }
-        if (class_exists('SoapClient')) {
-            $location = config('wechat.service_url') . "/service/api.client/soap/{$token}";
-            return new \SoapClient(null, ['uri' => strtolower($name), 'location' => $location]);
-        }
-        throw new \think\Exception("Yar or soap extensions are not installed.");
-    }
-
-    /**
-     * 获取微信网页JSSDK
-     * @param string $url JS签名地址
-     * @return array
-     * @throws \WeChat\Exceptions\InvalidResponseException
-     * @throws \WeChat\Exceptions\LocalCacheException
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function getWebJssdkSign($url = null)
-    {
-        $url = is_null($url) ? request()->url(true) : $url;
-        if (self::getType() === 'api') {
-            return self::WeChatScript()->getJsSign($url);
-        } else {
-            return self::wechat()->jsSign($url);
-        }
-    }
-
-    /**
-     * 初始化进入授权
-     * @param string $url 授权页面URL地址
-     * @param integer $isfull 授权公众号模式
-     * @param boolean $isRedirect 是否进行跳转
-     * @return array
-     * @throws \WeChat\Exceptions\InvalidResponseException
-     * @throws \WeChat\Exceptions\LocalCacheException
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function getWebOauthInfo($url, $isfull = 0, $isRedirect = true)
-    {
-        $appid = self::getAppid();
-        list($openid, $fansinfo) = [session("{$appid}_openid"), session("{$appid}_fansinfo")];
-        if ((empty($isfull) && !empty($openid)) || (!empty($isfull) && !empty($openid) && !empty($fansinfo))) {
-            empty($fansinfo) || Fans::set($fansinfo);
-            return ['openid' => $openid, 'fansinfo' => $fansinfo];
-        }
-        if (self::getType() === 'api') {
-            $wechat = self::WeChatOauth();
-            if (request()->get('state') !== $appid) {
-                $snsapi = empty($isfull) ? 'snsapi_base' : 'snsapi_userinfo';
-                $param = (strpos($url, '?') !== false ? '&' : '?') . 'rcode=' . encode($url);
-                $OauthUrl = $wechat->getOauthRedirect($url . $param, $appid, $snsapi);
-                if ($isRedirect) redirect($OauthUrl, [], 301)->send();
-                exit("window.location.href='{$OauthUrl}'");
-            }
-            if (($token = $wechat->getOauthAccessToken()) && isset($token['openid'])) {
-                session("{$appid}_openid", $openid = $token['openid']);
-                if (empty($isfull) && request()->get('rcode')) {
-                    redirect(decode(request()->get('rcode')), [], 301)->send();
-                }
-                session("{$appid}_fansinfo", $fansinfo = $wechat->getUserInfo($token['access_token'], $openid));
-                empty($fansinfo) || Fans::set($fansinfo);
-            }
-            redirect(decode(request()->get('rcode')), [], 301)->send();
-        } else {
-            $result = self::wechat()->oauth(session_id(), $url, $isfull);
-            session("{$appid}_openid", $openid = $result['openid']);
-            session("{$appid}_fansinfo", $fansinfo = $result['fans']);
-            if ((empty($isfull) && !empty($openid)) || (!empty($isfull) && !empty($openid) && !empty($fansinfo))) {
-                empty($fansinfo) || Fans::set($fansinfo);
-                return ['openid' => $openid, 'fansinfo' => $fansinfo];
-            }
-            if ($isRedirect && !empty($result['url'])) {
-                redirect($result['url'], [], 301)->send();
-            }
-            exit("window.location.href='{$result['url']}'");
-        }
-    }
-
-    /**
-     * 获取当前公众号APPID
-     * @return bool|string
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function getAppid()
-    {
-        if (self::getType() === 'api') {
-            return sysconf('wechat_appid');
-        } else {
-            return sysconf('wechat_thr_appid');
-        }
-    }
-
-    /**
-     * 获取接口授权模式
-     * @return string
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function getType()
-    {
-        $type = strtolower(sysconf('wechat_type'));
-        if (in_array($type, ['api', 'thr'])) return $type;
-        throw new \think\Exception('请在后台配置微信对接授权模式');
-    }
-
-}

+ 10 - 10
application/wechat/view/config/options.html

@@ -3,10 +3,10 @@
 {block name="content"}
 
 <div style="max-width:1000px">
-    <form class="layui-card layui-form">
+    <div class="layui-card layui-form">
         <div class="layui-card-body think-box-shadow padding-bottom-5">
-            <div class="layui-form-item">
-                <label class="layui-form-label">Type<br><span class="nowrap color-desc">对接方式</span></label>
+            <div class="layui-form-item margin-bottom-0">
+                <label class="layui-form-label">Auth<br><span class="nowrap color-desc">授权方式</span></label>
                 <div class="layui-input-block">
                     {foreach ['api'=>'公众号平台API模式','thr'=>'第三方平台授权模式','test'=>'接口功能测试'] as $k=>$v}
                     <input type="radio" data-wechat-type="{$k}" name="wechat_type" value="{$k}" title="{$v}" lay-filter="wechat_type">
@@ -15,11 +15,11 @@
                 </div>
             </div>
         </div>
-    </form>
-    <div class="think-box-shadow">
-        <div data-type="api">{include file='config/options_api'}</div>
-        <div data-type="thr">{include file='config/options_thr'}</div>
-        <div data-type="test">{include file='config/options_help'}</div>
+    </div>
+    <div class="think-box-shadow ">
+        <div class="layui-anim layui-anim-upbit" data-type="api">{include file='config/options_api'}</div>
+        <div class="layui-anim layui-anim-upbit" data-type="thr">{include file='config/options_thr'}</div>
+        <div class="layui-anim layui-anim-upbit" data-type="test">{include file='config/options_help'}</div>
     </div>
 </div>
 
@@ -35,8 +35,8 @@
         });
 
         function apply(value) {
-            var $active = $("[data-wechat-type='" + value + "']").trigger('click');
-            if ($active.size() < 1) $("[data-wechat-type]:first").trigger('click');
+            this.$active = $("[data-wechat-type='" + value + "']").trigger('click');
+            if (this.$active.size() < 1) $("[data-wechat-type]:first").trigger('click');
             $('[data-type="' + value + '"]').show().siblings('[data-type]').hide();
         }
     });

+ 1 - 1
application/wechat/view/config/options_help.html

@@ -1,4 +1,4 @@
-<form onsubmit="return false;" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+<form onsubmit="return false;" data-auto="true" method="post" class='layui-form layui-card padding-bottom-20' autocomplete="off">
 
     <div class="layui-card-body" style="padding-left:40px">
         <div class="layui-elem-quote border-0">

+ 16 - 25
application/wechat/view/config/payment.html

@@ -3,39 +3,33 @@
 {block name="content"}
 <form onsubmit="return false;" data-auto="true" method="post" class='layui-form layui-card ' autocomplete="off" lay-filter="payment" style="max-width:1000px">
 
-    <div class="layui-card-body think-box-shadow padding-bottom-20">
-
-        <div class="layui-form-item margin-top-20">
-            <label class="layui-form-label">MchId<br><span class="nowrap color-desc">微信商户ID</span></label>
-            <div class="layui-input-block">
+    <div class="layui-card-body think-box-shadow">
+        <div class="padding-left-40 padding-right-30">
+            <label class="layui-form-item margin-top-20 block relative">
+                <span class="color-green margin-right-10">微信商户ID</span><span class="nowrap color-desc">MCH_ID</span>
                 <input name="wechat_mch_id" required placeholder="请输入微信商户ID(必填)" value="{:sysconf('wechat_mch_id')}" class="layui-input">
-                <p class="help-block">微信商户ID,可以在微信商户平台或开通时的邮件中获取。</p>
-            </div>
-        </div>
-
-        <div class="layui-form-item">
-            <label class="layui-form-label">MchKey<br><span class="nowrap color-desc">微信商户KEY</span></label>
-            <div class="layui-input-block">
+                <p class="help-block">微信商户ID,需要在微信商户平台获取,MCH_ID 与 APPID 匹配</p>
+            </label>
+            <label class="layui-form-item margin-top-20 block relative">
+                <span class="color-green margin-right-10">微信商户KEY</span><span class="nowrap color-desc">MCH_KEY</span>
                 <input name="wechat_mch_key" placeholder="请输入微信商户密钥(必填)" maxlength="32" required value="{:sysconf('wechat_mch_key')}" class="layui-input">
-                <p class="help-block">微信商户密钥,需要在微信商户平台操作设置密码并获取</p>
-            </div>
+                <p class="help-block">微信商户密钥,需要在微信商户平台操作设置密码并获取密钥</p>
+            </label>
         </div>
-
         <div class="hr-line-dashed"></div>
-
-        <div class="layui-form-item">
-            <label class="layui-form-label">MchCert<br><span class="nowrap color-desc">微信商户证书</span></label>
-            <div class="layui-input-block">
+        <div class="padding-left-40 padding-right-30">
+            <span class="color-green margin-right-10">微信商户证书</span><span class="nowrap color-desc">MCH_CERT</span>
+            <div class="">
                 {foreach ['p12'=>'上传 P12 证书','pem'=>'上传 PEM 证书'] as $k=>$v}
                 <input type="radio" data-pem-type="{$k}" name="wechat_mch_ssl_type" value="{$k}" title="{$v}" lay-filter="data-mch-type">
                 {/foreach}
-                <p class="help-block">请选择需要上传证书类型,P12 和 PEM 二选一,证书需要从微信商户平台获取</p>
+                <p class="help-block">请选择需要上传证书类型,P12 和 PEM 二选一,证书需要从微信商户平台获取</p>
                 <div data-mch-type="p12" class="layui-tab-item padding-top-15 padding-bottom-15">
                     <input name="wechat_mch_ssl_p12" value="{$wechat_mch_ssl_p12|default=''}" type="hidden">
                     <button data-file="btn" data-uptype="local" data-safe="true" data-type="p12" data-field="wechat_mch_ssl_p12" type="button" class="layui-btn layui-btn-primary">
                         <i class="layui-icon layui-icon-vercode font-s14"></i> 上传 P12 证书
                     </button>
-                    <p class="help-block margin-top-10">微信商户支付 P12 证书,实现订单退款、打款、发红包等支出功能都使用证书</p>
+                    <p class="help-block margin-top-10">微信商户支付 P12 证书,实现订单退款、打款、发红包等支出功能都使用证书</p>
                 </div>
                 <div data-mch-type="pem" class="layui-tab-item padding-top-15 padding-bottom-15">
                     <input name="wechat_mch_ssl_key" value="{$wechat_mch_ssl_key|default=''}" type="hidden">
@@ -46,17 +40,14 @@
                     <button data-file="btn" data-uptype="local" data-safe="true" data-type="pem" data-field="wechat_mch_ssl_cer" type="button" class="layui-btn layui-btn-primary">
                         <i class="layui-icon layui-icon-vercode font-s14"></i> 上传CERT证书
                     </button>
-                    <p class="help-block margin-top-10">微信商户支付 PEM 双向证书,实现订单退款、打款、发红包等支出功能都使用证书</p>
+                    <p class="help-block margin-top-10">微信商户支付 PEM 双向证书,实现订单退款、打款、发红包等支出功能都使用证书</p>
                 </div>
             </div>
         </div>
-
         <div class="hr-line-dashed"></div>
-
         <div class="layui-form-item text-center">
             <button class="layui-btn" type="submit">保存配置</button>
         </div>
-
     </div>
 
 </form>

+ 6 - 4
application/wechat/view/fans/index.html

@@ -20,7 +20,7 @@
 <div class="think-box-shadow">
     <table class="layui-table" lay-skin="line">
         <caption class="margin-bottom-10 text-left">{include file='fans/index_search'}</caption>
-        <!--{notempty name='list'}-->
+        {notempty name='list'}
         <thead>
         <tr>
             <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
@@ -32,9 +32,9 @@
             <th></th>
         </tr>
         </thead>
-        <!--{/notempty}-->
+        {/notempty}
         <tbody>
-        <!--{foreach $list as $key=>$vo}-->
+        {foreach $list as $key=>$vo}
         <tr>
             <td class='list-table-check-td think-checkbox'>
                 <input class="list-check-box" value='{$vo.openid}' type='checkbox'>
@@ -86,9 +86,11 @@
                 <!--{/if}-->
             </td>
         </tr>
-        <!--{/foreach}-->
+        {/foreach}
         </tbody>
     </table>
+
     {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+
 </div>
 {/block}

+ 2 - 2
application/wechat/view/keys/index.html

@@ -16,7 +16,7 @@
 <div class="think-box-shadow">
     <table class="layui-table" lay-skin="line">
         <caption class="margin-bottom-10 text-left">{include file='keys/index_search'}</caption>
-        <!--{notempty name='list'}-->
+        {notempty name='list'}
         <thead>
         <tr>
             <th class='list-table-check-td think-checkbox'>
@@ -33,7 +33,7 @@
             <th></th>
         </tr>
         </thead>
-        <!--{/notempty}-->
+        {/notempty}
         <tbody>
         {foreach $list as $key=>$vo}
         <tr>