作者 何书鹏
1 个管道 的构建 通过 耗费 11 秒

修改bug

@@ -38,6 +38,12 @@ class Cart extends Api @@ -38,6 +38,12 @@ class Cart extends Api
38 }) 38 })
39 */ 39 */
40 public function index(){ 40 public function index(){
  41 + // 删除所有超过一天的立即购买数据
  42 + $this->model
  43 + ->where('isbuynow','1')
  44 + ->where('createtime','<',time()-86400)
  45 + ->delete();
  46 + // 购物车数据
41 $this->success(__('成功'),$this->model->getList($this->user,['isbuynow'=>'0'])); 47 $this->success(__('成功'),$this->model->getList($this->user,['isbuynow'=>'0']));
42 } 48 }
43 49
@@ -39,7 +39,7 @@ class Category extends Api @@ -39,7 +39,7 @@ class Category extends Api
39 } 39 }
40 $tree = Tree::instance(); 40 $tree = Tree::instance();
41 $tree->init(collection($list)->toArray(), 'pid'); 41 $tree->init(collection($list)->toArray(), 'pid');
42 - $list = $tree->getTreeArray(0); 42 + $list = $this->getTreeList($tree->getTreeArray(0));
43 // 拼接全部分类,方便前端展示 43 // 拼接全部分类,方便前端展示
44 $all_list = []; 44 $all_list = [];
45 foreach($list as $v){ 45 foreach($list as $v){
@@ -52,7 +52,7 @@ class Category extends Api @@ -52,7 +52,7 @@ class Category extends Api
52 "id" => 0, 52 "id" => 0,
53 "pid" => 0, 53 "pid" => 0,
54 "name" => "全部", 54 "name" => "全部",
55 - "image" => "http://www.silk.top/uploads/20200715/a9c98c6c32fe55481fff5a0f730f9e0d.png", 55 + "image" => cdnurl('/assets/img/qrcode.png',true),
56 "type_text" => "商品分类", 56 "type_text" => "商品分类",
57 "flag_text" => "", 57 "flag_text" => "",
58 "spacer" => "", 58 "spacer" => "",
@@ -61,13 +61,15 @@ class Category extends Api @@ -61,13 +61,15 @@ class Category extends Api
61 "id" => 0, 61 "id" => 0,
62 "pid" => 0, 62 "pid" => 0,
63 "name" => "全部", 63 "name" => "全部",
64 - "image" => "http://www.silk.top/uploads/20200715/a9c98c6c32fe55481fff5a0f730f9e0d.png", 64 + "image" => cdnurl('/assets/img/qrcode.png',true),
65 "type_text" => "商品分类", 65 "type_text" => "商品分类",
66 "flag_text" => "", 66 "flag_text" => "",
67 "spacer" => "", 67 "spacer" => "",
68 "childlist" => $all_list 68 "childlist" => $all_list
69 ] 69 ]
70 - ] 70 + ],
  71 + "haschild" => 1,
  72 + "level" => 1
71 ]; 73 ];
72 array_unshift($list,$all); 74 array_unshift($list,$all);
73 $this->success(__('成功'),compact('list')); 75 $this->success(__('成功'),compact('list'));
@@ -102,4 +104,22 @@ class Category extends Api @@ -102,4 +104,22 @@ class Category extends Api
102 $list = \app\common\model\Goods::getList($where,$page,$rows); 104 $list = \app\common\model\Goods::getList($where,$page,$rows);
103 $this->success(__('成功'),compact('list')); 105 $this->success(__('成功'),compact('list'));
104 } 106 }
  107 +
  108 + // 判断等级和是否有下级
  109 + public function getTreeList($data = [], $level = 1)
  110 + {
  111 + $arr = [];
  112 + $n = 0;
  113 + foreach ($data as $k => $v) {
  114 + $childlist = isset($v['childlist']) ? $v['childlist'] : [];
  115 + $v['haschild'] = $childlist ? 1 : 0;
  116 + $v['level'] = $v['pid'] == 0 ? 1 : $level+1;
  117 + $arr[$n] = $v;
  118 + if ($childlist) {
  119 + $arr[$n]['childlist'] = $this->getTreeList($childlist, $v['level']);
  120 + }
  121 + $n++;
  122 + }
  123 + return $arr;
  124 + }
105 } 125 }
@@ -397,7 +397,9 @@ class Order extends Model @@ -397,7 +397,9 @@ class Order extends Model
397 { 397 {
398 $list = $this->getList($user_id,'payment'); 398 $list = $this->getList($user_id,'payment');
399 foreach($list as $v){ 399 foreach($list as $v){
400 - $v->cancel(); 400 + if($v['createtime'] < time()-86400){
  401 + $v->cancel();
  402 + }
401 } 403 }
402 return true; 404 return true;
403 } 405 }