es
parent
f01afc88dd
commit
71c430d639
@ -0,0 +1,35 @@ |
||||
<?php |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\store\controller\user; |
||||
|
||||
use app\store\controller\Controller; |
||||
use app\store\model\user\UserInvoice; |
||||
use think\db\exception\DbException; |
||||
use think\response\Json; |
||||
|
||||
class Invoice extends Controller |
||||
{ |
||||
/** |
||||
* @notes:发票列表 |
||||
* @return Json |
||||
* @throws DbException |
||||
* @author: wanghousheng |
||||
*/ |
||||
public function index(): Json |
||||
{ |
||||
$where = []; |
||||
$type = intval($this->request->post('type', 0)); |
||||
if ($type) { |
||||
$where['type'] = $type; |
||||
} |
||||
$source = intval($this->request->post('source', 0)); |
||||
if ($source) { |
||||
$where['source'] = $source; |
||||
} |
||||
$list = (new UserInvoice)->getList($where); |
||||
$data['list'] = $list->items(); |
||||
$data['total'] = $list->total(); |
||||
return $this->renderSuccess($data); |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\store\model\user; |
||||
|
||||
use app\common\model\user\UserInvoice as UserInvoiceModel; |
||||
use think\db\exception\DbException; |
||||
use think\Paginator; |
||||
|
||||
class UserInvoice extends UserInvoiceModel |
||||
{ |
||||
/** |
||||
* @notes:获取列表 |
||||
* @param array $where |
||||
* @param int $listRows |
||||
* @return Paginator |
||||
* @throws DbException |
||||
* @author: wanghousheng |
||||
*/ |
||||
public function getList(array $where = [], int $listRows = 10): Paginator |
||||
{ |
||||
return $this->with(['user.avatar']) |
||||
->where($where) |
||||
->order($this->getPk(), 'desc') |
||||
->paginate($listRows); |
||||
} |
||||
} |
Loading…
Reference in new issue