优化invoice后台返回给前端的错误语句
给用户开发票接口,默认后台生成当前时间 修复多个接口的没有数据报404问题,没有数据让其返回null值 修改bootrap.yml中的发票下载附件存放路径,让其为本地,合并是需要更改为服务器存放地址
This commit is contained in:
parent
e2ab06708b
commit
fad1e6f7cc
@ -25,7 +25,7 @@ public class LoginUser implements Serializable
|
||||
private Long userid;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
* 用户账号(手机号、账号)
|
||||
*/
|
||||
private String username;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
@ -18,11 +19,12 @@ public interface UserTypeService {
|
||||
|
||||
/**
|
||||
* 根据手机号(账号),用户id和类型 获取用户信息
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/common/getUser")
|
||||
R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType,@RequestParam(value = "serialNumber")String serialNumber,@RequestParam(value = "tenantId")String tenantId);
|
||||
R<Map<String, Object>> getUser(@RequestParam(value = "phone") String phone, @RequestParam(value = "userId") Long userId, @RequestParam(value = "userType") Integer userType, @RequestParam(value = "serialNumber") String serialNumber, @RequestParam(value = "tenantId") String tenantId);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.xhpc.invoice;
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
||||
@ -95,7 +95,7 @@ public class XhpcInvoiceController extends BaseController {
|
||||
public AjaxResult invoiceToUser(@RequestBody InvoiceToUserRequest requestData) {
|
||||
//前置条件
|
||||
if (requestData.getInvoiceId() == null) {
|
||||
return AjaxResult.error("必须传递未开发票id");
|
||||
return AjaxResult.error("必须上传发票id");
|
||||
}
|
||||
if (requestData.getStatus() == null || requestData.getStatus().equals(InvoiceStatusConst.INVOICING)) {
|
||||
return AjaxResult.error("必须传递发票状态或发票状态不能为0");
|
||||
|
||||
@ -128,6 +128,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean invoiceToUser(InvoiceToUserRequest requestData) {
|
||||
//获取当前时间
|
||||
requestData.setInvoicingTime(DateUtil.getYyyyMmDdHhMmSs());
|
||||
//根据操作人的id,查询操作人的名字
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(requestData.getDrawer()));
|
||||
requestData.setDrawer(sysUser.getNickName());
|
||||
@ -137,7 +139,14 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
//从阿里云上下载下来电子发票
|
||||
String fileUrl = requestData.getEletricInvoiceUrl();
|
||||
File electricInvoiceFile = new File(environment.getProperty("file.serverStoreDisposableFileLocation") + "ElectricInvoice.pdf");
|
||||
HttpUtil.downloadFile(fileUrl, electricInvoiceFile);
|
||||
try {
|
||||
//参数1 文件下载路径
|
||||
//参数2 文件存放位置
|
||||
//服务器响应404 表示服务器找不到客户端所请求的资源
|
||||
HttpUtil.downloadFile(fileUrl, electricInvoiceFile);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("在阿里云上无法找到该文件,请检查上传的图片路径是否完整或有误");
|
||||
}
|
||||
try {
|
||||
MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile);
|
||||
} catch (Exception e) {
|
||||
@ -161,6 +170,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void failInvoiceToUser(InvoiceToUserRequest requestData) {
|
||||
//获取当前时间
|
||||
requestData.setInvoicingTime(DateUtil.getYyyyMmDdHhMmSs());
|
||||
//根据操作人的id,查询操作人的名字
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(requestData.getDrawer()));
|
||||
requestData.setDrawer(sysUser.getNickName());
|
||||
@ -196,6 +207,11 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
public InvoiceTitleResponse findTitleInfo(String firmName) {
|
||||
|
||||
List<XhpcInvoice> xhpcInvoiceList = xhpcInvoiceMapper.selectInvoiceTitleInfo(firmName);
|
||||
InvoiceTitleResponse invoiceTitleResponse = new InvoiceTitleResponse();
|
||||
//如果没有记录,则返回空包装类
|
||||
if (xhpcInvoiceList.size() == 0) {
|
||||
return invoiceTitleResponse;
|
||||
}
|
||||
ArrayList<InvoiceTitleResponse.DataDTO> dataDTOList = new ArrayList<>();
|
||||
for (XhpcInvoice xhpcInvoice : xhpcInvoiceList) {
|
||||
InvoiceTitleResponse.DataDTO dataDTO = new InvoiceTitleResponse.DataDTO();
|
||||
@ -203,7 +219,6 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
dataDTO.setDutyNumber(xhpcInvoice.getDutyNumber());
|
||||
dataDTOList.add(dataDTO);
|
||||
}
|
||||
InvoiceTitleResponse invoiceTitleResponse = new InvoiceTitleResponse();
|
||||
invoiceTitleResponse.setData(dataDTOList);
|
||||
return invoiceTitleResponse;
|
||||
}
|
||||
@ -223,6 +238,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
|
||||
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectUserLastInputInvoiceInfo(creatorId, creatorType);
|
||||
TitleResponse titleResponse = new TitleResponse();
|
||||
//如果数据库本身就没有数据,那么就返回空实体类对象
|
||||
if (xhpcInvoice == null) {
|
||||
return titleResponse;
|
||||
}
|
||||
BeanUtils.copyProperties(xhpcInvoice, titleResponse);
|
||||
return titleResponse;
|
||||
|
||||
@ -251,6 +270,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
//查询该用户3个月内可以开发票的历史订单
|
||||
List<Map<String, Object>> xhpcHistoryOrderList = xhpcHistoryOrderMapper.findByCondition(invoicedOrdersRequest, lockOrderNumberList);
|
||||
InvoicedOrderResponse invoicedOrderResponse = new InvoicedOrderResponse();
|
||||
//没有则直接返回空对象出去
|
||||
if (xhpcHistoryOrderList.size() == 0) {
|
||||
return invoicedOrderResponse;
|
||||
}
|
||||
//设置该用户3个月内可以开发票的历史订单数量
|
||||
invoicedOrderResponse.setTotalItems(xhpcHistoryOrderList.size());
|
||||
//查询该用户所有可以开的发票的历史订单数量
|
||||
@ -312,29 +335,6 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
invoicedOrderResponse.setItems(itemsDTOS);
|
||||
return invoicedOrderResponse;
|
||||
|
||||
// //计算分页索引,放置到currentPage属性中
|
||||
// int startIndex = (invoicedOrdersRequest.getCurrentPage() - 1) * invoicedOrdersRequest.getItems();
|
||||
// invoicedOrdersRequest.setCurrentPage(startIndex);
|
||||
// //先查询该用户被锁定了的订单,过滤掉它
|
||||
// List<Integer> lockOrderNumberList = xhpcInvoiceMapHistoryOrderMapper.findLockOrdersByUserIdAndUserType(invoicedOrdersRequest);
|
||||
// //查询该用户3个月内可以开发票的历史订单
|
||||
// List<XhpcHistoryOrder> xhpcHistoryOrderList = xhpcHistoryOrderMapper.findByCondition(invoicedOrdersRequest, lockOrderNumberList);
|
||||
// ArrayList<InvoiceOrdersResponse.ItemsDTO> itemsDTOList = new ArrayList<>();
|
||||
// for (XhpcHistoryOrder xhpcHistoryOrder : xhpcHistoryOrderList) {
|
||||
// InvoiceOrdersResponse.ItemsDTO itemsDTO = new InvoiceOrdersResponse.ItemsDTO();
|
||||
// itemsDTO.setOrderId(xhpcHistoryOrder.getHistoryOrderId());
|
||||
// itemsDTO.setOrderNumber(xhpcHistoryOrder.getSerialNumber());
|
||||
// itemsDTO.setOrderMoney(xhpcHistoryOrder.getActPrice());
|
||||
// itemsDTO.setOrderTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcHistoryOrder.getCreateTime()));
|
||||
// itemsDTOList.add(itemsDTO);
|
||||
// }
|
||||
// InvoiceOrdersResponse invoiceOrdersResponse = new InvoiceOrdersResponse();
|
||||
// invoiceOrdersResponse.setItems(itemsDTOList);
|
||||
// //查询该用户所有可以开发票的历史订单的数量
|
||||
// Long allOrdersCount = xhpcHistoryOrderMapper.findAllOrdersByCondition(invoicedOrdersRequest, lockOrderNumberList);
|
||||
// invoiceOrdersResponse.setTotalItems(allOrdersCount);
|
||||
// return invoiceOrdersResponse;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,6 +353,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
//对拷发票部分数据
|
||||
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(invoiceId);
|
||||
SpecificInvoicedResponse specificInvoicedResponse = new SpecificInvoicedResponse();
|
||||
//查不出来返回空包装类
|
||||
if (xhpcInvoice == null) {
|
||||
return specificInvoicedResponse;
|
||||
}
|
||||
specificInvoicedResponse.setCreatorTime(DateUtils.parseDateToStr(xhpcInvoice.getCreateTime()));
|
||||
specificInvoicedResponse.setReceiveEmail(xhpcInvoice.getReceiveEmail());
|
||||
specificInvoicedResponse.setTitleType(xhpcInvoice.getTitleType());
|
||||
@ -462,6 +466,11 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
invoiceHistoryRecordsRequest.setCurrentPage(startIndex);
|
||||
//获取该用户所提交的每个发票信息
|
||||
List<XhpcInvoice> invoicesList = xhpcInvoiceMapper.findInvoicesByCreatorIdAndCreatorType(invoiceHistoryRecordsRequest);
|
||||
//如果为0,那么则返回空的实体类出去
|
||||
InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = new InvoiceHistoryRecordsResponse();
|
||||
if (invoicesList.size() == 0) {
|
||||
return invoiceHistoryRecordsResponse;
|
||||
}
|
||||
//实体类对拷
|
||||
ArrayList<InvoiceHistoryRecordsResponse.ItemsDTO> itemsDTOS = new ArrayList<>();
|
||||
for (XhpcInvoice xhpcInvoice : invoicesList) {
|
||||
@ -473,7 +482,6 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
itemsDTO.setIsRead(xhpcInvoice.getIsRead());
|
||||
itemsDTOS.add(itemsDTO);
|
||||
}
|
||||
InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = new InvoiceHistoryRecordsResponse();
|
||||
invoiceHistoryRecordsResponse.setItems(itemsDTOS);
|
||||
Long userInvoiceItems = xhpcInvoiceMapper.getUserInvoiceItemsByCreatorIdAndCreatorType(invoiceHistoryRecordsRequest.getCreatorId(), invoiceHistoryRecordsRequest.getCreatorType());
|
||||
invoiceHistoryRecordsResponse.setTotalItems(userInvoiceItems);
|
||||
|
||||
@ -37,4 +37,5 @@ oss:
|
||||
#文件路径
|
||||
file:
|
||||
aliyunPath: invoicePdf/
|
||||
serverStoreDisposableFileLocation: /www/wwwroot/xhpc.scxhua.com/disposableFiles/
|
||||
# serverStoreDisposableFileLocation: /www/wwwroot/xhpc.scxhua.com/disposableFiles/
|
||||
serverStoreDisposableFileLocation: C:\\www\\wwwroot\\xhpc.scxhua.com\\disposableFiles\\
|
||||
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!--suppress ALL -->
|
||||
<mapper namespace="com.xhpc.invoice.mapper.XhpcInvoiceMapHistoryOrderMapper">
|
||||
<resultMap id="BaseResultMap" type="com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder">
|
||||
<result column="invoice_id" jdbcType="BIGINT" property="invoiceId"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user