Просмотр исходного кода

车票增加分类ids字段;claude code兑换

zoujiajian 11 месяцев назад
Родитель
Сommit
f578b6c380

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GoodsDonCategoryRelateMapper.java

@@ -18,4 +18,6 @@ public interface GoodsDonCategoryRelateMapper extends BaseMapper<GoodsDonCategor
 	List<GoodsDonCategory> getCateGoryViewByGoodsId(Long goodsId);
 
 	void saveBatchGoodsRelate(@Param("goodsId") Long goodsId, @Param("list") List<Long> categoryList);
+
+	List<Long> selectCategoryIdsByGid(Long goodsId);
 }

+ 8 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GroupsRelation.java

@@ -169,6 +169,14 @@ public class GroupsRelation extends BaseEntity {
      */
     private Boolean isVip;
 
+
+    /**
+     * 是否是claude code 续费
+     */
+    @DbIgnore
+    @TableField(exist = false)
+    private Boolean isClaudeCodeRenew;
+
     /**
      * 是否是claude code 续费升级
      */

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java

@@ -345,6 +345,12 @@ public class RenewalView {
     @DbField("a.act_code")
     private String actCode;
 
+    /**
+     * 分类id
+     */
+    @DbIgnore
+    private List<Long> categoryIdList;
+
     /**
      * mj 套餐包最低单价
      */

+ 4 - 0
netflix-dao/src/main/resources/mapper/GoodsDonCategoryRelateMapper.xml

@@ -16,4 +16,8 @@
         select gc.* from goods_don_category gc left join goods_don_category_relate gcr on gcr.category = gc.id
         where gcr.goods_id = #{goodsId}
     </select>
+
+    <select id="selectCategoryIdsByGid" resultType="java.lang.Long">
+        select distinct category from goods_don_category_relate where goods_id = #{goodsId}
+    </select>
 </mapper>

+ 27 - 16
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -391,11 +391,14 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 			orderDonMapper.insert(orderDon);
 			log.info("用户{}兑换规格:{}车位成功", user.getId(), orderDon.getSkuId());
 
-			if (relation.getIsClaudeCodeUpgrade() != null && relation.getIsClaudeCodeUpgrade()) {
-				//claude code 是否升级
+			if (relation.getIsClaudeCodeRenew() != null && relation.getIsClaudeCodeRenew()) {
+				//claude code续费
 				orderDon.setOrderType(2);
 				orderDonMapper.updateById(orderDon);
-				claudeCodeService.handleClaudeCodeUserPackageSku(relation, sku, orderDon.getId());
+				//续费且升级
+				if (relation.getIsClaudeCodeUpgrade() != null && relation.getIsClaudeCodeUpgrade()) {
+					claudeCodeService.handleClaudeCodeUserPackageSku(relation, sku, orderDon.getId());
+				}
 			}
 		}
 		if (orderDonTye == OrderDon.Type.EX_CODE) {
@@ -424,23 +427,31 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 
 	@Override
 	public GroupsRelation getRelationNoOrder(GoodsDonSku sku, Long userId, Long yhsId) {
-		//claude code商品兑换 只能兑换一次 后续兑换增加车票时长
+		//claude code商品兑换
 		if (sku.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
 			List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 			GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getUserId, userIdList).op(Operator.InList).field(GroupsRelationView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan).build());
 			if (groupsRelationView != null) {
-//				Date expiryTime = groupsRelationView.getExpiryTime();
-//				if (sku.getDays() != null) {
-//					expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
-//				} else {
-//					expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
-//				}
-//				GroupsRelation relation = groupsRelationMapper.selectById(groupsRelationView.getId());
-//				relation.setExpiryTime(expiryTime);
-//				groupsRelationMapper.updateById(relation);
-//				relation.setIsClaudeCodeUpgrade(true);
-//				return relation;
-				throw BusinessRuntimeException.getInstance("您当前已有车票,暂时无法兑换");
+				GoodsDonSku relationSku = goodsDonSkuMapper.selectById(groupsRelationView.getSkuId());
+				//兑换的规格 低于当前规格 不让兑换
+				if (relationSku.getCodePoints() > sku.getCodePoints()) {
+					throw BusinessRuntimeException.getInstance("请在claude code当前版本过期后再兑换");
+				}
+				Date expiryTime = groupsRelationView.getExpiryTime();
+				if (sku.getDays() != null) {
+					expiryTime = DateUtil.offsetDay(expiryTime, sku.getDays());
+				} else {
+					expiryTime = DateUtil.offsetMonth(expiryTime, sku.getMonths());
+				}
+				GroupsRelation relation = groupsRelationMapper.selectById(groupsRelationView.getId());
+				relation.setExpiryTime(expiryTime);
+				groupsRelationMapper.updateById(relation);
+				//同规格只加时长
+				relation.setIsClaudeCodeRenew(Boolean.TRUE);
+				if (relationSku.getCodePoints() != sku.getCodePoints()) {
+					relation.setIsClaudeCodeUpgrade(true);
+				}
+				return relation;
 			}
 		}
 		Integer retryNum = 1;

+ 4 - 1
netflix-service/src/main/java/com/cyksj/service/mange/impl/MirrorUserCleatServiceImpl.java

@@ -183,7 +183,10 @@ public class MirrorUserCleatServiceImpl implements MirrorUserCleatService {
 						renewExpiryTime = DateUtil.offsetMonth(DateTime.now(), otherRenewSku.getMonths());
 					}
 					//相差多少天
-					Long betDay = DateUtil.betweenDay(otherRenewRecord.getCreatedTime(), presentRenewOrderDon.getCreatedTime(), false);
+					Long betDay = 0l;
+					if (presentRenewOrderDon != null && presentRenewOrderDon.getCreatedTime().compareTo(otherRenewRecord.getCreatedTime()) > 0) {
+						betDay = DateUtil.betweenDay(otherRenewRecord.getCreatedTime(), presentRenewOrderDon.getCreatedTime(), false);
+					}
 					renewExpiryTime = DateUtil.offsetDay(renewExpiryTime, -betDay.intValue());
 
 					claudeCodeUser.setRenewOrderId(otherRenewRecord.getOrderId());

+ 4 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -207,6 +207,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 
 	private final ClaudeCodeUserRenewExpiryRecordMapper claudeCodeUserRenewExpiryRecordMapper;
 
+	private final GoodsDonCategoryRelateMapper goodsDonCategoryRelateMapper;
+
 	private final ClaudeCodeService claudeCodeService;
 
 	@Override
@@ -295,6 +297,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 				if (ticket.getSkuNum() > 1) {
 					ticket.setIsMulti(true);
 				}
+				//分类ids
+				ticket.setCategoryIdList(goodsDonCategoryRelateMapper.selectCategoryIdsByGid(ticket.getGoodsId()));
 				//chatGPT直连
 				if (ticket.getGoodsId().equals(42l)) {
 					if (StrUtil.isNotBlank(ticket.getAccount())) {