Browse Source

nano推广

zoujiajian 11 months ago
parent
commit
f946adca51

+ 11 - 1
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -687,5 +687,15 @@ public interface Constant {
 	/**
 	 * nano 渠道优惠券id
 	 */
-	Long DISTRIBUTE_NANO_COUPON_ID = 104L;
+	Long DISTRIBUTE_NANO_COUPON_ID = 275L;
+
+	/**
+	 * nano 渠道体验卡规格id
+	 */
+	Long DISTRIBUTE_NANO_TRIAL_SKU_ID = 740L;
+
+	/**
+	 * nano推广标识
+	 */
+	String NANO_DISTRIBUTE_MARK = "nano";
 }

+ 10 - 0
netflix-dao/src/main/java/com/cyksj/mapper/nano/NanoUserTrialReceiveRecordMapper.java

@@ -0,0 +1,10 @@
+package com.cyksj.mapper.nano;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.NanoUserTrialReceiveRecord;
+
+/**
+ * Nano用户试用体验卡领取记录 Mapper
+ */
+public interface NanoUserTrialReceiveRecordMapper extends BaseMapper<NanoUserTrialReceiveRecord> {
+}

+ 20 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/NanoUserTrialReceiveRecord.java

@@ -0,0 +1,20 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Nano用户试用体验卡领取记录
+ * 项目名: yhlxj11111111
+ * 文件名: NanoUserTrialReceiveRecord
+ * 创建者: Claude Code
+ * 创建时间:2025/9/4
+ */
+@Getter
+@Setter
+public class NanoUserTrialReceiveRecord extends BaseEntity {
+	
+	private Long userId;
+	
+	private Long relationId;
+}

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -860,6 +860,7 @@ public class RedisService {
         GPT_RECHARGE_KEY("gpt_recharge_key:", "gpt代充", 60),
         GPT_RECHARGE_RECOVER_KEY("gpt_recharge_recover_key:", "gpt代充恢复key", 60 * 5l),
         CLAUDE_CODE_TY_DAY_CARD_KEY("claude_code_ty_day_card_key:", "claude_code体验天卡key", 30L),
+        NANO_TY_DAY_CARD_KEY("nano_ty_day_card_key:", "nano体验天卡key", 30L),
         ;
 
         private String name;

+ 59 - 22
netflix-service/src/main/java/com/cyksj/service/gzh/factory/EventMsgService.java

@@ -18,6 +18,7 @@ import com.cyksj.mapper.manage.coupon.CouponDistributePopularizeMapper;
 import com.cyksj.mapper.manage.coupon.CouponRecommendMapper;
 import com.cyksj.mapper.manage.cps.UserDistributePopularizeMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
+import com.cyksj.mapper.nano.NanoUserTrialReceiveRecordMapper;
 import com.cyksj.mapper.station.CollegeStudentStationUserRelateMapper;
 import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
@@ -91,6 +92,8 @@ public class EventMsgService implements GzhMsgService {
 
 	private final ClaudeCodeUserTrialReceiveRecordMapper claudeCodeUserTrialReceiveRecordMapper;
 
+	private final NanoUserTrialReceiveRecordMapper nanoUserTrialReceiveRecordMapper;
+
 	private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
 	@Override
@@ -271,7 +274,7 @@ public class EventMsgService implements GzhMsgService {
 				}
 			}
 			//查找渠道是否有设置了对应的claude code优惠码
-			setClaudeCodePopularize(sharedId, dsPopularizeId, user);
+			handlerSpecialPopularize(sharedId, dsPopularizeId, user);
 			//每日活跃记录
 			userLoginRecordService.saveUserLoginDayRecord(user.getId());
 			//是否是大学生快递站进来的用户
@@ -379,7 +382,7 @@ public class EventMsgService implements GzhMsgService {
 	/**
 	 * 查找渠道是否有设置了对应的claude code优惠码
 	 */
-	public void setClaudeCodePopularize(Long sharedId, Long dsPopularizeId, User user) {
+	public void handlerSpecialPopularize(Long sharedId, Long dsPopularizeId, User user) {
 		//查找渠道是否有设置了对应的claude code优惠码
 		if (sharedId != null) {
 			UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, sharedId).eq(UserDistribute::getDeleted, Boolean.TRUE).last("limit 1"));
@@ -392,33 +395,58 @@ public class EventMsgService implements GzhMsgService {
 					return;
 				}
 				//是否是cc推广
-				if (StrUtil.isEmpty(userDistributePopularize.getOtherUrl()) || !"cc".equals(userDistributePopularize.getOtherUrl())) {
-					return;
+				if (Constant.CC_DISTRIBUTE_MARK.equals(userDistributePopularize.getOtherUrl())) {
+					Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID));
+					//是否设置claude cod优惠券
+					if (selectCount > 0) {
+						//设置了 直接发送优惠券
+						Boolean b = couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						if (!b) {
+							return;
+						}
+						if (redisService.setNx(RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getTimeout())) {
+							//存在Claude code车票不发送体验卡
+							if (!claudeCodeService.checkClaudeCodeUser(user.getId())) {
+								Integer receiveRecord = claudeCodeUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(ClaudeCodeUserTrialReceiveRecord.class).eq(ClaudeCodeUserTrialReceiveRecord::getUserId, user.getId()));
+								if (receiveRecord > 0) {
+									return;
+								}
+								//发送claude code 体验卡
+								Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 1);
+								recordReceiveClaudeCodeRecord(user.getId(), relationId);
+							}
+						}
+					} else {
+						//该优惠券是否处于推荐中
+						int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
+						if (isTj != 0) {
+							//发送无优惠码的 优惠券
+							couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						}
+					}
 				}
-				Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID));
-				//是否设置claude cod优惠券
-				if (selectCount > 0) {
-					//设置了 直接发送优惠券
-					couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
-					if (redisService.setNx(RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getTimeout())) {
-						//存在Claude code车票不发送体验卡
-						if (!claudeCodeService.checkClaudeCodeUser(user.getId())) {
-							Integer receiveRecord = claudeCodeUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(ClaudeCodeUserTrialReceiveRecord.class).eq(ClaudeCodeUserTrialReceiveRecord::getUserId, user.getId()));
+
+				//是否是nano 推广
+				if (Constant.NANO_DISTRIBUTE_MARK.equals(userDistributePopularize.getOtherUrl())) {
+					Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_NANO_COUPON_ID));
+					//是否设置claude cod优惠券
+					if (selectCount > 0) {
+						//设置了 直接发送优惠券
+						Boolean b = couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_NANO_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						if (!b) {
+							return;
+						}
+						if (redisService.setNx(RedisService.key.NANO_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.NANO_TY_DAY_CARD_KEY.getTimeout())) {
+							//存在Claude code车票不发送体验卡
+							Integer receiveRecord = nanoUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(NanoUserTrialReceiveRecord.class).eq(NanoUserTrialReceiveRecord::getUserId, user.getId()));
 							if (receiveRecord > 0) {
 								return;
 							}
 							//发送claude code 体验卡
-							Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 1);
-							recordReceiveClaudeCodeRecord(user.getId(), relationId);
+							Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_NANO_TRIAL_SKU_ID, 1);
+							recordReceiveNanoRecord(user.getId(), relationId);
 						}
 					}
-				} else {
-					//该优惠券是否处于推荐中
-					int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
-					if (isTj != 0) {
-						//发送无优惠码的 优惠券
-						couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
-					}
 				}
 			}
 		}
@@ -432,4 +460,13 @@ public class EventMsgService implements GzhMsgService {
 			claudeCodeUserTrialReceiveRecordMapper.insert(record);
 		}
 	}
+
+	private void recordReceiveNanoRecord(Long userId, Long relationId) {
+		if (relationId != null) {
+			NanoUserTrialReceiveRecord record = new NanoUserTrialReceiveRecord();
+			record.setUserId(userId);
+			record.setRelationId(relationId);
+			nanoUserTrialReceiveRecordMapper.insert(record);
+		}
+	}
 }

+ 7 - 0
netflix-service/src/main/java/com/cyksj/service/nano/NanoService.java

@@ -0,0 +1,7 @@
+package com.cyksj.service.nano;
+
+/**
+ * Nano服务接口
+ */
+public interface NanoService {
+}

+ 19 - 0
netflix-service/src/main/java/com/cyksj/service/nano/impl/NanoServiceImpl.java

@@ -0,0 +1,19 @@
+package com.cyksj.service.nano.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.mapper.NanoUserQuotaMapper;
+import com.cyksj.model.entity.NanoUserQuota;
+import com.cyksj.service.nano.NanoService;
+import com.cyksj.service.user.UserBindRelationService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Nano服务实现
+ */
+@Service
+@RequiredArgsConstructor
+public class NanoServiceImpl implements NanoService {
+}

+ 61 - 24
netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java

@@ -29,6 +29,7 @@ import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
 import com.cyksj.mapper.market.task.UserBindDetailMapper;
 import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
+import com.cyksj.mapper.nano.NanoUserTrialReceiveRecordMapper;
 import com.cyksj.mapper.station.CollegeStudentStationUserRelateMapper;
 import com.cyksj.mapper.vip.VipUserMapper;
 import com.cyksj.model.dto.*;
@@ -156,6 +157,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
 	private final ClaudeCodeUserTrialReceiveRecordMapper claudeCodeUserTrialReceiveRecordMapper;
 
+	private final NanoUserTrialReceiveRecordMapper nanoUserTrialReceiveRecordMapper;
+
 	private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
 	@Override
@@ -248,8 +251,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 		if (sharedId != null && dsType != null && dsType == 2) {
 			equipDistributeService.saveDistributionInvitation(sharedId, isNewUser, user.getId());
 		}
-		//查找渠道是否有设置了对应的claude code优惠码
-		setClaudeCodePopularize(sharedId, dsPopularizeId, user);
+		//处理特殊推广
+		handlerSpecialPopularize(sharedId, dsPopularizeId, user);
 		//每日活跃记录
 		userLoginRecordService.saveUserLoginDayRecord(user.getId());
 		//是否是大学生快递站进来的用户
@@ -603,7 +606,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 			equipDistributeService.saveDistributionInvitation(sharedId, isNewUser, user.getId());
 		}
 		//查找渠道是否有设置了对应的claude code优惠码
-		setClaudeCodePopularize(sharedId, dsPopularizeId, user);
+		handlerSpecialPopularize(sharedId, dsPopularizeId, user);
 
 		//每日活跃记录
 		userLoginRecordService.saveUserLoginDayRecord(user.getId());
@@ -947,7 +950,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 	/**
 	 * 查找渠道是否有设置了对应的claude code优惠码
 	 */
-	public void setClaudeCodePopularize(Long sharedId, Long dsPopularizeId, User user) {
+	public void handlerSpecialPopularize(Long sharedId, Long dsPopularizeId, User user) {
 		//查找渠道是否有设置了对应的claude code优惠码
 		if (sharedId != null) {
 			UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, sharedId).eq(UserDistribute::getDeleted, Boolean.TRUE).last("limit 1"));
@@ -960,33 +963,58 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 					return;
 				}
 				//是否是cc推广
-				if (StrUtil.isEmpty(userDistributePopularize.getOtherUrl()) || !"cc".equals(userDistributePopularize.getOtherUrl())) {
-					return;
+				if (Constant.CC_DISTRIBUTE_MARK.equals(userDistributePopularize.getOtherUrl())) {
+					Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID));
+					//是否设置claude cod优惠券
+					if (selectCount > 0) {
+						//设置了 直接发送优惠券
+						Boolean b = couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						if (!b) {
+							return;
+						}
+						if (redisService.setNx(RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getTimeout())) {
+							//存在Claude code车票不发送体验卡
+							if (!claudeCodeService.checkClaudeCodeUser(user.getId())) {
+								Integer receiveRecord = claudeCodeUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(ClaudeCodeUserTrialReceiveRecord.class).eq(ClaudeCodeUserTrialReceiveRecord::getUserId, user.getId()));
+								if (receiveRecord > 0) {
+									return;
+								}
+								//发送claude code 体验卡
+								Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 1);
+								recordReceiveClaudeCodeRecord(user.getId(), relationId);
+							}
+						}
+					} else {
+						//该优惠券是否处于推荐中
+						int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
+						if (isTj != 0) {
+							//发送无优惠码的 优惠券
+							couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						}
+					}
 				}
-				Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID));
-				//是否设置claude cod优惠券
-				if (selectCount > 0) {
-					//设置了 直接发送优惠券
-					couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
-					if (redisService.setNx(RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.CLAUDE_CODE_TY_DAY_CARD_KEY.getTimeout())) {
-						//存在Claude code车票不发送体验卡
-						if (!claudeCodeService.checkClaudeCodeUser(user.getId())) {
-							Integer receiveRecord = claudeCodeUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(ClaudeCodeUserTrialReceiveRecord.class).eq(ClaudeCodeUserTrialReceiveRecord::getUserId, user.getId()));
+
+				//是否是nano 推广
+				if (Constant.NANO_DISTRIBUTE_MARK.equals(userDistributePopularize.getOtherUrl())) {
+					Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getDeleted, Boolean.TRUE).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_NANO_COUPON_ID));
+					//是否设置claude cod优惠券
+					if (selectCount > 0) {
+						//设置了 直接发送优惠券
+						Boolean b = couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_NANO_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
+						if (!b) {
+							return;
+						}
+						if (redisService.setNx(RedisService.key.NANO_TY_DAY_CARD_KEY.getName() + user.getId(), user.getId(), RedisService.key.NANO_TY_DAY_CARD_KEY.getTimeout())) {
+							//存在Claude code车票不发送体验卡
+							Integer receiveRecord = nanoUserTrialReceiveRecordMapper.selectCount(Wrappers.lambdaQuery(NanoUserTrialReceiveRecord.class).eq(NanoUserTrialReceiveRecord::getUserId, user.getId()));
 							if (receiveRecord > 0) {
 								return;
 							}
 							//发送claude code 体验卡
-							Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 1);
-							recordReceiveClaudeCodeRecord(user.getId(), relationId);
+							Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_NANO_TRIAL_SKU_ID, 1);
+							recordReceiveNanoRecord(user.getId(), relationId);
 						}
 					}
-				} else {
-					//该优惠券是否处于推荐中
-					int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
-					if (isTj != 0) {
-						//发送无优惠码的 优惠券
-						couponCommonService.sendCouponToUser(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID, 0l, 0l, dsPopularizeId, CouponUser.Channel.manual);
-					}
 				}
 			}
 		}
@@ -1000,4 +1028,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 			claudeCodeUserTrialReceiveRecordMapper.insert(record);
 		}
 	}
+
+	public void recordReceiveNanoRecord(Long userId, Long relationId) {
+		if (relationId != null) {
+			NanoUserTrialReceiveRecord record = new NanoUserTrialReceiveRecord();
+			record.setUserId(userId);
+			record.setRelationId(relationId);
+			nanoUserTrialReceiveRecordMapper.insert(record);
+		}
+	}
 }