客户月结报告;
This commit is contained in:
+59
@@ -147,6 +147,65 @@ public class BillManageApplicationService {
|
|||||||
return billManagePOS;
|
return billManagePOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||||
|
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||||
|
Long frontendOrganizationId = billManageDO.getOrganizationId(); // 前端传递的 organizationId
|
||||||
|
|
||||||
|
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||||
|
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||||
|
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||||
|
if (frontendOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||||
|
billManageDO.setOrganizationId(frontendOrganizationId);
|
||||||
|
billManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||||
|
billManageDO.setOrganizationId(null);
|
||||||
|
billManageDO.setTopOrganizationId(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||||
|
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||||
|
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||||
|
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||||
|
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||||
|
billManageDO.setOrganizationId(userOrganizationId);
|
||||||
|
}
|
||||||
|
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||||
|
} else {
|
||||||
|
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||||
|
if (userOrganizationId != null) {
|
||||||
|
billManageDO.setOrganizationId(userOrganizationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||||
|
if (billManageDO.getOrganizationId() == null) {
|
||||||
|
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||||
|
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||||
|
billManageDO.setTopOrganizationId(topOrganizationId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 对于非2827组织,必须设置 topOrganizationId=2827
|
||||||
|
billManageDO.setTopOrganizationId(2827L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<BillManagePO> billManagePOS = billManageDomainService.customerMonthlyReport(billManageDO);
|
||||||
|
for (BillManagePO billManagePO : billManagePOS) {
|
||||||
|
String billNumber = billManagePO.getBillNumber(); // 获取账单编号
|
||||||
|
// 原有 - 前端列表用,不变
|
||||||
|
List<BillDetail> billDetails = billDetailMapper.selectList(new LambdaQueryWrapper<BillDetail>().eq(BillDetail::getBillNumber, billNumber));
|
||||||
|
billManagePO.setBillDetailList(billDetails);
|
||||||
|
// 新增 - 导出用,LEFT JOIN billing_statement 拿到费用科目
|
||||||
|
List<BillDetailPO> billDetailPOs = billDetailMapper.getDetailsByBillManageId(billManagePO.getBillManageId());
|
||||||
|
billManagePO.setBillDetailPOList(billDetailPOs);
|
||||||
|
}
|
||||||
|
return billManagePOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
|
|||||||
+3
@@ -21,6 +21,9 @@ public interface IBillManageService extends IService<BillManage>
|
|||||||
*/
|
*/
|
||||||
public List<BillManagePO> queryList(BillManageDO billManageDO);
|
public List<BillManagePO> queryList(BillManageDO billManageDO);
|
||||||
|
|
||||||
|
|
||||||
|
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户每月账单分组查询
|
* 客户每月账单分组查询
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
@@ -20,6 +20,8 @@ public interface BillManageMapper extends BaseMapper<BillManage>
|
|||||||
*/
|
*/
|
||||||
public List<BillManagePO> queryList(@Param("billManageDO") BillManageDO billManageDO);
|
public List<BillManagePO> queryList(@Param("billManageDO") BillManageDO billManageDO);
|
||||||
|
|
||||||
|
public List<BillManagePO> customerMonthlyReport(@Param("billManageDO") BillManageDO billManageDO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户每月账单分组查询
|
* 客户每月账单分组查询
|
||||||
*/
|
*/
|
||||||
|
|||||||
+8
@@ -127,6 +127,14 @@ public class BillManageImpl extends ServiceImpl<BillManageMapper, BillManage> im
|
|||||||
return billManageMapper.queryList(billManageDO);
|
return billManageMapper.queryList(billManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO)
|
||||||
|
{
|
||||||
|
return billManageMapper.customerMonthlyReport(billManageDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
@@ -88,6 +88,10 @@ public class BillManageDomainService {
|
|||||||
return billManageService.queryList(billManageDO);
|
return billManageService.queryList(billManageDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BillManagePO> customerMonthlyReport(BillManageDO billManageDO) {
|
||||||
|
return billManageService.customerMonthlyReport(billManageDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增账单管理
|
* 新增账单管理
|
||||||
|
|||||||
@@ -547,6 +547,21 @@ public class BillManageApi extends BaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户月结报表
|
||||||
|
*/
|
||||||
|
@ApiOperation("客户月结报表")
|
||||||
|
@GetMapping("/customerMonthlyReport")
|
||||||
|
public TableDataInfo customerMonthlyReport(BillManageDTO billManageDTO)
|
||||||
|
{
|
||||||
|
//转换实体
|
||||||
|
BillManageDO billManageDO = new BillManageDO();
|
||||||
|
BeanUtils.copyProperties(billManageDTO,billManageDO);
|
||||||
|
startPage();
|
||||||
|
billManageDO.setBillType(1);
|
||||||
|
List<BillManagePO> list = billManageApplicationService.customerMonthlyReport(billManageDO);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ORDER BY a.create_time DESC
|
ORDER BY a.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="customerMonthlyReport" parameterType="com.mhd.bms.domain.billManage.repository.todo.BillManageDO" resultType="com.mhd.bms.domain.billManage.repository.po.BillManagePO">
|
||||||
|
SELECT
|
||||||
|
a.*,
|
||||||
|
b.SETTLEMENT_ENTITY_ID AS "settlementEntityId",
|
||||||
|
(SELECT MAX(c.collection_time)
|
||||||
|
FROM receipt_detail rd
|
||||||
|
LEFT JOIN receipt_manage c ON rd.receipt_manage_id = c.receipt_manage_id
|
||||||
|
WHERE rd.bill_manage_id = a.bill_manage_id
|
||||||
|
AND rd.del_flag = 1
|
||||||
|
AND c.del_flag = 1) AS "collectionTime",
|
||||||
|
(SELECT LISTAGG(bs.CONTRACT_NUMBER, ',') WITHIN GROUP (ORDER BY bs.CONTRACT_NUMBER)
|
||||||
|
FROM BILLING_STATEMENT bs
|
||||||
|
WHERE bs.BILL_MANAGE_ID = a.bill_manage_id
|
||||||
|
AND bs.CONTRACT_NUMBER IS NOT NULL) AS "contractNumbers"
|
||||||
|
FROM bill_manage a
|
||||||
|
LEFT JOIN SETTLEMENT_CUSTOMERS b ON a.SETTLEMENT_CUSTOMERS_ID = b.SETTLEMENT_CUSTOMERS_ID
|
||||||
|
WHERE a.del_flag = 1
|
||||||
|
<include refid="common_where"/>
|
||||||
|
ORDER BY a.create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="queryCustomerMonthBillList" parameterType="com.mhd.bms.domain.billManage.repository.todo.BillManageDO" resultType="com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO">
|
<select id="queryCustomerMonthBillList" parameterType="com.mhd.bms.domain.billManage.repository.todo.BillManageDO" resultType="com.mhd.bms.interfaces.dto.billManage.CustomerMonthBillVO">
|
||||||
SELECT
|
SELECT
|
||||||
a.SETTLEMENT_CUSTOMERS_ID AS settlementCustomersId,
|
a.SETTLEMENT_CUSTOMERS_ID AS settlementCustomersId,
|
||||||
|
|||||||
Reference in New Issue
Block a user