Authored by caoyan

Merge branch 'master' of http://git.yoho.cn/ufo/ufo-platform

@@ -175,17 +175,31 @@ @@ -175,17 +175,31 @@
175 </update> 175 </update>
176 176
177 <select id="selectProductStorageCount" resultType="java.lang.Integer"> 177 <select id="selectProductStorageCount" resultType="java.lang.Integer">
178 - select count(*) from product p where <include refid="skcPageCondition" /> 178 + select
  179 + <if test="product.storageNum != null"> count(DISTINCT p.id) </if>
  180 + <if test="product.storageNum == null"> count(p.id) </if>
  181 + from product p where
  182 + <include refid="skcPageCondition" />
179 </select> 183 </select>
180 184
181 <select id="selectProductStorageList" resultMap="BaseResultMap"> 185 <select id="selectProductStorageList" resultMap="BaseResultMap">
182 - select id, brand_id, product_name, max_sort_id, mid_sort_id 186 + select
  187 + <if test="product.storageNum != null"> DISTINCT p.id, p.brand_id, p.product_name, p.max_sort_id, p.mid_sort_id </if>
  188 + <if test="product.storageNum == null"> p.id, p.brand_id, p.product_name, p.max_sort_id, p.mid_sort_id </if>
183 from product p 189 from product p
184 where <include refid="skcPageCondition" /> limit #{start},#{rows} 190 where <include refid="skcPageCondition" /> limit #{start},#{rows}
185 </select> 191 </select>
186 192
187 <sql id="skcPageCondition"> 193 <sql id="skcPageCondition">
188 1 = 1 194 1 = 1
  195 + <if test="product.storageNum != null">
  196 + <if test="product.storageNum == 0">
  197 + And exists(SELECT 1 FROM storage s WHERE s.storage_num = 0 AND s.product_id= p.id)
  198 + </if>
  199 + <if test="product.storageNum != 0">
  200 + And exists(SELECT 1 FROM storage s WHERE s.storage_num >= 1 AND s.product_id= p.id)
  201 + </if>
  202 + </if>
189 <if test="product.id != null and product.id > 0"> 203 <if test="product.id != null and product.id > 0">
190 and p.id = #{product.id} 204 and p.id = #{product.id}
191 </if> 205 </if>
@@ -52,7 +52,7 @@ public class StorageService { @@ -52,7 +52,7 @@ public class StorageService {
52 52
53 // 如果查询条件含storage_price,先根据条件查询出productId列表 ,再到product表中联合查询 53 // 如果查询条件含storage_price,先根据条件查询出productId列表 ,再到product表中联合查询
54 List<Integer> integerList = storagePriceService.selectProductIdBySkupInfo(product); 54 List<Integer> integerList = storagePriceService.selectProductIdBySkupInfo(product);
55 - if (null != integerList && integerList.isEmpty()) { 55 + if (null != integerList && integerList.isEmpty()) { // 返回空列表,代表查询了storage_price表,但是查询的接口是空,再联合查询肯定也是空,所有直接返回空
56 LOGGER.warn("storagePriceService.selectProductIdBySkupInfo count is 0.param = {}", bo); 56 LOGGER.warn("storagePriceService.selectProductIdBySkupInfo count is 0.param = {}", bo);
57 return new PageResponseBO<>(); 57 return new PageResponseBO<>();
58 } 58 }