作者 开飞机的舒克

条形码识别问题

@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 namespace app\api\controller; 3 namespace app\api\controller;
4 4
5 use app\common\controller\Api; 5 use app\common\controller\Api;
  6 +use app\common\controller\Resource;
  7 +
6 mb_internal_encoding("UTF-8"); 8 mb_internal_encoding("UTF-8");
7 /** 9 /**
8 * 示例接口 10 * 示例接口
@@ -67,6 +69,10 @@ class Demo extends Api @@ -67,6 +69,10 @@ class Demo extends Api
67 */ 69 */
68 public function test3() 70 public function test3()
69 { 71 {
  72 + $id = 97;
  73 + $res = str_pad($id,8,"0",STR_PAD_LEFT);
  74 + $data = Resource::StudyBar($res);
  75 + $this->success($data);
70 } 76 }
71 77
72 } 78 }
@@ -2,19 +2,16 @@ @@ -2,19 +2,16 @@
2 2
3 namespace app\common\controller; 3 namespace app\common\controller;
4 4
5 -use Qiniu\Auth;  
6 use tinymeng\code\Generate; 5 use tinymeng\code\Generate;
7 6
8 class Resource 7 class Resource
9 { 8 {
10 /** 9 /**
11 * 生成条形码 10 * 生成条形码
12 - * @param $res  
13 - * @return false|string  
14 */ 11 */
15 public static function StudyBar($res){ 12 public static function StudyBar($res){
16 $generate = Generate::bar(); 13 $generate = Generate::bar();
17 - $file_path = $generate->create($res,true,true,4,40); 14 + $file_path = $generate->create($res,false,true);
18 $file_path = substr($file_path,strripos($file_path,"public")+6); 15 $file_path = substr($file_path,strripos($file_path,"public")+6);
19 return $file_path; 16 return $file_path;
20 } 17 }
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 "ext-bcmath": "*", 32 "ext-bcmath": "*",
33 "txthinking/mailer": "^2.0", 33 "txthinking/mailer": "^2.0",
34 "phpoffice/phpexcel": "^1.8", 34 "phpoffice/phpexcel": "^1.8",
35 - "tinymeng/code": "dev-master" 35 + "tinymeng/code": "^2.0"
36 }, 36 },
37 "config": { 37 "config": {
38 "preferred-install": "dist", 38 "preferred-install": "dist",
@@ -1063,8 +1063,8 @@ @@ -1063,8 +1063,8 @@
1063 }, 1063 },
1064 { 1064 {
1065 "name": "overtrue/wechat", 1065 "name": "overtrue/wechat",
1066 - "version": "4.7.0",  
1067 - "version_normalized": "4.7.0.0", 1066 + "version": "4.8.0",
  1067 + "version_normalized": "4.8.0.0",
1068 "source": { 1068 "source": {
1069 "type": "git", 1069 "type": "git",
1070 "url": "https://github.com/w7corp/easywechat.git", 1070 "url": "https://github.com/w7corp/easywechat.git",
@@ -1131,7 +1131,7 @@ @@ -1131,7 +1131,7 @@
1131 ], 1131 ],
1132 "support": { 1132 "support": {
1133 "issues": "https://github.com/w7corp/easywechat/issues", 1133 "issues": "https://github.com/w7corp/easywechat/issues",
1134 - "source": "https://github.com/w7corp/easywechat/tree/4.7.0" 1134 + "source": "https://github.com/w7corp/easywechat/tree/4.8.0"
1135 }, 1135 },
1136 "funding": [ 1136 "funding": [
1137 { 1137 {
@@ -2966,8 +2966,8 @@ @@ -2966,8 +2966,8 @@
2966 }, 2966 },
2967 { 2967 {
2968 "name": "tinymeng/code", 2968 "name": "tinymeng/code",
2969 - "version": "dev-master",  
2970 - "version_normalized": "dev-master", 2969 + "version": "v2.0.1",
  2970 + "version_normalized": "2.0.1.0",
2971 "source": { 2971 "source": {
2972 "type": "git", 2972 "type": "git",
2973 "url": "https://github.com/majiameng/phpQrCode.git", 2973 "url": "https://github.com/majiameng/phpQrCode.git",
@@ -2984,7 +2984,6 @@ @@ -2984,7 +2984,6 @@
2984 "tinymeng/tools": "^1.0.7" 2984 "tinymeng/tools": "^1.0.7"
2985 }, 2985 },
2986 "time": "2020-03-28T10:11:51+00:00", 2986 "time": "2020-03-28T10:11:51+00:00",
2987 - "default-branch": true,  
2988 "type": "library", 2987 "type": "library",
2989 "installation-source": "dist", 2988 "installation-source": "dist",
2990 "autoload": { 2989 "autoload": {
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 'name' => 'karsonzhang/fastadmin', 3 'name' => 'karsonzhang/fastadmin',
4 'pretty_version' => 'dev-master', 4 'pretty_version' => 'dev-master',
5 'version' => 'dev-master', 5 'version' => 'dev-master',
6 - 'reference' => '3adf148ca4f5939e55dd606e8cb9b4c4545de89b', 6 + 'reference' => '11dcb6c44732b8867d69444db4589246a6fe0f66',
7 'type' => 'project', 7 'type' => 'project',
8 'install_path' => __DIR__ . '/../../', 8 'install_path' => __DIR__ . '/../../',
9 'aliases' => array(), 9 'aliases' => array(),
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 'karsonzhang/fastadmin' => array( 58 'karsonzhang/fastadmin' => array(
59 'pretty_version' => 'dev-master', 59 'pretty_version' => 'dev-master',
60 'version' => 'dev-master', 60 'version' => 'dev-master',
61 - 'reference' => '3adf148ca4f5939e55dd606e8cb9b4c4545de89b', 61 + 'reference' => '11dcb6c44732b8867d69444db4589246a6fe0f66',
62 'type' => 'project', 62 'type' => 'project',
63 'install_path' => __DIR__ . '/../../', 63 'install_path' => __DIR__ . '/../../',
64 'aliases' => array(), 64 'aliases' => array(),
@@ -146,8 +146,8 @@ @@ -146,8 +146,8 @@
146 'dev_requirement' => false, 146 'dev_requirement' => false,
147 ), 147 ),
148 'overtrue/wechat' => array( 148 'overtrue/wechat' => array(
149 - 'pretty_version' => '4.7.0',  
150 - 'version' => '4.7.0.0', 149 + 'pretty_version' => '4.8.0',
  150 + 'version' => '4.8.0.0',
151 'reference' => '4accb0627803ffb6e45d2988898a0293d2a48e68', 151 'reference' => '4accb0627803ffb6e45d2988898a0293d2a48e68',
152 'type' => 'library', 152 'type' => 'library',
153 'install_path' => __DIR__ . '/../overtrue/wechat', 153 'install_path' => __DIR__ . '/../overtrue/wechat',
@@ -443,14 +443,12 @@ @@ -443,14 +443,12 @@
443 'dev_requirement' => false, 443 'dev_requirement' => false,
444 ), 444 ),
445 'tinymeng/code' => array( 445 'tinymeng/code' => array(
446 - 'pretty_version' => 'dev-master',  
447 - 'version' => 'dev-master', 446 + 'pretty_version' => 'v2.0.1',
  447 + 'version' => '2.0.1.0',
448 'reference' => 'a5a6ba189f18a8e1f826dfa4994e26da5714d8ad', 448 'reference' => 'a5a6ba189f18a8e1f826dfa4994e26da5714d8ad',
449 'type' => 'library', 449 'type' => 'library',
450 'install_path' => __DIR__ . '/../tinymeng/code', 450 'install_path' => __DIR__ . '/../tinymeng/code',
451 - 'aliases' => array(  
452 - 0 => '9999999-dev',  
453 - ), 451 + 'aliases' => array(),
454 'dev_requirement' => false, 452 'dev_requirement' => false,
455 ), 453 ),
456 'tinymeng/tools' => array( 454 'tinymeng/tools' => array(
@@ -53,7 +53,7 @@ class Bar extends Gateway{ @@ -53,7 +53,7 @@ class Bar extends Gateway{
53 mkdir($filePath, 0777, true); 53 mkdir($filePath, 0777, true);
54 } 54 }
55 55
56 - $file_name = is_int($data) ? $data : $data; 56 + $file_name = $data;
57 $filename = $filePath.$file_name.'.png'; 57 $filename = $filePath.$file_name.'.png';
58 $drawing = new BCGDrawing($filename, $colorBack); 58 $drawing = new BCGDrawing($filename, $colorBack);
59 $drawing->setBarcode($code); 59 $drawing->setBarcode($code);
@@ -54,9 +54,9 @@ class Qr extends Gateway{ @@ -54,9 +54,9 @@ class Qr extends Gateway{
54 } 54 }
55 55
56 if(is_int($data)){ 56 if(is_int($data)){
57 - $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png'; 57 + $file_name = 'qr'.$data.'.png';
58 }else{ 58 }else{
59 - $file_name = $data.'.png'; 59 + $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png';
60 } 60 }
61 $filename = $filePath.$file_name; 61 $filename = $filePath.$file_name;
62 QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); 62 QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
@@ -11,7 +11,6 @@ use \tinymeng\tools\Strings; @@ -11,7 +11,6 @@ use \tinymeng\tools\Strings;
11 * @package tinymeng\mailer 11 * @package tinymeng\mailer
12 */ 12 */
13 define('saveFilePath',dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'barimages'.DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR); 13 define('saveFilePath',dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'barimages'.DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR);
14 -  
15 class Generate 14 class Generate
16 { 15 {
17 /** 16 /**