Commit 89ef4069 authored by jiaorz's avatar jiaorz

发票

parent 754b5937
...@@ -10,6 +10,7 @@ import com.github.wxiaoqi.security.common.util.Query; ...@@ -10,6 +10,7 @@ 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.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;
...@@ -75,11 +76,30 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> { ...@@ -75,11 +76,30 @@ 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) { //不存在就添加
OrderData orderData = new OrderData();
if (baseOrder.getType() == OrderTypeEnum.RENT_VEHICLE.getCode()) {
orderData.setOrderName(OrderTypeEnum.RENT_VEHICLE.getDesc());
}
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 {//已开票
log.info("该订单已经开票, {}", orderId);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该订单已经开票: orderId = " + orderId);
}
}
orderInvoice.setUserId(appUserDTO.getUserid()); orderInvoice.setUserId(appUserDTO.getUserid());
insertSelectiveRe(orderInvoice); insertSelectiveRe(orderInvoice);
log.info("添加发票记录成功: {}", orderInvoice); log.info("添加发票记录成功: {}", orderInvoice);
OrderInvoice newValue = selectByUserIdAndOrderId(appUserDTO.getUserid(), Integer.parseInt(orderId)).getData(); List<OrderInvoice> invoiceList = selectByIds(orderInvoice.getOrderIds()).getData();
if(newValue != null) { if(invoiceList != null && invoiceList.size() > 0) {
OrderInvoice newValue = invoiceList.get(0);
//调用第三方开票接口 //调用第三方开票接口
InvoiceVo invoiceVo = new InvoiceVo(); InvoiceVo invoiceVo = new InvoiceVo();
invoiceVo.setContent(newValue.getContentTitle()); invoiceVo.setContent(newValue.getContentTitle());
...@@ -90,22 +110,29 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> { ...@@ -90,22 +110,29 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> {
invoiceVo.setPurchaserName(newValue.getTitleName()); invoiceVo.setPurchaserName(newValue.getTitleName());
invoiceVo.setPurchaserTaxCode(newValue.getTaxCode()); invoiceVo.setPurchaserTaxCode(newValue.getTaxCode());
invoiceVo.setRemark(newValue.getContentRemark()); invoiceVo.setRemark(newValue.getContentRemark());
invoiceVo.setOrderInvoiceId(newValue.getId());
thirdFeign.invoicing(invoiceVo); 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.setInvoiceStatus(1);
baseOrder.setInvoiceId(newValue.getId()); baseOrder.setInvoiceId(newValue.getId());
baseOrderBiz.updateBaseOrder(baseOrder); baseOrderBiz.updateBaseOrder(baseOrder);
}
} else { } else {
return ObjectRestResponse.createFailedResult(ResultCode.DB_OPERATION_FAIL_CODE, ResultCode.getMsg(ResultCode.DB_OPERATION_FAIL_CODE)); return ObjectRestResponse.createFailedResult(ResultCode.DB_OPERATION_FAIL_CODE, ResultCode.getMsg(ResultCode.DB_OPERATION_FAIL_CODE));
} }
} else {//已开票
log.info("该订单已经开票, {}", orderId);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该订单已经开票: orderId = " + orderId);
}
}
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
/** /**
* 根据orderIds字符串查询对应的发票记录 * 根据orderIds字符串查询对应的发票记录
* @param orderIds * @param orderIds
......
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