作者 王晓刚
1 个管道 的构建 通过 耗费 2 秒

合并分支 'wangxiaogang' 到 'master'

Wangxiaogang



查看合并请求 !58
@@ -138,7 +138,7 @@ class BirdController extends HomeBaseController @@ -138,7 +138,7 @@ class BirdController extends HomeBaseController
138 * @throws \think\db\exception\ModelNotFoundException 138 * @throws \think\db\exception\ModelNotFoundException
139 * @throws \think\exception\DbException 139 * @throws \think\exception\DbException
140 */ 140 */
141 - public function getOrder($indent_id = 112){ 141 + public function getOrder($indent_id = null){
142 if(empty($indent_id)){ 142 if(empty($indent_id)){
143 $this->error('缺少必要参数','','',''); 143 $this->error('缺少必要参数','','','');
144 } 144 }
@@ -50,7 +50,7 @@ class LoadController extends HomeBaseController @@ -50,7 +50,7 @@ class LoadController extends HomeBaseController
50 foreach($result['Data'] as $key => $vo){ 50 foreach($result['Data'] as $key => $vo){
51 $indent = $indentModel->findData(['logistic_code'=>$vo['LogisticCode']]); 51 $indent = $indentModel->findData(['logistic_code'=>$vo['LogisticCode']]);
52 if(!empty($indent)){ 52 if(!empty($indent)){
53 - if($vo['state'] >=1 && $vo['state'] != 4){ 53 + if($vo['State'] >=1 && $vo['State'] != 4){
54 if($indent['state'] == 2){ 54 if($indent['state'] == 2){
55 $indentModel->updateData(['id'=>$indent['id']],['state'=>5]); 55 $indentModel->updateData(['id'=>$indent['id']],['state'=>5]);
56 } 56 }
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Administrator
  5 + * Date: 2019/6/8
  6 + * Time: 18:59
  7 + */
  8 +
  9 +namespace app\portal\controller;
  10 +
  11 +
  12 +use cmf\controller\WeChatBaseController;
  13 +use think\Db;
  14 +
  15 +class ShareController extends WeChatBaseController
  16 +{
  17 + public function index(){
  18 + //判断用户是否填写手机号
  19 + $user_id = cmf_get_current_user_id();
  20 + $my_user = Db::name('my_user')->where('uid',$user_id)->find();
  21 + $user = Db::name('user')->where('id',$user_id)->find();
  22 + if(empty($my_user)){
  23 + $this->error('查询为空','','','');
  24 + }
  25 + if(empty($my_user['phone'])){
  26 + $this->error('跳转补全信息页面','','','');
  27 + }
  28 + //判断有没有生成过
  29 + if(file_exists('./upload/poster/poster_'.$user_id.".png")){
  30 + $url = $this->get_url($user_id,$my_user['status']);
  31 + $webPath = 'qrcode/share_'.$user_id.'.png';
  32 + $savePath = './upload/'.$webPath;
  33 + //生成带参二维码
  34 + if(!file_exists($savePath)){
  35 + $prcode_url = $this->get_code($user_id,$url);
  36 + }
  37 + //保存头像
  38 + $avatar=$this->getImage($user['avatar'],'avatar_'.$user['id']);
  39 + if($avatar['code']==1){
  40 + $this->error($avatar['msg']);
  41 + }
  42 + $savePath = './upload/poster';
  43 + if(!file_exists($savePath)){
  44 + mkdir ($savePath,0777,true);
  45 + }
  46 + $image = \think\Image::open(ROOT_PATH."public/upload/avatar/avatar_".$user_id.".jpeg");
  47 + $image->thumb(173,173,\think\Image::THUMB_FIXED)->save('./upload/avatar/avatar_'.$user_id.".png");
  48 + $image = \think\Image::open(ROOT_PATH."public/white.png");
  49 + $image->water(ROOT_PATH."public/upload/qrcode/share_".$user_id.".png",[195,725],100)
  50 + ->water(ROOT_PATH."public/upload/avatar/avatar_".$user_id.".png",[289,478],100)
  51 + ->water(ROOT_PATH."public/bg.png",\think\Image::WATER_CENTER,100)
  52 + ->save('./upload/poster/poster_'.$user_id.".png");
  53 + }
  54 + $share_image = cmf_get_image_url('poster/poster_'.$user_id.".png");
  55 + $this->assign('share_image',$share_image);
  56 + return $this->fetch();
  57 + }
  58 +
  59 + /**
  60 + * 分享链接
  61 + * @param $user_id
  62 + * @param $status
  63 + * @return string
  64 + */
  65 + public function get_url($user_id,$status){
  66 + //http://xkeasy.w.bronet.cn/portal/index/index/my_user_id/用户id/status_id/身份id
  67 + $url = url('portal/index/index',['my_user_id'=>$user_id,'status_id'=>$status]);
  68 + return $url;
  69 + }
  70 +
  71 + /**
  72 + * 生成二维码
  73 + * @param $user_id
  74 + * @param $qrData
  75 + * @return bool|string
  76 + */
  77 + public function get_code($user_id,$qrData){
  78 + /*存储本地*/
  79 + $webPath = 'qrcode/';
  80 +
  81 + $savePath = './upload/'.$webPath;
  82 + if(!file_exists($savePath)){
  83 + mkdir ($savePath,0777,true);
  84 + }
  85 + $saveName = "share_".$user_id;
  86 + $qrLevel = 'H';
  87 + $qrSize = '8';
  88 + $savePrefix = "";
  89 + if($filename = createQRcode($savePath, $qrData, $qrLevel, $qrSize, $savePrefix,$saveName)){
  90 + $pic = $webPath .$savePrefix. $saveName . '.png';
  91 + return $pic;
  92 + }else{
  93 + return false;
  94 + }
  95 + }
  96 + /**
  97 + * 下载微信头像保存到本地
  98 + * @param $url
  99 + * @param $filename
  100 + * @return array
  101 + */
  102 + function getImage($url,$filename){
  103 + $save_dir='./upload/avatar/';
  104 + if(!file_exists($save_dir)&&!mkdir($save_dir,0777,true)){
  105 + return ['code'=>1,'msg'=>'图片路径错误'];
  106 + }
  107 + $header = array(
  108 + 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0',
  109 + 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
  110 + 'Accept-Encoding: gzip, deflate',);
  111 + $curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  112 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
  113 + curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  114 + $data = curl_exec($curl);
  115 + $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  116 + curl_close($curl);
  117 + if ($code == 200) {//把URL格式的图片转成base64_encode格式的!
  118 + $imgBase64Code = "data:image/jpeg;base64," . base64_encode($data);
  119 + }else{
  120 + return ['code'=>1,'msg'=>'图片转换失败'];
  121 + }
  122 + $img_content=$imgBase64Code;//图片内容
  123 +
  124 + if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $img_content, $result)) {
  125 + $type = $result[2];
  126 + $new_file = $save_dir.$filename.'.'.$type;
  127 + $save_path= 'avatar/'.$filename.'.'.$type;
  128 + if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $img_content)))) {
  129 + return ['code'=>0,'file_path'=>$new_file,'save_path'=>$save_path];
  130 + }else{
  131 + return ['code'=>1,'msg'=>'图片保存失败'];
  132 + }
  133 + }else{
  134 + return ['code'=>1,'msg'=>'图片格式错误'];
  135 + }
  136 + }
  137 +
  138 +}
@@ -30,7 +30,9 @@ @@ -30,7 +30,9 @@
30 "ezyang/htmlpurifier": "^4.9", 30 "ezyang/htmlpurifier": "^4.9",
31 "weiwei/api-doc": "^1.6", 31 "weiwei/api-doc": "^1.6",
32 "hooklife/thinkphp5-wechat": "^1.1", 32 "hooklife/thinkphp5-wechat": "^1.1",
33 - "yly-openapi/yly-openapi-sdk": "v1.0.1" 33 + "yly-openapi/yly-openapi-sdk": "v1.0.1",
  34 + "dh2y/think-qrcode": "^1.0",
  35 + "aferrandini/phpqrcode": "^1.0"
34 }, 36 },
35 "extra": { 37 "extra": {
36 }, 38 },
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +
  4 +<head>
  5 + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  6 + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
  7 + <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8 + <title>学考无忧-我的推广</title>
  9 + <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
  10 + <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
  11 + <style>
  12 + html,
  13 + body {
  14 + width: 100%;
  15 + height: 100%;
  16 + display: flex;
  17 + display: -webkit-flex;
  18 + justify-content: flex-start;
  19 + align-items: flex-start;
  20 + flex-direction: column;
  21 + }
  22 +
  23 + .code_Box {
  24 + background: #FF5C19 url("{:cmf_get_image_url($share_image)}") no-repeat top left;
  25 + background-size: 100%;
  26 + -webkit-background-size: 100%;
  27 +
  28 + }
  29 + </style>
  30 +</head>
  31 +
  32 +<body>
  33 + <!-- 顶部 -->
  34 + <div class="order_top" style="background-color: #FF5C19">
  35 + <img src="__TMPL__/public/assets/images/left2.png" alt="">
  36 + <p style="color:white">我的推广</p>
  37 + </div>
  38 + <div class="code_Box">
  39 +
  40 + </div>
  41 + <script src="__TMPL__/public/assets/js/base.js"></script>
  42 +</body>
  43 +
  44 +</html>
@@ -1822,4 +1822,49 @@ function getAccessToken(){ @@ -1822,4 +1822,49 @@ function getAccessToken(){
1822 $jssdk=new \JSSDK(config('wx_app_id'),config('wx_app_secret')); 1822 $jssdk=new \JSSDK(config('wx_app_id'),config('wx_app_secret'));
1823 return $jssdk->getAccessToken(); 1823 return $jssdk->getAccessToken();
1824 } 1824 }
  1825 +/**
  1826 + * 功能:生成二维码
  1827 + * @param string $savePath 图片存储路径
  1828 + * @param string $qrData 手机扫描后要跳转的网址
  1829 + * @param string $qrLevel 默认纠错比例 分为L、M、Q、H四个等级,H代表最高纠错能力
  1830 + * @param int $qrSize 二维码图大小,1-10可选,数字越大图片尺寸越大
  1831 + * @param string $savePrefix 图片名称前缀
  1832 + * @param array $saveName 图片名称前缀
  1833 + * @return bool|string
  1834 + */
  1835 +function createQRcode($savePath, $qrData = 'PHP QR Code :)', $qrLevel = 'L', $qrSize = 4, $savePrefix = '',$saveName)
  1836 +{
  1837 + if (!isset($savePath)) return '';
  1838 + //设置生成png图片的路径
  1839 + $PNG_TEMP_DIR = $savePath;
1825 1840
  1841 + //检测并创建生成文件夹
  1842 + if (!file_exists($PNG_TEMP_DIR)) {
  1843 + mkdir($PNG_TEMP_DIR,777,true);
  1844 + }
  1845 + $filename = $PNG_TEMP_DIR . 'test.png';
  1846 + $errorCorrectionLevel = 'L';
  1847 + if (isset($qrLevel) && in_array($qrLevel, ['L', 'M', 'Q', 'H'])) {
  1848 + $errorCorrectionLevel = $qrLevel;
  1849 + }
  1850 + $matrixPointSize = 4;
  1851 + if (isset($qrSize)) {
  1852 + $matrixPointSize = min(max((int)$qrSize, 1), 10);
  1853 + }
  1854 + if (isset($qrData)) {
  1855 + if (trim($qrData) == '') {
  1856 + die('data cannot be empty!');
  1857 + }
  1858 + //生成文件名 文件路径+图片名字前缀+md5(名称)+.png
  1859 + $filename = $PNG_TEMP_DIR . $savePrefix .$saveName . '.png';
  1860 + //开始生成
  1861 + \PHPQRCode\QRcode::png($qrData, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
  1862 + } else {
  1863 + //默认生成
  1864 + \PHPQRCode\QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
  1865 + }
  1866 + if (file_exists($PNG_TEMP_DIR . basename($filename)))
  1867 + return basename($filename);
  1868 + else
  1869 + return FALSE;
  1870 +}
@@ -9,6 +9,7 @@ return array( @@ -9,6 +9,7 @@ return array(
9 'Svg\\' => array($vendorDir . '/phenx/php-svg-lib/src'), 9 'Svg\\' => array($vendorDir . '/phenx/php-svg-lib/src'),
10 'Sabberworm\\CSS' => array($vendorDir . '/sabberworm/php-css-parser/lib'), 10 'Sabberworm\\CSS' => array($vendorDir . '/sabberworm/php-css-parser/lib'),
11 'Pimple' => array($vendorDir . '/pimple/pimple/src'), 11 'Pimple' => array($vendorDir . '/pimple/pimple/src'),
  12 + 'PHPQRCode' => array($vendorDir . '/aferrandini/phpqrcode/lib'),
12 'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'), 13 'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),
13 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), 14 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
14 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'), 15 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'),
@@ -11,6 +11,7 @@ return array( @@ -11,6 +11,7 @@ return array(
11 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 11 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
12 'think\\' => array($vendorDir . '/topthink/think-image/src'), 12 'think\\' => array($vendorDir . '/topthink/think-image/src'),
13 'mindplay\\annotations\\' => array($vendorDir . '/mindplay/annotations/src/annotations'), 13 'mindplay\\annotations\\' => array($vendorDir . '/mindplay/annotations/src/annotations'),
  14 + 'dh2y\\qrcode\\' => array($vendorDir . '/dh2y/think-qrcode/src'),
14 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'), 15 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
15 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 16 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
16 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), 17 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
@@ -34,6 +34,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7 @@ -34,6 +34,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7
34 array ( 34 array (
35 'mindplay\\annotations\\' => 21, 35 'mindplay\\annotations\\' => 21,
36 ), 36 ),
  37 + 'd' =>
  38 + array (
  39 + 'dh2y\\qrcode\\' => 12,
  40 + ),
37 'S' => 41 'S' =>
38 array ( 42 array (
39 'Symfony\\Polyfill\\Php70\\' => 23, 43 'Symfony\\Polyfill\\Php70\\' => 23,
@@ -109,6 +113,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7 @@ -109,6 +113,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7
109 array ( 113 array (
110 0 => __DIR__ . '/..' . '/mindplay/annotations/src/annotations', 114 0 => __DIR__ . '/..' . '/mindplay/annotations/src/annotations',
111 ), 115 ),
  116 + 'dh2y\\qrcode\\' =>
  117 + array (
  118 + 0 => __DIR__ . '/..' . '/dh2y/think-qrcode/src',
  119 + ),
112 'Symfony\\Polyfill\\Php70\\' => 120 'Symfony\\Polyfill\\Php70\\' =>
113 array ( 121 array (
114 0 => __DIR__ . '/..' . '/symfony/polyfill-php70', 122 0 => __DIR__ . '/..' . '/symfony/polyfill-php70',
@@ -205,6 +213,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7 @@ -205,6 +213,10 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7
205 array ( 213 array (
206 0 => __DIR__ . '/..' . '/pimple/pimple/src', 214 0 => __DIR__ . '/..' . '/pimple/pimple/src',
207 ), 215 ),
  216 + 'PHPQRCode' =>
  217 + array (
  218 + 0 => __DIR__ . '/..' . '/aferrandini/phpqrcode/lib',
  219 + ),
208 'PHPExcel' => 220 'PHPExcel' =>
209 array ( 221 array (
210 0 => __DIR__ . '/..' . '/phpoffice/phpexcel/Classes', 222 0 => __DIR__ . '/..' . '/phpoffice/phpexcel/Classes',
1 [ 1 [
2 { 2 {
  3 + "name": "aferrandini/phpqrcode",
  4 + "version": "1.0.1",
  5 + "version_normalized": "1.0.1.0",
  6 + "source": {
  7 + "type": "git",
  8 + "url": "https://github.com/aferrandini/PHPQRCode.git",
  9 + "reference": "3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46"
  10 + },
  11 + "dist": {
  12 + "type": "zip",
  13 + "url": "https://api.github.com/repos/aferrandini/PHPQRCode/zipball/3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46",
  14 + "reference": "3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46",
  15 + "shasum": ""
  16 + },
  17 + "require": {
  18 + "php": ">=5.3.0"
  19 + },
  20 + "time": "2013-07-08T09:39:08+00:00",
  21 + "type": "library",
  22 + "installation-source": "dist",
  23 + "autoload": {
  24 + "psr-0": {
  25 + "PHPQRCode": "lib/"
  26 + }
  27 + },
  28 + "notification-url": "https://packagist.org/downloads/",
  29 + "license": [
  30 + "MIT"
  31 + ],
  32 + "authors": [
  33 + {
  34 + "name": "Ariel Ferrandini",
  35 + "email": "arielferrandini@gmail.com",
  36 + "homepage": "http://www.ferrandini.com/",
  37 + "role": "Developer"
  38 + }
  39 + ],
  40 + "description": "PHPQRCode porting and changed for PHP 5.3 compatibility",
  41 + "homepage": "https://github.com/aferrandini/PHPQRCode",
  42 + "keywords": [
  43 + "barcode",
  44 + "php",
  45 + "qrcode"
  46 + ],
  47 + "abandoned": "endroid/qr-code"
  48 + },
  49 + {
  50 + "name": "dh2y/think-qrcode",
  51 + "version": "1.0",
  52 + "version_normalized": "1.0.0.0",
  53 + "source": {
  54 + "type": "git",
  55 + "url": "https://github.com/cinaofdai/think-qrcode.git",
  56 + "reference": "e4eb6f588ffb6b99ef4fb4610d44e338c9b4c506"
  57 + },
  58 + "dist": {
  59 + "type": "zip",
  60 + "url": "https://api.github.com/repos/cinaofdai/think-qrcode/zipball/e4eb6f588ffb6b99ef4fb4610d44e338c9b4c506",
  61 + "reference": "e4eb6f588ffb6b99ef4fb4610d44e338c9b4c506",
  62 + "shasum": ""
  63 + },
  64 + "require": {
  65 + "php": ">=5.4.0"
  66 + },
  67 + "time": "2018-10-16T04:31:01+00:00",
  68 + "type": "library",
  69 + "installation-source": "dist",
  70 + "autoload": {
  71 + "psr-4": {
  72 + "dh2y\\qrcode\\": "src/"
  73 + }
  74 + },
  75 + "notification-url": "https://packagist.org/downloads/",
  76 + "license": [
  77 + "MIT"
  78 + ],
  79 + "authors": [
  80 + {
  81 + "name": "dh2y",
  82 + "email": "xiaodai54_long@163.com"
  83 + }
  84 + ],
  85 + "description": "qrcode for thinkphp5",
  86 + "homepage": "https://github.com/cinaofdai/think-qrcode"
  87 + },
  88 + {
3 "name": "doctrine/cache", 89 "name": "doctrine/cache",
4 "version": "v1.4.4", 90 "version": "v1.4.4",
5 "version_normalized": "1.4.4.0", 91 "version_normalized": "1.4.4.0",
@@ -607,4 +607,31 @@ class Image @@ -607,4 +607,31 @@ class Image
607 empty($this->im) || imagedestroy($this->im); 607 empty($this->im) || imagedestroy($this->im);
608 } 608 }
609 609
  610 + function round() {
  611 +
  612 + $w = $this->info['width'];
  613 + $h = $this->info['height'];
  614 + $w = min($w, $h);
  615 + $h = $w;
  616 + $img = imagecreatetruecolor($w, $h);
  617 + //这一句一定要有
  618 + imagesavealpha($img, true);
  619 + //拾取一个完全透明的颜色,最后一个参数127为全透明
  620 + $bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
  621 + imagefill($img, 0, 0, $bg);
  622 + $r = $w / 2; //圆半径
  623 + $y_x = $r; //圆心X坐标
  624 + $y_y = $r; //圆心Y坐标
  625 + for ($x = 0; $x < $w; $x++) {
  626 + for ($y = 0; $y < $h; $y++) {
  627 + $rgbColor = imagecolorat($this->im, $x, $y);
  628 + if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
  629 + imagesetpixel($img, $x, $y, $rgbColor);
  630 + }
  631 + }
  632 + }
  633 + $this->im= $img;
  634 +
  635 + return $this;
  636 + }
610 } 637 }