no commit message
This commit is contained in:
@@ -59,7 +59,9 @@ class Base extends Controller {
|
||||
*/
|
||||
public function isAdmin()
|
||||
{
|
||||
return in_array("Biz_system_admin", $this->userInfo['roleCode']);
|
||||
return in_array("Biz_system_admin", $this->userInfo['roleCode']) ||
|
||||
in_array("admin", $this->userInfo['roleCode']) ||
|
||||
in_array("COM_TOP_ADMIN", $this->userInfo['roleCode']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,6 +95,7 @@ class Estimate extends Base
|
||||
// }
|
||||
$where[] = ['i.is_simple', '=', 0];
|
||||
$where[] = ['i.estimate_status', '=', $estimate_status];
|
||||
$where[] = ['i.status', 'in', [9, 10, 11, 12]];
|
||||
$start_time && $where[] = ['i.create_time', '>=', $start_time . " 00:00:00"];
|
||||
$end_time && $where[] = ['i.create_time', '<=', $end_time . " 23:59:59"];
|
||||
$is_multiple && $where[] = ['i.is_multiple', '=', $is_multiple];
|
||||
@@ -540,6 +541,10 @@ class Estimate extends Base
|
||||
if (!$in_upd) {
|
||||
return $this->buildFailed('操作失败!');
|
||||
}
|
||||
|
||||
// 推送预估数量更新给所有客户端
|
||||
fetchAndPushEstimatePendingCount();
|
||||
|
||||
return $this->buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,56 @@ class Pending extends Base
|
||||
return $this->buildSuccess(['count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告制作数量(status=9)
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function getReportPendingCount()
|
||||
{
|
||||
$Inquiry = new Inquiry();
|
||||
|
||||
// 查询 status = 9 的数量
|
||||
$count = $Inquiry->where('status', 9)->count();
|
||||
|
||||
return $this->buildSuccess(['count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有预估状态数量
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function getEstimatePendingCount()
|
||||
{
|
||||
$Inquiry = new Inquiry();
|
||||
|
||||
// 待制作:status=9
|
||||
$pendingCount = $Inquiry->where('status', 9)->count();
|
||||
|
||||
// 二审待制作:status=10 且 estimate_status=2
|
||||
$secondReviewCount = $Inquiry->where('status', 10)
|
||||
->where('estimate_status', '=', '2', false)
|
||||
->count();
|
||||
|
||||
// 三审待制作:status=10 且 estimate_status=3
|
||||
$thirdReviewCount = $Inquiry->where('status', 10)
|
||||
->where('estimate_status', '=', '3', false)
|
||||
->count();
|
||||
|
||||
// 待签章:status=11
|
||||
$signCount = $Inquiry->where('status', 11)->count();
|
||||
|
||||
// 总和
|
||||
$total = $pendingCount + $secondReviewCount + $thirdReviewCount + $signCount;
|
||||
|
||||
return $this->buildSuccess([
|
||||
'pending' => $pendingCount,
|
||||
'secondReview' => $secondReviewCount,
|
||||
'thirdReview' => $thirdReviewCount,
|
||||
'sign' => $signCount,
|
||||
'total' => $total
|
||||
]);
|
||||
}
|
||||
|
||||
//询价编号前缀 - 住宅
|
||||
const INQUERY_NUMBER_RESIDENCE_PREFIX = "GZ01";
|
||||
|
||||
@@ -3687,6 +3737,9 @@ class Pending extends Base
|
||||
return $this->buildFailed("确认回价失败");
|
||||
}
|
||||
|
||||
// 推送预估数量更新到前端
|
||||
fetchAndPushEstimatePendingCount();
|
||||
|
||||
return $this->buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,15 @@ class Property_cert_info extends Base
|
||||
if ($result['code'] == -1) {
|
||||
return $this->buildFailed($result['msg']);
|
||||
}
|
||||
|
||||
// 发起查勘成功后,推送查勘跟进中数量更新
|
||||
error_log("=== reqApplySurvey 推送调试 ===");
|
||||
error_log("用户ID: " . $this->userInfo['user_id']);
|
||||
error_log("是否管理员: " . ($this->isAdmin() ? 'true' : 'false'));
|
||||
|
||||
$pushResult = fetchAndPushSurveyFollowCount($this->userInfo['user_id'], $this->isAdmin());
|
||||
error_log("推送结果: " . ($pushResult ? '成功' : '失败'));
|
||||
|
||||
return $this->buildSuccess('发起查勘成功');
|
||||
|
||||
}
|
||||
|
||||
@@ -2848,6 +2848,55 @@ EOF;
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告制作数量统计
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getReportProduceCount() {
|
||||
$pendingCount = Db::name('report')
|
||||
->alias('r')
|
||||
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||
->where('r.report_source', 1)
|
||||
->where('r.status', 1)
|
||||
->where('r.create_time', 'gt', '2025-02-01 00:00:00');
|
||||
$pending = $pendingCount->count();
|
||||
|
||||
// 二审待制作:以 pg_report 为主表,review_status=1 且 status=2,关联 pg_inquiry
|
||||
$secondReviewCount = Db::name('report')
|
||||
->alias('r')
|
||||
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||
->where('r.report_source', 1)
|
||||
->where('r.review_status', 1)
|
||||
->where('r.status', 2)
|
||||
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||
->where('i.status', 7)
|
||||
->group('r.quot_id');
|
||||
|
||||
$secondReview = $secondReviewCount->count();
|
||||
|
||||
// 三审待制作:以 pg_report 为主表,review_status=2 且 review2_status=1 且 status=2,关联 pg_inquiry
|
||||
$thirdReviewCount = Db::name('report')
|
||||
->alias('r')
|
||||
->join('inquiry i', 'r.quot_id = i.id', 'LEFT')
|
||||
->where('r.report_source', 1)
|
||||
->where('r.review_status', 2)
|
||||
->where('r.review2_status', 1)
|
||||
->where('r.create_time', 'gt', '2025-02-01 00:00:00')
|
||||
->where('r.status', 2);
|
||||
|
||||
$thirdReview = $thirdReviewCount->count();
|
||||
|
||||
// 计算总数
|
||||
$total = $pending + $secondReview + $thirdReview;
|
||||
|
||||
return $this->buildSuccess([
|
||||
'pending' => $pending,
|
||||
'secondReview' => $secondReview,
|
||||
'thirdReview' => $thirdReview,
|
||||
'total' => $total
|
||||
]);
|
||||
}
|
||||
|
||||
public function cancelAntiCounterfeitCode()
|
||||
{
|
||||
$reportid = $this->request->post("reportid");
|
||||
|
||||
@@ -561,9 +561,29 @@ class Survey extends Base
|
||||
if (is_array($list)) {
|
||||
$refer = array();
|
||||
foreach ($list as $key => $data) {
|
||||
// 跳过空数据或非数组数据
|
||||
if (!is_array($data) || empty($data)) {
|
||||
continue;
|
||||
}
|
||||
// 确保主键字段存在
|
||||
if (!isset($data[$pk])) {
|
||||
continue;
|
||||
}
|
||||
$refer[$data[$pk]] = &$list[$key];
|
||||
}
|
||||
foreach ($list as $key => $data) {
|
||||
// 跳过空数据或非数组数据
|
||||
if (!is_array($data) || empty($data)) {
|
||||
continue;
|
||||
}
|
||||
// 确保父ID字段存在
|
||||
if (!isset($data[$pid])) {
|
||||
continue;
|
||||
}
|
||||
// 确保code字段存在
|
||||
if (!isset($data['code'])) {
|
||||
continue;
|
||||
}
|
||||
$parentId = $data[$pid];
|
||||
if ($root == $parentId) {
|
||||
$tree[$data['code']] = &$list[$key];
|
||||
@@ -759,4 +779,53 @@ class Survey extends Base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查勘跟进中数量(当前登录人)
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function surveyFollowCount()
|
||||
{
|
||||
// 检查用户信息
|
||||
if (empty($this->userInfo)) {
|
||||
error_log("surveyFollowCount: userInfo is empty");
|
||||
return $this->buildFailed('用户信息不存在');
|
||||
}
|
||||
|
||||
// 检查用户ID
|
||||
if (!isset($this->userInfo['user_id'])) {
|
||||
error_log("surveyFollowCount: user_id is not set");
|
||||
return $this->buildFailed('用户ID不存在');
|
||||
}
|
||||
|
||||
$Survey = new SurveyModel();
|
||||
|
||||
// 如果是管理员(admin 或 COM_TOP_ADMIN),不限制 user_id
|
||||
if ($this->isAdmin()) {
|
||||
$count = $Survey->alias('s')
|
||||
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||
->where('i.status', 4)
|
||||
->where('s.status', 2)
|
||||
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||
->group('s.id')
|
||||
->count();
|
||||
} else {
|
||||
// 非管理员,只统计当前用户的查勘
|
||||
$userId = $this->userInfo['user_id'];
|
||||
$count = $Survey->alias('s')
|
||||
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
|
||||
->where('i.status', 4)
|
||||
->where('s.status', 2)
|
||||
->where('s.user_id', $userId)
|
||||
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
|
||||
->group('s.id')
|
||||
->count();
|
||||
}
|
||||
|
||||
error_log("surveyFollowCount: count = $count, userId = " . $this->userInfo['user_id'] . ", isAdmin = " . ($this->isAdmin() ? 'true' : 'false'));
|
||||
|
||||
return $this->buildSuccess([
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class SurveyService extends CommonService
|
||||
}
|
||||
|
||||
//更新订单状态:查勘待派单
|
||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => date('Y-m-d H:i:s')])) {
|
||||
Db::rollback();
|
||||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class SurveyService extends CommonService
|
||||
}
|
||||
|
||||
//更新订单状态:查勘待派单
|
||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => new \DateTime])) {
|
||||
if (!Db::name('inquiry')->where(['order_no' => $data['order_no']])->update(['status'=>4, 'update_time' => date('Y-m-d H:i:s')])) {
|
||||
Db::rollback();
|
||||
return ['code'=>-1, 'msg'=>'更新订单状态失败'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user