package com.hx.phip.his.service.impl;
|
|
import com.hx.phip.common.HisUrl;
|
import com.hx.phip.his.config.SystemConfig;
|
import com.hx.phiappt.dao.mapper.SystemParameterMapper;
|
import com.hx.phip.his.service.GetTokenService;
|
import com.hx.phip.his.service.SyncSalesFinancialDataService;
|
import com.hx.phip.uti.ApiUtil;
|
import com.hx.phip.uti.HisHttpUtil;
|
import com.hx.resultTool.Result;
|
import com.hx.util.StringUtils;
|
import com.hz.util.http.HttpHzUtil;
|
import com.hz.util.http.dto.HttpHzResponse;
|
import net.sf.json.JSONObject;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @Author
|
*/
|
@Transactional
|
@Service
|
public class SyncSalesFinancialDataServiceImpl implements SyncSalesFinancialDataService {
|
|
@Resource
|
private SystemParameterMapper systemParameterMapper;
|
@Resource
|
private SystemConfig systemConfig;
|
@Resource
|
private GetTokenService getTokenService;
|
/**
|
* 获取HIS token
|
* @return
|
*/
|
public String getToken(){
|
//获取 领健 token
|
String at = getTokenService.getHisToken(systemParameterMapper, systemConfig.getApiAppId(), systemConfig.getApiCode(),
|
systemConfig.getApiSecret(), systemConfig.getApiUrl());
|
return at;
|
}
|
@Override
|
public Result payment(JSONObject jsonObject) {
|
String at = getToken();
|
Map<String,String> header=new HashMap<>();
|
header.put("x-access-token",at);
|
StringBuffer url=new StringBuffer(systemConfig.getApiUrl()+ HisUrl.API_V1_BILLING_PAYMENT);
|
if(StringUtils.isEmpty(jsonObject.optString("page"))){
|
url.append("?page="+0);
|
}else {
|
url.append("?page="+jsonObject.optString("page"));
|
}
|
if(StringUtils.isEmpty(jsonObject.optString("size"))){
|
url.append("&size="+50);
|
}else {
|
url.append("&size="+jsonObject.optString("size"));
|
}
|
|
if (!StringUtils.isEmpty(jsonObject.optString("clinicId"))) url.append("&clinicId="+jsonObject.optString("size"));
|
if (!StringUtils.isEmpty(jsonObject.optString("customerId"))) url.append("&customerId="+jsonObject.optString("customerId"));
|
if (!StringUtils.isEmpty(jsonObject.optString("start"))) url.append("&start="+jsonObject.optString("start"));
|
if (!StringUtils.isEmpty(jsonObject.optString("end"))) url.append("&start="+jsonObject.optString("end"));
|
if(!StringUtils.isEmpty(jsonObject.optString("orderIds"))){
|
List<String> list = com.alibaba.fastjson.JSONArray.parseArray(jsonObject.optString("orderIds"), String.class);
|
for (String id : list) {
|
url.append("&orderIds="+id);
|
}
|
}
|
HttpHzResponse httpHzResponse = HttpHzUtil.HttpURLUtilJson(url.toString(),null,null,header,"GET",null);
|
|
return Result.success(httpHzResponse.getData());
|
}
|
}
|