2 changed files with 56 additions and 0 deletions
@ -0,0 +1,55 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\controller\admin; |
||||
|
|
||||
|
use app\model\WechatPucode; |
||||
|
use think\Response; |
||||
|
use app\model\InvoiceHead as InvoiceHeadModel; |
||||
|
use app\model\WechatUser as WechatUserModel; |
||||
|
|
||||
|
class InvoiceHead extends Base |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* 获取发票申请列表 |
||||
|
* @return Response |
||||
|
* @throws \think\db\exception\DbException |
||||
|
*/ |
||||
|
public function index(): Response |
||||
|
{ |
||||
|
|
||||
|
$param = $this->request->get(); |
||||
|
$limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); |
||||
|
$start = $this->request->get('page', 1); |
||||
|
|
||||
|
$where = []; |
||||
|
|
||||
|
if (isset($param['pucode']) && !empty($param['pucode'])) { |
||||
|
$wechat_user_ids = WechatPucode::where('pucode', $param['pucode'])->column('wechat_user_id'); |
||||
|
$where[] = ['wechat_user_id', 'in', $wechat_user_ids]; |
||||
|
} |
||||
|
|
||||
|
$InvoiceHead = new InvoiceHeadModel(); |
||||
|
|
||||
|
$listObj = $InvoiceHead->where($where) |
||||
|
->order('create_time', 'DESC') |
||||
|
->paginate(['page' => $start, 'list_rows' => $limit]) |
||||
|
->each(function ($item, $key) use ($InvoiceHead) { |
||||
|
$item['type'] = InvoiceHeadModel::$typeArr[$item['type']]; |
||||
|
$WechatUser = WechatUserModel::where('id', $item['wechat_user_id'])->find(); |
||||
|
if ($WechatUser) { |
||||
|
$item['wechat_user_name'] = $WechatUser['nickname']; |
||||
|
$item['headimgurl'] = $WechatUser['headimgurl']; |
||||
|
} |
||||
|
$item['pucode'] = WechatPucode::where('wechat_user_id', $item['wechat_user_id'])->value('pucode'); |
||||
|
unset($item['wechat_user_id']); |
||||
|
})->toArray(); |
||||
|
$listInfo = $listObj['data']; |
||||
|
|
||||
|
return $this->buildSuccess([ |
||||
|
'list' => $listInfo, |
||||
|
'count' => $listObj['total'] |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue