作者 刘朕
1 个管道 的构建 通过 耗费 8 秒

模型视图优化

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 namespace app\admin\controller; 9 namespace app\admin\controller;
10 10
11 use app\admin\model\OrderModel; 11 use app\admin\model\OrderModel;
  12 +use app\portal\model\OrderViewModel;
12 use cmf\controller\AdminBaseController; 13 use cmf\controller\AdminBaseController;
13 use think\Db; 14 use think\Db;
14 15
@@ -140,7 +141,9 @@ class OrderController extends AdminBaseController @@ -140,7 +141,9 @@ class OrderController extends AdminBaseController
140 $where['create_time'] = ['<= time', $endTime]; 141 $where['create_time'] = ['<= time', $endTime];
141 } 142 }
142 } 143 }
143 - $list = $this->singleData('order_view',$where,2,[],10); 144 + $order_view_model = new OrderViewModel();
  145 + $list = $order_view_model->where($where)
  146 + ->paginate(10);
144 $orderList = $list->items(); 147 $orderList = $list->items();
145 foreach ($orderList as $k=>$v) { 148 foreach ($orderList as $k=>$v) {
146 $v['options'] = json_decode($v['options'],true); 149 $v['options'] = json_decode($v['options'],true);
@@ -219,7 +222,9 @@ class OrderController extends AdminBaseController @@ -219,7 +222,9 @@ class OrderController extends AdminBaseController
219 $where['create_time'] = ['<= time', $endTime]; 222 $where['create_time'] = ['<= time', $endTime];
220 } 223 }
221 } 224 }
222 - $list = $this->singleData('order_view',$where,2,[],10); 225 + $order_view_model = new OrderViewModel();
  226 + $list = $order_view_model->where($where)
  227 + ->paginate(10);
223 $orderList = $list->items(); 228 $orderList = $list->items();
224 foreach ($orderList as $k=>$v) { 229 foreach ($orderList as $k=>$v) {
225 $v['options'] = json_decode($v['options'],true); 230 $v['options'] = json_decode($v['options'],true);
@@ -304,7 +309,9 @@ class OrderController extends AdminBaseController @@ -304,7 +309,9 @@ class OrderController extends AdminBaseController
304 $where['create_time'] = ['<= time', $endTime]; 309 $where['create_time'] = ['<= time', $endTime];
305 } 310 }
306 } 311 }
307 - $list = $this->singleData('order_view',$where,2,[],10); 312 + $order_view_model = new OrderViewModel();
  313 + $list = $order_view_model->where($where)
  314 + ->paginate(10);
308 $orderList = $list->items(); 315 $orderList = $list->items();
309 foreach ($orderList as $k=>$v) { 316 foreach ($orderList as $k=>$v) {
310 $v['options'] = json_decode($v['options'],true); 317 $v['options'] = json_decode($v['options'],true);
@@ -10,6 +10,7 @@ namespace app\portal\controller; @@ -10,6 +10,7 @@ namespace app\portal\controller;
10 10
11 use app\admin\model\OrderModel; 11 use app\admin\model\OrderModel;
12 use app\admin\model\OrderSortModel; 12 use app\admin\model\OrderSortModel;
  13 +use app\portal\model\OrderViewModel;
13 use cmf\controller\HomeBaseController; 14 use cmf\controller\HomeBaseController;
14 use cmf\lib\Upload; 15 use cmf\lib\Upload;
15 use think\Cache; 16 use think\Cache;
@@ -274,7 +275,8 @@ class MemberSalesController extends HomeBaseController @@ -274,7 +275,8 @@ class MemberSalesController extends HomeBaseController
274 'is_stop' => 0, 275 'is_stop' => 0,
275 'delete_time' => 0 276 'delete_time' => 0
276 ]; 277 ];
277 - $orderList = Db::name('OrderView') 278 + $order_view_model = new OrderViewModel();
  279 + $orderList = $order_view_model
278 ->where(function ($q) use ($order_where1) {$q->where($order_where1);}) 280 ->where(function ($q) use ($order_where1) {$q->where($order_where1);})
279 ->whereOr(function ($q) use ($order_where2) {$q->where($order_where2);}) 281 ->whereOr(function ($q) use ($order_where2) {$q->where($order_where2);})
280 ->select()->toArray(); 282 ->select()->toArray();
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: 29925
  5 + * Date: 2018/11/21
  6 + * Time: 9:43
  7 + */
  8 +
  9 +namespace app\portal\model;
  10 +
  11 +use think\Model;
  12 +
  13 +class OrderViewModel extends Model
  14 +{
  15 +
  16 + // 开启自动写入时间戳字段
  17 + protected $autoWriteTimestamp = true;
  18 +}
@@ -1506,3 +1506,23 @@ @@ -1506,3 +1506,23 @@
1506 'buyer_logon_id' => '186****5098', 1506 'buyer_logon_id' => '186****5098',
1507 'point_amount' => '0.00', 1507 'point_amount' => '0.00',
1508 ) 1508 )
  1509 +2018-11-15 08:23:45 {"trade_no":"","out_trade_no":"2018111552100565"}
  1510 +2018-11-15 08:23:47 response: stdClass::__set_state(array(
  1511 + 'alipay_trade_query_response' =>
  1512 + stdClass::__set_state(array(
  1513 + 'code' => '10000',
  1514 + 'msg' => 'Success',
  1515 + 'buyer_logon_id' => 'bie***@eyou.com',
  1516 + 'buyer_pay_amount' => '0.00',
  1517 + 'buyer_user_id' => '2088002229941027',
  1518 + 'invoice_amount' => '0.00',
  1519 + 'out_trade_no' => '2018111552100565',
  1520 + 'point_amount' => '0.00',
  1521 + 'receipt_amount' => '0.00',
  1522 + 'send_pay_date' => '2018-11-15 12:29:27',
  1523 + 'total_amount' => '4000.00',
  1524 + 'trade_no' => '2018111522001441021009470070',
  1525 + 'trade_status' => 'TRADE_SUCCESS',
  1526 + )),
  1527 + 'sign' => 'q1EHSxY3l5PEDeR1fglLQNPU/k+M8AbyzNgEJIx63m/vm4+yAIo+mg6QSiF+czi9ufHxhrIbaokgJdvAgNQYc8w6PBr73OLLSpc3eBUuYzF5kywqbS9ORWYH4/QUABLMUsGK/a+Vkn6H1iSx9DH5/6MWRrDSt52Nm2+Mm4SAekNf1ZMYjcm9FvSuCk8lP1StLS7zfIoPoF78qI4c2skU8E/DaBdKIJRDgbNZUbn+xaQSbEnepMcjHnSgNFNqRZREWwrWVsISmOtyeCNkfG90jkNLUWCkqoKovn3ICjx58ONwExXrbVbtsELvSsLVsiWoeUd95GhhIg9pFeu+54m3bw==',
  1528 +))