Commit a45d589c authored by jiaorz's avatar jiaorz

Merge branch 'master-invoice-modular' into dev

parents b9093bb4 89ef4069
...@@ -123,4 +123,9 @@ public class OrderInvoice { ...@@ -123,4 +123,9 @@ public class OrderInvoice {
* 发票PDF路径 * 发票PDF路径
*/ */
private String invoiceUrl; private String invoiceUrl;
/**
* 发票内容
*/
private String contentTitle;
} }
\ No newline at end of file
...@@ -9,10 +9,15 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -9,10 +9,15 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderInvoice; import com.xxfc.platform.order.entity.OrderInvoice;
import com.xxfc.platform.order.mapper.OrderInvoiceMapper; import com.xxfc.platform.order.mapper.OrderInvoiceMapper;
import com.xxfc.platform.order.pojo.dto.OrderInvoiceDto; import com.xxfc.platform.order.pojo.dto.OrderInvoiceDto;
import com.xxfc.platform.universal.entity.OrderData;
import com.xxfc.platform.universal.entity.vo.InvoiceVo;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -42,6 +47,10 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> { ...@@ -42,6 +47,10 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> {
@Autowired @Autowired
HttpServletRequest request; HttpServletRequest request;
@Autowired
ThirdFeign thirdFeign;
/** /**
* 添加发票记录 * 添加发票记录
* @return * @return
...@@ -56,6 +65,7 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> { ...@@ -56,6 +65,7 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> {
return ObjectRestResponse.paramIsEmpty(); return ObjectRestResponse.paramIsEmpty();
} }
String[] orderIdArray = orderInvoice.getOrderIds().split(","); String[] orderIdArray = orderInvoice.getOrderIds().split(",");
List<OrderData> list = Lists.newArrayList();
if (orderIdArray.length > 0) { if (orderIdArray.length > 0) {
for (int a = 0; a <= orderIdArray.length - 1; a ++) { for (int a = 0; a <= orderIdArray.length - 1; a ++) {
String orderId = StringUtils.isBlank(orderIdArray[a])? "0" : orderIdArray[a]; String orderId = StringUtils.isBlank(orderIdArray[a])? "0" : orderIdArray[a];
...@@ -66,26 +76,63 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> { ...@@ -66,26 +76,63 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> {
//查询是否已开票 //查询是否已开票
OrderInvoice oldValue = selectByUserIdAndOrderId(appUserDTO.getUserid(), Integer.parseInt(orderId)).getData(); OrderInvoice oldValue = selectByUserIdAndOrderId(appUserDTO.getUserid(), Integer.parseInt(orderId)).getData();
if (oldValue == null) { //不存在就添加 if (oldValue == null) { //不存在就添加
orderInvoice.setUserId(appUserDTO.getUserid()); OrderData orderData = new OrderData();
insertSelectiveRe(orderInvoice); if (baseOrder.getType() == OrderTypeEnum.RENT_VEHICLE.getCode()) {
log.info("添加发票记录成功: {}", orderInvoice); orderData.setOrderName(OrderTypeEnum.RENT_VEHICLE.getDesc());
OrderInvoice newValue = selectByUserIdAndOrderId(appUserDTO.getUserid(), Integer.parseInt(orderId)).getData();
if(newValue != null) {
baseOrder.setInvoiceStatus(1);
baseOrder.setInvoiceId(newValue.getId());
baseOrderBiz.updateBaseOrder(baseOrder);
} else {
return ObjectRestResponse.createFailedResult(ResultCode.DB_OPERATION_FAIL_CODE, ResultCode.getMsg(ResultCode.DB_OPERATION_FAIL_CODE));
} }
if (baseOrder.getType() == OrderTypeEnum.TOUR.getCode()) {
orderData.setOrderName(OrderTypeEnum.TOUR.getDesc());
}
if (baseOrder.getType() == OrderTypeEnum.MEMBER.getCode()) {
orderData.setOrderName(OrderTypeEnum.MEMBER.getDesc());
}
orderData.setPrice(baseOrder.getRealAmount());
list.add(orderData);
continue;
} else {//已开票 } else {//已开票
log.info("该订单已经开票, {}", orderId); log.info("该订单已经开票, {}", orderId);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该订单已经开票: orderId = " + orderId); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该订单已经开票: orderId = " + orderId);
} }
} }
orderInvoice.setUserId(appUserDTO.getUserid());
insertSelectiveRe(orderInvoice);
log.info("添加发票记录成功: {}", orderInvoice);
List<OrderInvoice> invoiceList = selectByIds(orderInvoice.getOrderIds()).getData();
if(invoiceList != null && invoiceList.size() > 0) {
OrderInvoice newValue = invoiceList.get(0);
//调用第三方开票接口
InvoiceVo invoiceVo = new InvoiceVo();
invoiceVo.setContent(newValue.getContentTitle());
invoiceVo.setOrderId(newValue.getOrderIds());
invoiceVo.setPurchaserAccountBank(newValue.getContentAccount());
invoiceVo.setPurchaserAddressPhone(newValue.getContentContact());
invoiceVo.setPurchaserEmail(newValue.getReceiveContent());
invoiceVo.setPurchaserName(newValue.getTitleName());
invoiceVo.setPurchaserTaxCode(newValue.getTaxCode());
invoiceVo.setRemark(newValue.getContentRemark());
invoiceVo.setOrderInvoiceId(newValue.getId());
thirdFeign.invoicing(invoiceVo);
//更新订单状态
for (int a = 0; a <= orderIdArray.length - 1; a ++) {
String orderId = StringUtils.isBlank(orderIdArray[a]) ? "0" : orderIdArray[a];
BaseOrder baseOrder = baseOrderBiz.selectById(Integer.parseInt(orderId));
if (baseOrder == null) {
return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_EXIST.getCode(), ResCode.ORDER_IS_NOT_EXIST.getDesc() + ", 订单Id = " + orderId);
}
baseOrder.setInvoiceStatus(1);
baseOrder.setInvoiceId(newValue.getId());
baseOrderBiz.updateBaseOrder(baseOrder);
}
} else {
return ObjectRestResponse.createFailedResult(ResultCode.DB_OPERATION_FAIL_CODE, ResultCode.getMsg(ResultCode.DB_OPERATION_FAIL_CODE));
}
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
/** /**
* 根据orderIds字符串查询对应的发票记录 * 根据orderIds字符串查询对应的发票记录
* @param orderIds * @param orderIds
......
...@@ -25,9 +25,11 @@ public class Invoice { ...@@ -25,9 +25,11 @@ public class Invoice {
private String orderId; private String orderId;
/** /**
* 公司代码 * 发票订单表id
*/ */
private String companyCode; private Integer orderInvoiceId;
/** /**
* 发票订单号 * 发票订单号
...@@ -35,11 +37,18 @@ public class Invoice { ...@@ -35,11 +37,18 @@ public class Invoice {
private String orderNo; private String orderNo;
/**
* 公司代码
*/
private String companyCode;
/** /**
* 机构代码 * 机构代码
*/ */
private String orgCode; private String orgCode;
/** /**
* 发票代码 * 发票代码
*/ */
......
...@@ -3,6 +3,8 @@ package com.xxfc.platform.universal.entity; ...@@ -3,6 +3,8 @@ package com.xxfc.platform.universal.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.Date; import java.util.Date;
...@@ -13,6 +15,9 @@ import java.util.Date; ...@@ -13,6 +15,9 @@ import java.util.Date;
@Data @Data
@Table(name = "invoice_query_error") @Table(name = "invoice_query_error")
public class InvoiceQueryError { public class InvoiceQueryError {
@Id
@GeneratedValue(generator ="JDBC" )
private Integer id; private Integer id;
private Integer invoiceId; private Integer invoiceId;
private String invoiceSerialNum; private String invoiceSerialNum;
......
...@@ -14,56 +14,60 @@ import java.util.List; ...@@ -14,56 +14,60 @@ import java.util.List;
@Data @Data
public class InvoiceVo { public class InvoiceVo {
/** /**
* 发票分类:01 专票,02 货物运输业增值税专用发票,03 机动车销售统一发票, * 发票分类:01 专票,02 货物运输业增值税专用发票,03 机动车销售统一发票,
* 04 增值税普通发票,10 增值税普通发票(电子),11 增值税普通发票(卷票),14 增值税普通发票(卷票) * 04 增值税普通发票,10 增值税普通发票(电子),11 增值税普通发票(卷票),14 增值税普通发票(卷票)
*/ */
private Integer invoiceCategory=10; private Integer invoiceCategory = 10;
/** /**
* 订单id :多个以逗号隔开 * 订单id :多个以逗号隔开
*/ */
private String orderId; private String orderId;
/**
* 发票订单表id
*/
private Integer orderInvoiceId;
/** /**
* 备注 * 备注
*/ */
private String remark; private String remark;
/** /**
* 购买方名称 * 购买方名称
*/ */
private String purchaserName; private String purchaserName;
/** /**
* 购买方纳税人识别号 * 购买方纳税人识别号
*/ */
private String purchaserTaxCode; private String purchaserTaxCode;
/** /**
* 购方邮箱 * 购方邮箱
*/ */
private String purchaserEmail; private String purchaserEmail;
/** /**
* 购买方地址电话 * 购买方地址电话
*/ */
private String purchaserAddressPhone; private String purchaserAddressPhone;
/** /**
* 购买方银行账号 * 购买方银行账号
*/ */
private String purchaserAccountBank; private String purchaserAccountBank;
/** /**
* 开票内容 * 开票内容
*/ */
private String content; private String content;
/**
* 购方手机
*/
private String purchaserPhone;
/**
* 购方手机
*/
private String purchaserPhone;
private List<OrderData> orders; private List<OrderData> orders;
} }
...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.entity.vo.InvoiceVo;
import com.xxfc.platform.universal.vo.*; import com.xxfc.platform.universal.vo.*;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -94,4 +95,9 @@ public interface ThirdFeign { ...@@ -94,4 +95,9 @@ public interface ThirdFeign {
@RequestMapping("/captcha/app/unauth/verify") @RequestMapping("/captcha/app/unauth/verify")
ObjectRestResponse<Boolean> verify(@RequestParam(value = "phone")String phone, @RequestParam(value = "pointList")String pointList); ObjectRestResponse<Boolean> verify(@RequestParam(value = "phone")String phone, @RequestParam(value = "pointList")String pointList);
/************************************发票*************************************/
@PostMapping("/invoice/invoicing")
public ObjectRestResponse invoicing(@RequestBody InvoiceVo invoiceVo);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment