You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
55 lines
2.0 KiB
<?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', 'like', "%{$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']
|
|
]);
|
|
}
|
|
|
|
}
|