|
@@ -0,0 +1,384 @@
|
|
|
+package com.iamberry.rst.util;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.iamberry.file.DownloadFile;
|
|
|
+import com.iamberry.nuonuo.bean.PrivateData;
|
|
|
+import com.iamberry.nuonuo.bean.PublicData;
|
|
|
+import com.iamberry.nuonuo.bean.RequestMode;
|
|
|
+import com.iamberry.nuonuo.exception.OpensnsException;
|
|
|
+import com.iamberry.nuonuo.oauth.Oauth2AccessToken;
|
|
|
+import com.iamberry.nuonuo.service.OpenApiV1;
|
|
|
+import com.iamberry.nuonuo.util.StateData;
|
|
|
+import com.iamberry.rst.core.ei.Billing;
|
|
|
+import com.iamberry.rst.core.ei.BillingItem;
|
|
|
+import com.iamberry.rst.core.ei.InvoPlatform;
|
|
|
+import com.iamberry.rst.core.ei.PlatformInfo;
|
|
|
+import com.iamberry.rst.faces.ei.BillingService;
|
|
|
+import com.iamberry.rst.faces.ei.InvoPlatformService;
|
|
|
+import com.iamberry.rst.faces.ei.PlatformInfoService;
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 诺诺开票系统
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class NuoNuoServiceUtil {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(NuoNuoServiceUtil.class);
|
|
|
+ private static String NUONUO_URL = NameUtils.getConfig("NUONUO_URL");
|
|
|
+ private static Integer NUONUO_ID = Integer.valueOf(NameUtils.getConfig("NUONUO_ID"));
|
|
|
+
|
|
|
+ private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InvoPlatformService invoPlatformService;
|
|
|
+ @Autowired
|
|
|
+ private PlatformInfoService platformInfoService;
|
|
|
+ @Autowired
|
|
|
+ private BillingService billingService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开票
|
|
|
+ * @param billing
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String nuoNInvo(Billing billing){
|
|
|
+ InvoPlatform invoPlatform = invoPlatformService.getInvoPlatformById(billing.getInvoPlatId());
|
|
|
+ PlatformInfo platformInfo = platformInfoService.getPlatformInfoById(billing.getPlatId());
|
|
|
+
|
|
|
+ if(StateData.app_id != billing.getInvoPlatId()){
|
|
|
+ this.setHeader(invoPlatform,platformInfo);
|
|
|
+ }
|
|
|
+ String msg = this.setToken(invoPlatform);
|
|
|
+ if(!"success".equals(msg)){
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,String> headers = getHeaders();
|
|
|
+ PublicData pdData = getPublicData("nuonuo.electronInvoice.requestBilling");
|
|
|
+ PrivateData<Object> pvData = new PrivateData<Object>();
|
|
|
+ List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
|
|
|
+ List<Map<String,Object>> list_invoiceDetail = new ArrayList<Map<String,Object>>();
|
|
|
+ Map<String,Object> map_s = new HashMap<String,Object>();
|
|
|
+ Map<String,Object> map_order = new HashMap<String,Object>();
|
|
|
+
|
|
|
+ map_order.put("buyerName", billing.getBillCompanyName()); //购方名称, 个人填“个人”
|
|
|
+ map_order.put("buyerTaxNum", billing.getBillTaxNumber()); //购方税号(企业要填,个人可为空)
|
|
|
+ if(billing.getBillTel() == null || "".equals(billing.getBillTel())){
|
|
|
+ map_order.put("buyerPhone", "13265476840"); //购方手机(开票成功会短信提醒购方,不受推送方式影响)
|
|
|
+ }else{
|
|
|
+ map_order.put("buyerPhone", billing.getBillTel()); //购方手机(开票成功会短信提醒购方,不受推送方式影响)
|
|
|
+ }
|
|
|
+ map_order.put("buyerAddress", billing.getBillAddress()); //购方地址
|
|
|
+
|
|
|
+ String billBankInfo = getStr(billing.getBillBankName()) + getStr(billing.getBillBankNumber());
|
|
|
+ map_order.put("buyerAccount", billBankInfo); // 购方银行账号及开户行地址
|
|
|
+ map_order.put("orderNo", billing.getBillOrderNo()); //订单号(每个企业唯一)
|
|
|
+
|
|
|
+ if(billing.getBillOrderDate() == null){
|
|
|
+ map_order.put("invoiceDate", sdf.format(new Date())); //订单时间
|
|
|
+ }else{
|
|
|
+ map_order.put("invoiceDate", sdf.format(billing.getBillOrderDate())); //订单时间
|
|
|
+ }
|
|
|
+
|
|
|
+ map_order.put("clerk", platformInfo.getPlatBilling()); //开票员 platBilling
|
|
|
+ String platBankInfo = getStr(platformInfo.getPlatBankName()) + getStr(platformInfo.getPlatBankNumber());
|
|
|
+ map_order.put("salerAccount", platBankInfo); //销方银行账号和开户行地址
|
|
|
+ map_order.put("salerTel", platformInfo.getPlatTel());
|
|
|
+ map_order.put("salerAddress", platformInfo.getPlatAddress());
|
|
|
+
|
|
|
+ if(1 == NUONUO_ID){ //表示沙箱环境
|
|
|
+ map_order.put("salerTaxNum", "339901999999142");
|
|
|
+ }else{
|
|
|
+ map_order.put("salerTaxNum", platformInfo.getPlatTaxNumber());
|
|
|
+ }
|
|
|
+
|
|
|
+ map_order.put("invoiceType", "1"); //开票类型:1,正票;2,红票
|
|
|
+ map_order.put("remark", ""); //冲红时,在备注中注明“对应正数发票代码:XXXXXXXXX号码:YYYYYYYY”文案,其中“X”为发票代码,“Y”为发票号码,可以不填,接口会自动添加该文案
|
|
|
+ map_order.put("payee", platformInfo.getPlatPayee()); //收款人platPayee
|
|
|
+ map_order.put("checker",platformInfo.getPlatReviewer()); //复核人 platReviewer
|
|
|
+ map_order.put("invoiceCode", ""); // 冲红时填写的对应蓝票发票代码(红票必填,不满12位请左补0)
|
|
|
+ map_order.put("invoiceNum", ""); //冲红时填写的对应蓝票发票号码(红票必填,不满8位请左补0)
|
|
|
+ map_order.put("pushMode", "1"); //推送方式:-1,不推送;0,邮箱;1,手机(默认);2,邮箱、手机
|
|
|
+ map_order.put("email", ""); //推送邮箱(pushMode为0或2时,此项为必填)
|
|
|
+ map_order.put("listFlag", "1"); //清单标志:0,根据项目名称数,自动产生清单;1,将项目信息打印至清单
|
|
|
+ map_order.put("listName", "详见销货清单"); //清单项目名称:打印清单时对应发票票面项目名称(listFlag为1是,此项为必填,默认为“详见销货清单”)
|
|
|
+ map_order.put("buyerTel", getStr(billing.getBillTel()));
|
|
|
+ map_order.put("proxyInvoiceFlag", "0"); //代开标志:0非代开;1代开。
|
|
|
+ map_order.put("departmentId", ""); //部门门店id(诺诺系统中的id) N
|
|
|
+ map_order.put("clerkId", ""); //开票员id(诺诺系统中的id) N
|
|
|
+
|
|
|
+ for (BillingItem billingItem : billing.getBillingItemList()) {
|
|
|
+ Map<String,Object> map_invoiceDetails = new HashMap<String,Object>();
|
|
|
+ map_invoiceDetails.put("goodsName", billingItem.getBillItemProductName()+"("+ billingItem.getBillItemColorName() +")"); //商品名称(如invoiceLineProperty =1,则此商品行为折扣行,折扣行不允许多行折扣,折扣行必须紧邻被折扣行,商品名称必须与被折扣行一致)
|
|
|
+ map_invoiceDetails.put("num", billingItem.getBillItemNum());
|
|
|
+ map_invoiceDetails.put("withTaxFlag", "1"); //单价含税标志,0:不含税,1:含税
|
|
|
+ map_invoiceDetails.put("price", Double.valueOf(billingItem.getBillItemUnitPrice())/100);
|
|
|
+ map_invoiceDetails.put("taxRate", "0.13"); //税率
|
|
|
+ map_invoiceDetails.put("specType", ""); //规格型号
|
|
|
+ map_invoiceDetails.put("unit", ""); // 单位
|
|
|
+ map_invoiceDetails.put("goodsCode", billingItem.getBillItemColorBar()); //商品编码(商品税收分类编码开发者自行填写) -- rst 标准69吗
|
|
|
+ map_invoiceDetails.put("selfCode", billingItem.getJdProductId()); //自行编码(可不填) - 京东
|
|
|
+ map_invoiceDetails.put("invoiceLineProperty", "0"); //发票行性质:0,正常行;1,折扣行;2,被折扣行
|
|
|
+ map_invoiceDetails.put("favouredPolicyFlag", "0"); //优惠政策标识:0,不使用;1,使用
|
|
|
+ map_invoiceDetails.put("favouredPolicyName", null); //增值税特殊管理(优惠政策名称),当favouredPolicyFlag为1时,此项必填
|
|
|
+ map_invoiceDetails.put("zeroRateFlag", null);
|
|
|
+ map_invoiceDetails.put("deduction", null); //扣除额。差额征收时填写,目前只支持填写一项
|
|
|
+// map_invoiceDetails.put("tax", "6.45");
|
|
|
+ map_invoiceDetails.put("taxIncludedAmount", null); //含税金额,[不含税金额] + [税额] = [含税金额],红票为负。不含税金额、税额、含税金额任何一个不传时,会根据传入的单价,数量进行计算,可能和实际数值存在误差,建议都传入
|
|
|
+ map_invoiceDetails.put("taxExcludedAmount", null); //不含税金额。红票为负。不含税金额、税额、含税金额任何一个不传时,会根据传入的单价,数量进行计算,可能和实际数值存在误差,建议都传入
|
|
|
+ list_invoiceDetail.add(map_invoiceDetails);
|
|
|
+ }
|
|
|
+
|
|
|
+ map_order.put("invoiceDetail", list_invoiceDetail);
|
|
|
+ map_order.put("invoiceLine", "p"); //发票种类:p,普通发票(电票)(默认);c,普通发票(纸票);s,专用发票;e,收购发票(电票);f,收购发票(纸质)
|
|
|
+ map_order.put("productOilFlag", "0"); //成品油标志:0,非成品油(默认);1,成品油
|
|
|
+ map_s.put("order", map_order);
|
|
|
+ list.add(map_s);
|
|
|
+ pvData.setServicedata(list);
|
|
|
+ RequestMode requestMode = getRequestMode(pdData,pvData);
|
|
|
+ OpenApiV1 sdk = new OpenApiV1();
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = sdk.handle(NUONUO_URL,headers, requestMode);
|
|
|
+ String invoiceSerialNum = ""; //调用结果与流水号
|
|
|
+ Integer status = 0; //状态 0:未开票; 1:开票中; 2为开票成功 3:开票失败;
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ if("E0000".equals(code)){
|
|
|
+ status = 1;
|
|
|
+ JSONObject jo = jsonObject.getJSONObject("result");
|
|
|
+ invoiceSerialNum = jo.getString("invoiceSerialNum");
|
|
|
+ msg = "success";
|
|
|
+ }else if("E9106".equals(code)){
|
|
|
+ status = 1;
|
|
|
+ msg = "success";
|
|
|
+ }else{
|
|
|
+ msg = "发票生成错误:"+result;
|
|
|
+ }
|
|
|
+ Billing bl = new Billing();
|
|
|
+ bl.setBillId(billing.getBillId());
|
|
|
+ bl.setBillInvoiceSerialNum(invoiceSerialNum); //billInvoiceSerialNum
|
|
|
+ bl.setBillResultMsg(msg);
|
|
|
+ bl.setBillStatus(status);
|
|
|
+ Integer flag = billingService.update(bl);
|
|
|
+ } catch (OpensnsException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ msg = "发票生成错误:"+result;
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取电子发票
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean invoGetByNuoNuo(String path){
|
|
|
+ boolean flag = true;
|
|
|
+
|
|
|
+ Billing bl = new Billing();
|
|
|
+ bl.setBillStatus(1);
|
|
|
+ List<Billing> billingList = billingService.getBillingList(bl);
|
|
|
+ if(billingList != null && billingList.size() > 0){
|
|
|
+ List<String> list_s = new ArrayList<>();
|
|
|
+ Integer platId = 0;
|
|
|
+ for (Billing bi:billingList) {
|
|
|
+ platId = bi.getPlatId();
|
|
|
+ list_s.add(bi.getBillInvoiceSerialNum());
|
|
|
+ }
|
|
|
+ invoGetByNuoNuoList(NUONUO_ID,platId,list_s,path);
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取电子发票
|
|
|
+ * @param InvoPlatId 诺诺平台在数据库的id
|
|
|
+ * @param platId 所属平台
|
|
|
+ * @param list_s
|
|
|
+ * @param path E:\java-work\iamberry-work\watero-rst-web\target\watero-rst-web\common
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void invoGetByNuoNuoList(Integer InvoPlatId,Integer platId, List<String> list_s,String path){
|
|
|
+ InvoPlatform invoPlatform = invoPlatformService.getInvoPlatformById(platId);
|
|
|
+ PlatformInfo platformInfo = platformInfoService.getPlatformInfoById(InvoPlatId);
|
|
|
+ if(StateData.app_id != InvoPlatId){
|
|
|
+ this.setHeader(invoPlatform,platformInfo);
|
|
|
+ }
|
|
|
+ this.setToken(invoPlatform);
|
|
|
+
|
|
|
+ Map<String,String> headers = getHeaders();
|
|
|
+ PublicData pdData = getPublicData("nuonuo.electronInvoice.CheckEInvoice");
|
|
|
+ PrivateData<Object> pvData = new PrivateData<Object>();
|
|
|
+ List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
|
|
|
+ Map<String,Object> map_s = new HashMap<String,Object>();
|
|
|
+ map_s.put("invoiceSerialNum", list_s);
|
|
|
+ list.add(map_s);
|
|
|
+ pvData.setServicedata(list);
|
|
|
+ RequestMode requestMode = getRequestMode(pdData,pvData);
|
|
|
+ OpenApiV1 sdk = new OpenApiV1();
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ result = sdk.handle(NUONUO_URL,headers, requestMode);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
+ String res = jsonObject.getString("result");
|
|
|
+ JSONArray jsonArray = JSON.parseArray(res);
|
|
|
+ for (int i=0;i<jsonArray.size();i++){
|
|
|
+ JSONObject jo = jsonArray.getJSONObject(i);
|
|
|
+ Integer status = jo.getInteger("status");
|
|
|
+ String orderNo = jo.getString("orderNo");
|
|
|
+ String statusMsg = jo.getString("statusMsg");
|
|
|
+ Billing billing = new Billing();
|
|
|
+ billing.setBillOrderNo(orderNo);
|
|
|
+ billing.setBillResultMsg(statusMsg);
|
|
|
+ if(2 == status){
|
|
|
+ String invoiceFileUrl = jo.getString("invoiceFileUrl");
|
|
|
+ String invoiceDate = jo.getString("invoiceDate"); //开票日期
|
|
|
+ String invoiceLine = jo.getString("invoiceLine");
|
|
|
+ String invoiceCode = jo.getString("invoiceCode"); //发票代码
|
|
|
+ String invoiceNum = jo.getString("invoiceNum"); ///发票号码
|
|
|
+ Double taxExcludedAmount = jo.getDouble("taxExcludedAmount")*100; //不含税金额 48*
|
|
|
+ Double taxIncludedAmount = jo.getDouble("taxIncludedAmount")*100; //总 48*
|
|
|
+
|
|
|
+ String pdfUnitPath = "common/ei/pdf";
|
|
|
+
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ DownloadFile.downLoadByUrl(invoiceFileUrl,orderNo+".pdf",path+pdfUnitPath);
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
+ System.out.println("下载pdf时间为:"+ (end-start));
|
|
|
+
|
|
|
+ String pdfFilePath = pdfUnitPath+ "/" + orderNo+".pdf";
|
|
|
+ billing.setBillStatus(status);
|
|
|
+ billing.setBillInvoiceFileUrl(pdfFilePath); //billInvoiceFileUrl
|
|
|
+ billing.setBillInvoiceImageUrl(invoiceFileUrl); //billInvoiceImageUrl
|
|
|
+ billing.setBillInvoiceDate(sdf.parse(invoiceDate));
|
|
|
+ billing.setBillInvoiceLine(invoiceLine);
|
|
|
+ billing.setBillTaxExcludedAmount(Integer.valueOf(taxExcludedAmount.intValue()));
|
|
|
+ billing.setBillTaxIncludedAmount(Integer.valueOf(taxIncludedAmount.intValue()));
|
|
|
+ billing.setBillInvoiceCode(invoiceCode);
|
|
|
+ billing.setBillInvoiceNum(invoiceNum);
|
|
|
+ Integer flag = billingService.updateByOrderNo(billing);
|
|
|
+ if(flag < 1){
|
|
|
+ logger.info("发票修改失败:"+result);
|
|
|
+ billing.setBillStatus(3);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ logger.info("订单编号:"+orderNo+",发票还在生成中!");
|
|
|
+ billing.setBillStatus(status);
|
|
|
+ }
|
|
|
+ Integer flag = billingService.updateByOrderNo(billing);
|
|
|
+ }
|
|
|
+ } catch (OpensnsException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.info("获取发票信息失败:"+list_s.toString());
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.info("获取发票信息失败:"+result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 如果token过期,获取新的token
|
|
|
+ * @param invoPlatform
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String setToken(InvoPlatform invoPlatform){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, 1); //因为有效期24小时,所以加一天
|
|
|
+ if(invoPlatform.getInvoPlatEndDate() == null || invoPlatform.getInvoPlatEndDate().before(new Date())){ //当前时间大于截止时间
|
|
|
+ StateData.grant_type_token = "authorization_code";
|
|
|
+ String msg = Oauth2AccessToken.getAccessToken();
|
|
|
+ String token = "";
|
|
|
+
|
|
|
+ try{
|
|
|
+ JSONObject jsonObject = JSON.parseObject(msg); //{"access_token":"fdd052d08bbad090aeff770tg7h2ehxs","expires_in":86400}
|
|
|
+ token = jsonObject.getString("access_token");
|
|
|
+ if(token == null || "".equals(token)){
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("获取新token失败,获取token结果:"+msg);
|
|
|
+ return "获取新token失败,获取token结果:"+msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ InvoPlatform ip = new InvoPlatform();
|
|
|
+ ip.setInvoPlatId(invoPlatform.getInvoPlatId());
|
|
|
+ ip.setInvoPlatAccessToken(token);
|
|
|
+ ip.setInvoPlatEndDate(calendar.getTime());
|
|
|
+ Integer flag = invoPlatformService.update(ip);
|
|
|
+ if(flag < 0){
|
|
|
+ logger.info("刷新诺诺token失败");
|
|
|
+ return "刷新诺诺token失败";
|
|
|
+ }
|
|
|
+ StateData.app_accessToken = token;
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置key
|
|
|
+ * @param invoPlatform
|
|
|
+ * @param platformInfo
|
|
|
+ */
|
|
|
+ private void setHeader(InvoPlatform invoPlatform,PlatformInfo platformInfo){
|
|
|
+ StateData.app_id = invoPlatform.getInvoPlatId(); //
|
|
|
+ StateData.app_secret = invoPlatform.getInvoPlatAppSecret(); // 填写本APP申请的 appSecret,注意区分正式环境与沙箱环境参数,如: 9B4CA8CEA5EE4823
|
|
|
+ StateData.app_key = invoPlatform.getInvoPlatAppKey(); // 填写本APP申请的 appKey,注意区分正式环境与沙箱环境参数,如:fk5dWkPA
|
|
|
+ StateData.app_accessToken = invoPlatform.getInvoPlatAccessToken(); // 填写本APP申请的 令牌 ,注意区分正式环境与沙箱环境参数,如://{"access_token":"fdd052d08bbad090aeff770kgia1mkms","expires_in":86400}
|
|
|
+ StateData.app_signType = "AES"; // 填写本APP传输数据加密格式,如:AES/AES
|
|
|
+
|
|
|
+ if(1 == NUONUO_ID){ //表示沙箱环境
|
|
|
+ StateData.user_Tax = "339901999999142";
|
|
|
+ }else{
|
|
|
+ StateData.user_Tax = platformInfo.getPlatTaxNumber(); //销方税号
|
|
|
+ }
|
|
|
+
|
|
|
+ Oauth2AccessToken.client_id = invoPlatform.getInvoPlatAppKey(); //创建应用后,分配给应用的appKey
|
|
|
+ Oauth2AccessToken.client_secret = invoPlatform.getInvoPlatAppSecret(); //创建应用后,分配给应用的appSecret
|
|
|
+ Oauth2AccessToken.token_grant_type = "client_credentials"; //授权类型,在本步骤中,此值为“authorization_code” ,获取token用client_credentials
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义请求头数据
|
|
|
+ private Map<String, String> getHeaders() {
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("appKey", StateData.app_key); // 用户申请的appkey
|
|
|
+ headers.put("accessToken", StateData.app_accessToken); // 用户Oauth登录后得到的令牌accessToken
|
|
|
+ headers.put("compress", StateData.app_compressType);// 压缩方式:提供GZIP 置空“”不压缩
|
|
|
+ headers.put("signMethod", StateData.app_signType); // 加密方式:提供AES/AES,不可为空
|
|
|
+ headers.put("dataType", StateData.app_dataType); // 数据请求格式: JSON/XML
|
|
|
+ headers.put("appRate", StateData.app_rate); // app并发请求数 ,平台默认10如需升级请联系开放平台
|
|
|
+ headers.put("userTax", StateData.user_Tax); // ISV下商家需要填写当前商户税号,普通商家模式用户可以不填写此值
|
|
|
+ headers.put("Content-Type", StateData.contentType); // http发送模式
|
|
|
+ return headers;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义请求体中的公共数据
|
|
|
+ private PublicData getPublicData(String api) {
|
|
|
+ PublicData pdData = new PublicData();
|
|
|
+ pdData.setVersion(StateData.app_apiVersion); // API版本
|
|
|
+ pdData.setTimestamp(String.valueOf(System.currentTimeMillis()));
|
|
|
+ pdData.setMethod(api);// API名称
|
|
|
+ return pdData;
|
|
|
+ }
|
|
|
+
|
|
|
+ private RequestMode getRequestMode(PublicData pdata, PrivateData<Object> pvData) {
|
|
|
+ RequestMode requestMode = new RequestMode();
|
|
|
+ requestMode.setPrivate(pvData);
|
|
|
+ requestMode.setPublic(pdata);
|
|
|
+ return requestMode;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getStr(String str){
|
|
|
+ if(str == null)
|
|
|
+ return "";
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+}
|