Selaa lähdekoodia

fix 分配车位数

zoujiajian 3 vuotta sitten
vanhempi
sitoutus
defd027787

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

@@ -32,7 +32,7 @@ public interface GroupsMapper extends BaseMapper<GroupsTrips> {
 
 	List<GroupsTrips> getExpiryAccountGroups(@Param("nextBeginDay") DateTime nextBeginDay, @Param("list") List<Long> aiSkuIds);
 
-	Long selectSameSpecItemGroupsByTime(@Param("groupsId") Long groupsId, @Param("skuId") Long skuId, @Param("expiryTime") Date expiryTime, @Param("betDay") DateTime betDay, @Param("isOverTen") Boolean isOverTen);
+	Long selectSameSpecItemGroupsByTime(@Param("groupsId") Long groupsId, @Param("skuId") Long skuId, @Param("expiryTime") Date expiryTime, @Param("betDay") DateTime betDay, @Param("extraNum") Integer extraNum);
 
 	Long selectSameSpecEmptyGroups(Long skuId);
 

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

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

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

@@ -46,15 +46,7 @@
         and a.expiry_time >= #{expiryTime}
         and a.expiry_time &lt;= #{betDay}
         and (select count(*) from groups_relation gr where gr.status ='outside' and gr.groups_id = gt.id and
-        gr.user_id != 0) &lt;
-        <choose>
-            <when test="!isOverTen">
-                20
-            </when>
-            <otherwise>
-                10
-            </otherwise>
-        </choose>
+        gr.user_id != 0) &lt; #{extraNum}
         order by gt.available_num asc limit 1
     </select>
 

+ 19 - 10
netflix-service/src/main/java/com/cyksj/service/scheduler/impl/SchedulerServiceImpl.java

@@ -90,7 +90,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 					.field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
 					.field(GroupsRelationView::getExpiryTime, nextBeginDay).op(Operator.GreaterEqual)
 					.build());
-			reAssign(g_groupsId, now, groupsRelations);
+			reAssign(g_groupsId, now, groupsRelations, UserTicketClearedRecord.Source.timing_change_ticket);
 		});
 	}
 
@@ -113,14 +113,14 @@ public class SchedulerServiceImpl implements SchedulerService {
 				.field(GroupsRelationView::getStatus, List.of(GroupsRelation.Status.validity.name(), GroupsRelation.Status.outside.name())).op(Operator.InList)
 				.field(GroupsRelationView::getExpiryTime, now).op(Operator.GreaterEqual)
 				.build());
-		reAssign(groupsId, now, groupsRelations);
+		reAssign(groupsId, now, groupsRelations, UserTicketClearedRecord.Source.disable);
 		redisService.del(key);
 	}
 
 	/**
 	 * 重新分配车位
 	 */
-	public void reAssign(Long g_groupsId, DateTime now, List<GroupsRelationView> groupsRelations) {
+	public void reAssign(Long g_groupsId, DateTime now, List<GroupsRelationView> groupsRelations, UserTicketClearedRecord.Source source) {
 		log.info("迁移groupsId:{}未过期用户数量:{}", g_groupsId, groupsRelations.size());
 		Map<Long, GoodsDon> goodsMap = new ConcurrentHashMap<>();
 		Map<Long, GoodsDonSku> skuMap = new ConcurrentHashMap<>();
@@ -136,16 +136,22 @@ public class SchedulerServiceImpl implements SchedulerService {
 				log.info("存在userId:{}无法转移的车票relationId:{}", userId, change_relationId);
 				return;
 			}
-			Date expiryTime = relationView.getExpiryTime();
+			Date expiryTime = DateUtil.beginOfDay(relationView.getExpiryTime());
 			Long skuId = relationView.getSkuId();
 			//仅针对chatGPT
 			if (relationView.getGoodsId() == 18) {
 				Long bet_day = DateUtil.between(now, expiryTime, DateUnit.DAY);
+				//10人月付 10天内硬塞20个 10天外硬塞10个
+				//4人月付 硬塞5个
+				Integer extra_num = 5;
 				//10天以内
 				if (bet_day <= 10) {
+					if (skuId.equals(161l)) {
+						extra_num = 20;
+					}
 					//分配到过期账号5天内误差的相同规格车队里
 					DateTime five_day = DateUtil.offsetDay(expiryTime, 5);
-					Long item_groupsId = groupsMapper.selectSameSpecItemGroupsByTime(g_groupsId, skuId, expiryTime, five_day, false);
+					Long item_groupsId = groupsMapper.selectSameSpecItemGroupsByTime(g_groupsId, skuId, expiryTime, five_day, extra_num);
 					if (item_groupsId == null) {
 						//无对应车队 退款
 						//退款至余额
@@ -171,7 +177,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 						}
 						//清除车票
 						GroupsRelation relation = groupsRelationMapper.selectById(change_relationId);
-						groupRelationClearService.clearTicket(relation, UserTicketClearedRecord.Source.timing_change_ticket);
+						groupRelationClearService.clearTicket(relation, source);
 						//退款至余额
 						//实付金额 + 余额
 						BigDecimal money = orderDon.getMoney().add(orderDon.getBalance());
@@ -215,13 +221,16 @@ public class SchedulerServiceImpl implements SchedulerService {
 						cmsOrderDonService.refundRecord(orderDon, goodsDon, sku, StrUtil.EMPTY, "balance");
 						return;
 					}
-					changeTickerRelation(item_groupsId, relationView, UserTicketClearedRecord.Source.timing_change_ticket);
+					changeTickerRelation(item_groupsId, relationView, source);
 					return;
 				}
 				//大于10天
 				//分配到过期账号10天内误差的相同规格车队里
+				if (skuId.equals(161l)) {
+					extra_num = 10;
+				}
 				DateTime ten_day = DateUtil.offsetDay(expiryTime, 10);
-				Long item_groupsId = groupsMapper.selectSameSpecItemGroupsByTime(g_groupsId, skuId, expiryTime, ten_day, true);
+				Long item_groupsId = groupsMapper.selectSameSpecItemGroupsByTime(g_groupsId, skuId, expiryTime, ten_day, extra_num);
 				if (item_groupsId == null) {
 					//无对应车队 生成空车队
 					//寻找空车队
@@ -236,7 +245,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 					changeTickerRelation(item_groupsId, relationView, UserTicketClearedRecord.Source.new_groups_ticket);
 					return;
 				}
-				changeTickerRelation(item_groupsId, relationView, UserTicketClearedRecord.Source.timing_change_ticket);
+				changeTickerRelation(item_groupsId, relationView, source);
 				return;
 			}
 			if (relationView.getGoodsId() == 26) {
@@ -248,7 +257,7 @@ public class SchedulerServiceImpl implements SchedulerService {
 					changeErrorRecordService.changeTicketErrorRecord(relationView, UserRelationChangeErrorRecord.Source.change);
 					return;
 				}
-				changeTickerRelation(item_groupsId, relationView, UserTicketClearedRecord.Source.timing_change_ticket);
+				changeTickerRelation(item_groupsId, relationView, source);
 			}
 		});
 	}

+ 1 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupRelationController.java

@@ -35,6 +35,7 @@ public class CmsGroupRelationController {
     @GetMapping("/get")
     public Result<List<GroupsRelationView>> get(){
         List<GroupsRelationView> search = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.flatBuilder(request.getParameterMap())
+                .field(GroupsRelationView::getUserId, 0).op(Operator.NotEqual)
                 .field(GroupsRelationView::getStatus, GroupsRelation.Status.none.toString()).op(Operator.NotEqual).build()
         );
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);