Kaynağa Gözat

fix 车位数可用库存规则修改;预警数可为负数

zoujiajian 2 yıl önce
ebeveyn
işleme
d8b8acf7b8

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

@@ -54,7 +54,9 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 
 	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 selectAvailableRelation(@Param("skuId") Long skuId, @Param("skuNum") Integer skuNum);
 
-	Integer selectSpecialGroupsRelationAvailable(@Param("skuId") Long skuId, @Param("maxNum") Integer maxNum, @Param("extractNum") Integer extractNum, @Param("tenExpiry") DateTime tenExpiry);
+	Integer selectSpecialGroupsRelationAvailable(@Param("skuId") Long skuId, @Param("maxNum") Integer maxNum, @Param("skuNum") Integer skuNum, @Param("extractNum") Integer extractNum, @Param("tenExpiry") DateTime tenExpiry);
+
+	Integer selectNumWaitingGroups(Long skuId);
 }

+ 0 - 2
netflix-dao/src/main/java/com/cyksj/model/entity/GroupsRelationAlert.java

@@ -3,7 +3,6 @@ package com.cyksj.model.entity;
 import lombok.Getter;
 import lombok.Setter;
 
-import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 
 /**
@@ -26,7 +25,6 @@ public class GroupsRelationAlert extends BaseEntity{
 	 * 预警数量
 	 */
 	@NotNull(message = "预警数量不为空")
-	@Min(value = 0, message = "请输入正确的库存预警数量")
 	private Integer num;
 
 	/**

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

@@ -245,28 +245,38 @@
             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'
+            and gr.status in ('none','locking')
+            and gr.num &lt;= #{skuNum}
     </select>
 
     <select id="selectSpecialGroupsRelationAvailable" resultType="java.lang.Integer">
-        select ifnull(sum(a1+(#{extractNum}-t1)),0) 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) = 0
+        select ifnull(sum(a1 + (#{extractNum} - t1)), 0)
+        from (select gt.id,
+                     (select count(*)
+                      from groups_relation gr2
+                      where gr2.groups_id = gt.id
+                        and num > #{skuNum}
+                        and num &lt;= #{maxNum})                         t1,
+                     (select count(*)
+                      from groups_relation gr2
+                      where gr2.groups_id = gt.id
+                        and num > #{skuNum}
+                        and num &lt;= #{maxNum}
+                        and (gr2.user_id = 0 or gr2.status = 'locking')) 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) = 0
+    </select>
+
+    <select id="selectNumWaitingGroups" resultType="java.lang.Integer">
+        select count(gr.id)
+        from `groups_trips` gt
+                 inner join groups_relation gr on gr.groups_id = gt.id
+            and gt.`status` = 'waiting'
+            and gt.sku_id = #{skuId}
+            and gr.status = 'validity'
     </select>
 </mapper>

+ 9 - 3
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -377,16 +377,22 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
             Integer extraNum = Constant.AI_EXTRACT_NUM;
             Integer maxNum = skuNum + extraNum;
             DateTime tenExpiry = DateUtil.offsetDay(DateTime.now(), 10);
-            Integer available = relationMapper.selectAvailableRelation(skuId);
+            Integer available = relationMapper.selectAvailableRelation(skuId, skuNum);
             //额外硬塞
-            Integer special_available = relationMapper.selectSpecialGroupsRelationAvailable(skuId, maxNum, extraNum, tenExpiry);
+            Integer special_available = relationMapper.selectSpecialGroupsRelationAvailable(skuId, maxNum, skuNum, extraNum, tenExpiry);
             available += special_available;
             available = getAvailableAfterPreAccount(available, skuId, maxNum, goodsId);
+            //待发车已有人员成功上车
+            Integer waitingNum = relationMapper.selectNumWaitingGroups(skuId);
+            available -= waitingNum;
             return available;
         }
 
-        Integer available = relationMapper.selectAvailableRelation(skuId);
+        Integer available = relationMapper.selectAvailableRelation(skuId, skuNum);
         available = getAvailableAfterPreAccount(available, skuId, skuNum, goodsId);
+        //待发车已有人员成功上车
+        Integer waitingNum = relationMapper.selectNumWaitingGroups(skuId);
+        available -= waitingNum;
         return available;
     }