hrjy 3 سال پیش
والد
کامیت
60319de311
2فایلهای تغییر یافته به همراه19 افزوده شده و 62 حذف شده
  1. 14 60
      app/api/controller/user/UserBillController.php
  2. 5 2
      app/models/user/WechatUser.php

+ 14 - 60
app/api/controller/user/UserBillController.php

@@ -258,73 +258,27 @@ class UserBillController
                     SystemAttachment::where(['name' => $name])->delete();
                 }
                 if (!$imageInfo) {
-//                    $qr_code = QrcodeService::getForeverQrcode('spread', $user['uid']);
-//                    if (isset($qr_code['url'])) {
-//                        $urlCode = $qr_code['url'];
-//                    } else {
-                        $codeUrl = set_http_type($siteUrl . '/index/#/pages/public/register/?spread=' . $user['uid'], 1);//二维码链接
+                    try {
+                        $qr_code = QrcodeService::getForeverQrcode('spread', $user['uid']);
+                        if (isset($qr_code['url'])) {
+                            $urlCode = $qr_code['url'];
+                        } else {
+                            $codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], 1);//二维码链接
+                            $imageInfo = UtilService::getQRCodePath($codeUrl, $name);
+                            if (is_string($imageInfo)) return app('json')->fail('二维码生成失败', ['error' => $imageInfo]);
+                            SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
+                            $urlCode = $imageInfo['dir'];
+                        }
+                    } catch (\Exception $e) {
+                        $codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], 1);//二维码链接
                         $imageInfo = UtilService::getQRCodePath($codeUrl, $name);
                         if (is_string($imageInfo)) return app('json')->fail('二维码生成失败', ['error' => $imageInfo]);
                         SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
                         $urlCode = $imageInfo['dir'];
-//                    }
+                    }
                 } else $urlCode = $imageInfo['att_dir'];
                 if ($imageInfo['image_type'] == 1) $urlCode = $siteUrl . $urlCode;
                 $siteUrl = set_http_type($siteUrl, 1);
-                $filelink = [
-                    'Bold' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
-                    'Normal' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
-                ];
-                if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold');
-                if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal');
-                foreach ($routineSpreadBanner as $key => &$item) {
-                    $posterInfo = '海报生成失败:(';
-                    $config = array(
-                        'image' => array(
-                            array(
-                                'url' => $urlCode,     //二维码资源
-                                'stream' => 0,
-                                'left' => 225,
-                                'top' => 913,
-                                'right' => 0,
-                                'bottom' => 0,
-                                'width' => 300,
-                                'height' => 300,
-                                'opacity' => 100
-                            )
-                        ),
-                        'text' => array(
-                            array(
-                                'text' => $user['nickname'],
-                                'left' => 250,
-                                'top' => 840,
-                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],     //字体文件
-                                'fontSize' => 16,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
-                                'angle' => 0,
-                            ),
-                            array(
-                                'text' => '邀请您加入' . sys_config('site_name'),
-                                'left' => 250,
-                                'top' => 880,
-                                'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'],     //字体文件
-                                'fontSize' => 16,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
-                                'angle' => 0,
-                            )
-                        ),
-                        'background' => $item['pic']
-                    );
-                    $resWap = $resWap && $posterInfo = UtilService::setSharePoster($config, 'wap/spread/poster');
-                    if (!is_array($posterInfo)) return app('json')->fail($posterInfo);
-                    SystemAttachment::attachmentAdd($posterInfo['name'], $posterInfo['size'], $posterInfo['type'], $posterInfo['dir'], $posterInfo['thumb_path'], 1, $posterInfo['image_type'], $posterInfo['time'], 2);
-                    if ($resWap) {
-                        if ($posterInfo['image_type'] == 1)
-                            $item['wap_poster'] = $siteUrl . $posterInfo['thumb_path'];
-                        else
-                            $item['wap_poster'] = UtilService::setHttpType($posterInfo['thumb_path'], 1);
-                    }
-                }
             }
             if ($resRoutine && $resWap) return app('json')->successful($routineSpreadBanner);
             else return app('json')->fail('生成图片失败');

+ 5 - 2
app/models/user/WechatUser.php

@@ -161,12 +161,13 @@ class WechatUser extends BaseModel
         //判断 unionid 是否存在
         if (isset($userInfo['unionid'])) {
             $wechatInfo = self::where('unionid', $userInfo['unionid'])->find();
-            unset($userInfo['qr_scene'], $userInfo['qr_scene_str'], $userInfo['qr_scene_str'], $userInfo['subscribe_scene']);
+            unset($userInfo['qr_scene'],$userInfo['qr_scene_str'],$userInfo['qr_scene_str'],$userInfo['subscribe_scene']);
             if ($wechatInfo) {
                 return self::edit($userInfo->toArray(), $userInfo['unionid'], 'unionid');
             }
         }
         self::beginTrans();
+        $userInfo['uid'] = User::getkeytoid('uid');
         $wechatUser = self::create(is_object($userInfo) ? $userInfo->toArray() : $userInfo);
         if (!$wechatUser) {
             self::rollbackTrans();
@@ -180,7 +181,6 @@ class WechatUser extends BaseModel
         self::userFirstSubGiveCoupon($openid);
         return $wechatUser;
     }
-
     /**
      * TODO 关注送优惠券
      * @param $openid
@@ -289,4 +289,7 @@ class WechatUser extends BaseModel
         if (!$wechatInfo) exception('获取用户信息失败!');
         return $wechatInfo->toArray();
     }
+
+
+
 }