wesmiler 6 лет назад
Родитель
Сommit
ebfa4beef8

+ 6 - 1
vendor/thinkcmf/cmf-app/src/weixin/controller/NotifyController.php

@@ -5,6 +5,7 @@
  */
 namespace app\weixin\controller;
 use app\weixin\model\Member;
+use app\weixin\model\Stroage;
 use app\weixin\model\Wechat;
 use app\weixin\model\Payment;
 use think\Controller;
@@ -248,7 +249,7 @@ class NotifyController extends Controller
         $status = isset($params['status'])? $params['status'] : '';
         if($status == 'success'){
             $info = db('print_files')->where(['task_id'=> $taskId])
-                ->field('id,order_id')
+                ->field('id,url,order_id')
                 ->find();
             if(empty($info)){
                 showJson('error','任务信息不存在');
@@ -267,6 +268,10 @@ class NotifyController extends Controller
                 ->count('id');
             if($completeFileCount>=$fileCount){
                 db('orders')->where(['id'=> $orderId])->update(['status'=> 3,'remark'=>'已打印完所有文件','updated_at'=>date('Y-m-d H:i:s')]);
+
+                // 删除文件
+                $url = isset($info['url'])? trim($info['url']) : '';
+                Stroage::delPrintFile($url);
                 showJson('success','全部打印完成');
             }
 

+ 2 - 3
vendor/thinkcmf/cmf-app/src/weixin/model/Devices.php

@@ -102,8 +102,7 @@ class Devices extends Model
         if (empty($file)) {
             return ['code' => 'error', 'message' => lang(3010)];
         }
-
-        echo file_exists('upload/' . $file['url']);
+        
         $fileUrl = $file['url'] ? cmf_get_image_preview_url($file['url']) : '';
         if (empty($fileUrl) || !file_exists('upload/' . $file['url'])) {
             return ['code' => 'error', 'message' => lang(3010)];
@@ -199,7 +198,7 @@ class Devices extends Model
         }
 
         // 发起请求
-        file_put_contents('logs/test_print.log', var_export($params, true), 8);
+        saveLogCache('print:params', $params);
         $res = httpRequest($apiUrl, $params, 'post', 'array', 300);
         $taskId = isset($res['taskID']) ? $res['taskID'] : '';
         db('print_files')->where(['id' => $fid])->update(['task_id' => $taskId, 'print_result' => json_encode($res, 256), 'updated_at' => date('Y-m-d H:i:s')]);

+ 20 - 1
vendor/thinkcmf/cmf-app/src/weixin/model/Stroage.php

@@ -285,7 +285,7 @@ class Stroage extends Model
     public static function filtterColor($file)
     {
         $filepath = dirname($file);
-        $newFile = $waterfile = $filepath . '/color_' . basename($file);
+        $newFile = $filepath . '/color_' . basename($file);
         if (!file_exists('upload/' . $file)) {
             return false;
         }
@@ -303,6 +303,25 @@ class Stroage extends Model
     }
 
     /**
+     * 删除打印文件
+     * @param $file
+     */
+    public static function delPrintFile($file){
+        if(!$file){
+            return false;
+        }
+        $filepath = dirname($file);
+        $newFile = $filepath . '/color_' . basename($file);
+        if(file_exists('upload/'.$file)){
+            unlink('upload/'.$file);
+        }
+
+        if(file_exists('upload/'.$newFile)){
+            unlink('upload/'.$newFile);
+        }
+    }
+
+    /**
      * 文件转换
      * @param $file 文件
      * @param string $type 转换类型