|
|
@ -102,6 +102,8 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
private GoodsUserAddressService goodsUserAddressService; |
|
|
|
private GoodsUserAddressService goodsUserAddressService; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsMerPayConfigService bsMerPayConfigService; |
|
|
|
private BsMerPayConfigService bsMerPayConfigService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsOrderMapper bsOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
@ -160,6 +162,13 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
// 查询规格
|
|
|
|
// 查询规格
|
|
|
|
GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); |
|
|
|
GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (specs.getPurLimit() != null) { |
|
|
|
|
|
|
|
boolean l = checkPurchaseLimit(order.getUserId() , specs.getId()); |
|
|
|
|
|
|
|
if (l) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商品限购数量不能超过" + specs.getPurLimit()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (specs != null) { |
|
|
|
if (specs != null) { |
|
|
|
// 校验商品购买是否超过库存
|
|
|
|
// 校验商品购买是否超过库存
|
|
|
|
if (specs.getStock() < child.getProductCount()) { |
|
|
|
if (specs.getStock() < child.getProductCount()) { |
|
|
@ -167,6 +176,9 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// checkPurchaseLimit 限购
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
child.setOrderNo(order.getOrderNo()); |
|
|
|
child.setOrderNo(order.getOrderNo()); |
|
|
|
// 子订单号 交易id + 线程随机数 + 4位随机数
|
|
|
|
// 子订单号 交易id + 线程随机数 + 4位随机数
|
|
|
|
child.setChildOrderNo(order.getId()+ IDGenerator.nextId(1) +RandomUtils.number(4, false)); |
|
|
|
child.setChildOrderNo(order.getId()+ IDGenerator.nextId(1) +RandomUtils.number(4, false)); |
|
|
@ -787,4 +799,26 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查购买限制
|
|
|
|
|
|
|
|
private boolean checkPurchaseLimit(Long userId , Long skuId) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询商品是否存在限购
|
|
|
|
|
|
|
|
GoodsSpecs goodsSpecs = goodsSpecsService.queryDetail(skuId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (goodsSpecs.getPurLimit() == null || goodsSpecs.getPurLimit() == 0) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询用户购买数量
|
|
|
|
|
|
|
|
Integer num = bsOrderMapper.toDyaGoodsLimit(userId , skuId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (num == null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return num >= goodsSpecs.getPurLimit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|