订单倒计时
会员余额明细 库存
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) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.model.PayReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
|
||||
@@ -147,6 +148,9 @@ public class PayService {
|
||||
if(!"unpaid".equals(orderInfo.getStatus())&&!"paying".equals(orderInfo.getStatus())){
|
||||
return Result.fail("订单状态异常,不允许支付");
|
||||
}
|
||||
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
|
||||
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNull(orderInfo.getMerchantId())||ObjectUtil.isEmpty(orderInfo.getMerchantId())){
|
||||
return Result.fail("没有对应的商户");
|
||||
@@ -303,6 +307,9 @@ public class PayService {
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
return Result.fail("订单信息不存在");
|
||||
}
|
||||
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
|
||||
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
|
||||
}
|
||||
|
||||
|
||||
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||
@@ -320,7 +327,7 @@ public class PayService {
|
||||
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus()) ) {
|
||||
return Result.fail("订单出状态异常");
|
||||
return Result.fail("订单状态异常");
|
||||
}
|
||||
|
||||
|
||||
@@ -717,6 +724,7 @@ public class PayService {
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
return Result.success(CodeEnum.SUCCESS,orderId);
|
||||
case "REFUND_ING":
|
||||
cartStatus="refunding";
|
||||
@@ -871,7 +879,7 @@ public class PayService {
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
return "SUCCESS";
|
||||
|
||||
}
|
||||
@@ -916,6 +924,7 @@ public class PayService {
|
||||
coupons.put("type","buy");
|
||||
coupons.put("orderId",orderInfo.getId().toString());
|
||||
producer.printCoupons(coupons.toJSONString());
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
return "SUCCESS";
|
||||
|
||||
}
|
||||
@@ -962,7 +971,7 @@ public class PayService {
|
||||
|
||||
public Result getShopByMember(String userId,String shopId,int page,int pageSize){
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<Map<String,Object>> list= tbShopUserMapper.selectByUserId(userId,shopId);
|
||||
List<ShopUserListVo> list= tbShopUserMapper.selectByUserId(userId,shopId);
|
||||
PageInfo pageInfo=new PageInfo(list);
|
||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||
}
|
||||
|
||||
@@ -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