|
|
@@ -13,10 +13,12 @@ import com.cyksj.mapper.channel.UserPayEquipmentAvailableBenefitsMapper;
|
|
|
import com.cyksj.mapper.channel.UserPayEquipmentReceiveBenefitsRecordMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
+import com.cyksj.model.views.UserAvailableGoodsTicketView;
|
|
|
import com.cyksj.service.exchange.ExchangeCodeService;
|
|
|
import com.cyksj.service.order.UserRealOrderBenefitsService;
|
|
|
import com.cyksj.service.relation.GroupRelationClearService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
+import com.ejlchina.searcher.param.Operator;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -24,10 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/*
|
|
|
*项目名: netflix
|
|
|
@@ -56,8 +55,9 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
private final OrderDonMapper orderDonMapper;
|
|
|
|
|
|
@Override
|
|
|
- public void getPayRealGoodsBenefits(Long userId, Long orderId, Long goodsId, List<Long> skuIds) {
|
|
|
- skuIds.forEach(skuId->{
|
|
|
+ public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, Long goodsId, List<Long> 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()
|
|
|
@@ -70,6 +70,11 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
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) {
|
|
|
//若有且只有一张增加时长
|
|
|
@@ -79,18 +84,23 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
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 {
|
|
|
+ } else {
|
|
|
//若有该规格多张车票,保存可获取的车票权益 以供用户自行选择
|
|
|
saveAvailableBenefits(userId, skuId, orderId);
|
|
|
+ if (isReceivedAll) {
|
|
|
+ isReceivedAll = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ return isReceivedAll;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -150,6 +160,7 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
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)
|
|
|
@@ -163,6 +174,22 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
|
|
|
return groupsRelationView;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<UserAvailableGoodsTicketView> getAvailableBenefitsTickets(Long userId) {
|
|
|
+ List<UserAvailableGoodsTicketView> ticketViews = beanSearcher.searchAll(UserAvailableGoodsTicketView.class, MapUtils.builder().field(UserAvailableGoodsTicketView::getUserId, userId)
|
|
|
+ .field(UserAvailableGoodsTicketView::getDeleted, true).build());
|
|
|
+ ticketViews.forEach(ticket -> {
|
|
|
+ List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getSkuId, ticket.getSkuId())
|
|
|
+ .field(GroupsRelationView::getUserId, userId)
|
|
|
+ .field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
|
|
|
+ .field(GroupsRelationView::getExpiryTime).op(Operator.NotNull)
|
|
|
+ .build());
|
|
|
+ ticket.setTicketList(relationViewList);
|
|
|
+ });
|
|
|
+ return ticketViews;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存获取权益记录
|
|
|
*/
|