wesley 6 years ago
parent
commit
7c78a01acb
1 changed files with 34 additions and 16 deletions
  1. 34 16
      app/Http/Controllers/Api/V1/FurnitureController.php

+ 34 - 16
app/Http/Controllers/Api/V1/FurnitureController.php

xqd xqd xqd xqd xqd xqd
@@ -20,11 +20,11 @@ use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use MGQrCodeReader\MGQrCodeReader;
-use Validator, Auth ,Image;
+use Validator, Auth, Image;
 use App\Services\Base\ErrorCode;
 use EasyWeChat\Factory;
 use Zxing\Qrcode\QRCodeReader;
-use ZBarCodeImage,ZBarCodeScanner;
+use ZBarCodeImage, ZBarCodeScanner;
 
 
 class FurnitureController extends Controller
@@ -1902,7 +1902,7 @@ class FurnitureController extends Controller
      * @apiVersion 0.1.0
      * @apiParam {string}    store_id
      * @apiParam {string}    order_id
-     * @apiParam {int}       role  1:生产部 
+     * @apiParam {int}       role  1:生产部
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
@@ -1972,18 +1972,35 @@ class FurnitureController extends Controller
         if ($order->remark && $role == 2) {
             $content .= "<B>备注:" . $order->remark . "</B><BR>";
         }
-        \Log::info($qrcode);
-        \Log::info($qrcodetext);
+        if ($role == 2) {
+            $content .= "<QR>" . $qrcodetext . "</QR><BR>";
+        }
+
         if ($role == 1) {
-            $content .= "<CB>客户:" . $order->customer_name . "</CB><BR>";
+            $parts = AlbumPartsModel::where('store_id', $this->getStoreId())->where('order_id', request('order_id'))
+                ->get(['name', 'count']);
+            $content .= "客户姓名:" . $order->customer_name . "<BR>";
+            $content .= "联系方式:" . $order->customer_phone . "<BR>";
+            $content .= "联系地址:" . $order->customer_address . "<BR>";
+
+            $content .= "产品分类:" . $order->category . "<BR>";
+            $content .= "产品型号:" . $order->type . "<BR>";
+            $content .= "产品颜色:" . $order->color . "<BR>";
+            if (count($parts)) {
+                $content .= "配件:";
+                foreach ($parts as $part) {
+                    $content .= "<C>".$part->name.'------'.$part->count . "</C><BR>";
+                };
+            }
+            $content .= "逾期时间:" . $order->expected_time . "<BR>";
         }
-        $content .= "<QR>" . $qrcodetext . "</QR><BR>";
+
 
         $setting = AlbumManufacturerModel::where('store_id', request('store_id'))->first();
 
-        if($setting->print_type == 2){
-            $res = $this->print_365($setting->print_no, $setting->print_key,$content, 1);
-        }else{
+        if ($setting->print_type == 2) {
+            $res = $this->print_365($setting->print_no, $setting->print_key, $content, 1);
+        } else {
             $res = $this->wp_print($setting->print_no, $content, 1);
         }
 
@@ -2003,7 +2020,8 @@ class FurnitureController extends Controller
 
     }
 
-    function print_365($printer_sn,$print_key, $orderInfo, $times){
+    function print_365($printer_sn, $print_key, $orderInfo, $times)
+    {
         $selfMessage = array(
             'deviceNo' => $printer_sn,
             'printContent' => $orderInfo,
@@ -2022,9 +2040,9 @@ class FurnitureController extends Controller
         $result = file_get_contents($url, false, $context);
         $res = json_decode($result);
 
-        if(isset($res->responseCode) && $res->responseCode === 0){
+        if (isset($res->responseCode) && $res->responseCode === 0) {
             return true;
-        }else{
+        } else {
             return false;
         }
     }
@@ -2131,13 +2149,13 @@ class FurnitureController extends Controller
             'response_type' => 'array',
         ];
         $app = Factory::miniProgram($config);
-        $response = $app->app_code->getQrCode('pages/search/search?order_id=' . $id,400);
+        $response = $app->app_code->getQrCode('pages/search/search?order_id=' . $id, 400);
         $path = public_path() . '/download';
         $qrcode = $response->save($path, $id);
 
-        $real_path = $path .'/'. $qrcode;
+        $real_path = $path . '/' . $qrcode;
 
-        Image::make($real_path)->crop(423, 415 , 0 , 0)->save($real_path);
+        Image::make($real_path)->crop(423, 415, 0, 0)->save($real_path);
         if ($qrcode) {
             $qrcode = env('APP_URL') . '/download/' . $id . '.jpg';
             $order = AlbumOrderModel::find($id);