parent
172006576e
commit
dc7c7172ce
|
|
@ -50,7 +50,7 @@ public class TbOrderInfoController {
|
|||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,4 +159,6 @@ public class TbOrderInfoDto implements Serializable {
|
|||
private List<TbOrderDetail> detailList;
|
||||
|
||||
private String payRemark;
|
||||
|
||||
private Integer isRefund;
|
||||
}
|
||||
|
|
@ -52,6 +52,9 @@ public class TbOrderInfoQueryCriteria{
|
|||
@Query
|
||||
private String payType;
|
||||
|
||||
@Query
|
||||
private String source;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
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 " +
|
||||
" 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);
|
||||
|
||||
@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.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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue