From 65bf50c49eaa34ea857de799e42aef7b18cf9e9d Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Sat, 23 Nov 2019 14:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B1=BB=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/admin/controller/Index.php | 18 ----------- .../controller/wechat/WechatController.php | 4 +-- crmeb/app/common.php | 32 +++++++++---------- .../utils/{CanvasService.php => Canvas.php} | 6 ++-- ...erviceProvider.php => ProgramProvider.php} | 8 ++--- ...scribeService.php => ProgramSubscribe.php} | 6 ++-- .../wechat/src/Foundation/Application.php | 2 +- 7 files changed, 28 insertions(+), 48 deletions(-) rename crmeb/crmeb/utils/{CanvasService.php => Canvas.php} (99%) rename crmeb/crmeb/utils/{ProgramServiceProvider.php => ProgramProvider.php} (73%) rename crmeb/crmeb/utils/{ProgramSubscribeService.php => ProgramSubscribe.php} (98%) diff --git a/crmeb/app/admin/controller/Index.php b/crmeb/app/admin/controller/Index.php index 5ca306d7..e0ab6cd7 100644 --- a/crmeb/app/admin/controller/Index.php +++ b/crmeb/app/admin/controller/Index.php @@ -12,9 +12,7 @@ use app\admin\model\user\UserExtract as UserExtractModel;//分销 use app\admin\model\user\User as UserModel;//用户 use app\admin\model\store\StoreProductReply as StoreProductReplyModel;//评论 use app\admin\model\store\StoreProduct as ProductModel;//产品 -use crmeb\utils\Template; use FormBuilder\Json; -use think\facade\Route; /** * 首页控制器 @@ -39,22 +37,6 @@ class Index extends AuthController return $this->fetch(); } - public function test() - { - $res = Template::instance()->wechat() - ->setTemplateCode('OPENTM207791277') - ->setTemplateData([ - 'first'=>'亲,您购买的商品已支付成功', - 'keyword1'=>'wx12545454545', - 'keyword2'=>'0.99', - 'remark'=>'点击查看订单详情' - ]) - ->setTemplateOpenId('od9iXwj58C4aLy11ABMxFkgJelt0') - ->setTemplateUrl(Route::buildUrl('order/detail/wx12545454545')) - ->send(); - var_dump($res); - } - //后台首页内容 public function main() { diff --git a/crmeb/app/api/controller/wechat/WechatController.php b/crmeb/app/api/controller/wechat/WechatController.php index 608e33bc..09b96747 100644 --- a/crmeb/app/api/controller/wechat/WechatController.php +++ b/crmeb/app/api/controller/wechat/WechatController.php @@ -8,7 +8,7 @@ use app\models\user\User; use app\models\user\UserToken; use app\models\user\WechatUser; use app\Request; -use crmeb\utils\CanvasService; +use crmeb\utils\Canvas; use crmeb\services\WechatService; use think\facade\Cookie; @@ -95,7 +95,7 @@ class WechatController public function follow() { - $canvas = CanvasService::instance(); + $canvas = Canvas::instance(); $path = 'uploads/follow/'; $imageType = 'jpg'; $name = 'follow'; diff --git a/crmeb/app/common.php b/crmeb/app/common.php index 12a447e8..5d8f78a6 100644 --- a/crmeb/app/common.php +++ b/crmeb/app/common.php @@ -100,33 +100,32 @@ if (!function_exists('make_path')) { */ function make_path($path, int $type = 2, bool $force = false) { - $path = DS.ltrim(rtrim($path)); - switch ($type){ + $path = DS . ltrim(rtrim($path)); + switch ($type) { case 1: - $path .= DS.date('Y'); + $path .= DS . date('Y'); break; case 2: - $path .= DS.date('Y').DS.date('m'); + $path .= DS . date('Y') . DS . date('m'); break; case 3: - $path .= DS.date('Y').DS.date('m').DS.date('d'); + $path .= DS . date('Y') . DS . date('m') . DS . date('d'); break; } - try{ - if (is_dir(app()->getRootPath().'public'.DS.'uploads'.$path) == true || mkdir(app()->getRootPath().'public'.DS.'uploads'.$path, 0777, true) == true) { - return trim(str_replace(DS, '/',$path),'.'); - }else return ''; - }catch (\Exception $e){ - if($force) + try { + if (is_dir(app()->getRootPath() . 'public' . DS . 'uploads' . $path) == true || mkdir(app()->getRootPath() . 'public' . DS . 'uploads' . $path, 0777, true) == true) { + return trim(str_replace(DS, '/', $path), '.'); + } else return ''; + } catch (\Exception $e) { + if ($force) throw new \Exception($e->getMessage()); - return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS. 'attach' . DS; + return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS; } } } -if(!function_exists('sysConfig')) -{ +if (!function_exists('sysConfig')) { /** * 获取系统单个配置 * @param string $name @@ -134,15 +133,14 @@ if(!function_exists('sysConfig')) */ function sysConfig(string $name) { - if(empty($name)) + if (empty($name)) return null; return app('sysConfig')->get($name); } } -if(!function_exists('sysData')) -{ +if (!function_exists('sysData')) { /** * 获取系统单个配置 * @param string $name diff --git a/crmeb/crmeb/utils/CanvasService.php b/crmeb/crmeb/utils/Canvas.php similarity index 99% rename from crmeb/crmeb/utils/CanvasService.php rename to crmeb/crmeb/utils/Canvas.php index f5d1620b..45405d8c 100644 --- a/crmeb/crmeb/utils/CanvasService.php +++ b/crmeb/crmeb/utils/Canvas.php @@ -6,8 +6,8 @@ use crmeb\traits\LogicTrait; use EasyWeChat\Core\Exceptions\RuntimeException; /** - * Class CanvasService - * @package crmeb\services + * Class Canvas + * @package crmeb\utils * @method $this setFileName(string $fileName) 设置文件名 * @method $this setPath(string $path) 设置存放路径 * @method $this setImageType(string $imageType) 设置图片类型 @@ -30,7 +30,7 @@ use EasyWeChat\Core\Exceptions\RuntimeException; * @method $this setImageHeight(int $imageHeight) 设置图片高 * @method $this setImageOpacity(int $imageOpacity) 设置图片透明度 */ -class CanvasService +class Canvas { use LogicTrait; diff --git a/crmeb/crmeb/utils/ProgramServiceProvider.php b/crmeb/crmeb/utils/ProgramProvider.php similarity index 73% rename from crmeb/crmeb/utils/ProgramServiceProvider.php rename to crmeb/crmeb/utils/ProgramProvider.php index 878fc797..743c98e6 100644 --- a/crmeb/crmeb/utils/ProgramServiceProvider.php +++ b/crmeb/crmeb/utils/ProgramProvider.php @@ -8,10 +8,10 @@ use Pimple\ServiceProviderInterface; /** * 注册订阅消息 - * Class ProgramServiceProvider - * @package crmeb\services + * Class ProgramProvider + * @package crmeb\utils */ -class ProgramServiceProvider implements ServiceProviderInterface +class ProgramProvider implements ServiceProviderInterface { public function register(Container $pimple) { @@ -24,7 +24,7 @@ class ProgramServiceProvider implements ServiceProviderInterface }; $pimple['mini_program.now_notice'] = function ($pimple) { - return new ProgramSubscribeService($pimple['mini_program.access_token']); + return new ProgramSubscribe($pimple['mini_program.access_token']); }; } } diff --git a/crmeb/crmeb/utils/ProgramSubscribeService.php b/crmeb/crmeb/utils/ProgramSubscribe.php similarity index 98% rename from crmeb/crmeb/utils/ProgramSubscribeService.php rename to crmeb/crmeb/utils/ProgramSubscribe.php index 9523ec7c..bfe5599d 100644 --- a/crmeb/crmeb/utils/ProgramSubscribeService.php +++ b/crmeb/crmeb/utils/ProgramSubscribe.php @@ -8,8 +8,8 @@ use EasyWeChat\Core\Exceptions\InvalidArgumentException; /** * 小程序订阅消息 - * Class ProgramSubscribeService - * @package crmeb\services + * Class ProgramSubscribe + * @package crmeb\utils * @method $this * @method $this withTemplate(string $template_id) 设置模板id * @method $this withTemplateId(string $template_id) 设置模板id @@ -24,7 +24,7 @@ use EasyWeChat\Core\Exceptions\InvalidArgumentException; * @method $this withData(array $data) 设置发送内容 * @method $this data(array $data) 设置发送内容 */ -class ProgramSubscribeService extends AbstractAPI +class ProgramSubscribe extends AbstractAPI { /** diff --git a/crmeb/vendor/overtrue/wechat/src/Foundation/Application.php b/crmeb/vendor/overtrue/wechat/src/Foundation/Application.php index 95c8843c..bf383877 100644 --- a/crmeb/vendor/overtrue/wechat/src/Foundation/Application.php +++ b/crmeb/vendor/overtrue/wechat/src/Foundation/Application.php @@ -106,7 +106,7 @@ class Application extends Container ServiceProviders\OpenPlatformServiceProvider::class, ServiceProviders\MiniProgramServiceProvider::class, ServiceProviders\CommentServiceProvider::class, - \crmeb\utils\ProgramServiceProvider::class, + \crmeb\utils\ProgramProvider::class, ]; /**