Merge branch 'feature-商品起售数量' into dev
This commit is contained in:
@@ -288,7 +288,6 @@ public class CartService {
|
||||
// log.error("长链接错误 createCart{}", e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
public void createCart(JSONObject jsonObject) {
|
||||
try {
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
@@ -311,10 +310,11 @@ public class CartService {
|
||||
Integer buyNum = jsonObject.getInteger("num");
|
||||
|
||||
String skuId = jsonObject.getString("skuId");
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() - buyNum < 0) {//是否售罄
|
||||
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() < buyNum ) {//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
@@ -326,8 +326,7 @@ public class CartService {
|
||||
throw new MsgException("该商品已售罄");
|
||||
}
|
||||
} else {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
if(tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() - buyNum < 0){//是否售罄
|
||||
if (tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() < buyNum ) {//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
@@ -360,6 +359,10 @@ public class CartService {
|
||||
if (cashierCart.getSkuId().equals(skuId)) {
|
||||
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + buyNum);
|
||||
cashierCart.setNumber(cashierCart.getNumber() + buyNum);
|
||||
if (buyNum < 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() <= tbProductSkuWithBLOBs.getSuit()) {
|
||||
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
||||
continue;
|
||||
}
|
||||
if (cashierCart.getNumber() > 0) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
@@ -498,9 +501,24 @@ public class CartService {
|
||||
throw new MsgException("该商品规格不存在");
|
||||
}
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
if (productSku.getSuit() != null && productSku.getSuit() > 1) {
|
||||
if (productSku.getSuit() > productSku.getStockNumber()) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品" + productSku.getSuit() + "起售,现库存不足");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
|
||||
log.error("购物车添加商品异常,该商品起售库存不足:{}", productId);
|
||||
throw new MsgException("该商品起售库存不足");
|
||||
}
|
||||
cashierCart.setNumber(productSku.getSuit());
|
||||
cashierCart.setTotalNumber(productSku.getSuit());
|
||||
}else {
|
||||
cashierCart.setNumber(num);
|
||||
cashierCart.setTotalNumber(num);
|
||||
}
|
||||
cashierCart.setProductId(productId);
|
||||
cashierCart.setSkuId(skuId);
|
||||
cashierCart.setNumber(num);
|
||||
cashierCart.setCoverImg(product.getCoverImg());
|
||||
cashierCart.setName(product.getName());
|
||||
cashierCart.setCategoryId(product.getCategoryId());
|
||||
@@ -515,7 +533,6 @@ public class CartService {
|
||||
cashierCart.setSalePrice(productSku.getSalePrice());
|
||||
cashierCart.setCreatedAt(Instant.now().toEpochMilli());
|
||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
cashierCart.setTotalNumber(num);
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
cashierCart.setRefundNumber(0);
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
||||
@@ -577,10 +594,10 @@ public class CartService {
|
||||
try {
|
||||
if (tbProduct1.getIsStock() == 1) {
|
||||
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
||||
}else {
|
||||
} else {
|
||||
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "商品库存不足" + tbProduct1.getName());
|
||||
@@ -590,9 +607,9 @@ public class CartService {
|
||||
}
|
||||
|
||||
// 发送判断耗材是否耗尽消息
|
||||
JSONObject objectMsg=new JSONObject();
|
||||
objectMsg.put("skuId",Integer.valueOf(cashierCart.getSkuId()));
|
||||
objectMsg.put("shopId",Integer.valueOf(cashierCart.getShopId()));
|
||||
JSONObject objectMsg = new JSONObject();
|
||||
objectMsg.put("skuId", Integer.valueOf(cashierCart.getSkuId()));
|
||||
objectMsg.put("shopId", Integer.valueOf(cashierCart.getShopId()));
|
||||
producer.con_msg(objectMsg.toString());
|
||||
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
|
||||
@@ -248,18 +248,6 @@ public class OrderService {
|
||||
|
||||
}
|
||||
|
||||
public void testMessage(String tableId, String message) throws IOException {
|
||||
// AppWebSocketServer.AppSendInfo(message,tableId);
|
||||
// redisUtil.seckill(tableId,message);
|
||||
// AppWebSocketServer.onClosed(tableId);
|
||||
List<TbProductSku> list = productSkuMapper.selectAll();
|
||||
for (TbProductSku productSku : list) {
|
||||
// productSku.setStockNumber(200.00);
|
||||
redisUtil.saveMessage("PRODUCT:" + productSku.getShopId() + ":" + productSku.getId(), "10000");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result tradeIntegral(String userId, String id) throws ParseException {
|
||||
updateIntegral(userId, id);
|
||||
|
||||
Reference in New Issue
Block a user