瀏覽代碼

修改订单数据

邹景立 4 年之前
父節點
當前提交
f8887f7431
共有 3 個文件被更改,包括 6 次插入12 次删除
  1. 1 1
      app/data/controller/api/Goods.php
  2. 2 3
      app/data/controller/api/auth/Order.php
  3. 3 8
      app/data/service/GoodsService.php

+ 1 - 1
app/data/controller/api/Goods.php

@@ -21,7 +21,7 @@ class Goods extends Controller
      */
     public function getCate()
     {
-        $this->success('获取分类成功', GoodsService::instance()->getCateList());
+        $this->success('获取分类成功', GoodsService::instance()->getCateTree());
     }
 
     /**

+ 2 - 3
app/data/controller/api/auth/Order.php

@@ -289,13 +289,12 @@ class Order extends Auth
             $openid = '';
             if (in_array($this->type, [UserService::APITYPE_WXAPP, UserService::APITYPE_WECHAT])) {
                 $openid = $this->user[UserService::TYPES[$this->type]['auth']] ?? '';
-                // if (empty($openid)) $this->error("发起支付失败");
+                if (empty($openid)) $this->error("发起支付失败");
             }
             // 返回订单数据及支付发起参数
             $type = $order['amount_real'] <= 0 ? 'empty' : $data['payment_code'];
             $param = PaymentService::instance($type)->create($openid, $order['order_no'], $order['amount_real'], '商城订单支付', '', $data['payment_back'], $data['payment_image']);
-            $order = $this->app->db->name('ShopOrder')->where($map)->find() ?: new \stdClass();
-            $this->success('获取支付参数', ['order' => $order, 'param' => $param]);
+            $this->success('获取支付参数', ['order' => $this->app->db->name('ShopOrder')->where($map)->find() ?: new \stdClass(), 'param' => $param]);
         } catch (HttpResponseException $exception) {
             throw $exception;
         } catch (\Exception $exception) {

+ 3 - 8
app/data/service/GoodsService.php

@@ -57,21 +57,16 @@ class GoodsService extends Service
 
     /**
      * 获取分类数据
-     * @param string $type 操作函数
      * @return array
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getCateList(string $type = 'arr2tree'): array
+    public function getCateTree(): array
     {
         $map = ['deleted' => 0, 'status' => 1];
         $query = $this->app->db->name('ShopGoodsCate')->where($map)->order('sort desc,id desc');
-        $cates = DataExtend::$type($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
-        if ($type === 'arr2table') foreach ($cates as &$vo) {
-            $vo['sat'] = $vo['spt'] !== $this->getCateLevel() - 1 ? 'disabled' : '';
-        }
-        return $cates;
+        return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
     }
 
     /**
@@ -133,7 +128,7 @@ class GoodsService extends Service
             foreach ($cates as $cate) if (in_array($cate['id'], $vo['cateids'])) $vo['cateinfo'] = $cate;
             [$vo['slider'], $vo['specs'], $vo['items']] = [str2arr($vo['slider'], '|'), json_decode($vo['data_specs'], true), []];
             foreach ($items as $item) if ($item['goods_code'] === $vo['code']) $vo['items'][] = $item;
-            if ($simple) unset($vo['marks'], $vo['sort'], $vo['status'], $vo['deleted'], $vo['data_items'], $vo['data_specs']);
+            if ($simple) unset($vo['marks'], $vo['sort'], $vo['status'], $vo['deleted'], $vo['data_items'], $vo['data_specs'], $vo['cateinfo']['parent']);
         }
         return $data;
     }