feat余额统计

This commit is contained in:
dzc committed 2025-10-22 16:27:55 +08:00
1 parent dbee49727e
commit ff25e0e5cf
4 files changed
+66 -57

No files matched your search

@@ -461,6 +461,15 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
});
}
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
List<HardSpuEntity> supList = hardSpuService.getByIds(productIds);
for (HardCreateCarDto v : list) {
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
str.append(spu.getName()).append("x").append(v.getProductCount()).append(";");
});
}
}
return str.toString();
}
@@ -670,8 +670,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
String subject = hardCarService.computerCarSubject(dto.getHardType(), dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(dto.getUserId())
@@ -399,7 +399,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto();
walletDto.setDeptIds(deptIds);
walletDto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE);
// walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE);
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
walletDto.setCreateTimeList(dto.getCreateTimeList());
}
@@ -194,20 +194,50 @@
</select>
<select id="selectTotalBalance" resultType="java.lang.Long">
SELECT SUM(latest_balance.balance)
FROM (
SELECT DISTINCT a.user_id,
m.wallet_type_id,
FIRST_VALUE(a.balance) OVER (
PARTITION BY a.user_id, m.wallet_type_id
ORDER BY a.create_time DESC
) as balance
SELECT
SUM(a.balance)
FROM wallet_transaction a
INNER JOIN wallet_manage m
ON a.wallet_id = m.id
LEFT JOIN wallet_manage m on a.wallet_id = m.id
<where>
a.del_flag = '0'
AND DATE_FORMAT(a.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}
a.del_flag = 0
<if test="dto.walletRecordMonth != null">
AND a.create_time = (
SELECT MAX(sub.create_time)
FROM wallet_transaction sub
LEFT JOIN wallet_manage wallet on wallet.id = sub.wallet_id
WHERE sub.user_id = a.user_id
AND DATE_FORMAT(sub.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}
<if test="dto.userId != null">
AND sub.user_id = #{dto.userId}
</if>
<if test="dto.userIds != null and dto.userIds.size() != 0">
and sub.user_id in
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and wallet.dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and wallet.dept_id NOT IN
</when>
<otherwise>
and wallet.dept_id IN
</otherwise>
</choose>
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.walletTypeId != null">
AND wallet.wallet_type_id = #{dto.walletTypeId}
</if>
limit 1
)
</if>
<if test="dto.userId != null">
AND a.user_id = #{dto.userId}
</if>
@@ -237,52 +267,22 @@
</foreach>
</if>
</where>
) latest_balance
</select>
<!-- SELECT-->
<!-- SUM(a.balance)-->
<!-- SELECT SUM(latest_balance.balance)-->
<!-- FROM (-->
<!-- SELECT DISTINCT a.user_id,-->
<!-- m.wallet_type_id,-->
<!-- FIRST_VALUE(a.balance) OVER (-->
<!-- PARTITION BY a.user_id, m.wallet_type_id-->
<!-- ORDER BY a.create_time DESC-->
<!-- ) as balance-->
<!-- FROM wallet_transaction a-->
<!-- LEFT JOIN wallet_manage m on a.wallet_id = m.id-->
<!-- INNER JOIN wallet_manage m-->
<!-- ON a.wallet_id = m.id-->
<!-- <where>-->
<!-- a.del_flag = 0-->
<!-- <if test="dto.walletRecordMonth != null">-->
<!-- AND a.create_time = (-->
<!-- SELECT MAX(sub.create_time)-->
<!-- FROM wallet_transaction sub-->
<!-- LEFT JOIN wallet_manage wallet on wallet.id = sub.wallet_id-->
<!-- WHERE sub.user_id = a.user_id-->
<!-- AND DATE_FORMAT(sub.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}-->
<!-- <if test="dto.userId != null">-->
<!-- AND sub.user_id = #{dto.userId}-->
<!-- </if>-->
<!-- <if test="dto.userIds != null and dto.userIds.size() != 0">-->
<!-- and sub.user_id in-->
<!-- <foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">-->
<!-- #{v}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="dto.deptIds != null and dto.deptIds.size() != 0">-->
<!-- <choose>-->
<!-- <when test="dto.isInclude != null and dto.isInclude == true">-->
<!-- and wallet.dept_id IN-->
<!-- </when>-->
<!-- <when test="dto.isInclude != null and dto.isInclude == false">-->
<!-- and wallet.dept_id NOT IN-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- and wallet.dept_id IN-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- <foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">-->
<!-- #{v}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="dto.walletTypeId != null">-->
<!-- AND wallet.wallet_type_id = #{dto.walletTypeId}-->
<!-- </if>-->
<!-- )-->
<!-- </if>-->
<!-- a.del_flag = '0'-->
<!-- AND DATE_FORMAT(a.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}-->
<!-- <if test="dto.userId != null">-->
<!-- AND a.user_id = #{dto.userId}-->
<!-- </if>-->
@@ -312,4 +312,5 @@
<!-- </foreach>-->
<!-- </if>-->
<!-- </where>-->
<!-- ) latest_balance-->
</mapper>