|
|
@@ -55,48 +55,47 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
private final OrderDonMapper orderDonMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, List<Long> skuIds) {
|
|
|
+ public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, List<GoodsDonSku> skuIds) {
|
|
|
Boolean isReceivedAll = true;
|
|
|
- for (Long skuId : skuIds) {
|
|
|
- GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(skuId);
|
|
|
- if (goodsDonSku != null) {
|
|
|
- List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
- .field(GroupsRelationView::getGoodsId, goodsDonSku.getGoodsId())
|
|
|
- .field(GroupsRelationView::getSkuId, skuId)
|
|
|
- .field(GroupsRelationView::getUserId, userId)
|
|
|
- .field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
|
|
|
- .build());
|
|
|
- //是否有该规格车票,若无直接发放车票
|
|
|
- if (CollUtil.isEmpty(relationViewList)) {
|
|
|
- //领取权益时,没有车票的用户自动上车,获得对应车票
|
|
|
- GroupsRelation relation = exchangeCodeService.getGroupTripsTicket(goodsDonSku, userId, null, OrderDon.Type.PAY_EQUIPMENT);
|
|
|
- //多给三天
|
|
|
- DateTime expiryTime = DateUtil.offsetDay(relation.getExpiryTime(), 3);
|
|
|
- groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
- .set(GroupsRelation::getExpiryTime, expiryTime)
|
|
|
- .eq(GroupsRelation::getId, relation.getId()));
|
|
|
- saveReceiveBenefitsRecord(userId, skuId, orderId, relation.getOrderId(), relation.getId(), goodsDonSku.getMonths(), 1);
|
|
|
- } else if (relationViewList.size() == 1) {
|
|
|
- //若有且只有一张增加时长
|
|
|
- GroupsRelationView groupsRelationView = relationViewList.get(0);
|
|
|
- Date expiryTime = groupsRelationView.getExpiryTime();
|
|
|
- if (expiryTime == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该车位暂未发车,请发车后再领取权益");
|
|
|
- }
|
|
|
- DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, goodsDonSku.getMonths());
|
|
|
- updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
|
|
|
- groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
- .eq(GroupsRelation::getId, groupsRelationView.getId())
|
|
|
- .eq(GroupsRelation::getUserId, userId)
|
|
|
- .set(GroupsRelation::getExpiryTime, updateExpiryTime));
|
|
|
- groupsRelationView.setUpdateExpiryTime(updateExpiryTime);
|
|
|
- saveReceiveBenefitsRecord(userId, skuId, orderId, null, groupsRelationView.getId(), goodsDonSku.getMonths(), 1);
|
|
|
- } else {
|
|
|
- //若有该规格多张车票,保存可获取的车票权益 以供用户自行选择
|
|
|
- saveAvailableBenefits(userId, skuId, orderId);
|
|
|
- if (isReceivedAll) {
|
|
|
- isReceivedAll = false;
|
|
|
- }
|
|
|
+ for (GoodsDonSku sku : skuIds) {
|
|
|
+ Long skuId = sku.getId();
|
|
|
+ Long goodsId = sku.getGoodsId();
|
|
|
+ List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getGoodsId, goodsId)
|
|
|
+ .field(GroupsRelationView::getSkuId, skuId)
|
|
|
+ .field(GroupsRelationView::getUserId, userId)
|
|
|
+ .field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
|
|
|
+ .build());
|
|
|
+ //是否有该规格车票,若无直接发放车票
|
|
|
+ if (CollUtil.isEmpty(relationViewList)) {
|
|
|
+ //领取权益时,没有车票的用户自动上车,获得对应车票
|
|
|
+ GroupsRelation relation = exchangeCodeService.getGroupTripsTicket(sku, userId, null, OrderDon.Type.PAY_EQUIPMENT);
|
|
|
+ //多给三天
|
|
|
+ DateTime expiryTime = DateUtil.offsetDay(relation.getExpiryTime(), 3);
|
|
|
+ groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getExpiryTime, expiryTime)
|
|
|
+ .eq(GroupsRelation::getId, relation.getId()));
|
|
|
+ saveReceiveBenefitsRecord(userId, skuId, orderId, relation.getOrderId(), relation.getId(), sku.getMonths(), 1);
|
|
|
+ } else if (relationViewList.size() == 1) {
|
|
|
+ //若有且只有一张增加时长
|
|
|
+ GroupsRelationView groupsRelationView = relationViewList.get(0);
|
|
|
+ Date expiryTime = groupsRelationView.getExpiryTime();
|
|
|
+ if (expiryTime == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该车位暂未发车,请发车后再领取权益");
|
|
|
+ }
|
|
|
+ DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, sku.getMonths());
|
|
|
+ updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
|
|
|
+ groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getId, groupsRelationView.getId())
|
|
|
+ .eq(GroupsRelation::getUserId, userId)
|
|
|
+ .set(GroupsRelation::getExpiryTime, updateExpiryTime));
|
|
|
+ groupsRelationView.setUpdateExpiryTime(updateExpiryTime);
|
|
|
+ saveReceiveBenefitsRecord(userId, skuId, orderId, null, groupsRelationView.getId(), sku.getMonths(), 1);
|
|
|
+ } else {
|
|
|
+ //若有该规格多张车票,保存可获取的车票权益 以供用户自行选择
|
|
|
+ saveAvailableBenefits(userId, skuId, orderId);
|
|
|
+ if (isReceivedAll) {
|
|
|
+ isReceivedAll = false;
|
|
|
}
|
|
|
}
|
|
|
}
|