Merge branch 'dev' into feature-integrated_with_JCPP

This commit is contained in:
Guoqs
2026-01-08 13:24:40 +08:00
5 changed files with 63 additions and 21 deletions

View File

@@ -54,4 +54,9 @@ public interface MemberPointsRecordMapper {
* 根据主键删除
*/
int deleteByPrimaryKey(Long id);
/**
* 根据订单号和类型统计记录数(用于幂等性校验)
*/
int countByOrderCodeAndType(@Param("orderCode") String orderCode, @Param("type") Integer type);
}

View File

@@ -63,6 +63,15 @@ public class MemberPointsInfoServiceImpl implements MemberPointsInfoService {
throw new BusinessException(ReturnCodeEnum.valueOf("参数错误"));
}
// 幂等性校验:检查该订单是否已发放过充电奖励积分
if (StringUtils.isNotBlank(orderCode)) {
int count = memberPointsRecordMapper.countByOrderCodeAndType(orderCode, POINTS_TYPE_CHARGE_REWARD);
if (count > 0) {
logger.warn("积分已发放跳过重复发放memberId: {}, orderCode: {}", memberId, orderCode);
return true;
}
}
// 检查积分账户是否存在,不存在则初始化
MemberPointsInfo pointsInfo = memberPointsInfoMapper.selectByMemberId(memberId);
if (pointsInfo == null) {

View File

@@ -150,4 +150,11 @@
from member_points_record
where id = #{id,jdbcType=BIGINT}
</delete>
<select id="countByOrderCodeAndType" resultType="int">
select count(1)
from member_points_record
where order_code = #{orderCode,jdbcType=VARCHAR}
and type = #{type,jdbcType=TINYINT}
</select>
</mapper>