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

修改bug

... ... @@ -38,6 +38,12 @@ class Cart extends Api
})
*/
public function index(){
// 删除所有超过一天的立即购买数据
$this->model
->where('isbuynow','1')
->where('createtime','<',time()-86400)
->delete();
// 购物车数据
$this->success(__('成功'),$this->model->getList($this->user,['isbuynow'=>'0']));
}
... ...
... ... @@ -39,7 +39,7 @@ class Category extends Api
}
$tree = Tree::instance();
$tree->init(collection($list)->toArray(), 'pid');
$list = $tree->getTreeArray(0);
$list = $this->getTreeList($tree->getTreeArray(0));
// 拼接全部分类,方便前端展示
$all_list = [];
foreach($list as $v){
... ... @@ -52,7 +52,7 @@ class Category extends Api
"id" => 0,
"pid" => 0,
"name" => "全部",
"image" => "http://www.silk.top/uploads/20200715/a9c98c6c32fe55481fff5a0f730f9e0d.png",
"image" => cdnurl('/assets/img/qrcode.png',true),
"type_text" => "商品分类",
"flag_text" => "",
"spacer" => "",
... ... @@ -61,13 +61,15 @@ class Category extends Api
"id" => 0,
"pid" => 0,
"name" => "全部",
"image" => "http://www.silk.top/uploads/20200715/a9c98c6c32fe55481fff5a0f730f9e0d.png",
"image" => cdnurl('/assets/img/qrcode.png',true),
"type_text" => "商品分类",
"flag_text" => "",
"spacer" => "",
"childlist" => $all_list
]
]
],
"haschild" => 1,
"level" => 1
];
array_unshift($list,$all);
$this->success(__('成功'),compact('list'));
... ... @@ -102,4 +104,22 @@ class Category extends Api
$list = \app\common\model\Goods::getList($where,$page,$rows);
$this->success(__('成功'),compact('list'));
}
// 判断等级和是否有下级
public function getTreeList($data = [], $level = 1)
{
$arr = [];
$n = 0;
foreach ($data as $k => $v) {
$childlist = isset($v['childlist']) ? $v['childlist'] : [];
$v['haschild'] = $childlist ? 1 : 0;
$v['level'] = $v['pid'] == 0 ? 1 : $level+1;
$arr[$n] = $v;
if ($childlist) {
$arr[$n]['childlist'] = $this->getTreeList($childlist, $v['level']);
}
$n++;
}
return $arr;
}
}
... ...
... ... @@ -397,7 +397,9 @@ class Order extends Model
{
$list = $this->getList($user_id,'payment');
foreach($list as $v){
$v->cancel();
if($v['createtime'] < time()-86400){
$v->cancel();
}
}
return true;
}
... ...