完成/selectInvoiceHistoryRecords用户开发票历史记录接口

This commit is contained in:
wen 2021-12-27 17:23:43 +08:00
parent a3de19f408
commit 6776fa3071
6 changed files with 115 additions and 14 deletions

View File

@ -1,10 +1,11 @@
package com.xhpc.common.core.utils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
/**
* 时间工具类
@ -63,24 +64,35 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return parseDateToStr(format, new Date());
}
public static final String dateTime(final Date date)
{
public static final String dateTime(final Date date) {
return parseDateToStr(YYYY_MM_DD, date);
}
public static final String parseDateToStr(final String format, final Date date)
{
public static final String parseDateToStr(final String format, final Date date) {
return new SimpleDateFormat(format).format(date);
}
public static final Date dateTime(final String format, final String ts)
{
try
{
/**
* 对parseDateStr方法进行再次封装默认转换格式为YYYY_MM_DD_HH_MM_SS
*
* @param date 时间对象
* @return YYYY_MM_DD_HH_MM_SS格式的时间字符串
* @author WH
* @date 2021/12/27 13:21
* @since version-1.0
*/
public static final String parseDateToStr(final Date date) {
return parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date);
}
public static final Date dateTime(final String format, final String ts) {
try {
return new SimpleDateFormat(format).parse(ts);
}
catch (ParseException e)
{
} catch (ParseException e) {
throw new RuntimeException(e);
}
}

View File

@ -30,9 +30,10 @@ public class XhpcInvoiceApiController extends BaseController {
* @since version-1.0
*/
@PostMapping(value = "/selectInvoiceHistoryRecords")
public AjaxResult selectInvoiceHistoryRecords(@RequestBody InvoicedOrdersRequest invoicedOrdersRequest) {
public AjaxResult selectInvoiceHistoryRecords(@RequestBody InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) {
return AjaxResult.success(null);
InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = xhpcInvoiceService.selectInvoiceHistoryRecords(invoiceHistoryRecordsRequest);
return AjaxResult.success(invoiceHistoryRecordsResponse);
}
/**

View File

@ -1,6 +1,7 @@
package com.xhpc.invoice.mapper;
import com.xhpc.invoice.domain.AllInvoiceOrdersRequest;
import com.xhpc.invoice.domain.InvoiceHistoryRecordsRequest;
import com.xhpc.invoice.domain.InvoiceToUserRequest;
import com.xhpc.invoice.pojo.XhpcInvoice;
import org.apache.ibatis.annotations.Param;
@ -111,6 +112,7 @@ public interface XhpcInvoiceMapper {
*
* @param creatorId 用户id
* @param creatorType 用户类型
*
* @return 最近一次提交的发票信息
* @author WH
* @date 2021/12/23 17:29
@ -118,4 +120,28 @@ public interface XhpcInvoiceMapper {
*/
XhpcInvoice selectUserLastInputInvoiceInfo(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType);
/**
* 查询用户提交的发票记录通过用户id用户类型来进行查询
*
* @param invoiceHistoryRecordsRequest 请求参数包装类
* @return 返回用户提交的发票记录
* @author WH
* @date 2021/12/27 15:30
* @since version-1.0
*/
List<XhpcInvoice> findInvoicesByCreatorIdAndCreatorType(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest);
/**
* 获取用户发票条数根据用户id和用户类型
*
* @param creatorId 用户id
* @param creatorType 用户类型
* @return 用户发票条数
* @author WH
* @date 2021/12/27 16:47
* @since version-1.0
*/
Long getUserInvoiceItemsByCreatorIdAndCreatorType(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType);
}

View File

@ -99,4 +99,15 @@ public interface XhpcInvoiceService {
*/
SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId);
/**
* 根据前端传递过来的请求参数查询所需要的开发票历史记录
*
* @param invoiceHistoryRecordsRequest 请求参数
* @return 所需要的开发票历史记录
* @author WH
* @date 2021/12/27 14:49
* @since version-1.0
*/
InvoiceHistoryRecordsResponse selectInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest);
}

View File

@ -249,6 +249,42 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
return specificInvoicedResponse;
}
/**
* 根据前端传递过来的请求参数查询所需要的开发票历史记录
*
* @param invoiceHistoryRecordsRequest 请求参数
* @return 所需要的开发票历史记录
* @author WH
* @date 2021/12/27 14:49
* @since version-1.0
*/
@Override
public InvoiceHistoryRecordsResponse selectInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) {
//计算分页索引
int startIndex = (int) ((invoiceHistoryRecordsRequest.getCurrentPage() - 1) * invoiceHistoryRecordsRequest.getItems());
if (startIndex < 0) {
startIndex = 0;
}
invoiceHistoryRecordsRequest.setCurrentPage(startIndex);
//获取该用户所提交的每个发票信息
List<XhpcInvoice> invoicesList = xhpcInvoiceMapper.findInvoicesByCreatorIdAndCreatorType(invoiceHistoryRecordsRequest);
//实体类对拷
ArrayList<InvoiceHistoryRecordsResponse.ItemsDTO> itemsDTOS = new ArrayList<>();
for (XhpcInvoice xhpcInvoice : invoicesList) {
InvoiceHistoryRecordsResponse.ItemsDTO itemsDTO = new InvoiceHistoryRecordsResponse.ItemsDTO();
itemsDTO.setInvoiceId(xhpcInvoice.getInvoiceId());
itemsDTO.setCreateTime(DateUtils.parseDateToStr(xhpcInvoice.getCreateTime()));
itemsDTO.setStatus(xhpcInvoice.getStatus());
itemsDTO.setInvoicingMoney(xhpcInvoice.getInvoiceMoney());
itemsDTOS.add(itemsDTO);
}
InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = new InvoiceHistoryRecordsResponse();
invoiceHistoryRecordsResponse.setItems(itemsDTOS);
Long userInvoiceItems = xhpcInvoiceMapper.getUserInvoiceItemsByCreatorIdAndCreatorType(invoiceHistoryRecordsRequest.getCreatorId(), invoiceHistoryRecordsRequest.getCreatorType());
invoiceHistoryRecordsResponse.setTotalItems(userInvoiceItems);
return invoiceHistoryRecordsResponse;
}
/**
* 通过发票id查找对应的发票数据
*

View File

@ -138,6 +138,21 @@
AND creator_type = #{creatorType}
ORDER BY invoice_id DESC LIMIT 0,1
</select>
<select id="findInvoicesByCreatorIdAndCreatorType" resultMap="BaseResultMap">
SELECT *
FROM xhpc_invoice
WHERE del_flag IS NULL
AND creator_id = #{creatorId}
AND creator_type = #{creatorType} LIMIT #{currentPage}
, #{items}
</select>
<select id="getUserInvoiceItemsByCreatorIdAndCreatorType" resultType="java.lang.Long">
SELECT count(invoice_id)
FROM xhpc_invoice
WHERE del_flag IS NULL
AND creator_id = #{creatorId}
AND creator_type = #{creatorType}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from xhpc_invoice