- 升级系统版本至1.0.100 - 新增订单详情页物流、资质等信息展示 - 优化师傅报价页收益计算与显示 - 新增企业资质管理模块 - 优化后台标签页管理与交互 - 修复标签解析与地址脱敏问题 - 优化预约时段选择逻辑 - 调整服务类型配置界面布局
174 行
5.4 KiB
PHP
174 行
5.4 KiB
PHP
<?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(html_entity_decode((string)$raw, ENT_QUOTES, 'UTF-8'));
|
||
if ($raw === '') {
|
||
return [];
|
||
}
|
||
if ($raw[0] === '[') {
|
||
$arr = json_decode($raw, true);
|
||
if (is_array($arr)) {
|
||
return array_values(array_filter(array_map('trim', $arr)));
|
||
}
|
||
// 兼容非标准 JSON(如空格分隔未加逗号)
|
||
if (preg_match_all('/"([^"]+)"/', $raw, $m) && !empty($m[1])) {
|
||
return array_values(array_filter(array_map('trim', $m[1])));
|
||
}
|
||
}
|
||
return array_values(array_filter(array_map('trim', explode(',', $raw))));
|
||
}
|
||
}
|