Parcourir la source

针对平台规格 展示对应的可用车位数

zoujiajian il y a 2 ans
Parent
commit
9b20389a54

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

@@ -212,4 +212,9 @@ public interface Constant {
 	 * 通知手机号
 	 */
 	String SERVICE_PHONE = "18658194165";
+
+	/**
+	 * AI 车票额外座位数
+	 */
+	Integer AI_EXTRACT_NUM = 5;
 }

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

@@ -53,4 +53,8 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 	Page<UserRecommendGoodsFrontView> getRecommendGoodsViews(@Param("page") Page<UserRecommendGoodsFrontView> page, @Param("list") List<Long> filter_goods_id, @Param("isPayNf") Boolean isPayNf);
 
 	Long getOutSideGroupsTripsRelationByGoodsId(@Param("skuId") Long skuId, @Param("beginOfDay") DateTime beginOfDay, @Param("extraNum") Integer extraNum, @Param("userId") Long userId);
+
+	Integer selectAvailableRelation(@Param("skuId") Long skuId);
+
+	Integer selectSpecialGroupsRelationAvailable(@Param("skuId") Long skuId, @Param("maxNum") Integer maxNum, @Param("extractNum") Integer extractNum, @Param("tenExpiry") DateTime tenExpiry);
 }

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

@@ -237,4 +237,36 @@
             = #{userId}) = 0
         order by RAND() limit 1
     </select>
+
+    <select id="selectAvailableRelation" resultType="java.lang.Integer">
+        select count(gr.id)
+        from account a
+                 inner join `groups_trips` gt on gt.account_id = a.id
+            and gt.`status` = 'validity'
+            and gt.sku_id = #{skuId}
+                 inner join groups_relation gr on gr.groups_id = gt.id
+            and gr.user_id = 0
+            and gr.status = 'none'
+    </select>
+
+    <select id="selectSpecialGroupsRelationAvailable" resultType="java.lang.Integer">
+        select a1+(#{extractNum}-t1) from
+                                         (select gt.id,
+        (select count(*)
+        from groups_relation gr2
+        where gr2.groups_id = gt.id
+        and status = 'outside'
+        and num lt;= #{maxNum}) t1,
+        (select count(*)
+        from groups_relation gr2
+        where gr2.groups_id = gt.id
+        and user_id = 0
+        and status = 'outside'
+        and num lt;= #{maxNum}) a1
+        from account a
+        inner join `groups_trips` gt on gt.account_id = a.id
+        and gt.`status` = 'validity'
+        and gt.sku_id = #{skuId}
+        and a.expiry_time >= #{tenExpiry}) s where t1 != 5 and a1 = 0
+    </select>
 </mapper>

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/CmsGroupService.java

@@ -17,4 +17,6 @@ public interface CmsGroupService extends IService<GroupsTrips> {
     void setAccount(GroupsTrips groupsTrips) throws Exception;
 
     void replaceTripsAccount(ReplaceTripsAccountReq req);
+
+	Integer getAvailableRelation(Long goodsId, Long skuId);
 }

+ 19 - 6
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -12,7 +12,6 @@ import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
 import com.cyksj.dto.RedisKey;
 import com.cyksj.mapper.*;
-import com.cyksj.mapper.manage.DelGroupsTripsRecordMapper;
 import com.cyksj.mapper.manage.GroupsTripsAccountReplaceRecordMapper;
 import com.cyksj.mapper.manage.cms.CmsUserMapper;
 import com.cyksj.model.entity.*;
@@ -67,14 +66,9 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
 
     private final RedisService redisService;
 
-    private final DelGroupsTripsRecordMapper delGroupsTripsRecordMapper;
-
     private final GroupsMapper groupsMapper;
 
     private final AccountCommonService accountCommonService;
-
-    private final OrderDiscountPlusPurchaseSkuRelationMapper discountPlusPurchaseSkuRelationMapper;
-
     private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
 
 
@@ -339,6 +333,25 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
         TASK_EXECUTOR.execute(() -> sendChangeAccountMsg(groupsId, goodsId));;
     }
 
+    @Override
+    public Integer getAvailableRelation(Long goodsId, Long skuId) {
+        //chatGPT
+        GoodsDonSku sku = skuMapper.selectById(skuId);
+        Integer num = sku.getNum();
+        if (Constant.AI_goodsIds.contains(sku.getGoodsId()) && sku.getNum() > 1) {
+            Integer extraNum = Constant.AI_EXTRACT_NUM;
+            Integer maxNum = num + extraNum;
+            DateTime tenExpiry = DateUtil.offsetDay(DateTime.now(), 10);
+            Integer available = relationMapper.selectAvailableRelation(skuId);
+            //额外硬塞
+            Integer special_available = relationMapper.selectSpecialGroupsRelationAvailable(skuId, maxNum, extraNum, tenExpiry);
+            return special_available + available;
+        }
+
+        Integer available = relationMapper.selectAvailableRelation(skuId);
+        return available;
+    }
+
     private void sendChangeAccountMsg(Long groupsId, Long goodsId) {
         GoodsDon goodsDon = goodsDonMapper.selectById(goodsId);
         String title = goodsDon != null ? goodsDon.getTitle() : "车票";

+ 9 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupController.java

@@ -331,4 +331,13 @@ public class CmsGroupController {
         re.putOpt("time", time);
         return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
     }
+
+    /**
+     * 获取该规格下可用车位数
+     */
+    @GetMapping("/get/available/relation")
+    public Result<Integer> getAvailableRelation(Long goodsId, Long skuId) {
+        Integer available = groupService.getAvailableRelation(goodsId, skuId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(available);
+    }
 }