diff --git a/app/controller/api/Consumer.php b/app/controller/api/Consumer.php index e75c7c2..73fb581 100644 --- a/app/controller/api/Consumer.php +++ b/app/controller/api/Consumer.php @@ -232,7 +232,7 @@ class Consumer extends Base throw new ValidateException('用户无效!'); } $data = AccountRepository::getInstance()->getBusinessFlowList($account->user_code,$page,$size,$keyword); - $data->each(function ($item){ + $data["list"]->each(function ($item){ $item->businessCover = $this->request->domain() . $item->background; }); return $this->json(0,"success",$data); diff --git a/app/traits/account/BusinessFlowTrait.php b/app/traits/account/BusinessFlowTrait.php index 80d3426..c3a4458 100644 --- a/app/traits/account/BusinessFlowTrait.php +++ b/app/traits/account/BusinessFlowTrait.php @@ -3,6 +3,7 @@ namespace app\traits\account; use app\model\BusinessFlow; +use think\Collection; trait BusinessFlowTrait { @@ -16,9 +17,15 @@ trait BusinessFlowTrait */ public function getBusinessFlowList($accountCode, $page, $size,$keyword=null) { - return BusinessFlow::alias("a") - ->join("business b","a.business_code = b.code") - ->where("a.user_code",$accountCode) + $data = [ + 'total' => 0, + 'current' => $page, + 'size' => $size, + 'list' => new Collection(), + ]; + $model = BusinessFlow::alias("a") + ->join("business b", "a.business_code = b.code") + ->where("a.user_code", $accountCode) ->when(!empty($keyword), function ($q) use ($keyword) { $q->where("b.business_name", "like", "%{$keyword}%"); }) @@ -29,10 +36,13 @@ trait BusinessFlowTrait "b.background", "a.create_time as createTime", "a.user_code as userCode", - ]) - ->page($page,$size) + ]); + $data["total"] = $model->count(); + $data["list"] = $model + ->page($page, $size) ->order("a.id desc") ->select(); + return $data; } /**