Merge branch 'refs/heads/dev' into test
# Conflicts: # eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java
This commit is contained in:
@@ -11,7 +11,6 @@ public class ReturnCartDTO {
|
||||
private Integer cartId;
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotNull
|
||||
private Long tableId;
|
||||
@NotNull
|
||||
@Min(value = 1, message = "最小数量为1")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.cons.TableConstant;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -48,5 +49,11 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||
*/
|
||||
boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId);
|
||||
|
||||
/**
|
||||
* 根据订单id更改购物车状态
|
||||
* @param status 状态
|
||||
* @param orderId 订单id
|
||||
*/
|
||||
boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -85,5 +86,12 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
||||
.eq(TbCashierCart::getTableId, tableId)
|
||||
.eq(TbCashierCart::getUseType, useType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId) {
|
||||
return update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, orderId)
|
||||
.set(TbCashierCart::getStatus, status.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,8 @@ import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.*;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.*;
|
||||
import cn.ysk.cashier.mybatis.service.impl.MpOrderDetailServiceImpl;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
@@ -30,6 +24,7 @@ import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
@@ -110,6 +105,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
private final PayService payService;
|
||||
private final MpOrderDetailService mpOrderDetailService;
|
||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||
private final MpCashierCartService mpCashierCartService;
|
||||
private final MpShopInfoMapper mpShopInfoMapper;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
private String url;
|
||||
@@ -168,6 +165,13 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
return predicate;
|
||||
}, pageable);
|
||||
|
||||
List<String> shopIds = page.getContent().stream().map(TbOrderInfo::getShopId).distinct().collect(Collectors.toList());
|
||||
HashMap<String, TbShopInfo> shopInfoMap = new HashMap<>();
|
||||
if (!shopIds.isEmpty()) {
|
||||
mpShopInfoMapper.selectBatchIds(shopIds).forEach(item -> {
|
||||
shopInfoMap.put(item.getId().toString(), item);
|
||||
});
|
||||
}
|
||||
List<TbOrderInfoVo> orderInfoVoList = new ArrayList<>();
|
||||
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
||||
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
||||
@@ -210,6 +214,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
orderInfoVo.setSeatInfo(seatInfo);
|
||||
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
||||
orderInfoVo.setRefundAmount(refundAmount);
|
||||
TbShopInfo shopInfo = shopInfoMap.get(tbOrderInfo.getShopId());
|
||||
if (shopInfo != null) {
|
||||
orderInfoVo.setRegisterType(shopInfo.getRegisterType());
|
||||
}
|
||||
orderInfoVoList.add(orderInfoVo);
|
||||
}
|
||||
return PageUtil.toPage(orderInfoVoList, page.getTotalElements());
|
||||
@@ -422,13 +430,35 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upOrderStatus(TbOrderInfo tbOrderInfo) {
|
||||
tbOrderInfo.setStatus("cancelled");
|
||||
//订单取消 赠送商品数量返回
|
||||
QueryWrapper<TbActivateOutRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", tbOrderInfo.getId());
|
||||
queryWrapper.eq("status", "create");
|
||||
List<TbActivateOutRecord> outRecords = outRecordService.list(queryWrapper);
|
||||
for (TbActivateOutRecord outRecord : outRecords) {
|
||||
TbActivateInRecord inRecord = inRecordService.getById(outRecord.getGiveId());
|
||||
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getUseNum());
|
||||
inRecordService.updateById(inRecord);
|
||||
}
|
||||
LambdaUpdateWrapper<TbActivateOutRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(TbActivateOutRecord::getOrderId, tbOrderInfo.getId())
|
||||
.eq(TbActivateOutRecord::getStatus, "create")
|
||||
.set(TbActivateOutRecord::getStatus, "cancel");
|
||||
outRecordService.update(lambdaUpdateWrapper);
|
||||
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (TbOrderDetail detail : details) {
|
||||
detail.setStatus("cancelled");
|
||||
// 返还库存
|
||||
productService.returnStockByPro(detail.getProductId(), detail.getProductSkuId(), detail.getNum());
|
||||
tbOrderDetailRepository.save(detail);
|
||||
keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId());
|
||||
}
|
||||
|
||||
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, tbOrderInfo.getId());
|
||||
String[] keysArray = keys.toArray(new String[keys.size()]);
|
||||
redisUtils.del(keysArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -55,7 +56,6 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.criteria.Order;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
@@ -660,8 +660,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
throw new BadRequestException("最大退菜数量为: {}", cashierCart.getNumber());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (cashierCart.getOrderId() == null) {
|
||||
throw new BadRequestException("此商品还未下单,无需退单");
|
||||
}
|
||||
@@ -1381,7 +1379,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
}
|
||||
|
||||
if (shopEatTypeInfoDTO.isIncrMaterId() && "pending".equals(orderInfo.getStatus())) {
|
||||
String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId());;
|
||||
String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId());
|
||||
;
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
@@ -1636,6 +1635,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));
|
||||
orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(finalAmount));
|
||||
}
|
||||
if (StrUtil.isEmpty(orderInfo.getMemberId())) {
|
||||
orderInfo.setMemberId(Convert.toStr(payDTO.getVipUserId()));
|
||||
}
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
@@ -1652,7 +1654,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
|
||||
.eq(TbOrderDetail::getStatus, "unpaid")
|
||||
.setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount() == null ? 1: payDTO.getDiscount()))
|
||||
.setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount() == null ? 1 : payDTO.getDiscount()))
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
@@ -117,4 +117,5 @@ public class TbOrderInfoVo {
|
||||
private List<? extends TbOrderDetail> detailList;
|
||||
|
||||
private TbOrderDetail seatInfo;
|
||||
private String registerType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user