fix: 分润,讨论后,发现问题统一修复。

This commit is contained in:
tianyongbao
2026-06-03 23:17:10 +08:00
parent fce70f98fc
commit 1e73d7e8ee
6 changed files with 97 additions and 30 deletions

View File

@@ -91,6 +91,16 @@ public class BasicProfitSharingRecordServiceImpl extends ServiceImpl<BasicProfit
}
// 兼容前端params[beginTime]/params[endTime]传参方式
Map<String, Object> params = basicProfitSharingRecord.getParams();
String scopeType = (String) params.get("scopeType");
Long scopeDeptId = (Long) params.get("scopeDeptId");
if (StringUtils.isNotNull(scopeDeptId)) {
if ("deptAndChild".equals(scopeType)) {
queryWrapper.inSql(BasicProfitSharingRecord::getDeptId,
"SELECT dept_id FROM sys_dept WHERE dept_id = " + scopeDeptId + " OR find_in_set(" + scopeDeptId + ", ancestors)");
} else if ("dept".equals(scopeType)) {
queryWrapper.eq(BasicProfitSharingRecord::getDeptId, scopeDeptId);
}
}
String beginTime = (String) params.get("beginTime");
String endTime = (String) params.get("endTime");
if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {

View File

@@ -21,22 +21,28 @@
<select id="selectInfoByHour" resultType="com.limap.core.basic.domain.AquPayDevice">
select id, user_id, pay_amount, pay_type, create_time as "createdTime",
device_type, serial_num, order_id, profit_status
from aqu_pay_device
where create_time &gt;= now() - interval '${hour} hour'
AND create_time &lt;= now() - interval '1 hour'
AND (profit_status IS NULL OR profit_status = 0)
AND pay_type = 1
select apd.id, apd.user_id, apd.pay_amount, apd.pay_type, apd.create_time as "createdTime",
apd.device_type, apd.serial_num, apd.order_id, apd.profit_status
from aqu_pay_device apd
inner join aqu_pay_order apo on apo.id = apd.order_id
where apd.create_time &gt;= now() - interval '${hour} hour'
AND apd.create_time &lt;= now() - interval '1 hour'
AND (apd.profit_status IS NULL OR apd.profit_status = 0)
AND apd.pay_type = 1
AND apd.pay_amount &gt; 0
AND apo.order_status = 2
</select>
<!-- 补录用: 查询指定时间范围内所有订单(忽略profit_status) -->
<!-- 补录用: 查询指定时间范围内支付成功订单(忽略profit_status) -->
<select id="selectInfoForBackfill" resultType="com.limap.core.basic.domain.AquPayDevice">
select id, user_id, pay_amount, pay_type, create_time as "createdTime",
device_type, serial_num, order_id, profit_status
from aqu_pay_device
where create_time &gt;= now() - interval '${hour} hour'
AND create_time &lt;= now() - interval '1 hour'
AND pay_type = 1
select apd.id, apd.user_id, apd.pay_amount, apd.pay_type, apd.create_time as "createdTime",
apd.device_type, apd.serial_num, apd.order_id, apd.profit_status
from aqu_pay_device apd
inner join aqu_pay_order apo on apo.id = apd.order_id
where apd.create_time &gt;= now() - interval '${hour} hour'
AND apd.create_time &lt;= now() - interval '1 hour'
AND apd.pay_type = 1
AND apd.pay_amount &gt; 0
AND apo.order_status = 2
</select>
</mapper>

View File

@@ -27,7 +27,10 @@
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="deptId != null">
<if test="deptId != null and params.scopeType == 'dept'">
and dept_id = #{deptId}
</if>
<if test="deptId != null and (params.scopeType == null or params.scopeType == 'deptAndChild')">
and dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId} or find_in_set( #{deptId} , ancestors ))
</if>
</where>

View File

@@ -21,7 +21,6 @@
FROM basic_profit_sharing_user bpsu
LEFT JOIN sys_user su ON bpsu.user_id = su.user_id
LEFT JOIN basic_user_bind_info bibi ON bpsu.user_id = bibi.user_id
WHERE bibi.device_name IS NOT NULL
</select>
<!-- 查询缓存用的分润用户列表 -->