|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.cyksj.common.I18nMessageUtil;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
@@ -117,14 +118,14 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
@NoSubmit
|
|
@NoSubmit
|
|
|
public Result<String> getTicketByExchangeCode(ExchangeCodeTicket exchangeCodeTicket, Long userId) {
|
|
public Result<String> getTicketByExchangeCode(ExchangeCodeTicket exchangeCodeTicket, Long userId) {
|
|
|
if (StrUtil.isEmpty(exchangeCodeTicket.getCode())) {
|
|
if (StrUtil.isEmpty(exchangeCodeTicket.getCode())) {
|
|
|
- throw BusinessRuntimeException.getInstance("兑换码有误,请使用正确的兑换码");
|
|
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ex_code_error"));
|
|
|
}
|
|
}
|
|
|
ExchangeCode exchangeCode = this.getOne(Wrappers.lambdaQuery(ExchangeCode.class).eq(ExchangeCode::getCode, exchangeCodeTicket.getCode()).last("limit 1"));
|
|
ExchangeCode exchangeCode = this.getOne(Wrappers.lambdaQuery(ExchangeCode.class).eq(ExchangeCode::getCode, exchangeCodeTicket.getCode()).last("limit 1"));
|
|
|
if (exchangeCode == null) {
|
|
if (exchangeCode == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("兑换码有误,请使用正确的兑换码");
|
|
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ex_code_error"));
|
|
|
}
|
|
}
|
|
|
if (exchangeCode.getUseStatus()) {
|
|
if (exchangeCode.getUseStatus()) {
|
|
|
- throw BusinessRuntimeException.getInstance("该兑换码已使用");
|
|
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ex_code_used"));
|
|
|
}
|
|
}
|
|
|
//兑换成功
|
|
//兑换成功
|
|
|
exchangeCode.setUseStatus(true);
|
|
exchangeCode.setUseStatus(true);
|
|
@@ -132,12 +133,12 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
|
|
|
exchangeCode.setUseTime(DateTime.now());
|
|
exchangeCode.setUseTime(DateTime.now());
|
|
|
int update = exchangeCodeMapper.update(exchangeCode, Wrappers.lambdaQuery(ExchangeCode.class).eq(ExchangeCode::getId, exchangeCode.getId()).eq(ExchangeCode::getUseStatus, false));
|
|
int update = exchangeCodeMapper.update(exchangeCode, Wrappers.lambdaQuery(ExchangeCode.class).eq(ExchangeCode::getId, exchangeCode.getId()).eq(ExchangeCode::getUseStatus, false));
|
|
|
if (update != 1) {
|
|
if (update != 1) {
|
|
|
- throw BusinessRuntimeException.getInstance("该兑换码已使用");
|
|
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ex_code_used"));
|
|
|
}
|
|
}
|
|
|
//生成车票订单
|
|
//生成车票订单
|
|
|
getGroupTripsTicket(goodsDonSkuMapper.selectById(exchangeCode.getSkuId()), userId);
|
|
getGroupTripsTicket(goodsDonSkuMapper.selectById(exchangeCode.getSkuId()), userId);
|
|
|
log.info("用户:{}通过兑换码:{}兑换成功", userId, exchangeCodeTicket.getCode());
|
|
log.info("用户:{}通过兑换码:{}兑换成功", userId, exchangeCodeTicket.getCode());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult("兑换成功");
|
|
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(I18nMessageUtil.getI18nMsg("ex_code_success"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|