Merge branch 'lyf' of https://e.coding.net/g-cphe0354/shouyinjixitong/wx-cashier-service into lyf
# Conflicts: # src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java # src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
This commit is contained in:
@@ -106,7 +106,7 @@ public class CartService1 {
|
||||
String skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"));
|
||||
TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
if (Integer.valueOf(skuNum) < 1) {
|
||||
if (Integer.valueOf(skuNum) < 1 && jsonObject.getInteger("num") > 0) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品库存已售罄");
|
||||
@@ -116,11 +116,6 @@ public class CartService1 {
|
||||
throw new MsgException("该商品库存已售罄");
|
||||
}
|
||||
}
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
|
||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
@@ -130,6 +125,12 @@ public class CartService1 {
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
} else {
|
||||
boolean flag = true;
|
||||
@@ -139,8 +140,15 @@ public class CartService1 {
|
||||
if (cashierCart.getSkuId().equals(jsonObject.getString("skuId"))) {
|
||||
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + jsonObject.getInteger("num"));
|
||||
cashierCart.setNumber(cashierCart.getNumber() + jsonObject.getInteger("num"));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
if (cashierCart.getNumber() > 0) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
} else {
|
||||
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
||||
@@ -156,6 +164,12 @@ public class CartService1 {
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -164,9 +178,10 @@ public class CartService1 {
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId), jsonArray.toJSONString());
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
|
||||
@@ -195,6 +195,13 @@ public class OrderService {
|
||||
orderVo.setDetails(details);
|
||||
orderVo.setOrderNo(orderInfo.getOrderNo());
|
||||
orderVo.setTime(orderInfo.getCreatedAt());
|
||||
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
|
||||
Long totalSeconds = orderInfo.getCreatedAt() + 15 * 60 * 1000l - System.currentTimeMillis();
|
||||
if(totalSeconds>0){
|
||||
orderVo.setExpiredMinutes(totalSeconds/1000 / 60);
|
||||
orderVo.setExpiredSeconds(totalSeconds/1000 % 60);
|
||||
}
|
||||
}
|
||||
orderVo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderVo.setTableName(tbShopTable == null ? "" : tbShopTable.getName());
|
||||
orderVo.setOrderType(orderInfo.getOrderType());
|
||||
@@ -214,6 +221,7 @@ public class OrderService {
|
||||
List<TbOrderInfo> tbOrderInfos = orderInfoMapper.selectByUserId(userId, status);
|
||||
|
||||
for (TbOrderInfo orderInfo : tbOrderInfos) {
|
||||
orderInfo.setDescription();
|
||||
List<TbOrderDetail> list = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
||||
int num = 0;
|
||||
for (TbOrderDetail orderDetail : list) {
|
||||
|
||||
@@ -218,7 +218,12 @@ public class ProductService {
|
||||
if (CollectionUtils.isEmpty(shopGroupInfoVos)) {
|
||||
return new PageInfo(shopGroupInfoVos);
|
||||
}
|
||||
List<Integer> productIds = shopGroupInfoVos.stream().map(ShopGroupInfoVo::getProId).collect(Collectors.toList());
|
||||
List<Integer> productIds = shopGroupInfoVos.stream()
|
||||
.filter(Objects::nonNull) // 过滤掉 null 的 ShopGroupInfoVo 对象
|
||||
.map(ShopGroupInfoVo::getProId)
|
||||
.filter(Objects::nonNull) // 过滤掉 null 的 ProId
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> stringList = productIds.stream()
|
||||
.map(Object::toString) // 将 Integer 对象映射为 String 对象
|
||||
.collect(Collectors.toList());
|
||||
@@ -227,6 +232,9 @@ public class ProductService {
|
||||
//组装
|
||||
List<HomeVO> homeVOList = new ArrayList<>();
|
||||
for (ShopGroupInfoVo o : shopGroupInfoVos) {
|
||||
if (o.getProId() == null) {
|
||||
continue;
|
||||
}
|
||||
HomeVO homeVO = new HomeVO();
|
||||
homeVO.setId(o.getProId());
|
||||
homeVO.setShopName(o.getShopName());
|
||||
@@ -291,6 +299,10 @@ public class ProductService {
|
||||
* @throws Exception
|
||||
*/
|
||||
public Result productInfo(Integer productId, String lat, String lng, String environment) throws Exception {
|
||||
if (StringUtils.isBlank(lat) || lat.equals("undefined")) {
|
||||
lat = "34.343207";
|
||||
lng = "108.939645";
|
||||
}
|
||||
CompletableFuture<TbProductWithBLOBs> product = CompletableFuture.supplyAsync(() ->
|
||||
tbProductMapper.selectByPrimaryKey(productId));
|
||||
CompletableFuture<List<TbProductSku>> productSku = CompletableFuture.supplyAsync(() ->
|
||||
|
||||
Reference in New Issue
Block a user