ソースを参照

MJ车票统一ip不允许上同一车次

zoujiajian 2 年 前
コミット
82f22896d2

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

@@ -31,7 +31,7 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 	@Update("update groups_relation set customer_service = null where id = #{id}")
 	void updateCustomerService(Long id);
 
-	Long selectSimilarExpiredRelation(@Param("skuId") Long skuId, @Param("minExpiryTime") DateTime minExpiryTime, @Param("maxNum") Integer maxNum);
+	Long selectSimilarExpiredRelation(@Param("skuId") Long skuId, @Param("minExpiryTime") DateTime minExpiryTime, @Param("maxNum") Integer maxNum, @Param("ip") String ip);
 
 	List<GroupsRelationView> selectRelationByGoodsId(@Param("goodsId") Long goodsId, @Param("userId") Long userId, @Param("yhsId") Long yhsId);
 

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

@@ -12,7 +12,6 @@
         user_id = #{entity.userId},
         account = null,
         customer_service = null,
-        verify_code = null,
         password = null,
         recharge_status = null,
         send_time = null,
@@ -49,17 +48,24 @@
     <select id="selectSimilarExpiredRelation" resultType="java.lang.Long">
         select s.id
         from (select gt.id, min(gr.expiry_time) minExpiryTime
-              from `groups_trips` gt
-                       left join `groups_relation` gr on gr.groups_id = gt.id
-              where gt.sku_id = #{skuId}
-                and (gt.available_parking_num = 0 or (select count(*) from groups_relation gr where gr.groups_id = gt.id and gr.user_id != 0 and gr.num &lt;= #{maxNum}) &lt; gt.available_parking_num)
-                and gt.available_num > 0
-                and gt.status = 'validity'
-                and gr.status = 'validity'
-                and gr.user_id != 0
-              and gr.expiry_time is not null
-              group by gr.groups_id) s
+        from `groups_trips` gt
+        left join `groups_relation` gr on gr.groups_id = gt.id
+        where gt.sku_id = #{skuId}
+        and (gt.available_parking_num = 0 or (select count(*)
+        from groups_relation gr
+        where gr.groups_id = gt.id and gr.user_id != 0 and gr.num &lt;=
+        #{maxNum}) &lt; gt.available_parking_num) and gt.available_num > 0
+        and gt.status = 'validity'
+        and gr.status = 'validity'
+        and gr.user_id != 0
+        and gr.expiry_time is not null
+        group by gr.groups_id) s
         where s.minExpiryTime >= #{minExpiryTime}
+        <if test="ip != null">
+            and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = s.id and gnr.user_id != 0) gr inner join
+            order_don o on o.user_id = gr.user_id and o.relation_id = gr.id
+            inner join order_don_location_relate ocr on ocr.order_id = o.id where ocr.ip = #{ip} limit 1)
+        </if>
         order by minExpiryTime desc limit 1
     </select>
 
@@ -108,6 +114,11 @@
         where groups_id = #{groupsId}
           and user_id = 0
           and status = 'none'
+        <if test="ip != null">
+            and not exists (select 1 from (select id, user_id from groups_relation gnr where gnr.groups_id = groups_id and gnr.user_id != 0) gr inner join
+            order_don o on o.user_id = gr.user_id and o.relation_id = gr.id
+            inner join order_don_location_relate ocr on ocr.order_id = o.id where ocr.ip = #{ip} limit 1)
+        </if>
         order by rand() limit 1
     </select>
 

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

@@ -367,7 +367,7 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 
 	public GroupsRelation getFinalRelation(GoodsDonSku sku, Long userId, Integer retryNum, Long yhsId, List<Long> errorsRelationIds) {
 		//获取车票车位
-		GroupsRelation relation = groupRelationFrontService.getRelation(null, userId, sku);
+		GroupsRelation relation = groupRelationFrontService.getRelation(null, userId, sku, null);
 
 		try {
 			//锁定座位

+ 6 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -2028,8 +2028,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	public GroupsRelation getRelation(OrderPayRequest payRequest, GoodsDonSku sku, Long yhsId) {
 		Long payRelationId = payRequest.getRelationId();
 		Long userId = payRequest.getUserId();
+		String ip = null;
+		//MJ车票统一ip不允许上同一车次
+		if (sku.getGoodsId() == 26) {
+			ip = payRequest.getIp();
+		}
 		//获取车票车位
-		GroupsRelation relation = groupRelationFrontService.getRelation(payRelationId, userId, sku);
+		GroupsRelation relation = groupRelationFrontService.getRelation(payRelationId, userId, sku, ip);
 
 		//锁定座位
 		setRelation(relation);

+ 2 - 2
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -21,7 +21,7 @@ public interface GroupRelationFrontService {
 
 	Boolean isJoinCorpWx(Long userId, Boolean isJoin, Boolean noCoupon);
 
-	GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds);
+	GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds, String ip);
 
 	Page<UserRecommendGoodsFrontView> getRecommendGoodsViews(Boolean isPayNf, List<Long> filter_goods_id, Integer start, Integer limit);
 
@@ -33,7 +33,7 @@ public interface GroupRelationFrontService {
 	/**
 	 * 获取车票座位
 	 */
-	GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku);
+	GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku, String ip);
 
 	/**
 	 * 获取车票账号登录 验证码

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

@@ -268,7 +268,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 	}
 
 	@Override
-	public GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds) {
+	public GroupsRelation getSimilarExpiredGroupRelation(GoodsDonSku sku, List<Long> errorsRelationIds, String ip) {
 		Long skuId = sku.getId();
 		Integer days = sku.getDays();
 		Integer months = sku.getMonths();
@@ -285,7 +285,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 		maxNum += extraNum;
 		DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
-		Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime, maxNum);
+		Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime, maxNum, ip);
 		if (groupsId == null) {
 			log.info("暂无相似过期时间车队");
 			return null;
@@ -346,7 +346,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 	}
 
 	@Override
-	public GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku) {
+	public GroupsRelation getRelation(Long payRelationId, Long userId, GoodsDonSku sku, String ip) {
 		GroupsRelation relation = null;
 		Integer maxNum = sku.getNum();
 		if (payRelationId != null && payRelationId > 0) {
@@ -397,7 +397,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			}
 			if (groups == null) {
 				//寻找差不多过期时间规格的车位
-				relation = getSimilarExpiredGroupRelation(sku,null);
+				relation = getSimilarExpiredGroupRelation(sku, null, ip);
 				if (relation == null) {
 					//TODO 如果没指定座位,等待逻辑确认
 					groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)