|
@ -52,6 +52,8 @@ import com.yihu.jw.wechat.dao.WechatDao;
|
|
|
import com.yihu.jw.wechat.dao.WxPayLogDao;
|
|
|
import com.yihu.jw.wechat.enterprise.EnterpriseService;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.network.HttpResponse;
|
|
|
import com.yihu.utils.network.HttpUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -432,18 +434,46 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
return HttpUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund",xml,hospitalSysDictDO.getDictCode(),hospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
|
|
|
|
|
|
public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId,boolean payFlag) throws Exception {
|
|
|
public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
|
|
|
HttpUtils httpUtils = new HttpUtils();
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("appid", appid);
|
|
|
param.put("secret", appSecret);
|
|
|
param.put("js_code", code);
|
|
|
param.put("grant_type", "authorization_code");
|
|
|
|
|
|
HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
|
|
|
org.json.JSONObject rs = new org.json.JSONObject(response.getContent());
|
|
|
Map<String, Object> res = new HashedMap();
|
|
|
logger.info("checkApplets:"+response.getContent());
|
|
|
if (rs.has("openid")){
|
|
|
res.put("openid", rs.getString("openid"));
|
|
|
res.put("sessionKey", rs.getString("session_key"));
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId,boolean payFlag,String appletCode) throws Exception {
|
|
|
WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
|
|
|
String body = businessOrderDO.getDescription();
|
|
|
String totalFee = businessOrderDO.getPayPrice().intValue()+"";
|
|
|
String patient = businessOrderDO.getPatient();
|
|
|
String openid = "";
|
|
|
if (StringUtils.isNoneBlank(patient)){
|
|
|
List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
|
|
|
if (patientWechatDo!=null&&patientWechatDo.size()!=0){
|
|
|
openid = patientWechatDo.get(0).getOpenid();
|
|
|
if (StringUtils.isNotBlank(appletCode)){
|
|
|
logger.info("appletCode不为空"+appletCode);
|
|
|
Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
|
|
|
if (objectMap!=null){
|
|
|
openid = objectMap.get("openid").toString();
|
|
|
logger.info("appletCode"+appletCode);
|
|
|
logger.info("openid"+openid);
|
|
|
}
|
|
|
}else {
|
|
|
logger.info("appletCode为空"+appletCode);
|
|
|
if (StringUtils.isNoneBlank(patient)){
|
|
|
List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
|
|
|
if (patientWechatDo!=null&&patientWechatDo.size()!=0){
|
|
|
openid = patientWechatDo.get(0).getOpenid();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String ourTradeNo = businessOrderDO.getOrderNo();
|
|
@ -516,10 +546,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
map.put("openid", openId);
|
|
|
}
|
|
|
if (tradeType.equalsIgnoreCase("APPLETS")){
|
|
|
BasePatientDO patientDO = patientDao.findById(code);
|
|
|
/*BasePatientDO patientDO = patientDao.findById(code);
|
|
|
if (patientDO!=null){
|
|
|
map.put("openid",patientDO.getOpenid());
|
|
|
}
|
|
|
}*/
|
|
|
map.put("openid", openId);
|
|
|
}
|
|
|
String wapUrl = "";
|
|
|
String wapName = "";
|