mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-14 23:08:35 +08:00
发积分幂等性校验
This commit is contained in:
@@ -54,4 +54,9 @@ public interface MemberPointsRecordMapper {
|
|||||||
* 根据主键删除
|
* 根据主键删除
|
||||||
*/
|
*/
|
||||||
int deleteByPrimaryKey(Long id);
|
int deleteByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号和类型统计记录数(用于幂等性校验)
|
||||||
|
*/
|
||||||
|
int countByOrderCodeAndType(@Param("orderCode") String orderCode, @Param("type") Integer type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,15 @@ public class MemberPointsInfoServiceImpl implements MemberPointsInfoService {
|
|||||||
throw new BusinessException(ReturnCodeEnum.valueOf("参数错误"));
|
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);
|
MemberPointsInfo pointsInfo = memberPointsInfoMapper.selectByMemberId(memberId);
|
||||||
if (pointsInfo == null) {
|
if (pointsInfo == null) {
|
||||||
|
|||||||
@@ -150,4 +150,11 @@
|
|||||||
from member_points_record
|
from member_points_record
|
||||||
where id = #{id,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</delete>
|
</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>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user