zoujiajian пре 10 месеци
родитељ
комит
386a8b8540

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

@@ -531,4 +531,14 @@ public interface Constant {
 	 * GPT代充平台id
 	 */
 	Long GPT_RECHARGE_GOODS_ID = 40L;
+
+	/**
+	 * claude code平台id
+	 */
+	Long CLAUDE_CODE_GOODS_ID = 102L;
+
+	/**
+	 * claude code日卡推广活动
+	 */
+	Long DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID = 732L;
 }

+ 1 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GroupsRelationMapper.java

@@ -84,4 +84,5 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 
 	List<UserTicketView> selectUserTickets(@Param("userIds") List<Long> userIds, @Param("goodsId") Long goodsId, @Param("skuId") Long skuId);
 
+	Integer selectCountByGoodsId(@Param("userIds") List<Long> userIdList, @Param("goodsId") Long goodsId, @Param("now") DateTime now);
 }

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/model/request/CcReq.java

@@ -0,0 +1,18 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj11111111
+ * 文件名: CcReq
+ * 创建者: JavaZou
+ * 创建时间:2025/9/28 14:58
+ */
+@Getter
+@Setter
+public class CcReq {
+	@NonNull
+	private Long userId;
+}

+ 11 - 0
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -413,4 +413,15 @@
             and gt.sku_id = #{skuId}
         </if>
     </select>
+
+    <select id="selectCountByGoodsId" resultType="java.lang.Integer">
+        select count(1) from groups_relation gr inner join groups_trips gt on gt.id = gr.groups_id inner join
+        goods_don_sku sku on sku.id = gt.sku_id
+        where sku.goods_id = #{goodsId}
+        and gr.user_id in
+        <foreach collection="userIds" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and gr.expiry_time > #{now}
+    </select>
 </mapper>

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpService.java

@@ -56,4 +56,6 @@ public interface CorpService {
 	 * @param corpUserPayIntention
 	 */
 	void updateUserIntention(CorpUserPayIntention corpUserPayIntention);
+
+	void sendCCTrialTicket(Long userId);
 }

+ 33 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpServiceImpl.java

@@ -20,7 +20,9 @@ import com.cyksj.common.util.corp.WxCryptUtil;
 import com.cyksj.config.corp.WeChatCorpFactory;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.dto.CorpOauth2UserInfo;
+import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.OrderDonMapper;
+import com.cyksj.mapper.UserTicketClearedRecordMapper;
 import com.cyksj.mapper.corp.*;
 import com.cyksj.mapper.corp.kf.*;
 import com.cyksj.model.dto.CorpKfServicerDto;
@@ -39,6 +41,8 @@ import com.cyksj.service.corp.msg.CorpEventActionService;
 import com.cyksj.service.corp.msg.CorpMessageHandler;
 import com.cyksj.service.corp.msg.CorpMessageRouter;
 import com.cyksj.service.order.OrderDonPostService;
+import com.cyksj.service.relation.GroupRelationFrontService;
+import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.util.WxCorpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -130,6 +134,18 @@ public class CorpServiceImpl implements CorpService {
 	@Autowired
 	private CorpKfServicerStatusChangeRecordMapper corpKfServicerStatusChangeRecordMapper;
 
+	@Autowired
+	private UserBindRelationService userBindRelationService;
+
+	@Autowired
+	private GroupsRelationMapper relationMapper;
+
+	@Autowired
+	private UserTicketClearedRecordMapper userTicketClearedRecordMapper;
+
+	@Autowired
+	private GroupRelationFrontService groupRelationFrontService;
+
 	@PostConstruct
 	private void init() {
 		corpMessageRouter = new CorpMessageRouter(this)
@@ -510,6 +526,23 @@ public class CorpServiceImpl implements CorpService {
 		}
 	}
 
+	@Override
+	public void sendCCTrialTicket(Long userId) {
+		//是否拥有这张车票
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		Integer selectCount = relationMapper.selectCountByGoodsId(userIdList, Constant.CLAUDE_CODE_GOODS_ID, DateTime.now());
+		if (selectCount > 0) {
+			throw BusinessRuntimeException.getInstance("已有claude code车票");
+		}
+		Integer count = userTicketClearedRecordMapper.selectCount(Wrappers.lambdaQuery(UserTicketClearedRecord.class).in(UserTicketClearedRecord::getUserId, userIdList).eq(UserTicketClearedRecord::getSkuId, Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID));
+		if (count > 0) {
+			throw BusinessRuntimeException.getInstance("已领取claude code体验天卡");
+		}
+
+		//发送claude code 体验卡
+		Long relationId = groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(userId, Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 1);
+	}
+
 	public void insertUserIntentionTag(CorpUserPayIntention corpUserPayIntention, String tagId, String tagName) {
 		CorpUserFollowRelation corpUserFollowRelation = corpUserFollowRelationMapper.getCorpUserFollowRelation(corpUserPayIntention.getUnionId(), corpUserPayIntention.getFollowId());
 		if (corpUserFollowRelation == null) {

+ 7 - 1
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -1207,6 +1207,12 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 				//体验规格
 				GroupsTrips groups = groupsMapper.selectCollegeStudentUserGptTicket(trialSkuId);
 				GroupsRelation relation = null;
+				if (groups == null) {
+					groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
+							.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting)
+							.eq(GroupsTrips::getSkuId, trialSkuId)
+							.last("limit 1"));
+				}
 				if (groups != null) {
 					relation = groupsRelationMapper.selectRandomOneRelationByGroupsId(groups.getId());
 				}
@@ -1226,7 +1232,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 						.eq(GroupsRelation::getId, relation.getId())
 						.eq(GroupsRelation::getUserId, 0));
 				if (update > 0) {
-					groupsMapper.decrAvailableNum(groups.getId());
+					groupsMapper.decrAvailableNum(relation.getGroupsId());
 					return relation.getId();
 				}
 				log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);

+ 14 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -28,6 +28,7 @@ import com.cyksj.model.dto.AuthRedirect;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.CorpQyMsgAuditChatView;
 import com.cyksj.model.manage.views.CorpWxOrderDonView;
+import com.cyksj.model.request.CcReq;
 import com.cyksj.model.request.OrderRefundReq;
 import com.cyksj.model.request.corp.CorpCommonReq;
 import com.cyksj.model.views.*;
@@ -581,4 +582,17 @@ public class WxCorpController {
 		String code = corpUserService.getPhoneTmpCode(phone);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(code);
 	}
+
+	/**
+	 * 发送CC体验卡
+	 */
+	@PostMapping("/send/cc/trial/ticket")
+	public Result<String> sendCCTrialTicket(@RequestBody @Validated CcReq ccReq) {
+		String corpUuid = getCorpUuid();
+		if (StrUtil.isEmpty(corpUuid)) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		corpService.sendCCTrialTicket(ccReq.getUserId());
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
 }