parent
e0291db00d
commit
cdf85e3940
|
|
@ -1,6 +1,5 @@
|
|||
package cn.ysk.cashier.config;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.utils.FastJsonUtils;
|
||||
import cn.ysk.cashier.utils.SpringContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -11,8 +10,6 @@ import org.aspectj.lang.annotation.Around;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -26,8 +23,6 @@ import java.util.Map;
|
|||
@Component
|
||||
@Slf4j
|
||||
public class AppApiMethodAspect {
|
||||
|
||||
// @Pointcut("execution(public * cn.ysk.cashier.controller.*.*(..))")
|
||||
@Pointcut("execution(public * (" +
|
||||
"cn.ysk.cashier.controller.* " +
|
||||
"|| cn.ysk.cashier.controller.*.* " +
|
||||
|
|
@ -62,26 +57,31 @@ public class AppApiMethodAspect {
|
|||
FastJsonUtils.toJSONString(result)
|
||||
);
|
||||
return result;
|
||||
} catch (BadRequestException e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
|
||||
} catch (Throwable e) {
|
||||
if(StringUtils.isBlank(e.getMessage())){
|
||||
} catch (RuntimeException e) {
|
||||
if (StringUtils.isBlank(e.getMessage())) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
}else{
|
||||
} else {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e.getMessage());
|
||||
}
|
||||
ResponseEntity<String> body = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
return body;
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,22 @@ package cn.ysk.cashier.controller.order;
|
|||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -57,6 +61,13 @@ public class TbOrderInfoController {
|
|||
return new ResponseEntity<>(tbOrderInfoService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/payCount")
|
||||
@Log("通过shopId查询支付统计")
|
||||
@ApiOperation("通过shopId查询支付统计")
|
||||
public List<TbOrderPayCountVo> queryTbOrderPayCount(String shopId){
|
||||
return tbOrderInfoService.queryTbOrderPayCount(shopId);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Log("通过Id查询订单")
|
||||
@ApiOperation("通过Id查询订单")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.repository.order;
|
||||
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-03-02
|
||||
**/
|
||||
public interface TbOrderPayCountRepository extends JpaRepository<TbOrderInfo, Integer> {
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(info.payType, SUM(info.amount)) " +
|
||||
"FROM TbOrderInfo info " +
|
||||
"WHERE info.shopId = :shopId " +
|
||||
"GROUP BY info.payType")
|
||||
List<TbOrderPayCountVo> queryTbOrderPayCount(@Param("shopId")String shopId);
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl.order;
|
||||
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
|
|
@ -22,9 +22,11 @@ import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
|||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderPayCountRepository;
|
||||
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
|
@ -38,11 +40,11 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-03-02
|
||||
**/
|
||||
* @author lyf
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @date 2024-03-02
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
|
|
@ -51,12 +53,15 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
private final TbOrderInfoMapper tbOrderInfoMapper;
|
||||
|
||||
private final TbOrderDetailRepository tbOrderDetailRepository;
|
||||
|
||||
private final TbOrderPayCountRepository tbOrderPayCountRepository;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbOrderInfoQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbOrderInfo> page = tbOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
public Map<String, Object> queryAll(TbOrderInfoQueryCriteria criteria, Pageable pageable) {
|
||||
Page<TbOrderInfo> page = tbOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
List<TbOrderInfoVo> orderInfoVoList = new ArrayList<>();
|
||||
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
||||
TbOrderInfoVo orderInfoVo=new TbOrderInfoVo();
|
||||
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
orderInfoVo.setDetailList(details);
|
||||
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
||||
|
|
@ -66,7 +71,12 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TbOrderInfoDto> queryAll(TbOrderInfoQueryCriteria criteria){
|
||||
public List<TbOrderPayCountVo> queryTbOrderPayCount(String shopId) {
|
||||
return tbOrderPayCountRepository.queryTbOrderPayCount(shopId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbOrderInfoDto> queryAll(TbOrderInfoQueryCriteria criteria) {
|
||||
List<TbOrderInfoDto> dto = tbOrderInfoMapper.toDto(tbOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
for (TbOrderInfoDto tbOrderInfo : dto) {
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
|
|
@ -79,7 +89,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
@Transactional
|
||||
public TbOrderInfoDto findById(Integer id) {
|
||||
TbOrderInfo tbOrderInfo = tbOrderInfoRepository.findById(id).orElseGet(TbOrderInfo::new);
|
||||
ValidationUtil.isNull(tbOrderInfo.getId(),"TbOrderInfo","id",id);
|
||||
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", id);
|
||||
TbOrderInfoDto dto = tbOrderInfoMapper.toDto(tbOrderInfo);
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
dto.setDetailList(details);
|
||||
|
|
@ -96,7 +106,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbOrderInfo resources) {
|
||||
TbOrderInfo tbOrderInfo = tbOrderInfoRepository.findById(resources.getId()).orElseGet(TbOrderInfo::new);
|
||||
ValidationUtil.isNull( tbOrderInfo.getId(),"TbOrderInfo","id",resources.getId());
|
||||
ValidationUtil.isNull(tbOrderInfo.getId(), "TbOrderInfo", "id", resources.getId());
|
||||
tbOrderInfo.copy(resources);
|
||||
tbOrderInfoRepository.save(tbOrderInfo);
|
||||
}
|
||||
|
|
@ -112,9 +122,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbOrderInfoDto tbOrderInfo : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("订单编号", tbOrderInfo.getOrderNo());
|
||||
switch (tbOrderInfo.getOrderType()){
|
||||
switch (tbOrderInfo.getOrderType()) {
|
||||
case "cash":
|
||||
tbOrderInfo.setOrderType("收银");
|
||||
break;
|
||||
|
|
@ -128,7 +138,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
tbOrderInfo.setOrderType("退单");
|
||||
break;
|
||||
default:
|
||||
tbOrderInfo.setOrderType(tbOrderInfo.getOrderType()+"未知订单类型");
|
||||
tbOrderInfo.setOrderType(tbOrderInfo.getOrderType() + "未知订单类型");
|
||||
break;
|
||||
}
|
||||
map.put("订单类型", tbOrderInfo.getOrderType());
|
||||
|
|
@ -146,7 +156,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
tbOrderInfo.setSendType("堂食");
|
||||
break;
|
||||
default:
|
||||
tbOrderInfo.setSendType(tbOrderInfo.getSendType()+"未知送货类型");
|
||||
tbOrderInfo.setSendType(tbOrderInfo.getSendType() + "未知送货类型");
|
||||
break;
|
||||
}
|
||||
map.put("发货类型", tbOrderInfo.getSendType());
|
||||
|
|
@ -193,12 +203,12 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
tbOrderInfo.setStatus("激活订单");
|
||||
break;
|
||||
default:
|
||||
tbOrderInfo.setStatus(tbOrderInfo.getStatus()+"未知订单状态");
|
||||
tbOrderInfo.setStatus(tbOrderInfo.getStatus() + "未知订单状态");
|
||||
break;
|
||||
}
|
||||
map.put("状态", tbOrderInfo.getStatus());
|
||||
map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt()));
|
||||
map.put("备注", tbOrderInfo.getRemark());
|
||||
map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt()));
|
||||
map.put("备注", tbOrderInfo.getRemark());
|
||||
//
|
||||
// map.put("商户结算金额", tbOrderInfo.getSettlementAmount());
|
||||
// map.put("包装费", tbOrderInfo.getPackFee());
|
||||
|
|
|
|||
|
|
@ -15,14 +15,16 @@
|
|||
*/
|
||||
package cn.ysk.cashier.service.order;
|
||||
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -40,6 +42,13 @@ public interface TbOrderInfoService {
|
|||
*/
|
||||
Map<String,Object> queryAll(TbOrderInfoQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 根据支付类型统计
|
||||
* @param shopId shopId
|
||||
* @return TbOrderPayCountVo
|
||||
*/
|
||||
List<TbOrderPayCountVo> queryTbOrderPayCount(String shopId);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Data
|
||||
public class TbOrderPayCountVo{
|
||||
private String payType;
|
||||
private BigDecimal payAmount;
|
||||
|
||||
// 构造函数,参数名需要与查询中的别名一致
|
||||
public TbOrderPayCountVo(String payType, BigDecimal payAmount) {
|
||||
this.payType = payType;
|
||||
this.payAmount = payAmount;
|
||||
}
|
||||
|
||||
// Getter和Setter方法
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public BigDecimal getPayAmount() {
|
||||
return payAmount;
|
||||
}
|
||||
|
||||
public void setPayAmount(BigDecimal payAmount) {
|
||||
this.payAmount = payAmount;
|
||||
}
|
||||
|
||||
// toString方法,用于简单的打印信息,可根据需要添加
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TbOrderPayCountVo{" +
|
||||
"payType='" + payType + '\'' +
|
||||
", payAmount=" + payAmount +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue