Authored by Lixiaodi

bug修改

@@ -27,6 +27,8 @@ public interface StoragePriceMapper { @@ -27,6 +27,8 @@ public interface StoragePriceMapper {
27 27
28 int updateStatus(@Param("skup") Integer skup, @Param("status") Integer status, @Param("beforeStatus") Integer beforeStatus); 28 int updateStatus(@Param("skup") Integer skup, @Param("status") Integer status, @Param("beforeStatus") Integer beforeStatus);
29 29
  30 + int cancelSaleSecondHandSkupAfterPay(Integer skup);
  31 +
30 int batchUpdateStatus(@Param("skupList") List<Integer> skupList, @Param("status") Integer status); 32 int batchUpdateStatus(@Param("skupList") List<Integer> skupList, @Param("status") Integer status);
31 33
32 int updateDepotNum(@Param("skup") Integer skup, @Param("depotNum") Integer depotNum); 34 int updateDepotNum(@Param("skup") Integer skup, @Param("depotNum") Integer depotNum);
@@ -126,6 +126,11 @@ @@ -126,6 +126,11 @@
126 and status = #{beforeStatus} 126 and status = #{beforeStatus}
127 </if> 127 </if>
128 </update> 128 </update>
  129 + <update id="cancelSaleSecondHandSkupAfterPay">
  130 + update storage_price set status = 4,
  131 + update_time = unix_timestamp()
  132 + where skup = #{skup,jdbcType=INTEGER} and status in(1,10)
  133 + </update>
129 <update id="updateDepotNum"> 134 <update id="updateDepotNum">
130 update storage_price set depot_num = #{depotNum,jdbcType=INTEGER}, 135 update storage_price set depot_num = #{depotNum,jdbcType=INTEGER},
131 update_time = unix_timestamp() 136 update_time = unix_timestamp()
@@ -401,10 +401,19 @@ public class ProductServiceImpl implements ProductService { @@ -401,10 +401,19 @@ public class ProductServiceImpl implements ProductService {
401 if (sp == null) { 401 if (sp == null) {
402 throw new ServiceException(400, "商品(skup)不存在:" + skup); 402 throw new ServiceException(400, "商品(skup)不存在:" + skup);
403 } 403 }
404 -  
405 - int expectedStatus = (status == 4) ? 1 : 0;  
406 - if (sp.getStatus() == null || sp.getStatus() != expectedStatus) {  
407 - throw new ServiceException(400, "商品(skup)状态已变更:" + sp.getStatus()); 404 + if (sp.getPreSaleFlag() == null || sp.getStatus() == null) {
  405 + throw new ServiceException(400, "商品(skup)类型异常:" + skup);
  406 + }
  407 + boolean isSecondHand = (sp.getPreSaleFlag() == 5 || sp.getPreSaleFlag() == 6);
  408 + if (isSecondHand && status == 4) {
  409 + if (sp.getStatus() != 1 && sp.getStatus() != 10) {
  410 + throw new ServiceException(400, "商品(skup)状态已变更:" + sp.getStatus());
  411 + }
  412 + } else {
  413 + int expectedStatus = (status == 4) ? 1 : 0;
  414 + if (sp.getStatus() != expectedStatus) {
  415 + throw new ServiceException(400, "商品(skup)状态已变更:" + sp.getStatus());
  416 + }
408 } 417 }
409 418
410 // 使其可售 419 // 使其可售
@@ -423,7 +432,12 @@ public class ProductServiceImpl implements ProductService { @@ -423,7 +432,12 @@ public class ProductServiceImpl implements ProductService {
423 } 432 }
424 } 433 }
425 } else { 434 } else {
426 - if (storagePriceMapper.updateStatus(skup, status, 1) == 0) { 435 + // 4:支付保证金后取消售卖
  436 + if (isSecondHand) {
  437 + if (storagePriceMapper.cancelSaleSecondHandSkupAfterPay(skup) == 0) {
  438 + throw new ServiceException(400, "商品(skup)状态已变更");
  439 + }
  440 + } else if (storagePriceMapper.updateStatus(skup, status, 1) == 0) {
427 throw new ServiceException(400, "商品(skup)状态已变更"); 441 throw new ServiceException(400, "商品(skup)状态已变更");
428 } 442 }
429 addStorageNum(skup, sp.getStorageId(), -1); 443 addStorageNum(skup, sp.getStorageId(), -1);