zoujiajian 11 maanden geleden
bovenliggende
commit
e7d8fdaf99
1 gewijzigde bestanden met toevoegingen van 17 en 0 verwijderingen
  1. 17 0
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

+ 17 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1892,6 +1892,23 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	}
 
 	private void createNanoUser(Long userId, Long relationId, GoodsDonSku sku) {
+		//nano
+		//是否存在nano 推广体验车票
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getSkuId, Constant.DISTRIBUTE_NANO_TRIAL_SKU_ID).field(GroupsRelationView::getUserId, userIdList).build());
+		if (groupsRelationView != null) {
+			//清除车票
+			Long trialRelationId = groupsRelationView.getId();
+			GroupsRelation trialRelation = groupsRelationMapper.selectById(trialRelationId);
+			groupRelationClearService.clearTicket(trialRelation, UserTicketClearedRecord.Source.vip_deduct);
+
+			NanoUserQuota nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).eq(NanoUserQuota::getRelationId, trialRelationId).last("limit 1"));
+			nanoUserQuota.setTotalQuota(nanoUserQuota.getTotalQuota() + sku.getNanoQuota());
+			nanoUserQuota.setRemainingQuota(nanoUserQuota.getRemainingQuota() + sku.getNanoQuota());
+			nanoUserQuota.setRelationId(relationId);
+			nanoUserQuotaMapper.updateById(nanoUserQuota);
+			return;
+		}
 		try {
 			User user = userMapper.selectById(userId);
 			NanoUserQuota nanoUserQuota = new NanoUserQuota();