feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
这个提交包含在:
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 业主晒单治理
|
||||
*
|
||||
* 管理小程序首页及晒单广场公开展示的完工实拍内容
|
||||
*
|
||||
* @icon fa fa-camera
|
||||
*/
|
||||
class Showcase extends Backend
|
||||
{
|
||||
/**
|
||||
* @var \app\admin\model\Showcase
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $relationSearch = true;
|
||||
protected $searchFields = 'id,user_name,service_name,region,content,master_name,order.order_no';
|
||||
protected $multiFields = 'status';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Showcase;
|
||||
$this->view->assign('statusList', $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 晒单列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with(['order', 'user', 'service'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$items = $list->items();
|
||||
foreach ($items as &$item) {
|
||||
if (!empty($item['images'])) {
|
||||
$item['images'] = implode(',', $this->parseTags($item['images']));
|
||||
}
|
||||
}
|
||||
unset($item);
|
||||
|
||||
return json(['total' => $list->total(), 'rows' => $items]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 晒单详情(关联源头工单与实拍组图)
|
||||
*/
|
||||
public function detail($ids = null)
|
||||
{
|
||||
$row = $this->model->with(['order', 'user', 'service'])->where('showcase.id', (int)$ids)->find();
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$images = $this->parseTags($row['images']);
|
||||
$tags = $this->parseTags($row['tags']);
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'images' => $images,
|
||||
'tags' => $tags,
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 晒单展示状态与封面治理
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->with(['order', 'user', 'service'])->where('showcase.id', (int)$ids)->find();
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$images = $this->parseTags($row['images']);
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'images' => $images,
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
$params = $this->request->post('row/a', []);
|
||||
$status = in_array($params['status'] ?? '', ['normal', 'hidden'], true) ? $params['status'] : $row['status'];
|
||||
$coverImage = trim((string)($params['cover_image'] ?? $row['cover_image']));
|
||||
|
||||
Db::name('showcase')->where('id', (int)$row['id'])->update([
|
||||
'status' => $status,
|
||||
'cover_image' => mb_substr($coverImage, 0, 255),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止后台伪造虚拟晒单
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->error('业主晒单仅由真实完工订单评价同步生成,后台不可手工伪造');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除违规晒单并同步复位源头工单晒单标记
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ids = $ids ?: $this->request->post('ids');
|
||||
$idArr = array_values(array_filter(array_map('intval', explode(',', (string)$ids))));
|
||||
if (!$idArr) {
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
$rows = Db::name('showcase')->where('id', 'in', $idArr)->field('id,order_id')->select();
|
||||
if (!$rows) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$orderIds = array_values(array_unique(array_filter(array_map('intval', array_column($rows, 'order_id')))));
|
||||
Db::name('showcase')->where('id', 'in', $idArr)->delete();
|
||||
if ($orderIds) {
|
||||
Db::name('order')->where('id', 'in', $orderIds)->update([
|
||||
'is_showcase' => 0,
|
||||
'showcase_time' => null,
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
protected function parseTags($raw)
|
||||
{
|
||||
$raw = trim((string)$raw);
|
||||
if ($raw === '') {
|
||||
return [];
|
||||
}
|
||||
if ($raw[0] === '[') {
|
||||
$arr = json_decode($raw, true);
|
||||
if (is_array($arr)) {
|
||||
return array_values(array_filter(array_map('trim', $arr)));
|
||||
}
|
||||
}
|
||||
return array_values(array_filter(array_map('trim', explode(',', $raw))));
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户