Przeglądaj źródła

fix 购买midJouryney课程的用户赠送车票

zoujiajian 3 lat temu
rodzic
commit
cdeab8da24

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -91,4 +91,9 @@ public interface Constant {
 
 	//发给商务
 	String BUSINESS_CHANNEL_MSG = "你的渠道%s(id%s)分销数据已低于7天平均值的50%%,请尽快与渠道沟通。【银河录像局】";
+
+	/**
+	 * midJourney课程赠送车票规格ids
+	 */
+	String MIDJOURNEY_TICKET_SKU_IDS = "midJourney_ticket_sku_ids";
 }

+ 26 - 11
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -2159,19 +2159,34 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	}
 
 	/**
-	 * 购买Midjourney课程 赠送Midjourney车票
+	 * 购买Midjourney课程 赠送车票
 	 */
 	private void sendMidjourneyTicketIfCourse(Long userId) {
-		Optional.ofNullable(goodsDonSkuMapper.selectById(185))
-				.ifPresent(sku -> {
-					GroupsRelation relation = exchangeCodeService.getRelationNoOrder(sku, userId);
-					if (relation.getExpiryTime() == null || relation.getStartTime() == null) {
-						DateTime now = DateTime.now();
-						relation.setStartTime(now);
-						relation.setExpiryTime(DateUtil.offsetMonth(now, sku.getMonths() * 1));
-						groupsRelationMapper.updateById(relation);
-					}
-				});
+		SysConfig config = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+				.eq(SysConfig::getSysKey, Constant.MIDJOURNEY_TICKET_SKU_IDS).last("limit 1"));
+		if (config != null) {
+			String sysValue = config.getSysValue();
+			if (StrUtil.isNotBlank(sysValue)) {
+				try {
+					//Midjourney车票、ChatGPT独立规格车票
+					List<Long> skuIds = Jsons.parseList(sysValue, Long.class);
+					skuIds.forEach(skuId->{
+						GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
+						if (sku != null && sku.getStatus()) {
+							GroupsRelation relation = exchangeCodeService.getRelationNoOrder(sku, userId);
+							if (relation.getExpiryTime() == null || relation.getStartTime() == null) {
+								DateTime now = DateTime.now();
+								relation.setStartTime(now);
+								relation.setExpiryTime(DateUtil.offsetMonth(now, sku.getMonths() * 1));
+								groupsRelationMapper.updateById(relation);
+							}
+						}
+					});
+				} catch (Exception e) {
+					log.error("购买midJourney课程赠送车票错误,errMsg:{}", StringUtil.getErrorText(e));
+				}
+			}
+		}
 	}
 
 	/**