From 463bea6903ccaed34d632f90430aeaa2a975c168 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Mon, 15 Apr 2024 17:22:20 +0800 Subject: [PATCH] 1 --- app/common/library/wxserver/Server.php | 43 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 5a743845..82f0bb08 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -649,7 +649,12 @@ class Server if ($access_token) { $url = 'https://api.weixin.qq.com/wxa/submit_audit?access_token=' . $access_token; $data['item_list'] = $this->getAllCategory($appid); - $result = $this->curlPost($url, json_encode($data)); + if (!empty($data['item_list'])) { + $data = '{}'; + } else { + $data = json_encode($data); + } + $result = $this->curlPost($url, $data); $result = json_decode($result, true); Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($result), 'created_at' => date('Y-m-d H:i:s')]); if (!empty($result) && intval($result['errcode']) == 0 && !empty($result['auditid'])) { @@ -717,20 +722,28 @@ class Server if ($result && !empty($result['category_list'])) { $category_list = $result['category_list']; foreach ($category_list as $value) { - $first_class = !empty($value['first_class']) ? $value['first_class'] : ''; - $second_class = !empty($value['second_class']) ? $value['second_class'] : ''; - $third_class = !empty($value['third_class']) ? $value['third_class'] : ''; - $first_id = !empty($value['first_id']) ? $value['first_id'] : ''; - $second_id = !empty($value['second_id']) ? $value['second_id'] : ''; - $third_id = !empty($value['third_id']) ? $value['third_id'] : ''; - $data[] = [ - 'first_class' => $first_class, - 'second_class' => $second_class, - 'third_class' => $third_class, - 'first_id' => $first_id, - 'second_id' => $second_id, - 'third_id' => $third_id, - ]; + $arr = []; + if (!empty($value['first_class'])) { + $arr['first_class'] = $value['first_class']; + } + if (!empty($value['second_class'])) { + $arr['second_class'] = $value['second_class']; + } + if (!empty($value['third_class'])) { + $arr['third_class'] = $value['third_class']; + } + if (!empty($value['first_id'])) { + $arr['first_id'] = $value['first_id']; + } + if (!empty($value['second_id'])) { + $arr['second_id'] = $value['second_id']; + } + if (!empty($value['third_id'])) { + $arr['third_id'] = $value['third_id']; + } + if ($arr) { + $data[] = $arr; + } } } }