wang hou sheng 7 months ago
parent f01afc88dd
commit 71c430d639
  1. 3
      app/store/controller/user/Identity.php
  2. 35
      app/store/controller/user/Invoice.php
  3. 27
      app/store/model/user/UserInvoice.php

@ -1,9 +1,10 @@
<?php <?php
declare (strict_types=1);
namespace app\store\controller\user; namespace app\store\controller\user;
use app\admin\controller\Controller;
use app\common\enum\user\IdentityEnum; use app\common\enum\user\IdentityEnum;
use app\store\controller\Controller;
use app\store\model\user\Identity as IdentityModel; use app\store\model\user\Identity as IdentityModel;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;

@ -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…
Cancel
Save