场景:对增加销售占用的接口服务做并发单元测试
商品库存PO:
@Data
@Entity
@Table(name = "product_sale_stock")
public class ProductSaleStockPo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/**
* 商品编码
*/
@Column
private Long productSale;
/**
* 仓库
*/
@Column
private Long dc;
/**
* 库存数量
*/
@Column
private int stock;
/**
* 销售占用
*/
@Column
private int sales;
/**
* 不准确库存
*/
@Column
private int incorrect;
}
增加销售占用接口服务:
@Service("xdtProductSaleStockService")
@Transactional(rollbackFor = Exception.class)
public class XdtProductSaleStockServiceImpl implements XdtProductSaleStockService {
@Override
public void increaseStockSales(int occupancy, long productSale, long dc) throws XdtProductSaleS