完成查询发票抬头信息接口
完成查询用户最后一次输入的发票信息接口
This commit is contained in:
parent
07a23d1d27
commit
1fff4d3549
@ -0,0 +1,57 @@
|
||||
package com.xhpc.invoice.api;
|
||||
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.invoice.domain.InvoiceTitleResponse;
|
||||
import com.xhpc.invoice.domain.TitleResponse;
|
||||
import com.xhpc.invoice.service.XhpcInvoiceService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 小程序的InvoiceController
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/12/23 13:49
|
||||
* @since version-1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/invoice")
|
||||
public class XhpcInvoiceApiController extends BaseController {
|
||||
|
||||
@Resource
|
||||
XhpcInvoiceService xhpcInvoiceService;
|
||||
|
||||
/**
|
||||
* 查询发票抬头信息
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/12/23 15:07
|
||||
* @since version-1.0
|
||||
*/
|
||||
@GetMapping(value = "/selectInvoiceTitleInfo")
|
||||
public AjaxResult selectInvoiceTitleInfo(@RequestParam(value = "firmName") String firmName) {
|
||||
|
||||
InvoiceTitleResponse invoiceTitleResponse = xhpcInvoiceService.selectInvoiceTitleInfo(firmName);
|
||||
return AjaxResult.success(invoiceTitleResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户最后一次输入的发票信息
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/12/23 15:07
|
||||
* @since version-1.0
|
||||
*/
|
||||
@GetMapping(value = "/selectUserInputInvoiceInfo")
|
||||
public AjaxResult selectUserInputInvoiceInfo(@RequestParam(value = "creatorId") Long creatorId, @RequestParam("creatorType") Integer creatorType) {
|
||||
|
||||
TitleResponse titleResponse = xhpcInvoiceService.selectUserInputInvoiceInfo(creatorId, creatorType);
|
||||
return AjaxResult.success(titleResponse);
|
||||
}
|
||||
|
||||
}
|
||||
@ -42,21 +42,26 @@ public class XhpcInvoiceController extends BaseController {
|
||||
public AjaxResult invoiceToUser(@RequestBody InvoiceToUserRequest requestData) {
|
||||
//前置条件
|
||||
if (requestData.getInvoiceId() == null) {
|
||||
AjaxResult.error("必须传递未开发票id");
|
||||
return AjaxResult.error("必须传递未开发票id");
|
||||
}
|
||||
if (requestData.getStatus() == null || requestData.getStatus().equals(InvoiceStatusConst.INVOICING)) {
|
||||
AjaxResult.error("必须传递发票状态或发票不能为0");
|
||||
return AjaxResult.error("必须传递发票状态或发票状态不能为0");
|
||||
}
|
||||
//开失败发票
|
||||
if (requestData.getStatus().equals(InvoiceStatusConst.FAIL)) {
|
||||
Boolean flagOfjudge = xhpcInvoiceService.failInvoiceToUser(requestData);
|
||||
try {
|
||||
xhpcInvoiceService.failInvoiceToUser(requestData);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("开失败发票失败");
|
||||
}
|
||||
} else {
|
||||
//开成功发票
|
||||
try {
|
||||
//捕获参数异常
|
||||
Boolean flagOfjudge = xhpcInvoiceService.invoiceToUser(requestData);
|
||||
if (!flagOfjudge) {
|
||||
AjaxResult.error("客户邮箱有误,邮件未发送成功,请通知用户修改邮箱");
|
||||
return AjaxResult.error("客户邮箱有误,邮件未发送成功,请通知用户修改邮箱");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
@ -78,7 +83,7 @@ public class XhpcInvoiceController extends BaseController {
|
||||
public AjaxResult selectAllInvoiceOrders(@RequestBody AllInvoiceOrdersRequest requestData) {
|
||||
|
||||
if (requestData.getCurrentPage() == null || requestData.getItems() == null) {
|
||||
AjaxResult.error("当前页数、每页要显示的条数为必传递项");
|
||||
return AjaxResult.error("当前页数、每页要显示的条数为必传递项");
|
||||
}
|
||||
AllInvoiceOrdersResponse allInvoiceOrdersResponse = xhpcInvoiceService.selectAllInvoiceOrders(requestData);
|
||||
return AjaxResult.success(allInvoiceOrdersResponse);
|
||||
@ -99,8 +104,9 @@ public class XhpcInvoiceController extends BaseController {
|
||||
Long invoiceId = Long.valueOf(String.valueOf(invoiceIdMap.get("invoiceId")));
|
||||
SpecificInvoiceWrap specificInvoiceWrap = xhpcInvoiceService.selectSpecificInvoice(invoiceId);
|
||||
if (specificInvoiceWrap == null) {
|
||||
AjaxResult.error("要回显的订单发票id有误");
|
||||
return AjaxResult.error("要回显的订单发票id有误");
|
||||
}
|
||||
return AjaxResult.success(specificInvoiceWrap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.xhpc.invoice.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* selectInvoiceTitle接口的回显包装类
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/12/23
|
||||
* @since version-1.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class InvoiceTitleResponse {
|
||||
|
||||
/**
|
||||
* 存放公司税号的集合
|
||||
*/
|
||||
@JsonProperty("data")
|
||||
private List<DataDTO> data;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DataDTO {
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@JsonProperty("firmName")
|
||||
private String firmName;
|
||||
/**
|
||||
* 税号
|
||||
*/
|
||||
@JsonProperty("dutyNumber")
|
||||
private String dutyNumber;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.xhpc.invoice.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* /selectTitle接口的返回数据的包装类
|
||||
*
|
||||
* @author WH
|
||||
* @date 2021/12/23 17:07
|
||||
* @since version-1.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class TitleResponse {
|
||||
|
||||
/**
|
||||
* 用户接收发票的邮箱
|
||||
*/
|
||||
@JsonProperty("receiveEmail")
|
||||
private String receiveEmail;
|
||||
/**
|
||||
* 用户所要开的发票的抬头类型,0为企业用户,1为非企业用户
|
||||
*/
|
||||
@JsonProperty("titleType")
|
||||
private Integer titleType;
|
||||
/**
|
||||
* 用户所填写的发票抬头类型
|
||||
*/
|
||||
@JsonProperty("titleContent")
|
||||
private String titleContent;
|
||||
/**
|
||||
* 发票税号
|
||||
*/
|
||||
@JsonProperty("dutyNumber")
|
||||
private String dutyNumber;
|
||||
/**
|
||||
* 用户所要开的发票的抬头内容
|
||||
*/
|
||||
@JsonProperty("invoiceContent")
|
||||
private String invoiceContent;
|
||||
/**
|
||||
* 公司地址
|
||||
*/
|
||||
@JsonProperty("firmAddress")
|
||||
private String firmAddress;
|
||||
/**
|
||||
* 公司号码
|
||||
*/
|
||||
@JsonProperty("firmPhone")
|
||||
private String firmPhone;
|
||||
/**
|
||||
* 公司开户行
|
||||
*/
|
||||
@JsonProperty("firmBank")
|
||||
private String firmBank;
|
||||
/**
|
||||
* 公司开户行账户
|
||||
*/
|
||||
@JsonProperty("firmBankAccount")
|
||||
private String firmBankAccount;
|
||||
/**
|
||||
* 是否显示交易日期(0,为不显示,1为显示)
|
||||
*/
|
||||
@JsonProperty("isShowDate")
|
||||
private Integer isShowDate;
|
||||
/**
|
||||
* 用户所填写的备注
|
||||
*/
|
||||
@JsonProperty("userNotes")
|
||||
private String userNotes;
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.xhpc.invoice.mapper;
|
||||
import com.xhpc.invoice.domain.AllInvoiceOrdersRequest;
|
||||
import com.xhpc.invoice.domain.InvoiceToUserRequest;
|
||||
import com.xhpc.invoice.pojo.XhpcInvoice;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@ -86,10 +87,35 @@ public interface XhpcInvoiceMapper {
|
||||
/**
|
||||
* 更新指定发票状态,让其成为开发票失败状态
|
||||
*
|
||||
* @param requestData 更新数据的来源
|
||||
* @return Long 返回受影响的行数
|
||||
* @author WH
|
||||
* @date 2021/12/23 13:30
|
||||
* @since version-1.0
|
||||
*/
|
||||
Long failInvoiceToUser(InvoiceToUserRequest requestData);
|
||||
|
||||
/**
|
||||
* 模糊查询指定公司名称和税号
|
||||
*
|
||||
* @param firmName 公司名称
|
||||
* @return 返回几个公司的名称和税号
|
||||
* @author WH
|
||||
* @date 2021/12/23 15:54
|
||||
* @since version-1.0
|
||||
*/
|
||||
List<XhpcInvoice> selectInvoiceTitleInfo(String firmName);
|
||||
|
||||
/**
|
||||
* 查询用户最近一次提交发票的发票信息
|
||||
*
|
||||
* @param creatorId 用户id
|
||||
* @param creatorType 用户类型
|
||||
* @return 最近一次提交的发票信息
|
||||
* @author WH
|
||||
* @date 2021/12/23 17:29
|
||||
* @since version-1.0
|
||||
*/
|
||||
XhpcInvoice selectUserLastInputInvoiceInfo(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType);
|
||||
|
||||
}
|
||||
@ -1,9 +1,6 @@
|
||||
package com.xhpc.invoice.service;
|
||||
|
||||
import com.xhpc.invoice.domain.AllInvoiceOrdersRequest;
|
||||
import com.xhpc.invoice.domain.AllInvoiceOrdersResponse;
|
||||
import com.xhpc.invoice.domain.InvoiceToUserRequest;
|
||||
import com.xhpc.invoice.domain.SpecificInvoiceWrap;
|
||||
import com.xhpc.invoice.domain.*;
|
||||
|
||||
/**
|
||||
* 用于处理发票相关请求的Service
|
||||
@ -48,16 +45,36 @@ public interface XhpcInvoiceService {
|
||||
Boolean invoiceToUser(InvoiceToUserRequest requestData);
|
||||
|
||||
/**
|
||||
* 存储发票开失败的状态,将该发票所包含的订单释放,
|
||||
* 即将其所包含的历史订单的del_flag设置为1,表明已经被删除,
|
||||
* 然后将其发票状态设置为取消开票状态
|
||||
* 存储发票开失败的状态,将其发票状态设置为取消开票状态
|
||||
*
|
||||
* @param requestData 开票失败所传递的参数
|
||||
* @return 是否执行成功
|
||||
* @author WH
|
||||
* @date 2021/12/23 12:48
|
||||
* @since version-1.0
|
||||
*/
|
||||
Boolean failInvoiceToUser(InvoiceToUserRequest requestData);
|
||||
void failInvoiceToUser(InvoiceToUserRequest requestData);
|
||||
|
||||
/**
|
||||
* 查询发票抬头信息
|
||||
*
|
||||
* @param firmName 公司名称
|
||||
* @return 公司名称以及对应的税号
|
||||
* @author WH
|
||||
* @date 2021/12/23 15:29
|
||||
* @since version-1.0
|
||||
*/
|
||||
InvoiceTitleResponse selectInvoiceTitleInfo(String firmName);
|
||||
|
||||
/**
|
||||
* 查询用户输入的最后一次的开发票所填写的信息
|
||||
*
|
||||
* @param creatorId 用户id
|
||||
* @param creatorType 用户类型
|
||||
* @return 要回显的数据
|
||||
* @author WH
|
||||
* @date 2021/12/23 17:23
|
||||
* @since version-1.0
|
||||
*/
|
||||
TitleResponse selectUserInputInvoiceInfo(Long creatorId, Integer creatorType);
|
||||
|
||||
}
|
||||
|
||||
@ -4,10 +4,7 @@ import cn.hutool.extra.mail.MailUtil;
|
||||
import com.xhpc.common.core.utils.DateUtils;
|
||||
import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||
import com.xhpc.common.domain.XhpcChargingStation;
|
||||
import com.xhpc.invoice.domain.AllInvoiceOrdersRequest;
|
||||
import com.xhpc.invoice.domain.AllInvoiceOrdersResponse;
|
||||
import com.xhpc.invoice.domain.InvoiceToUserRequest;
|
||||
import com.xhpc.invoice.domain.SpecificInvoiceWrap;
|
||||
import com.xhpc.invoice.domain.*;
|
||||
import com.xhpc.invoice.mapper.*;
|
||||
import com.xhpc.invoice.pojo.XhpcInvoice;
|
||||
import com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder;
|
||||
@ -109,9 +106,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
//发送电子发票pdf到接收者邮箱
|
||||
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId());
|
||||
String receiveEmail = xhpcInvoice.getReceiveEmail();
|
||||
File eletricInvoiceFile = new File("D:\\Enterprise_Resources\\ElectricInvoice\\ElectricInvoice.pdf");
|
||||
//todo 从阿里云上下载下来电子发票
|
||||
File electricInvoiceFile = new File("D:\\Enterprise_Resources\\ElectricInvoice\\ElectricInvoice.pdf");
|
||||
try {
|
||||
MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, eletricInvoiceFile);
|
||||
MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return Boolean.FALSE;
|
||||
@ -126,11 +124,47 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean failInvoiceToUser(InvoiceToUserRequest requestData) {
|
||||
//todo
|
||||
//最后入库更新
|
||||
public void failInvoiceToUser(InvoiceToUserRequest requestData) {
|
||||
//根据操作人的id,查询操作人的名字
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(requestData.getDrawer()));
|
||||
requestData.setDrawer(sysUser.getNickName());
|
||||
//入库更新
|
||||
xhpcInvoiceMapper.failInvoiceToUser(requestData);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvoiceTitleResponse selectInvoiceTitleInfo(String firmName) {
|
||||
|
||||
List<XhpcInvoice> xhpcInvoiceList = xhpcInvoiceMapper.selectInvoiceTitleInfo(firmName);
|
||||
ArrayList<InvoiceTitleResponse.DataDTO> dataDTOList = new ArrayList<>();
|
||||
for (XhpcInvoice xhpcInvoice : xhpcInvoiceList) {
|
||||
InvoiceTitleResponse.DataDTO dataDTO = new InvoiceTitleResponse.DataDTO();
|
||||
dataDTO.setFirmName(xhpcInvoice.getTitleContent());
|
||||
dataDTO.setDutyNumber(xhpcInvoice.getDutyNumber());
|
||||
dataDTOList.add(dataDTO);
|
||||
}
|
||||
InvoiceTitleResponse invoiceTitleResponse = new InvoiceTitleResponse();
|
||||
invoiceTitleResponse.setData(dataDTOList);
|
||||
return invoiceTitleResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户输入的最后一次的开发票所填写的信息
|
||||
*
|
||||
* @param creatorId 用户id
|
||||
* @param creatorType 用户类型
|
||||
* @return 要回显的数据
|
||||
* @author WH
|
||||
* @date 2021/12/23 17:23
|
||||
* @since version-1.0
|
||||
*/
|
||||
@Override
|
||||
public TitleResponse selectUserInputInvoiceInfo(Long creatorId, Integer creatorType) {
|
||||
|
||||
XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectUserLastInputInvoiceInfo(creatorId, creatorType);
|
||||
TitleResponse titleResponse = new TitleResponse();
|
||||
BeanUtils.copyProperties(xhpcInvoice, titleResponse);
|
||||
return titleResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -124,6 +124,20 @@
|
||||
WHERE del_flag IS NULL
|
||||
AND `status` = 0
|
||||
</select>
|
||||
<select id="selectInvoiceTitleInfo" resultMap="BaseResultMap">
|
||||
SELECT title_content,
|
||||
duty_number
|
||||
FROM `xhpc_invoice`
|
||||
WHERE title_content LIKE concat("%", #{firmName}, "%")
|
||||
GROUP BY title_content LIMIT 0,3
|
||||
</select>
|
||||
<select id="selectUserLastInputInvoiceInfo" resultMap="BaseResultMap">
|
||||
SELECT *
|
||||
FROM `xhpc_invoice`
|
||||
WHERE creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType}
|
||||
ORDER BY invoice_id DESC LIMIT 0,1
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete
|
||||
from xhpc_invoice
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user