Authored by mali

批量修改skup价格

... ... @@ -36,4 +36,12 @@ public interface StoragePriceMapper {
List<StoragePrice> selectByStorageIds(List<Integer> storageIds);
List<StoragePrice> selectBySkupList(@Param("skupList")List<Integer> skupList);
/**
* 批量修改skup价格
* @param skupList
* @param price
* @return
*/
int updateBatchPrice(@Param("skupList")List<Integer> skupList, @Param("price")Double price);
}
\ No newline at end of file
... ...
... ... @@ -128,4 +128,13 @@
#{skup}
</foreach>
</update>
<update id="updateBatchPrice">
update storage_price set price = #{price,jdbcType=DECIMAL},
update_time = unix_timestamp()
where skup in
<foreach item="skup" index="index" collection="skupList" open="(" separator="," close=")">
#{skup}
</foreach>
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -337,4 +337,28 @@ public class ProductController {
}
});
}
// 商家修改状态:1:上架 2:下架
@RequestMapping(params = "method=ufo.product.sellerBatchUpdatePrice")
public ApiResponse sellerBatchUpdatePrice(@RequestParam(value = "skupList", required = true) List<Integer> skupList,
@RequestParam(value = "price", required = true) Double price){
LOG.info("in method=ufo.product.sellerBatchUpdatePrice skupList is {}, price is {}", skupList, price);
if(null == price || price <= 0) {
throw new ServiceException(400, "价格只能是非负数");
}
try {
productService.sellerBatchUpdatePrice(skupList, price);
//清缓存
LOG.info("sellerBatchUpdatePrice success and async clearProductCache skupList = {}", skupList);
clearBatchProductCache(skupList);
return new ApiResponse(200, "更新成功!", Boolean.TRUE);
} catch (Exception e) {
LOG.error("sellerBatchUpdatePrice失败!", e);
int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
}
}
}
\ No newline at end of file
... ...
... ... @@ -50,4 +50,12 @@ public interface ProductService {
void sellerBatchUpdateStatus(List<Integer> skupList, int status);
List<StoragePrice> getStoragePriceBySkupList(List<Integer> skupList);
/**
* 批量修改skup价格
* @param skupList
* @param price
* @return
*/
int sellerBatchUpdatePrice(List<Integer> skupList, Double price);
}
... ...
... ... @@ -634,4 +634,14 @@ public class ProductServiceImpl implements ProductService{
productDetailResp.setProduct_info(productInfo);
return productDetailResp;
}
/**
* 批量修改skup价格
* @param skupList
* @param price
* @return
*/
public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) {
return storagePriceMapper.updateBatchPrice(skupList, price);
}
}
... ...