订单管理 列表退款金额回显 导出
商品详情 skuResult回显
This commit is contained in:
@@ -27,6 +27,8 @@ import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -37,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -46,6 +49,7 @@ import java.util.stream.Collectors;
|
||||
* @description 服务实现
|
||||
* @date 2024-03-02
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@@ -58,8 +62,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Override
|
||||
public Map<String, Object> queryAllPage(TbOrderInfoQueryCriteria criteria) {
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by(Sort.Direction.DESC, "createdAt"));
|
||||
if(criteria!=null){
|
||||
if (criteria.getOrderType().equals("0")) {
|
||||
if (criteria != null) {
|
||||
if (StringUtils.isNotBlank(criteria.getOrderType()) && criteria.getOrderType().equals("0")) {
|
||||
criteria.setOrderType(null);
|
||||
}
|
||||
}
|
||||
@@ -68,8 +72,19 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
||||
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
BigDecimal refundAmount = BigDecimal.ZERO;
|
||||
for (TbOrderDetail detail : details) {
|
||||
if(tbOrderInfo.getStatus().equals("refund")){
|
||||
refundAmount = refundAmount.add(detail.getPriceAmount());
|
||||
}else{
|
||||
if (detail.getStatus().equals("refund")) {
|
||||
refundAmount = refundAmount.add(detail.getPriceAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
orderInfoVo.setDetailList(details);
|
||||
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
||||
orderInfoVo.setRefundAmount(refundAmount);
|
||||
orderInfoVoList.add(orderInfoVo);
|
||||
}
|
||||
return PageUtil.toPage(orderInfoVoList, page.getTotalElements());
|
||||
@@ -82,8 +97,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
|
||||
@Override
|
||||
public List<TbOrderInfoDto> queryAll(TbOrderInfoQueryCriteria criteria) {
|
||||
if(criteria!=null){
|
||||
if (criteria.getOrderType().equals("0")) {
|
||||
if (criteria != null) {
|
||||
if (StringUtils.isNotBlank(criteria.getOrderType()) && criteria.getOrderType().equals("0")) {
|
||||
criteria.setOrderType(null);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +117,23 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", id);
|
||||
TbOrderInfoDto dto = tbOrderInfoMapper.toDto(tbOrderInfo);
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
dto.setIsRefund(0);
|
||||
BigDecimal refundAmount = BigDecimal.ZERO;
|
||||
for (TbOrderDetail detail : details) {
|
||||
if(tbOrderInfo.getStatus().equals("refund")){
|
||||
refundAmount = refundAmount.add(detail.getPriceAmount());
|
||||
}else{
|
||||
if (detail.getStatus().equals("refund")) {
|
||||
refundAmount = refundAmount.add(detail.getPriceAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
int refund = tbOrderInfoRepository.isRefund(id, tbOrderInfo.getShopId());
|
||||
if (refund > 0) {
|
||||
dto.setIsRefund(1);
|
||||
}
|
||||
log.info("退款金额为:{}",refundAmount);
|
||||
dto.setRefundAmount(refundAmount);
|
||||
dto.setDetailList(details);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,10 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
} else {
|
||||
tbProductVo.setSkuList(tbProductSkus.get());
|
||||
}
|
||||
if ("sku".equals(tbProductVo.getTypeEnum())) {
|
||||
Optional<TbProductSkuResult> skuResult = tbProductSkuResultRepository.findById(tbProductVo.getId());
|
||||
tbProductVo.setSkuSnap(skuResult.get().getTagSnap());
|
||||
}
|
||||
return tbProductVo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user