From c5d3709d735dd4d8dc23892e102ecbf3ef73b310 Mon Sep 17 00:00:00 2001 From: zengyyh Date: Tue, 13 Aug 2024 22:56:48 +0800 Subject: [PATCH] beizhu --- app/admin/controller/Wxserve.php | 2 +- app/api/controller/Order.php | 26 ++++++++++++++++++-------- app/store/controller/Order.php | 24 ++++++++++++++++++------ 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index 99513cc7..20db7e41 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -332,7 +332,7 @@ class Wxserve extends Controller if ($appid) { $obj = new Server(); $msg = $obj->applySetOrderPathInfo([$appid]); - if ($msg['errmsg'] == 'ok') { + if ($msg == 'ok') { return $this->renderSuccess('success'); } } diff --git a/app/api/controller/Order.php b/app/api/controller/Order.php index 4325f1e8..7153db86 100644 --- a/app/api/controller/Order.php +++ b/app/api/controller/Order.php @@ -82,14 +82,24 @@ class Order extends Controller $model = OrderModel::getUserOrderDetail($orderId); $MerchantRemarks = new MerchantRemarksModel; $merchant = $MerchantRemarks->orderRemarkList($orderId); - foreach ($merchant as $key => $value) { - if (isset($value['image_id'])) { - // 解码 JSON 字符串并确保返回的是数组 - $decodedImageId = json_decode($value['image_id'], true); - - if (is_array($decodedImageId) && isset($decodedImageId['image_id'])) { - $value['image_id'] = $decodedImageId['image_id']; - $value['image_url'] = UploadFile::getFileList($value['image_id']); + $merchant = $MerchantRemarks->orderRemarkList($orderId); + if ($merchant) { + foreach ($merchant as $key => $value) { + // 初始化 $image_id 为 null 或者一个默认值 + $image_id = null; + + if (isset($value['image_id']) && !empty($value['image_id'])) { + $decoded_image_id = json_decode($value['image_id'], true); + + // 检查 json_decode 是否成功并且结果中存在 'image_id' 键 + if (is_array($decoded_image_id) && isset($decoded_image_id['image_id'])) { + $image_id = $decoded_image_id['image_id']; + } + } + + if ($image_id !== null) { // 确保 $image_id 已经被设置 + $item['image_id'] = $image_id; + $value['image_url'] = $MerchantRemarks->getRemarkImage($item['image_id']); } } } diff --git a/app/store/controller/Order.php b/app/store/controller/Order.php index daab62f2..54887c94 100644 --- a/app/store/controller/Order.php +++ b/app/store/controller/Order.php @@ -119,12 +119,24 @@ class Order extends Controller return $this->renderError('未找到该订单记录'); } $merchant = $MerchantRemarks->orderRemarkList($orderId); - if($merchant){ - foreach($merchant as $key => $value){ - if(isset($value['image_id']) && !empty($value['image_id'])) - $image_id = json_decode($value['image_id'],true); - $item['image_id'] = $image_id['image_id']; - $value['image_url'] = $MerchantRemarks->getRemarkImage($item['image_id']); + if ($merchant) { + foreach ($merchant as $key => $value) { + // 初始化 $image_id 为 null 或者一个默认值 + $image_id = null; + + if (isset($value['image_id']) && !empty($value['image_id'])) { + $decoded_image_id = json_decode($value['image_id'], true); + + // 检查 json_decode 是否成功并且结果中存在 'image_id' 键 + if (is_array($decoded_image_id) && isset($decoded_image_id['image_id'])) { + $image_id = $decoded_image_id['image_id']; + } + } + + if ($image_id !== null) { // 确保 $image_id 已经被设置 + $item['image_id'] = $image_id; + $value['image_url'] = $MerchantRemarks->getRemarkImage($item['image_id']); + } } } $detail['merchant'] = $merchant;