|
@@ -25,14 +25,12 @@ import com.qs.mp.common.core.redis.RedisCache;
|
|
|
import com.qs.mp.common.enums.ChannelMoneyEnum;
|
|
|
import com.qs.mp.common.enums.CommStatusEnum;
|
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
|
-import com.qs.mp.common.enums.MqTopicType;
|
|
|
import com.qs.mp.common.enums.TicketBoxStatusEnum;
|
|
|
import com.qs.mp.common.enums.TicketStatusEnum;
|
|
|
import com.qs.mp.common.enums.TicketTypeEnum;
|
|
|
import com.qs.mp.common.enums.UserCouponStatusEnum;
|
|
|
import com.qs.mp.common.enums.UserTicketOrderStatusEnum;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
-import com.qs.mp.common.pulsar.PulsarClientService;
|
|
|
import com.qs.mp.common.utils.LogUtil;
|
|
|
import com.qs.mp.common.utils.RSAUtil;
|
|
|
import com.qs.mp.common.utils.StringUtils;
|
|
@@ -40,12 +38,10 @@ import com.qs.mp.framework.redis.RedisKey;
|
|
|
import com.qs.mp.pay.domain.PayOrder;
|
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
|
import com.qs.mp.user.domain.UserCoupon;
|
|
|
-import com.qs.mp.user.domain.UserDeliverOrder;
|
|
|
import com.qs.mp.user.domain.UserTicketOrder;
|
|
|
import com.qs.mp.user.domain.UserTicketOrderItem;
|
|
|
import com.qs.mp.user.domain.vo.TicketOrderSettleVO;
|
|
|
import com.qs.mp.user.domain.vo.UserCoupon4OrderVO;
|
|
|
-import com.qs.mp.user.domain.vo.UserCouponVO;
|
|
|
import com.qs.mp.user.domain.vo.UserShareVO;
|
|
|
import com.qs.mp.user.mapper.UserTicketOrderMapper;
|
|
|
import com.qs.mp.user.service.IUserCouponService;
|
|
@@ -57,7 +53,6 @@ import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
-import org.apache.pulsar.client.api.PulsarClientException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -114,7 +109,8 @@ public class UserTicketOrderServiceImpl extends
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public String submitOrder(Long userId, TicketOrderSettleVO orderSettleVO, UserShareVO userShareVO) {
|
|
|
+ public String submitOrder(Long userId, TicketOrderSettleVO orderSettleVO,
|
|
|
+ UserShareVO userShareVO) {
|
|
|
if (StringUtils.isBlank(orderSettleVO.getTicketId())) {
|
|
|
return createOnlineOrder(userId, orderSettleVO, userShareVO);
|
|
|
}
|
|
@@ -123,7 +119,8 @@ public class UserTicketOrderServiceImpl extends
|
|
|
return createOfflineOrder(userId, orderSettleVO);
|
|
|
}
|
|
|
|
|
|
- private String createOnlineOrder(Long userId, TicketOrderSettleVO orderSettleVO, UserShareVO userShareVO) {
|
|
|
+ private String createOnlineOrder(Long userId, TicketOrderSettleVO orderSettleVO,
|
|
|
+ UserShareVO userShareVO) {
|
|
|
// 线上票更新票组销量,防止超卖
|
|
|
TicketBox ticketBox = ticketBoxService.getById(orderSettleVO.getBoxId());
|
|
|
if (ticketBox.getStatus() == TicketBoxStatusEnum.PUT_OFF
|
|
@@ -216,11 +213,13 @@ public class UserTicketOrderServiceImpl extends
|
|
|
Ticket ticket = ticketService.getById(orderSettleVO.getTicketId());
|
|
|
Assert.isTrue(ticket.getStatus() == TicketStatusEnum.NOT_PAY,
|
|
|
"盲票已付款,ticketId:" + ticket.getTicketId());
|
|
|
- if (redisCache.getCacheObject(RedisKey.build(RedisKey.OFFLINE_TICKET_ID_KEY, ticket.getTicketId()))) {
|
|
|
+ if (redisCache.getCacheObject(
|
|
|
+ RedisKey.build(RedisKey.OFFLINE_TICKET_ID_KEY, ticket.getTicketId()))) {
|
|
|
LogUtil.error(logger, "线下盲票重复购买,ticketNo:", ticket.getSerialNo());
|
|
|
throw new ServiceException("重复购买,请稍后再试");
|
|
|
}
|
|
|
- redisCache.setCacheObject(RedisKey.build(RedisKey.OFFLINE_TICKET_ID_KEY, ticket.getTicketId()), userId, 5, TimeUnit.MINUTES);
|
|
|
+ redisCache.setCacheObject(RedisKey.build(RedisKey.OFFLINE_TICKET_ID_KEY, ticket.getTicketId()),
|
|
|
+ userId, 5, TimeUnit.MINUTES);
|
|
|
|
|
|
// 核销优惠券
|
|
|
String couponIds = verifyUserCoupon(orderSettleVO.getCouponList());
|
|
@@ -290,7 +289,8 @@ public class UserTicketOrderServiceImpl extends
|
|
|
int sumTicket = 0;
|
|
|
for (String orderId : orderIds) {
|
|
|
UserTicketOrder userTicketOrder = getById(orderId);
|
|
|
- Assert.isTrue(userTicketOrder.getResource() == TicketTypeEnum.ONLINE, "非在线盲票不用取消。boxId:" + boxId);
|
|
|
+ Assert.isTrue(userTicketOrder.getResource() == TicketTypeEnum.ONLINE,
|
|
|
+ "非在线盲票不用取消。boxId:" + boxId);
|
|
|
if (!rollbackOrder(userTicketOrder)) {
|
|
|
return false;
|
|
|
}
|
|
@@ -302,13 +302,15 @@ public class UserTicketOrderServiceImpl extends
|
|
|
|
|
|
private void rollbackBoxQty(String boxId, int qty) {
|
|
|
TicketBox ticketBox = ticketBoxService.getById(boxId);
|
|
|
- boolean updateBox = ticketBoxService.update(new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getSaleQty,
|
|
|
- ticketBox.getSaleQty() - qty)
|
|
|
- .set(
|
|
|
- ticketBox.getStatus() == TicketBoxStatusEnum.PUT_OFF && ticketBox.getManualOff() != 1,
|
|
|
- TicketBox::getStatus, TicketBoxStatusEnum.PUT_ON)
|
|
|
- .eq(TicketBox::getBoxId, ticketBox.getBoxId())
|
|
|
- .eq(TicketBox::getSaleQty, ticketBox.getSaleQty()));
|
|
|
+ boolean updateBox = ticketBoxService.update(
|
|
|
+ new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getSaleQty,
|
|
|
+ ticketBox.getSaleQty() - qty)
|
|
|
+ .set(
|
|
|
+ ticketBox.getStatus() == TicketBoxStatusEnum.PUT_OFF
|
|
|
+ && ticketBox.getManualOff() != 1,
|
|
|
+ TicketBox::getStatus, TicketBoxStatusEnum.PUT_ON)
|
|
|
+ .eq(TicketBox::getBoxId, ticketBox.getBoxId())
|
|
|
+ .eq(TicketBox::getSaleQty, ticketBox.getSaleQty()));
|
|
|
Assert.isTrue(updateBox, "取消过期未支付盲票购买订单,恢复票组销量失败。boxId:{0}" + boxId);
|
|
|
}
|
|
|
|
|
@@ -342,8 +344,9 @@ public class UserTicketOrderServiceImpl extends
|
|
|
.set(UserCoupon::getStatus, UserCouponStatusEnum.UNUSED)
|
|
|
.set(UserCoupon::getVerifyTime, null)
|
|
|
.in(UserCoupon::getId, userCouponIds));
|
|
|
- Assert.isTrue(rst, "盲票购买订单取消时,反核销优惠券失败。orderId:" + userTicketOrder.getOrderId() + "userCouponIds:"
|
|
|
- + userTicketOrder.getCouponInfo());
|
|
|
+ Assert.isTrue(rst,
|
|
|
+ "盲票购买订单取消时,反核销优惠券失败。orderId:" + userTicketOrder.getOrderId() + "userCouponIds:"
|
|
|
+ + userTicketOrder.getCouponInfo());
|
|
|
}
|
|
|
|
|
|
boolean rst = update(new LambdaUpdateWrapper<UserTicketOrder>().set(UserTicketOrder::getStatus,
|
|
@@ -430,7 +433,8 @@ public class UserTicketOrderServiceImpl extends
|
|
|
channelCommission.setSaleCommAmt(siteCommission.getSaleCommAmt());
|
|
|
channelCommission.setCommRate(channel.getCommRate());
|
|
|
channelCommission.setCommAmt(new BigDecimal(channelCommission.getSaleCommAmt()).multiply(
|
|
|
- channelCommission.getCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN).intValue() - sumCommAmt);
|
|
|
+ channelCommission.getCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN)
|
|
|
+ .intValue() - sumCommAmt);
|
|
|
channelCommissionService.save(channelCommission);
|
|
|
sumCommAmt += channelCommission.getCommAmt();
|
|
|
}
|
|
@@ -476,7 +480,8 @@ public class UserTicketOrderServiceImpl extends
|
|
|
siteCommission.setSaleAmt(ticketOrder.getPayAmt());
|
|
|
siteCommission.setSaleCommRate(ticketBox.getSaleCommRate());
|
|
|
siteCommission.setSaleCommAmt(new BigDecimal(siteCommission.getSaleAmt()).multiply(
|
|
|
- siteCommission.getSaleCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN).intValue());
|
|
|
+ siteCommission.getSaleCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN)
|
|
|
+ .intValue());
|
|
|
siteCommission.setCommRate(channel.getCommRate());
|
|
|
siteCommission.setCommAmt(new BigDecimal(siteCommission.getSaleCommAmt()).multiply(
|
|
|
siteCommission.getCommRate()).divide(new BigDecimal(100), 0, RoundingMode.DOWN).intValue());
|
|
@@ -484,50 +489,50 @@ public class UserTicketOrderServiceImpl extends
|
|
|
return siteCommission;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<IndexVO> selectIndexPayAmtList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
- return getBaseMapper().selectIndexPayAmtList(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IndexVO> selectIndexPayUserCntList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
- return getBaseMapper().selectIndexPayUserCntList(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IndexVO> selectIndexDailyInfoList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
- return getBaseMapper().selectIndexDailyInfoList(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IndexVO> selectIndexTicketBoxTop(Wrapper<UserTicketOrder> wrapper) {
|
|
|
- return getBaseMapper().selectIndexTicketBoxTop(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IndexVO> selectIndexTicketSiteTop(Wrapper<UserTicketOrder> wrapper) {
|
|
|
- return getBaseMapper().selectIndexTicketSiteTop(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getChannelTotalTicketNumCnt(String channelNo) {
|
|
|
- return getBaseMapper().getChannelTotalTicketNumCnt(channelNo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getSaleSiteTotalTicketNumCnt(Long channelId) {
|
|
|
- return getBaseMapper().getSaleSiteTotalTicketNumCnt(channelId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public TicketCntVO getTicketSaleCnt(Long channelId) {
|
|
|
- return getBaseMapper().getTicketSaleCnt(channelId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<TicketCntVO> listTicketSaleCnt(Wrapper<UserTicketOrder> queryWrapper) {
|
|
|
- return getBaseMapper().listTicketSaleCnt(queryWrapper);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public List<IndexVO> selectIndexPayAmtList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
+ return getBaseMapper().selectIndexPayAmtList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IndexVO> selectIndexPayUserCntList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
+ return getBaseMapper().selectIndexPayUserCntList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IndexVO> selectIndexDailyInfoList(Wrapper<UserTicketOrder> wrapper) {
|
|
|
+ return getBaseMapper().selectIndexDailyInfoList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IndexVO> selectIndexTicketBoxTop(Wrapper<UserTicketOrder> wrapper) {
|
|
|
+ return getBaseMapper().selectIndexTicketBoxTop(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IndexVO> selectIndexTicketSiteTop(Wrapper<UserTicketOrder> wrapper) {
|
|
|
+ return getBaseMapper().selectIndexTicketSiteTop(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getChannelTotalTicketNumCnt(String channelNo) {
|
|
|
+ return getBaseMapper().getChannelTotalTicketNumCnt(channelNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getSaleSiteTotalTicketNumCnt(Long channelId) {
|
|
|
+ return getBaseMapper().getSaleSiteTotalTicketNumCnt(channelId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TicketCntVO getTicketSaleCnt(Long channelId) {
|
|
|
+ return getBaseMapper().getTicketSaleCnt(channelId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TicketCntVO> listTicketSaleCnt(Wrapper<UserTicketOrder> queryWrapper) {
|
|
|
+ return getBaseMapper().listTicketSaleCnt(queryWrapper);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|