feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
这个提交包含在:
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 资金流水台账
|
||||
*
|
||||
* 不可篡改的财务审计总账,支持按账户主体与变动类型溯源对账
|
||||
*
|
||||
* @icon fa fa-exchange
|
||||
*/
|
||||
class WalletLog extends Backend
|
||||
{
|
||||
/**
|
||||
* @var \app\admin\model\WalletLog
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $searchFields = 'id,remark';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\WalletLog;
|
||||
$this->view->assign('userTypeList', $this->model->getUserTypeList());
|
||||
$this->view->assign('typeList', $this->model->getTypeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 流水总账列表(批量解析师傅/用户姓名手机及关联订单号,并计算汇总指标)
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
$totalIncome = round((float)Db::name('wallet_log')->where('amount', '>', 0)->sum('amount'), 2);
|
||||
$totalOutflow = round(abs((float)Db::name('wallet_log')->where('amount', '<', 0)->sum('amount')), 2);
|
||||
$this->view->assign([
|
||||
'totalIncome' => $totalIncome,
|
||||
'totalOutflow' => $totalOutflow,
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$rows = $list->items();
|
||||
$masterIds = [];
|
||||
$userIds = [];
|
||||
$orderIds = [];
|
||||
foreach ($rows as $r) {
|
||||
if ($r['user_type'] === 'master' && (int)$r['user_id'] > 0) {
|
||||
$masterIds[] = (int)$r['user_id'];
|
||||
} elseif ($r['user_type'] === 'user' && (int)$r['user_id'] > 0) {
|
||||
$userIds[] = (int)$r['user_id'];
|
||||
}
|
||||
if ((int)$r['order_id'] > 0) {
|
||||
$orderIds[] = (int)$r['order_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$masterMap = $masterIds
|
||||
? Db::name('master')->where('id', 'in', array_unique($masterIds))->column('id,realname,mobile', 'id')
|
||||
: [];
|
||||
$userMap = $userIds
|
||||
? Db::name('user')->where('id', 'in', array_unique($userIds))->column('id,nickname,username,mobile', 'id')
|
||||
: [];
|
||||
$orderMap = $orderIds
|
||||
? Db::name('order')->where('id', 'in', array_unique($orderIds))->column('id,order_no,service_name', 'id')
|
||||
: [];
|
||||
|
||||
foreach ($rows as &$item) {
|
||||
$uid = (int)$item['user_id'];
|
||||
if ($item['user_type'] === 'master') {
|
||||
$m = $masterMap[$uid] ?? null;
|
||||
$item['account_name'] = $m ? ($m['realname'] ?: ('师傅#' . $uid)) : ('师傅#' . $uid);
|
||||
$item['account_mobile'] = $m['mobile'] ?? '';
|
||||
} else {
|
||||
$u = $userMap[$uid] ?? null;
|
||||
$item['account_name'] = $u ? ($u['nickname'] ?: ($u['username'] ?: ('用户#' . $uid))) : ('用户#' . $uid);
|
||||
$item['account_mobile'] = $u['mobile'] ?? '';
|
||||
}
|
||||
$oid = (int)$item['order_id'];
|
||||
$ord = $oid > 0 ? ($orderMap[$oid] ?? null) : null;
|
||||
$item['order_no'] = $ord['order_no'] ?? '';
|
||||
$item['service_name'] = $ord['service_name'] ?? '';
|
||||
}
|
||||
unset($item);
|
||||
|
||||
return json(['total' => $list->total(), 'rows' => $rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 资金流水溯源详情
|
||||
*/
|
||||
public function detail($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$owner = [];
|
||||
if ($row['user_type'] === 'master' && (int)$row['user_id'] > 0) {
|
||||
$m = Db::name('master')->where('id', (int)$row['user_id'])->find();
|
||||
if ($m) {
|
||||
$owner = [
|
||||
'role' => '认证师傅',
|
||||
'name' => $m['realname'],
|
||||
'mobile' => $m['mobile'],
|
||||
'money' => $m['money'],
|
||||
'frozen' => $m['frozen_money'],
|
||||
];
|
||||
}
|
||||
} elseif ((int)$row['user_id'] > 0) {
|
||||
$u = Db::name('user')->where('id', (int)$row['user_id'])->find();
|
||||
if ($u) {
|
||||
$owner = [
|
||||
'role' => '平台注册用户',
|
||||
'name' => $u['nickname'] ?: $u['username'],
|
||||
'mobile' => $u['mobile'],
|
||||
'money' => $u['money'],
|
||||
'frozen' => '0.00',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$order = (int)$row['order_id'] > 0 ? Db::name('order')->where('id', (int)$row['order_id'])->find() : null;
|
||||
$settle = (int)$row['order_id'] > 0 ? Db::name('settle')->where('order_id', (int)$row['order_id'])->find() : null;
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'owner' => $owner,
|
||||
'order' => $order ?: [],
|
||||
'settle' => $settle ?: [],
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$this->error('财务资金流水由业务交易自动记账,禁止手工新增');
|
||||
}
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$this->error('财务资金流水属于不可篡改审计凭证,禁止编辑');
|
||||
}
|
||||
|
||||
public function del($ids = null)
|
||||
{
|
||||
$this->error('财务资金流水属于不可篡改审计凭证,禁止删除');
|
||||
}
|
||||
|
||||
public function multi($ids = null)
|
||||
{
|
||||
$this->error('财务资金流水禁止批量修改');
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户