Browse Source

订单详情

lizhen_gitee 6 months ago
parent
commit
e6411d5983
2 changed files with 68 additions and 11 deletions
  1. 49 10
      addons/unishop/controller/Order.php
  2. 19 1
      application/common.php

+ 49 - 10
addons/unishop/controller/Order.php

@@ -622,9 +622,9 @@ class Order extends Base
                     'extend' => function ($query) {
                         $query->field('id,order_id,address_id,address_json,express_number,express_company');
                     },
-                    'evaluate' => function ($query) {
+                    /*'evaluate' => function ($query) {
                         $query->field('id,order_id,product_id');
-                    }
+                    }*/
                 ])
                 ->where(['id' => $order_id, 'user_id' => $this->auth->id])->find();
 
@@ -632,38 +632,59 @@ class Order extends Base
                 $order = $order->append(['state', 'paidtime', 'deliveredtime', 'receivedtime', 'commentedtime', 'pay_type_text', 'refund_status_text'])->toArray();
 
                 // 快递单号
-                $order['express_number'] = $order['extend']['express_number'];
+                /*$order['express_number'] = $order['extend']['express_number'];
                 $order['express_company'] = '快递单号';
                 $order['express'] = '';
                 if (class_exists(\addons\expressquery\library\Expressquery::class)) {
                     $expressInfo = Db::name('expressquery')->where(['express' => $order['extend']['express_company']])->find();
                     $order['express_company'] = $expressInfo['name'] ?? '快递单号';
                     $order['express'] = $expressInfo['express'] ?? '';
-                }
+                }*/
 
                 // 送货地址
-                $address = json_decode($order['extend']['address_json'], true);
+                /*$address = json_decode($order['extend']['address_json'], true);
                 $area = (new \addons\unishop\model\Area())
                     ->whereIn('id', [$address['province_id'], $address['city_id'], $address['area_id']])
                     ->column('name', 'id');
                 $delivery['username'] = $address['name'];
                 $delivery['mobile'] = $address['mobile'];
                 $delivery['address'] = $area[$address['province_id']] . ' ' . $area[$address['city_id']] . ' ' . $area[$address['area_id']] . ' ' . $address['address'];
-                $order['delivery'] = $delivery;
+                $order['delivery'] = $delivery;*/
 
                 // 是否已评论
-                $evaluate = array_column($order['evaluate'], 'product_id');
+//                $evaluate = array_column($order['evaluate'], 'product_id');
                 foreach ($order['products'] as &$product) {
                     $product['image'] = Config::getImagesFullUrl($product['image']);
-                    if (in_array($product['id'], $evaluate)) {
+                    /*if (in_array($product['id'], $evaluate)) {
                         $product['evaluate'] = true;
                     } else {
                         $product['evaluate'] = false;
-                    }
+                    }*/
                 }
 
-                unset($order['evaluate']);
+//                unset($order['evaluate']);
                 unset($order['extend']);
+
+                //预约日期
+                $week_data = [
+                    0 => '周日',
+                    1 => '周一',
+                    2 => '周二',
+                    3 => '周三',
+                    4 => '周四',
+                    5 => '周五',
+                    6 => '周六',
+                    7 => '周日',
+                ];
+                $order['bookdate'] = date('Y-m-d H:i',$order['booktime']) .' '. $week_data[date('w',$order['booktime'])];
+
+                //追加退改规则
+                $order['order_refund_rule'] = config('site.order_refund_rule');
+
+                //电子凭证,核销码
+                $qrcode_string = 'order_hexiao_no|' . $order['out_trade_no'];
+                $order['order_hexiao_qrcode'] = httpurllocal($this->inviteimage($qrcode_string));
+
             }
 
         } catch (Exception $e) {
@@ -673,6 +694,24 @@ class Order extends Base
         $this->success('', $order);
     }
 
+    //生成核销码
+    private function inviteimage($introcode) {
+        $params['text'] = $introcode;
+        $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
+
+        $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
+        if (!is_dir($qrcodePath)) {
+            @mkdir($qrcodePath);
+        }
+        if (is_really_writable($qrcodePath)) {
+            $filename = md5(implode('', $params)) . '.png';
+            $filePath = $qrcodePath . $filename;
+            $qrcode_service->writeFile($filePath);
+        }
+
+        return '/uploads/qrcode/' . $filename;
+    }
+
     /**
      * @ApiTitle    (申请售后信息)
      * @ApiSummary  (申请售后信息)

+ 19 - 1
application/common.php

@@ -670,7 +670,7 @@ if (!function_exists('get_rand_nick_name')) {
 
     }
 }
-if (!function_exists('get_rand_nick_name')) {
+if (!function_exists('createUniqueNo')) {
     //创建订单号
     function createUniqueNo($prifix = 'P',$id = 0)
     {
@@ -912,6 +912,7 @@ if(!function_exists('file_exist')) {
         }
     }
 }
+
 if(!function_exists('list_birthday_age')) {
     //结果集信息里,生日转换年龄
     function list_birthday_age($list){
@@ -981,4 +982,21 @@ if(!function_exists('birthtime_to_age')) {
 
         return $age;
     }
+}
+
+if (!function_exists('httpurllocal')) {
+    /**
+     * 判断当前url是否为全路径,并返回全路径
+     */
+    function httpurllocal($path) {
+        if(!$path) return $path;
+        $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
+        // 获取当前域名
+        if(strpos($path,'http://') === false && strpos($path,'https://') === false) {
+            $url = $host.$path;
+        } else {
+            $url = $path;
+        }
+        return $url;
+    }
 }