FnaElecInvoiceUtil.jsp
3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<%@page import="weaver.fna.invoice.common.FnaInvoiceCommon"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="weaver.file.FileUpload"%>
<%@page import="java.util.ArrayList"%>
<%@page import="weaver.fna.maintenance.BudgetfeeTypeComInfo"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.util.List"%>
<%@page import="weaver.fna.general.FnaCommon"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.general.BaseBean"%>
<%@page import="weaver.general.Util"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
User user = HrmUserVarify.getUser(request, response);
if(user == null){
throw new Exception(SystemEnv.getHtmlLabelName(125220, user.getLanguage()));//请重新登录
}
FnaInvoiceCommon fnaInvoiceCommon = new FnaInvoiceCommon();
int userid = user.getUID();
RecordSet rs = new RecordSet();
JSONObject returnJson = new JSONObject();
String jsonData = Util.null2String(request.getParameter("jsonData"));
BaseBean bb = new BaseBean();
FileUpload fu = new FileUpload(request,false);
String type = Util.null2String(fu.getParameter("type")).trim();
DecimalFormat df = new DecimalFormat("###########################0.00");
try{
if("list".equals(type)){//获取发票列表
//查询当前用户的所有发票信息(不局限于电子发票)
String sql = "select * from FnaInvoiceLedger where userid_new = "+userid+" order by billingDate desc";
rs.execute(sql);
String seller = "";//销售方
String purchaser = "";//购买方
double priceWithoutTax = 0d;
String billingDate = "";//开票日期
String status = "";//报销状态
JSONArray array = new JSONArray();
int status_count = 0;
while(rs.next()){
JSONObject json = new JSONObject();
seller = Util.null2String(rs.getString("seller"));
purchaser = Util.null2String(rs.getString("purchaser"));
priceWithoutTax = Util.getDoubleValue(rs.getString("taxIncludedPrice"),0.00);
billingDate = Util.null2String(rs.getString("billingDate"));
status = Util.null2String(rs.getString("status"));
if("1".equals(status) || "2".equals(status)){
status_count ++;
}
json.put("seller", seller);
json.put("purchaser", purchaser);
json.put("priceWithoutTax", df.format(priceWithoutTax));
json.put("billingDate", billingDate);
array.add(json);
}
returnJson.put("data", array);
returnJson.put("statusCount", status_count);
returnJson.put("err_code", "0");
}else if("synchronize".equals(type)){//同步电子发票
String poststr = Util.null2String(fu.getParameter("poststr")).trim();
poststr = poststr.replaceAll(",s,", "|");
JSONObject jsonObject = new JSONObject();
JSONArray array = new JSONArray();
for(int i = 0;i<poststr.split("\\|").length;i++){
JSONObject json = new JSONObject();
String card_id = poststr.split("\\|")[i].split(",")[0];
String encrypt_code = poststr.split("\\|")[i].split(",")[1];
String app_id = poststr.split("\\|")[i].split(",")[2];
card_id = card_id.replaceAll(" ","+");
encrypt_code = encrypt_code.replaceAll(" ","+");
// new BaseBean().writeLog("card_id:", card_id);
// new BaseBean().writeLog("encrypt_code:", encrypt_code);
// new BaseBean().writeLog("app_id:", app_id);
json.put("card_id", card_id);
json.put("encrypt_code", encrypt_code);
json.put("app_id", app_id);
array.add(json);
}
jsonObject.put("info", array);
String returnStr = fnaInvoiceCommon.getInfoEntrance(jsonObject, userid);
if(!"".equals(returnStr)){
returnJson.put("err_code", "1");
returnJson.put("err_msg", returnStr);
}
}
}catch(Exception e){
returnJson.put("err_code", "1");
returnJson.put("err_msg", e.getMessage());
}
out.print(returnJson);
%>