This commit is contained in:
liuzhao 2018-09-09 19:21:04 +08:00
parent bede8a1962
commit f5d80ff5d1
8 changed files with 928 additions and 16 deletions

View File

@ -0,0 +1,76 @@
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><%
/*
Author: undefined 2018-09-05
Content:
History Log:
*/
ASObjectModel doTemp = new ASObjectModel("BackRentInvoiceOthers");
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //--设置为Grid风格--
dwTemp.MultiSelect = true; //多选
dwTemp.ReadOnly = "1"; //只读模式
dwTemp.setPageSize(10);
dwTemp.genHTMLObjectWindow("");
//0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标CSS层叠样式 10、风格
String sButtons[][] = {
//{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""},
//{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""},
//{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""},
{"true","","Button","申请开票","申请开票","ApplyInvoice()","","","","btn_icon_add",""},
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function ApplyInvoice(){
if(confirm('确实要执行申请操作吗?')){
var sParm = getItemValueArray(0,"contract_id");
var types = getItemValueArray(0,"moneytype");
if(typeof(sParm) == "undefined" || sParm.length == 0 )
{
alert("请选择查询开票数据!");
return;
}
var moneyTypes = "";
for(var i = 0;i < types.length; i++){
moneyTypes += sParm[i]+"#"+types[i] +"@";
alert(moneyTypes);
}
moneyTypes = moneyTypes.substr(0,moneyTypes.length-1);
alert(moneyTypes);
/* for(var i = 0;i < sParm.length; i++){
if(uids.length == 0){
uids += sParm[i] +"@";
alert(uids);
}else{
uids += sParm[i] +"@";
alert(uids);
}
} */
spara = "moneyTypes="+moneyTypes+",CurUserID=<%=CurUser.getUserID()%>";
var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.apzl.invoicemanager.rentplaninvoice.rentPlanInvoiceManager","selectApplyOtherConfirm",spara);
alert(returnValue);
reloadSelf();
}
}
function newRecord(){
var sUrl = "";
AsControl.OpenView(sUrl,'','_self','');
}
function viewAndEdit(){
var sUrl = "";
var sPara = getItemValue(0,getRow(0),'SerialNo');
if(typeof(sPara)=="undefined" || sPara.length==0 ){
alert("参数不能为空!");
return ;
}
AsControl.OpenView(sUrl,'SerialNo=' +sPara ,'_self','');
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,63 @@
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><%
/*
Author: undefined 2018-08-09
Content:
History Log:
*/
ASObjectModel doTemp = new ASObjectModel("InvoiceRentInterest");
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //--设置为Grid风格--
dwTemp.ReadOnly = "1"; //只读模式
dwTemp.setPageSize(10);
dwTemp.MultiSelect=true;
dwTemp.genHTMLObjectWindow("");
//0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标CSS层叠样式 10、风格
String sButtons[][] = {
//{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""},
//{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""},
//{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""},
{"true","","Button","申请开票","申请开票","ApplyInvoice()","","","","btn_icon_add",""},
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function ApplyInvoice(){
if(confirm('确实要执行申请操作吗?')){
var sParm = getItemValueArray(0,"plan_id");
if(typeof(sParm) == "undefined" || sParm.length == 0 )
{
alert("请选择查询开票数据!");
return;
}
var planIds = "";
for(var i = 0;i < sParm.length; i++){
if(planIds.length == 0){
planIds += sParm[i] +"@";
}else{
planIds += sParm[i] +"@";
}
}
spara = "planIds="+planIds+",CurUserID=<%=CurUser.getUserID()%>";
var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.apzl.invoicemanager.rentplaninvoice.rentPlanInvoiceManager","selectApplyConfirm",spara);
alert(returnValue);
reloadSelf();
}
}
function newRecord(){
var sUrl = "";
AsControl.OpenView(sUrl,'','_self','');
}
function viewAndEdit(){
var sUrl = "";
var sPara = getItemValue(0,getRow(0),'SerialNo');
if(typeof(sPara)=="undefined" || sPara.length==0 ){
alert("参数不能为空!");
return ;
}
AsControl.OpenView(sUrl,'SerialNo=' +sPara ,'_self','');
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,85 @@
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><%
/*
Author: undefined 2018-09-03
Content:
History Log:
*/
ASObjectModel doTemp = new ASObjectModel("InvoiceRentPlanConfirm");
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //--设置为Grid风格--
dwTemp.MultiSelect = true; //多选
dwTemp.ReadOnly = "1"; //只读模式
dwTemp.setPageSize(10);
dwTemp.genHTMLObjectWindow("");
//0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标CSS层叠样式 10、风格
String sButtons[][] = {
//{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""},
//{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""},
//{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""},
{"true","","Button","退回","退回","gobackInvoice()","","","","btn_icon_return",""},
{"true","","Button","确认提交","确认提交","submitInvoice()","","","","btn_icon_submit",""},
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function submitInvoice(){
debugger;
var sParm = getItemValueArray(0,"id");
if(typeof(sParm) == "undefined" || sParm.length == 0 )
{
alert("请选择开票数据!");
return;
}
var ids = "";
for(var i = 0;i < sParm.length; i++){
if(ids.length == 0){
ids += sParm[i] +"@";
}else{
ids += sParm[i] +"@";
}
}
spara = "ids="+ids+",CurUserID=<%=CurUser.getUserID()%>";
var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.apzl.invoicemanager.rentplaninvoice.rentPlanInvoiceManager","invoiceConfirmSubmit",spara);
alert(returnValue);
reloadSelf();
}
function gobackInvoice(){
var sParm = getItemValueArray(0,"id");
if(typeof(sParm) == "undefined" || sParm.length == 0 )
{
alert("请选择开票数据!");
return;
}
var ids = "";
for(var i = 0;i < sParm.length; i++){
if(ids.length == 0){
ids += sParm[i] +"@";
}else{
ids += sParm[i] +"@";
}
}
spara = "ids="+ids+",CurUserID=<%=CurUser.getUserID()%>";
var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.apzl.invoicemanager.rentplaninvoice.rentPlanInvoiceManager","backInvoice",spara);
alert(returnValue);
reloadSelf();
}
function newRecord(){
var sUrl = "";
AsControl.OpenView(sUrl,'','_self','');
}
function viewAndEdit(){
var sUrl = "";
var sPara = getItemValue(0,getRow(0),'SerialNo');
if(typeof(sPara)=="undefined" || sPara.length==0 ){
alert("参数不能为空!");
return ;
}
AsControl.OpenView(sUrl,'SerialNo=' +sPara ,'_self','');
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -47,6 +47,9 @@
} */
spara = "sid="+sid+",CurUserID=<%=CurUser.getUserID()%>";
var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.lease.app.invoicemanager.InvoiceManagerController","selectConfirm",spara);
//var returnValue = AsControl.RunJavaMethodTrans("com.tenwa.apzl.invoicemanager.rentplaninvoice.rentPlanInvoiceManager","selectConfirm",spara);
alert(returnValue);
reloadSelf();
}

View File

@ -50,8 +50,8 @@
<tr style="height:40px;">
<td nowarp height="35" align="left" valign="middle" colspan="2" style="border-top:1px solid #d8d8d8">
<%=new Button("ÉêÇ뿪Ʊ", "", "newRecord()","","btn_icon_add").getHtmlText()%>
<%=new Button("暂不开票", "", "novoice()","","btn_icon_add").getHtmlText()%>
<%=new Button("修改开票信息", "", "viewAndEdit()","","btn_icon_edit").getHtmlText()%>
<%-- <%=new Button("暂不开票", "", "novoice()","","btn_icon_add").getHtmlText()%>
<%=new Button("修改开票信息", "", "viewAndEdit()","","btn_icon_edit").getHtmlText()%> --%>
</td>
</tr>
<tr>

View File

@ -3543,6 +3543,7 @@
<attribute name="plan_date" label="plan_date" type="STRING"/>
<attribute name="plan_money" label="plan_money" type="STRING"/>
<attribute name="invoice_money" label="invoice_money" type="STRING"/>
<attribute name="tax_type" label="tax_type" type="STRING"/>
<attribute name="cert_id" label="cert_id" type="STRING"/>
<attribute name="account" label="account" type="STRING"/>
<attribute name="acc_number" label="acc_number" type="STRING"/>

View File

@ -0,0 +1,684 @@
package com.tenwa.apzl.invoicemanager.rentplaninvoice;
import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import jbo.app.tenwa.calc.LC_RENT_PLAN;
import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM;
import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM_DETAIL;
import jbo.app.tenwa.calc.LI_INVOICE_RESULT;
import jbo.app.tenwa.calc.VI_INVOICE_RENT_PLAN_CONFIRM;
import jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS;
import jbo.app.tenwa.calc.VI_LI_INVOICE_RENT;
import jbo.app.tenwa.customer.CUSTOMER_COMPANY;
import jbo.app.tenwa.customer.CUSTOMER_PERSON;
import jbo.awe.USER_INFO;
import jbo.com.tenwa.entity.comm.invoice.LI_RENT_INVOICE_INFO;
import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT;
import jbo.com.tenwa.entity.comm.own.OWN_INFO;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.Configure;
import com.tenwa.app.invoice.action.InvoiceRequest;
import com.tenwa.app.invoice.data.ResponseEnum;
import com.tenwa.app.invoice.pojo.ResultPojo;
import com.tenwa.app.invoice.request.InvoiceRequestBase;
import com.tenwa.app.invoice.request.InvoiceRequestHead;
import com.tenwa.app.invoice.utils.DownloadPdfUtil;
import com.tenwa.app.invoice.utils.JaxbUtil;
import com.tenwa.app.invoice.utils.MathUtil;
import com.tenwa.app.invoice.utils.Num2ChineseUtil;
import com.tenwa.app.invoice.utils.PasswordGenerateUtil;
import com.tenwa.app.invoice.utils.ResultUtil;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.flow.action.comm.BaseTable;
import com.tenwa.util.SecurityUtil;
public class rentPlanInvoiceManager extends BaseTable{
private String planIds;
private String ids;
private String moneyTypes;
private String sid;
public String getPlanIds() {
return planIds;
}
public void setPlanIds(String planIds) {
this.planIds = planIds;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getMoneyTypes() {
return moneyTypes;
}
public void setMoneyTypes(String moneyTypes) {
this.moneyTypes = moneyTypes;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
/**
* 选择申请开票的数据
* @param tx
* @return
* @throws Exception
*/
public String selectApplyConfirm(JBOTransaction tx) throws Exception{
BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
BizObjectManager viInvoiceRentManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_RENT.CLASS_NAME);
tx.join(lriiManager);
tx.join(viInvoiceRentManager);
String[] planIds = this.getPlanIds().split("@");
String invoice_status = "1";
String bill_type = "invoice";
String invoice_money = "";
String tax_type = "";
String plan_id = "";
String PAYMENT_NUMBER = "";
String TAX_REG_CODE="";
String TAX_BANK="";
String TAX_ACC="";
String contract_id="";
for(int i=0;i<planIds.length;i++){
String id=UUID.randomUUID().toString().replaceAll("-", "");
String planId = planIds[i];
BizObject viInvoiceRent = viInvoiceRentManager.createQuery("plan_id=:plan_id").setParameter("plan_id", planId).getSingleResult(false);
invoice_money = viInvoiceRent.getAttribute("plan_money").toString();
plan_id = viInvoiceRent.getAttribute("plan_id").toString();
PAYMENT_NUMBER = viInvoiceRent.getAttribute("payment_number").toString();
TAX_REG_CODE = viInvoiceRent.getAttribute("cert_id").toString();
TAX_BANK = viInvoiceRent.getAttribute("bank_name").toString();
TAX_ACC = viInvoiceRent.getAttribute("acc_number").toString();
contract_id = viInvoiceRent.getAttribute("contract_id").toString();
tax_type = viInvoiceRent.getAttribute("tax_type").toString();
BizObject lriiObject = lriiManager.createQuery("plan_id=:plan_id").setParameter("plan_id", planId).getSingleResult(false);
if(lriiObject!=null){
lriiManager.createQuery("update o set invoice_status='1' where plan_id=:plan_id").setParameter("plan_id", planId).executeUpdate();
}else{
BizObject rentInvoiceInfo = lriiManager.newObject();
rentInvoiceInfo.setAttributeValue("id", id);
rentInvoiceInfo.setAttributeValue("invoice_status", invoice_status);
rentInvoiceInfo.setAttributeValue("bill_type", bill_type);
rentInvoiceInfo.setAttributeValue("invoice_money", invoice_money);
if("利息".equals(tax_type)){
rentInvoiceInfo.setAttributeValue("tax_type", "interest");
}else if("逾期利息".equals(tax_type)){
rentInvoiceInfo.setAttributeValue("tax_type", "overinterest");
}else{
return "金额类型为空!";
}
rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("plan_id", plan_id);
rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER", PAYMENT_NUMBER);
rentInvoiceInfo.setAttributeValue("TAX_REG_CODE", TAX_REG_CODE);// 纳税人识别号
rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);//开户行
rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);//开户账号
rentInvoiceInfo.setAttributeValue("contract_id", contract_id);
rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo);
lriiManager.saveObject(rentInvoiceInfo);
}
}
return "开票成功";
}
public String selectApplyOtherConfirm(JBOTransaction tx) throws Exception{
BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
BizObjectManager viInvoiceOtherManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_OTHERS.CLASS_NAME);
tx.join(lriiManager);
tx.join(viInvoiceOtherManager);
String[] moneyTypes = this.getMoneyTypes().split("@");
String invoice_status = "1";
String bill_type = "invoice";
String invoice_money = "";
String plan_id = "";
String PAYMENT_NUMBER = "";
String TAX_REG_CODE="";
String TAX_BANK="";
String TAX_ACC="";
String moneytype = "";
String contract_id="";
for(int i=0;i<moneyTypes.length;i++){
String id=UUID.randomUUID().toString().replaceAll("-", "");
String[] str = moneyTypes[i].split("#");
contract_id=str[0];
moneytype=str[1];
//Map<String,String> map = new HashMap<String, String>();
//map.put("contract_id", contract_id);
//map.put("moneytype", moneytype);
//BizObject viInvoiceOther = DataOperatorUtil.getJBOBySQL("SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O", "jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS", map, tx);
//BizObject viInvoiceOther = viInvoiceOtherManager.createQuery("contract_id=:contract_id AND moneytype=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false);
BizObject viInvoiceOther = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS", "SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O where contract_id=:contract_id AND moneytype=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false);
invoice_money = viInvoiceOther.getAttribute("invoice_price").toString();
PAYMENT_NUMBER = viInvoiceOther.getAttribute("PAYMENT_NUMBER").toString();
TAX_REG_CODE = viInvoiceOther.getAttribute("cert_id").toString();
TAX_BANK = viInvoiceOther.getAttribute("bank_name").toString();
TAX_ACC = viInvoiceOther.getAttribute("acc_number").toString();
BizObject lriiObject = lriiManager.createQuery("contract_id=:contract_id and tax_type=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false);
if(lriiObject !=null){
lriiManager.createQuery("update o set invoice_status='1' where contract_id=:contract_id and tax_type=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).executeUpdate();
}else{
BizObject rentInvoiceInfo = lriiManager.newObject();
rentInvoiceInfo.setAttributeValue("id", id);
rentInvoiceInfo.setAttributeValue("invoice_status", invoice_status);
rentInvoiceInfo.setAttributeValue("bill_type", bill_type);
rentInvoiceInfo.setAttributeValue("invoice_money", invoice_money);
if("gps".equals(moneytype)){
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
}else if("sxf".equals(moneytype)){
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
}else if("myhj".equals(moneytype)){
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
}else{
return "金额类型为空!";
}
rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("plan_id", plan_id);
rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER", PAYMENT_NUMBER);
rentInvoiceInfo.setAttributeValue("TAX_REG_CODE", TAX_REG_CODE);// 纳税人识别号
rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);//开户行
rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);//开户账号
rentInvoiceInfo.setAttributeValue("contract_id", contract_id);
rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo);
lriiManager.saveObject(rentInvoiceInfo);
}
}
return "开票成功";
}
/**
* 开票确认提交
* @param tx
* @return
* @throws Exception
*/
public String invoiceConfirmSubmit(JBOTransaction tx) throws Exception{
BizObjectManager ownAccountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME);
BizObject ownAccount = ownAccountManager.createQuery("state_=:state and acc_type=:acc_type and money_type=:money_type and account_type=:account_type")
.setParameter("state", "0010").setParameter("acc_type", "0010")
.setParameter("money_type", "01").setParameter("account_type", "invoice").getSingleResult(false);
if(ownAccount==null || "".equals(ownAccount)){
return "您的本方银行账户为空!";
}
String[] rentPlanids = this.getIds().split("@");
List<String> rentPlanIdList = new ArrayList<String>();
for(int i=0;i<rentPlanids.length;i++){
rentPlanIdList.add("'"+rentPlanids[i]+"'");
}
String customerid="";
String customerName="";
String rentPlanstr =StringUtils.join(rentPlanIdList.toArray(), ",");
BizObjectManager invoiceManager = JBOFactory.getBizObjectManager(VI_INVOICE_RENT_PLAN_CONFIRM.CLASS_NAME);
tx.join(invoiceManager);
@SuppressWarnings("unchecked")
List<BizObject> checkInvoiceList= (List<BizObject>)invoiceManager.createQuery("SELECT DISTINCT O.customer_name,O.CUSTOMER_ID FROM O WHERE O.id IN ("+rentPlanstr+")").getResultList(false);
if(checkInvoiceList!=null &&checkInvoiceList.size()>1){
return "选择的不是同一个客户!";
}else if(checkInvoiceList!=null &&checkInvoiceList.size()==1){
customerid = checkInvoiceList.get(0).getAttribute("CUSTOMER_ID").toString();
customerName = checkInvoiceList.get(0).getAttribute("customer_name").toString();
}else{
return "ERROR[02]";
}
String confirmId=UUID.randomUUID().toString().replaceAll("-", "");
Double hjje =0.00;
Double hjse = 0.00;
Double jshj = 0.00;
List<BizObject> confirmDetailList = new ArrayList<BizObject>();
DecimalFormat df2 = new DecimalFormat(".00");
DecimalFormat df6 = new DecimalFormat(".000000");
BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
Double sl = 0.06;
for(int i=0;i<rentPlanids.length;i++){
String invoiceId = rentPlanids[i];
BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
tx.join(confirmDetailManager);
BizObject confirmDetailBizObject = confirmDetailManager.newObject();
Double invoiceMoney = 0.00;
String planid="";
String planList="";
String TAX_TYPE ="";
BizObject invoiceRentBizObject = invoiceRentManager.createQuery("ID=:id ").setParameter("id",invoiceId).getSingleResult(false);
invoiceMoney = new BigDecimal(invoiceRentBizObject.getAttribute("INVOICE_MONEY").getString()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
TAX_TYPE = invoiceRentBizObject.getAttribute("TAX_TYPE").getString();
planid = invoiceRentBizObject.getAttribute("plan_id").toString();
if(planid !=null || !"".equals(planid)){
BizObjectManager rentPlanManager = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME);
BizObject rentPlan = rentPlanManager.createQuery("id=:plan_id").setParameter("plan_id", planid).getSingleResult(false);
planList = rentPlan.getAttribute("plan_list").toString();
planList = Num2ChineseUtil.format(planList);
if("overinterest".equals(TAX_TYPE)){
planList += " "+"逾期利息";
}
}
Double se = Double.valueOf( df2.format(invoiceMoney*sl ));
confirmDetailBizObject.setAttributeValue("dj","");
confirmDetailBizObject.setAttributeValue("je",invoiceMoney);
hjje=MathUtil.add(hjje, invoiceMoney);
hjse=MathUtil.add(hjse, se);
confirmDetailBizObject.setAttributeValue("invoice_type","interest");
confirmDetailBizObject.setAttributeValue("invoice_id",invoiceId);
confirmDetailBizObject.setAttributeValue("spsl","");
confirmDetailBizObject.setAttributeValue("dw","");
confirmDetailBizObject.setAttributeValue("fphxz","0");
/*if("sxf".equals(TAX_TYPE)){
confirmDetailBizObject.setAttributeValue("spmc","手续费");
}else if("myhj".equals(TAX_TYPE)){
confirmDetailBizObject.setAttributeValue("spmc","名义货价");
}else if("gps".equals(TAX_TYPE)){
confirmDetailBizObject.setAttributeValue("spmc","GPS安装服务费");
}else{
confirmDetailBizObject.setAttributeValue("spmc","租赁利息");
}*/
if("overinterest".equals(TAX_TYPE) || "interest".equals(TAX_TYPE)){
confirmDetailBizObject.setAttributeValue("spmc","租赁利息");
}else{
confirmDetailBizObject.setAttributeValue("spmc","其他费用");
}
confirmDetailBizObject.setAttributeValue("spsm","");
confirmDetailBizObject.setAttributeValue("ggxh",planList);
confirmDetailBizObject.setAttributeValue("invoice_confirm_id",confirmId);
confirmDetailBizObject.setAttributeValue("sl",sl);
confirmDetailBizObject.setAttributeValue("se",se);
confirmDetailBizObject.setAttributeValue("hsbz","0");
confirmDetailBizObject.setAttributeValue("spbm","3060109010000000000");
confirmDetailBizObject.setAttributeValue("zxbm","");
confirmDetailBizObject.setAttributeValue("yhzcbs","0");
confirmDetailBizObject.setAttributeValue("slbs","");
confirmDetailBizObject.setAttributeValue("zzstsgl","");
confirmDetailBizObject = this.initTabeUserInfo(confirmDetailBizObject);
confirmDetailManager.saveObject(confirmDetailBizObject);
confirmDetailList.add(confirmDetailBizObject);
}
if(confirmDetailList.size()>0){
BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME);
tx.join(confirmManager);
BizObject confirmBizObject = confirmManager.newObject();
String ownId = ownAccount.getAttribute("own_id").toString();
BizObjectManager ownInfoManager = JBOFactory.getBizObjectManager(OWN_INFO.CLASS_NAME);
BizObject ownInfo = ownInfoManager.createQuery("OWN_NUMBER=:OWN_NUMBER").setParameter("OWN_NUMBER", ownId).getSingleResult(false);
String xhdwdzdh = ownInfo.getAttribute("LEASE_TEL").toString();//销货单位地址电话
BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME);
BizObjectManager customerCompanyManager = JBOFactory.getBizObjectManager(CUSTOMER_COMPANY.CLASS_NAME);
BizObject customerPerson = customerPersonManager.createQuery("SELECT o.certid,caa.fulladdress,o.mobile,ca.acc_number,ca.bank_name from o JOIN jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca ON ca.customerid=o.customerid JOIN jbo.app.tenwa.customer.CUSTOMER_ADDRESS caa ON caa.customerid=ca.customerid where o.customerid=:customerid")
.setParameter("customerid", customerid).getSingleResult(false);
BizObject customerCompany = customerCompanyManager.createQuery("customerid=:customerid").setParameter("customerid", customerid).getSingleResult(false);
String companyTel="";
if(customerCompany!=null){
companyTel = customerCompany.getAttribute("company_tel").toString();
}
String certid="";
String fulladdress="";
String mobile="";
String acc_number="";
String bank_name="";
String acc_bank="";
String address_tel="";
if(customerPerson!=null){
certid=customerPerson.getAttribute("certid").toString();
fulladdress=customerPerson.getAttribute("fulladdress").toString();
mobile=customerPerson.getAttribute("mobile").toString();
acc_number=customerPerson.getAttribute("acc_number").toString();
bank_name=customerPerson.getAttribute("bank_name").toString();
acc_bank = "["+bank_name+"]["+acc_number+"]";
address_tel = "["+mobile+"]["+fulladdress+"]";
}
BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id,ci.customertype FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id JOIN jbo.app.tenwa.customer.CUSTOMER_INFO ci ON ci.customerid=lul.customer_id WHERE O.businesstype='1' AND lul.customer_id=:customerid").setParameter("customerid",customerid).getSingleResult(false);
String customertype = contractInfo.getAttribute("customertype").toString();//客户类型自然人或法人
BizObjectManager userInfoManager = JBOFactory.getBizObjectManager(USER_INFO.CLASS_NAME);
BizObject userInfo = userInfoManager.createQuery("userid=:userid").setParameter("userid", CurUserID).getSingleResult(false);
String username=userInfo.getAttribute("username").toString();//开票人
confirmBizObject.setAttributeValue("id", confirmId);
confirmBizObject.setAttributeValue("sid", PasswordGenerateUtil.getRandom(64, PasswordGenerateUtil.TYPE.LETTER_CAPITAL));
confirmBizObject.setAttributeValue("yylxdm", "1");
confirmBizObject.setAttributeValue("fplxdm", "026");
confirmBizObject.setAttributeValue("kplx", "0");
confirmBizObject.setAttributeValue("tspz", "00");
confirmBizObject.setAttributeValue("xhdwdzdh", xhdwdzdh);
confirmBizObject.setAttributeValue("xhdwyhzh", ownAccount.getAttribute("acc_number").toString());
confirmBizObject.setAttributeValue("ghdwsbh", certid);
confirmBizObject.setAttributeValue("ghdwmc", customerName);
confirmBizObject.setAttributeValue("ghdwdzdh", address_tel);
confirmBizObject.setAttributeValue("ghdwyhzh", acc_bank);
confirmBizObject.setAttributeValue("hsslbs", "0");
confirmBizObject.setAttributeValue("zhsl", "");
confirmBizObject.setAttributeValue("hjje", hjje);
confirmBizObject.setAttributeValue("hjse", hjse);
confirmBizObject.setAttributeValue("jshj", MathUtil.add( hjje,hjse ));
confirmBizObject.setAttributeValue("fhr", "");
confirmBizObject.setAttributeValue("kpr", username);
confirmBizObject.setAttributeValue("zyspmc", "");
confirmBizObject.setAttributeValue("spsm", "");
confirmBizObject.setAttributeValue("ssyf", "");
confirmBizObject.setAttributeValue("tzdbh", "");
confirmBizObject.setAttributeValue("yfpdm", "");
confirmBizObject.setAttributeValue("yfphm", "");
confirmBizObject.setAttributeValue("GMF_DZYX", "");
if(customertype=="01"){
confirmBizObject.setAttributeValue("GMF_SJHM", companyTel);
}else{
confirmBizObject.setAttributeValue("GMF_SJHM", mobile);
}
confirmBizObject.setAttributeValue("GMF_OPENID", "");
confirmBizObject = this.initTabeUserInfo(confirmBizObject);
confirmManager.saveObject(confirmBizObject);
InvoiceRequest invoiceRequest = new InvoiceRequest();
ResultPojo result = invoiceRequest.send(confirmBizObject,confirmDetailList);
if(result.getCode()==0){
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
System.out.println("[OK][returncode]=>>>"+returncode);
System.out.println("[OK][returnmsg]=>>>"+returnmsg);
if("0".equals(returncode)){
System.out.println("[OK][SUCCESS]");
for(BizObject confirmDetailBizObject : confirmDetailList){
String invoiceId = confirmDetailBizObject.getAttribute("invoice_id").toString();
String invoice_type = confirmDetailBizObject.getAttribute("invoice_type").toString();
//if("fund".equals(invoice_type)){
//invoiceFundManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate();
//}else{
invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate();
//}
}
return "开票申请成功";
}else{
return returnmsg;
}
}else{
System.out.println("[FAIL]=>>>"+result.getMsg());
return result.getMsg();
}
}else{
return "操作失败!";
}
}
/**
* 退回申请开票
* @param tx
* @return
* @throws Exception
*/
public String backInvoice(JBOTransaction tx) throws Exception{
BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
//BizObjectManager lfiiManager = JBOFactory.getBizObjectManager(LI_FUND_INVOICE_INFO.CLASS_NAME);
tx.join(lriiManager);
//tx.join(lfiiManager);
String[] rentPlanids = this.getIds().split("@");
for(int i=0;i<rentPlanids.length;i++){
//if(rentPlanids[i+1].equals("fund")){
// lfiiManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",rentPlanids[i]).setParameter("invoicestatus",InvoiceStatus).executeUpdate();
//}else{
lriiManager.createQuery("update o set INVOICE_STATUS='2' where ID=:id ").setParameter("id",rentPlanids[i]).executeUpdate();
//}
}
return "操作成功!";
}
public String selectConfirm(JBOTransaction tx) throws JBOException{
Configure config = Configure.getInstance();
String INVOICE_LOCAL_PATH="";
String appId = "";
try {
INVOICE_LOCAL_PATH = config.getConfigure("INVOICE_LOCAL_PATH");
appId = config.getConfigure("INVOICE_APPID");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "a3web->[INVOICE_LOCAL_PATH]不存在";
}
String sid = this.getSid();
InvoiceRequestBase invoiceRequestBase = new InvoiceRequestBase();
InvoiceRequestHead invoiceRequestHead = new InvoiceRequestHead();
invoiceRequestHead.setAppid(appId);
invoiceRequestHead.setSid(sid);
invoiceRequestBase.setHead(invoiceRequestHead);
invoiceRequestBase.setComment("查询开票结果");
invoiceRequestBase.setId("CXKPJG");
invoiceRequestBase.setVersion("1.0");
String xml = JaxbUtil.convertToXml(invoiceRequestBase);
ResultPojo result = doPost(xml);
BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME);
BizObject confirm = confirmManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false);
String invoice_confirm_id = confirm.getAttribute("id").toString();
String id=UUID.randomUUID().toString().replaceAll("-", "");
if(result.getCode()==0){
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
String fplxdm = responseBase.getBody().getFplxdm();
String fpdm = responseBase.getBody().getFpdm();
String fphm = responseBase.getBody().getFphm();
String kprq = responseBase.getBody().getKprq();
String hjje = responseBase.getBody().getHjje();
String skm = responseBase.getBody().getSkm();
String jym = responseBase.getBody().getJym();
String pdfurl = "";
String localFile = "";
String path="";
if("0".equals(returncode)){
pdfurl = responseBase.getBody().getPdfurl();
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYYMMdd");
String ydm = dateFormat.format(new Date());
path = File.separator + ydm.substring(0, 4)+File.separator + ydm.substring(4, 6)+File.separator + ydm.substring(6, 8);
path = path+File.separator+PasswordGenerateUtil.getRandom(50, PasswordGenerateUtil.TYPE.LETTER_CAPITAL)+".pdf";
localFile = INVOICE_LOCAL_PATH+path;
try {
DownloadPdfUtil.go(pdfurl,localFile);
} catch (Exception e) {
e.printStackTrace();
return "下载PDF失败";
}
}
try {
path = SecurityUtil.encrypt(path, "invoice");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BizObjectManager confirmResultManager = JBOFactory.getBizObjectManager(LI_INVOICE_RESULT.CLASS_NAME);
BizObject confirmResult = confirmResultManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false);
if(confirmResult==null){
BizObject confirmResultNew = confirmResultManager.newObject();
confirmResultNew.setAttributeValue("ID",id);
confirmResultNew.setAttributeValue("sid",sid);
confirmResultNew.setAttributeValue("fplxdm",fplxdm);
confirmResultNew.setAttributeValue("fpdm",fpdm );
confirmResultNew.setAttributeValue("fphm",fphm);
confirmResultNew.setAttributeValue("kprq",kprq);
confirmResultNew.setAttributeValue("hjje",hjje);
confirmResultNew.setAttributeValue("skm",skm);
confirmResultNew.setAttributeValue("jym",jym);
confirmResultNew.setAttributeValue("pdfurl",pdfurl);
confirmResultNew.setAttributeValue("localFile",path );
confirmResultNew.setAttributeValue("returncode",returncode);
confirmResultNew.setAttributeValue("returnmsg",returnmsg);
confirmResultManager.saveObject(confirmResultNew);
}else{
confirmResultManager.createQuery("update o set fplxdm=:fplxdm,fpdm=:fpdm,fphm=:fphm,kprq=:kprq,hjje=:hjje,skm=:skm,jym=:jym,pdfurl=:pdfurl,localFile=:localFile,returncode=:returncode,returnmsg=:returnmsg where sid=:sid ")
.setParameter("sid",sid).setParameter("fplxdm","fplxdm")
.setParameter("fpdm",fpdm).setParameter("fphm","fphm")
.setParameter("kprq",kprq).setParameter("hjje","hjje")
.setParameter("skm",skm).setParameter("jym","jym")
.setParameter("pdfurl",pdfurl).setParameter("localFile","localFile")
.setParameter("returncode",returncode).setParameter("returnmsg","returnmsg")
.executeUpdate();
}
System.out.println("[OK][returncode]=>>>"+returncode);
System.out.println("[OK][returnmsg]=>>>"+returnmsg);
if("0".equals(returncode)){
//System.out.println("[OK][SUCCESS]");
BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id").setParameter("invoice_confirm_id", invoice_confirm_id).getSingleResult(false);
String invoiceId = confirmDetail.getAttribute("invoice_id").toString();
BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME, tx);
invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate();
return "开票申请成功";
}else{
return returnmsg;
}
}else{
System.out.println("[FAIL]=>>>"+result.getMsg());
return result.getMsg();
}
/*
if(result.getCode().toString()!="0"){
return "查询失败";
}
System.out.println("result=>>>"+JSONObject.toJSONString(result));
showResult(result);
return "查询成功";*/
}
public ResultPojo doPost(String xml){
Configure config = Configure.getInstance();
String url="";
try {
url = config.getConfigure("INVOICE_URL");
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
HttpHeaders httpHeaders = new HttpHeaders();
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
param.add("bw",xml) ;
RestTemplate restTemplate = new RestTemplate();
HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(param, httpHeaders);
ResponseEntity<String> response = null ;
try {
response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
}catch (Exception e){
return ResultUtil.error(ResponseEnum.NETWORK.getMsg());
}
System.out.println(response.getBody());
InvoiceRequestBase r = JaxbUtil.converyToJavaBean(response.getBody(), InvoiceRequestBase.class);
return ResultUtil.success(r);
}
private void showResult(ResultPojo result) {
if(result.getCode()==0){
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
System.out.println("[OK][returncode]=>>>"+returncode);
System.out.println("[OK][returnmsg]=>>>"+returnmsg);
if("0".equals(returncode)){
System.out.println("[OK][SUCCESS]");
}
}else{
System.out.println("[FAIL]=>>>"+result.getMsg());
}
}
}

View File

@ -691,8 +691,8 @@ public class InvoiceManagerController extends BaseTable{
}
BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id WHERE lul.customer_id=:customerid").setParameter("customerid",customerid).getSingleResult(false);
String leas_form = contractInfo.getAttribute("leas_form").toString();
BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id,ci.customertype FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id JOIN jbo.app.tenwa.customer.CUSTOMER_INFO ci ON ci.customerid=lul.customer_id WHERE O.businesstype='1' AND lul.customer_id=:customerid").setParameter("customerid",customerid).getSingleResult(false);
String customertype = contractInfo.getAttribute("customertype").toString();
BizObjectManager userInfoManager = JBOFactory.getBizObjectManager(USER_INFO.CLASS_NAME);
@ -725,7 +725,7 @@ public class InvoiceManagerController extends BaseTable{
confirmBizObject.setAttributeValue("yfpdm", "");
confirmBizObject.setAttributeValue("yfphm", "");
confirmBizObject.setAttributeValue("GMF_DZYX", "");
if(leas_form=="01"){
if(customertype=="01"){
confirmBizObject.setAttributeValue("GMF_SJHM", companyTel);
}else{
confirmBizObject.setAttributeValue("GMF_SJHM", mobile);
@ -747,7 +747,7 @@ public class InvoiceManagerController extends BaseTable{
System.out.println("[OK][returnmsg]=>>>"+returnmsg);
if("0".equals(returncode)){
System.out.println("[OK][SUCCESS]");
for(BizObject confirmDetailBizObject : confirmDetailList){
/*for(BizObject confirmDetailBizObject : confirmDetailList){
String invoiceId = confirmDetailBizObject.getAttribute("invoice_id").toString();
String invoice_type = confirmDetailBizObject.getAttribute("invoice_type").toString();
if("fund".equals(invoice_type)){
@ -755,7 +755,7 @@ public class InvoiceManagerController extends BaseTable{
}else{
//invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate();
}
}
}*/
return "开票申请成功";
}else{
return returnmsg;
@ -868,17 +868,17 @@ public class InvoiceManagerController extends BaseTable{
System.out.println("[OK][returncode]=>>>"+returncode);
System.out.println("[OK][returnmsg]=>>>"+returnmsg);
if("0".equals(returncode)){
/*System.out.println("[OK][SUCCESS]");
BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id").setParameter("invoice_confirm_id", invoice_confirm_id).getSingleResult(false);
String invoiceId = confirmDetail.getAttribute("invoice_id").toString();
String invoice_type = confirmDetail.getAttribute("invoice_type").toString();
if("fund".equals(invoice_type)){
//System.out.println("[OK][SUCCESS]");
// BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
//BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id").setParameter("invoice_confirm_id", invoice_confirm_id).getSingleResult(false);
//String invoiceId = confirmDetail.getAttribute("invoice_id").toString();
// String invoice_type = confirmDetail.getAttribute("invoice_type").toString();
//if("fund".equals(invoice_type)){
//invoiceFundManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate();
}else{
//}else{
//invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate();
}
*/
//}
return "开票申请成功";
}else{
return returnmsg;