Authored by Lixiaodi

bug修改

... ... @@ -27,6 +27,8 @@ public interface StoragePriceMapper {
int updateStatus(@Param("skup") Integer skup, @Param("status") Integer status, @Param("beforeStatus") Integer beforeStatus);
int cancelSaleSecondHandSkupAfterPay(Integer skup);
int batchUpdateStatus(@Param("skupList") List<Integer> skupList, @Param("status") Integer status);
int updateDepotNum(@Param("skup") Integer skup, @Param("depotNum") Integer depotNum);
... ...
... ... @@ -126,6 +126,11 @@
and status = #{beforeStatus}
</if>
</update>
<update id="cancelSaleSecondHandSkupAfterPay">
update storage_price set status = 4,
update_time = unix_timestamp()
where skup = #{skup,jdbcType=INTEGER} and status in(1,10)
</update>
<update id="updateDepotNum">
update storage_price set depot_num = #{depotNum,jdbcType=INTEGER},
update_time = unix_timestamp()
... ...
... ... @@ -401,11 +401,20 @@ public class ProductServiceImpl implements ProductService {
if (sp == null) {
throw new ServiceException(400, "商品(skup)不存在:" + skup);
}
if (sp.getPreSaleFlag() == null || sp.getStatus() == null) {
throw new ServiceException(400, "商品(skup)类型异常:" + skup);
}
boolean isSecondHand = (sp.getPreSaleFlag() == 5 || sp.getPreSaleFlag() == 6);
if (isSecondHand && status == 4) {
if (sp.getStatus() != 1 && sp.getStatus() != 10) {
throw new ServiceException(400, "商品(skup)状态已变更:" + sp.getStatus());
}
} else {
int expectedStatus = (status == 4) ? 1 : 0;
if (sp.getStatus() == null || sp.getStatus() != expectedStatus) {
if (sp.getStatus() != expectedStatus) {
throw new ServiceException(400, "商品(skup)状态已变更:" + sp.getStatus());
}
}
// 使其可售
if (status == 1) {
... ... @@ -423,7 +432,12 @@ public class ProductServiceImpl implements ProductService {
}
}
} else {
if (storagePriceMapper.updateStatus(skup, status, 1) == 0) {
// 4:支付保证金后取消售卖
if (isSecondHand) {
if (storagePriceMapper.cancelSaleSecondHandSkupAfterPay(skup) == 0) {
throw new ServiceException(400, "商品(skup)状态已变更");
}
} else if (storagePriceMapper.updateStatus(skup, status, 1) == 0) {
throw new ServiceException(400, "商品(skup)状态已变更");
}
addStorageNum(skup, sp.getStorageId(), -1);
... ...