订单管理 列表退款金额回显 导出
商品详情 skuResult回显
This commit is contained in:
@@ -50,7 +50,7 @@ public class TbOrderInfoController {
|
|||||||
@Log("导出数据")
|
@Log("导出数据")
|
||||||
@ApiOperation("导出数据")
|
@ApiOperation("导出数据")
|
||||||
@PostMapping(value = "/download")
|
@PostMapping(value = "/download")
|
||||||
public void exportTbOrderInfo(HttpServletResponse response, TbOrderInfoQueryCriteria criteria) throws IOException {
|
public void exportTbOrderInfo(HttpServletResponse response, @RequestBody TbOrderInfoQueryCriteria criteria) throws IOException {
|
||||||
tbOrderInfoService.download(tbOrderInfoService.queryAll(criteria), response);
|
tbOrderInfoService.download(tbOrderInfoService.queryAll(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,4 +159,6 @@ public class TbOrderInfoDto implements Serializable {
|
|||||||
private List<TbOrderDetail> detailList;
|
private List<TbOrderDetail> detailList;
|
||||||
|
|
||||||
private String payRemark;
|
private String payRemark;
|
||||||
|
|
||||||
|
private Integer isRefund;
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,9 @@ public class TbOrderInfoQueryCriteria{
|
|||||||
@Query
|
@Query
|
||||||
private String payType;
|
private String payType;
|
||||||
|
|
||||||
|
@Query
|
||||||
|
private String source;
|
||||||
|
|
||||||
/** 精确 */
|
/** 精确 */
|
||||||
@Query
|
@Query
|
||||||
private String shopId;
|
private String shopId;
|
||||||
|
|||||||
@@ -43,4 +43,7 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
|||||||
@Query(value = "SELECT COUNT(1) ,pay_type AS payType FROM tb_order_info Where shop_id = :shopId AND " +
|
@Query(value = "SELECT COUNT(1) ,pay_type AS payType FROM tb_order_info Where shop_id = :shopId AND " +
|
||||||
" created_at BETWEEN :startTime AND :endTime AND status='closed' GROUP BY pay_type" ,nativeQuery = true)
|
" created_at BETWEEN :startTime AND :endTime AND status='closed' GROUP BY pay_type" ,nativeQuery = true)
|
||||||
List<Object[]> countByShopId(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
List<Object[]> countByShopId(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||||
|
|
||||||
|
@Query("SELECT count(1) FROM TbOrderInfo WHERE source = :source AND shopId=:shopId")
|
||||||
|
int isRefund(@Param("source")Integer source,@Param("shopId") String shopId);
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,8 @@ import cn.ysk.cashier.utils.*;
|
|||||||
import cn.ysk.cashier.vo.TbOrderInfoVo;
|
import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@@ -37,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ import java.util.stream.Collectors;
|
|||||||
* @description 服务实现
|
* @description 服务实现
|
||||||
* @date 2024-03-02
|
* @date 2024-03-02
|
||||||
**/
|
**/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||||
@@ -58,8 +62,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAllPage(TbOrderInfoQueryCriteria criteria) {
|
public Map<String, Object> queryAllPage(TbOrderInfoQueryCriteria criteria) {
|
||||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by(Sort.Direction.DESC, "createdAt"));
|
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by(Sort.Direction.DESC, "createdAt"));
|
||||||
if(criteria!=null){
|
if (criteria != null) {
|
||||||
if (criteria.getOrderType().equals("0")) {
|
if (StringUtils.isNotBlank(criteria.getOrderType()) && criteria.getOrderType().equals("0")) {
|
||||||
criteria.setOrderType(null);
|
criteria.setOrderType(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,8 +72,19 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
||||||
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
||||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
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);
|
orderInfoVo.setDetailList(details);
|
||||||
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
||||||
|
orderInfoVo.setRefundAmount(refundAmount);
|
||||||
orderInfoVoList.add(orderInfoVo);
|
orderInfoVoList.add(orderInfoVo);
|
||||||
}
|
}
|
||||||
return PageUtil.toPage(orderInfoVoList, page.getTotalElements());
|
return PageUtil.toPage(orderInfoVoList, page.getTotalElements());
|
||||||
@@ -82,8 +97,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TbOrderInfoDto> queryAll(TbOrderInfoQueryCriteria criteria) {
|
public List<TbOrderInfoDto> queryAll(TbOrderInfoQueryCriteria criteria) {
|
||||||
if(criteria!=null){
|
if (criteria != null) {
|
||||||
if (criteria.getOrderType().equals("0")) {
|
if (StringUtils.isNotBlank(criteria.getOrderType()) && criteria.getOrderType().equals("0")) {
|
||||||
criteria.setOrderType(null);
|
criteria.setOrderType(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +117,23 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", id);
|
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", id);
|
||||||
TbOrderInfoDto dto = tbOrderInfoMapper.toDto(tbOrderInfo);
|
TbOrderInfoDto dto = tbOrderInfoMapper.toDto(tbOrderInfo);
|
||||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
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);
|
dto.setDetailList(details);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,10 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
} else {
|
} else {
|
||||||
tbProductVo.setSkuList(tbProductSkus.get());
|
tbProductVo.setSkuList(tbProductSkus.get());
|
||||||
}
|
}
|
||||||
|
if ("sku".equals(tbProductVo.getTypeEnum())) {
|
||||||
|
Optional<TbProductSkuResult> skuResult = tbProductSkuResultRepository.findById(tbProductVo.getId());
|
||||||
|
tbProductVo.setSkuSnap(skuResult.get().getTagSnap());
|
||||||
|
}
|
||||||
return tbProductVo;
|
return tbProductVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user