Authored by LUOXC

Merge branch 'test6.9.9' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.9

@@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Param; @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Param;
7 import java.util.List; 7 import java.util.List;
8 8
9 public interface StorageDepositMapper { 9 public interface StorageDepositMapper {
10 - int deleteByPrimaryKey(Integer id);  
11 10
12 int insert(StorageDeposit record); 11 int insert(StorageDeposit record);
13 12
@@ -88,4 +87,11 @@ public interface StorageDepositMapper { @@ -88,4 +87,11 @@ public interface StorageDepositMapper {
88 * @return 87 * @return
89 */ 88 */
90 int updateDelStatusByCode(@Param("uid")Integer uid, @Param("depositCode")String depositCode, @Param("status")Integer status); 89 int updateDelStatusByCode(@Param("uid")Integer uid, @Param("depositCode")String depositCode, @Param("status")Integer status);
  90 +
  91 +
  92 + int updateStorageShelveStatusByCAS(@Param("uid")int uid,
  93 + @Param("depositCode")String depositCode,
  94 + @Param("status")int status,
  95 + @Param("expectStatus")int expectStatus
  96 + );
91 } 97 }
@@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
43 from storage_deposit 43 from storage_deposit
44 where id = #{id,jdbcType=INTEGER} 44 where id = #{id,jdbcType=INTEGER}
45 </select> 45 </select>
  46 +
46 <select id="queryByDepositCode" resultMap="BaseResultMap"> 47 <select id="queryByDepositCode" resultMap="BaseResultMap">
47 select 48 select
48 <include refid="Base_Column_List" /> 49 <include refid="Base_Column_List" />
@@ -50,10 +51,6 @@ @@ -50,10 +51,6 @@
50 where deposit_code = #{depositCode} and del_status=0 and owner_uid=#{uid} 51 where deposit_code = #{depositCode} and del_status=0 and owner_uid=#{uid}
51 </select> 52 </select>
52 53
53 - <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >  
54 - delete from storage_deposit  
55 - where id = #{id,jdbcType=INTEGER}  
56 - </delete>  
57 <insert id="insert" parameterType="com.yohoufo.dal.order.model.StorageDeposit" > 54 <insert id="insert" parameterType="com.yohoufo.dal.order.model.StorageDeposit" >
58 insert into storage_deposit (id, product_id, goods_id, 55 insert into storage_deposit (id, product_id, goods_id,
59 storage_id, deposit_code, shelf_code, 56 storage_id, deposit_code, shelf_code,
@@ -283,7 +280,11 @@ @@ -283,7 +280,11 @@
283 </select> 280 </select>
284 281
285 <select id="queryUserDepositProduct" resultMap="CountResultMap"> 282 <select id="queryUserDepositProduct" resultMap="CountResultMap">
286 - select product_id , count(distinct storage_id) as storage_id_count,count(*) as storage_count,sum( if( order_status = 0, 1, 0)) as un_shelf_storage_count,max(skup) as skup from storage_deposit 283 + select product_id ,
  284 + count(distinct storage_id) as storage_id_count,
  285 + count(*) as storage_count,
  286 + sum( if( order_status = 0, 1, 0)) as un_shelf_storage_count,
  287 + max(skup) as skup from storage_deposit
287 where owner_uid = #{uid} and status=1 and del_status=0 288 where owner_uid = #{uid} and status=1 and del_status=0
288 and product_id in 289 and product_id in
289 <foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")"> 290 <foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")">
@@ -291,10 +292,12 @@ @@ -291,10 +292,12 @@
291 </foreach> 292 </foreach>
292 group by product_id 293 group by product_id
293 </select> 294 </select>
  295 +
294 <select id="queryUserDopositBackCount" resultType="java.lang.Integer" parameterType="java.lang.Integer" > 296 <select id="queryUserDopositBackCount" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
295 select count(*) from storage_deposit 297 select count(*) from storage_deposit
296 where owner_uid = #{uid} and status in(2,3,4,5) and out_type in(1,3) and del_status=0 298 where owner_uid = #{uid} and status in(2,3,4,5) and out_type in(1,3) and del_status=0
297 </select> 299 </select>
  300 +
298 <select id="queryUserDopositBack" resultMap="BaseResultMap"> 301 <select id="queryUserDopositBack" resultMap="BaseResultMap">
299 select * from storage_deposit 302 select * from storage_deposit
300 where owner_uid = #{uid} and status in(2,3,4,5) and out_type in(1,3) and del_status=0 303 where owner_uid = #{uid} and status in(2,3,4,5) and out_type in(1,3) and del_status=0
@@ -331,7 +334,8 @@ @@ -331,7 +334,8 @@
331 334
332 <select id="getDepositOffs" resultMap="BaseResultMap"> 335 <select id="getDepositOffs" resultMap="BaseResultMap">
333 select * from storage_deposit 336 select * from storage_deposit
334 - where owner_uid = #{uid} and storage_id = #{storageId} and status=1 and order_status=0 and del_status=0 limit 0, #{count} 337 + where owner_uid = #{uid} and storage_id = #{storageId}
  338 + and status=1 and order_status=0 and del_status=0 limit 0, #{count}
335 </select> 339 </select>
336 340
337 <select id="selectByDepositCode" resultMap="BaseResultMap"> 341 <select id="selectByDepositCode" resultMap="BaseResultMap">
@@ -350,7 +354,10 @@ @@ -350,7 +354,10 @@
350 <if test="outType != null" > 354 <if test="outType != null" >
351 , out_type = #{outType} 355 , out_type = #{outType}
352 </if> 356 </if>
353 - where id = #{depositId,jdbcType=INTEGER} AND del_status = 0 AND order_status = #{orderStatus,jdbcType=INTEGER} AND owner_uid = #{uid,jdbcType=INTEGER} 357 + where id = #{depositId,jdbcType=INTEGER}
  358 + AND del_status = 0
  359 + AND order_status = #{orderStatus,jdbcType=INTEGER}
  360 + AND owner_uid = #{uid,jdbcType=INTEGER}
354 </update> 361 </update>
355 362
356 <select id="selectByOrderCode" resultMap="BaseResultMap"> 363 <select id="selectByOrderCode" resultMap="BaseResultMap">
@@ -401,6 +408,17 @@ @@ -401,6 +408,17 @@
401 <update id="updateDelStatusByCode"> 408 <update id="updateDelStatusByCode">
402 update storage_deposit 409 update storage_deposit
403 set del_status = 1, update_time = unix_timestamp(now()) 410 set del_status = 1, update_time = unix_timestamp(now())
404 - where deposit_code = #{depositCode,jdbcType=VARCHAR} AND del_status = 0 AND owner_uid = #{uid,jdbcType=INTEGER} AND status = #{status,jdbcType=INTEGER} 411 + where deposit_code = #{depositCode,jdbcType=VARCHAR}
  412 + AND del_status = 0 AND owner_uid = #{uid,jdbcType=INTEGER}
  413 + AND status = #{status,jdbcType=INTEGER}
  414 + </update>
  415 +
  416 +
  417 + <update id="updateStorageShelveStatusByCAS">
  418 + update storage_deposit
  419 + set order_status = #{status,jdbcType=INTEGER} ,update_time = unix_timestamp(now())
  420 + where owner_uid = #{uid,jdbcType=INTEGER}
  421 + and deposit_code = #{depositCode,jdbcType=VARCHAR}
  422 + AND order_status = #{expectStatus,jdbcType=INTEGER}
405 </update> 423 </update>
406 </mapper> 424 </mapper>
@@ -33,6 +33,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; @@ -33,6 +33,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService;
33 import com.yohoufo.order.service.proxy.SellerNoticeFacade; 33 import com.yohoufo.order.service.proxy.SellerNoticeFacade;
34 import com.yohoufo.order.service.seller.SkupService; 34 import com.yohoufo.order.service.seller.SkupService;
35 import com.yohoufo.order.utils.LoggerUtils; 35 import com.yohoufo.order.utils.LoggerUtils;
  36 +import org.apache.commons.collections.CollectionUtils;
36 import org.slf4j.Logger; 37 import org.slf4j.Logger;
37 import org.springframework.beans.factory.annotation.Autowired; 38 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.stereotype.Service; 39 import org.springframework.stereotype.Service;
@@ -309,9 +310,34 @@ public class DepositServiceImpl implements DepositService { @@ -309,9 +310,34 @@ public class DepositServiceImpl implements DepositService {
309 return successList; 310 return successList;
310 } 311 }
311 312
312 - // 批量上架-查询 313 + /**
  314 + * 批量上架-查询
  315 + * TODO 应当锁定相关记录,加中间状态
  316 + * @param uid
  317 + * @param storageId
  318 + * @param num
  319 + * @return
  320 + */
313 public List<StorageDeposit> getStorageDeposit4Publish(Integer uid, Integer storageId, int num) { 321 public List<StorageDeposit> getStorageDeposit4Publish(Integer uid, Integer storageId, int num) {
314 - return storageDepositMapper.getDepositOffs(uid, storageId, num); 322 + List<StorageDeposit> sdList = storageDepositMapper.getDepositOffs(uid, storageId, num);
  323 + if (CollectionUtils.isEmpty(sdList)){
  324 + LOGGER.warn("in getStorageDeposit4Publish StorageDeposit empty, uid {} storageId {} num {}",
  325 + uid, storageId, num);
  326 + return sdList;
  327 + }
  328 + /*
  329 + List<StorageDeposit> lockedList = new ArrayList<>(sdList.size());
  330 + for (StorageDeposit sd : sdList){
  331 +
  332 + int rows= storageDepositMapper.updateStorageShelveStatusByCAS(uid, sd.getDepositCode(), 11, 0);
  333 + if(rows == 1){
  334 + lockedList.add(sd);
  335 + }else{
  336 + LOGGER.warn("getStorageDeposit4Publish updateStorageShelveStatusByCAS fail ,{}", sd);
  337 + }
  338 + return lockedList;
  339 + */
  340 + return sdList;
315 } 341 }
316 342
317 // 批量下架 343 // 批量下架