【R】商户Invoice接口

master
liuxinxin 5 years ago
parent 74d0ca7365
commit 1193f70c05

@ -47,4 +47,11 @@ public class PartnerInvoiceController {
params.put("client_moniker",client.getString("client_moniker"));
return params;
}
@GetMapping(value = "/trans_flow/pdf/{clientMoniker}")
public void exportTransFlowPDF(@PathVariable String clientMoniker,TradeLogQuery query,HttpServletResponse httpResponse) throws Exception {
JSONObject partner = new JSONObject();
partner.put("client_moniker",clientMoniker);
tradeLogService.exportTransFlowApi(query,partner,httpResponse);
}
}

@ -36,6 +36,8 @@ public interface TradeLogService {
void exportTransFlow(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception;
void exportTransFlowApi(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception;
void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception;
void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception;

@ -23,6 +23,7 @@ import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
@ -130,6 +131,8 @@ public class TradeLogServiceImpl implements TradeLogService {
private ClientDeviceMapper clientDeviceMapper;
@Resource
private MerchantInfoProvider merchantInfoProvider;
@Resource
private Locker locker;
// @Value("classpath:/jasper/trans_flow.jasper")
// @Value("classpath:/jasper/trans_flow_new.jasper")
@ -713,6 +716,44 @@ public class TradeLogServiceImpl implements TradeLogService {
}
}
@Override
public void exportTransFlowApi(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
query.setClearing_status(-1);
String clientKey = "exportTransFlow:" + partner.getString("client_id");
JSONObject client = clientManager.getClientInfoByMoniker(partner.getString("client_moniker"));
if (client == null) {
throw new InvalidShortIdException();
}
partner.put("client_id",client.getIntValue("client_id"));
partner.put("client",client);
long internal = 0;
try{
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
long start = formatter.parse(query.getDatefrom()).getTime();
long end= formatter.parse(query.getDateto()).getTime();
internal = (end-start)/(1000*60*60*24);
}catch (Exception e){
throw new ServerErrorException("查询参数格式不正确");
}
if(internal > 90){
throw new ServerErrorException("最大查询区间为90天请确认查询区间");
}
try{
if (!locker.lock(clientKey, 300_000)) {
throw new ServerErrorException("其他Invoice正在生成中请稍后再试");
}
exportTransFlow( query, partner, response);
}
finally {
locker.unlock(clientKey);
}
}
private void scaleDecimalVal(JSONObject obj, String key, String currency) {
BigDecimal decimal = obj.getBigDecimal(key);
if (decimal == null) {

Loading…
Cancel
Save