瀏覽代碼

fix midJourney未过期车票清除并退余额

zoujiajian 3 年之前
父節點
當前提交
04ed131fe4

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

@@ -39,7 +39,7 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 
 	List<GroupsRelation> selectExpiredRelationByCondition(@Param("now") DateTime now, @Param("list") List<Long> filterSkuIds);
 
-	GroupsRelation selectOutsideRelationByGroupsId(Long groupsId);
+	GroupsRelation selectOutsideRelationByGroupsId(@Param("groupsId") Long groupsId, @Param("relationNum") Integer relationNum);
 
 	List<GroupsRelation> selectExpiredChatGPTRelation(@Param("nextBeginDay") DateTime nextBeginDay, @Param("list") List<Long> gptSkuIds);
 }

+ 1 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/UserTicketClearedRecord.java

@@ -52,6 +52,7 @@ public class UserTicketClearedRecord extends BaseEntity{
 		timing_change_ticket("定时更换车票"),
 		new_groups_ticket("新空车队车票"),
 		disable("禁用账号分配车票"),
+		refund_balance("退款余额"),
 		;
 		String desc;
 

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

@@ -117,7 +117,7 @@
         from groups_relation
         where groups_id = #{groupsId}
           and user_id = 0
-          and num > 20
+          and num > #{relationNum}
           and status = 'outside'
         order by rand() limit 1
     </select>

+ 1 - 0
netflix-dao/src/main/resources/mapper/GroupsMapper.xml

@@ -45,6 +45,7 @@
         and gt.status = 'validity'
         and a.expiry_time >= #{expiryTime}
         and a.expiry_time &lt;= #{betDay}
+        and available_num = 0
         and (select count(*) from groups_relation gr where gr.status ='outside' and gr.groups_id = gt.id and
         gr.user_id != 0) &lt; #{extraNum}
         order by gt.available_num asc limit 1

+ 8 - 7
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -338,14 +338,15 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                 .last("limit 1");
         GroupsTrips groups = groupsMapper.selectOne(queryWrapper);
         if (groups == null) throw BusinessRuntimeException.getInstance("车队不存在或已下架");
-        if (orderDon.getGoodsId() != 18 && groups.getAvailableNum() <= 0) {
+        if (!Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && groups.getAvailableNum() <= 0) {
             throw BusinessRuntimeException.getInstance("该新车位人员已满");
         }
+        Integer relationNum = groups.getNum();
         //获取新车队车位
         GroupsRelation newRelation;
-        if (orderDon.getGoodsId() == 18 && groups.getAvailableNum() == 0) {
-            //GPT车队 额外增加车位 并不让上车
-            newRelation = getChatGPTOutsideRelation(orderDon.getUserId(), groupId, 1);
+        if (Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && groups.getAvailableNum() == 0) {
+            //Ai车队 额外增加车位 并不让上车
+            newRelation = getChatGPTOutsideRelation(orderDon.getUserId(), groupId, relationNum, 1);
         } else {
             newRelation = getRelationThisTrips(orderDon.getUserId(), groupId, 1);
         }
@@ -665,9 +666,9 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         return relation;
     }
 
-    private GroupsRelation getChatGPTOutsideRelation(Long userId, Long groupsId, Integer retryNum) {
+    private GroupsRelation getChatGPTOutsideRelation(Long userId, Long groupsId, Integer relationNum, Integer retryNum) {
         //寻找快满编车队额外座位
-        GroupsRelation relation = relationMapper.selectOutsideRelationByGroupsId(groupsId);
+        GroupsRelation relation = relationMapper.selectOutsideRelationByGroupsId(groupsId, relationNum);
         if (relation == null) {
             relation = new GroupsRelation();
             relation.setStatus(GroupsRelation.Status.outside);
@@ -682,7 +683,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         if (!redisService.setNx(RedisKey.GROUPS_RELATION_NUM_KEY + relationId, userId, 60 * 5L)) {
             if (retryNum == 7) throw BusinessRuntimeException.getInstance("该车队人员已满,请选择另一车队");
             retryNum++;
-            getChatGPTOutsideRelation(userId, groupsId, retryNum);
+            getChatGPTOutsideRelation(userId, groupsId, relationNum, retryNum);
         }
         return relation;
     }

+ 2 - 13
netflix-service/src/main/java/com/cyksj/service/scheduler/impl/SchedulerServiceImpl.java

@@ -139,7 +139,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 			Date expiryTime = DateUtil.beginOfDay(relationView.getExpiryTime());
 			Long skuId = relationView.getSkuId();
 			//仅针对chatGPT
-			if (relationView.getGoodsId() == 18) {
+			if (Constant.AI_goodsIds.contains(relationView.getGoodsId())) {
 				Long bet_day = DateUtil.between(now, expiryTime, DateUnit.DAY);
 				//10人月付 10天内硬塞20个 10天外硬塞10个
 				//4人月付 硬塞5个
@@ -177,7 +177,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 						}
 						//清除车票
 						GroupsRelation relation = groupsRelationMapper.selectById(change_relationId);
-						groupRelationClearService.clearTicket(relation, source);
+						groupRelationClearService.clearTicket(relation, UserTicketClearedRecord.Source.refund_balance);
 						//退款至余额
 						//实付金额 + 余额
 						BigDecimal money = orderDon.getMoney().add(orderDon.getBalance());
@@ -248,17 +248,6 @@ public class SchedulerServiceImpl implements SchedulerService {
 				changeTickerRelation(item_groupsId, relationView, source);
 				return;
 			}
-			if (relationView.getGoodsId() == 26) {
-				//移入合适车队
-				Long item_groupsId = groupsMapper.selectMidJourneySameSpecItemGroups(g_groupsId, skuId, expiryTime);
-				if (item_groupsId == null) {
-					//midJourney 无合适车队
-					log.error("midJourney账号过期groupsId:{},用户车票relation_id:{}", g_groupsId, change_relationId);
-					changeErrorRecordService.changeTicketErrorRecord(relationView, UserRelationChangeErrorRecord.Source.change);
-					return;
-				}
-				changeTickerRelation(item_groupsId, relationView, source);
-			}
 		});
 	}
 

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/CmsOrderController.java

@@ -533,7 +533,7 @@ public class CmsOrderController {
 				.field(EmptyGroupsRelationView::getSkuId, skuId).orderBy(EmptyGroupsRelationView::getAvailableNum)
 				.desc();
 		GoodsDonSku sku = skuMapper.selectById(skuId);
-		if (sku.getGoodsId() != 18) {
+		if (!Constant.AI_goodsIds.contains(sku.getGoodsId())) {
 			builder.field(EmptyGroupsRelationView::getAvailableNum, 0).op(Operator.GreaterThan);
 		}
 		SearchResult<EmptyGroupsRelationView> search = beanSearcher.search(EmptyGroupsRelationView.class,