| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.onlinePay.OnlinePayDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWeChatInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.job.adapt.DatabusAdaptImpl; |
| | | import com.java110.po.onlinePay.OnlinePayPo; |
| | |
| | | import org.apache.http.ssl.SSLContexts; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | |
| | | @Component(value = "returnPayFeeMoneyAdapt") |
| | | public class ReturnPayFeeMoneyAdapt extends DatabusAdaptImpl { |
| | | |
| | | |
| | | //微信支付 |
| | | public static final String DOMAIN_WECHAT_PAY = "WECHAT_PAY"; |
| | | // 微信服务商支付开关 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH = "WECHAT_SERVICE_PAY_SWITCH"; |
| | | |
| | | //开关ON打开 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH_ON = "ON"; |
| | | |
| | | |
| | | private static final String WECHAT_SERVICE_APP_ID = "SERVICE_APP_ID"; |
| | | |
| | | private static final String WECHAT_SERVICE_MCH_ID = "SERVICE_MCH_ID"; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | |
| | | |
| | | String payPassword = ""; |
| | | String certData = ""; |
| | | |
| | | String mchPassword = ""; |
| | | SmallWeChatDto smallWeChatDto = new SmallWeChatDto(); |
| | | smallWeChatDto.setMchId(onlinePayDtos.get(0).getMchId()); |
| | | smallWeChatDto.setAppId(onlinePayDtos.get(0).getAppId()); |
| | |
| | | if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) { |
| | | payPassword = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "key"); |
| | | certData = MappingCache.getRemark(WechatConstant.WECHAT_DOMAIN, "cert"); |
| | | mchPassword = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "mchId"); |
| | | } else { |
| | | payPassword = smallWeChatDtos.get(0).getPayPassword(); |
| | | certData = smallWeChatDtos.get(0).getCertPath(); |
| | | |
| | | mchPassword = smallWeChatDtos.get(0).getMchId(); |
| | | } |
| | | |
| | | SortedMap<String, String> parameters = new TreeMap<String, String>(); |
| | | String paySwitch = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_PAY_SWITCH); |
| | | |
| | | parameters.put("appid", onlinePayDtos.get(0).getAppId());//appid |
| | | parameters.put("mch_id", onlinePayDtos.get(0).getMchId());//商户号 |
| | | if (WECHAT_SERVICE_PAY_SWITCH_ON.equals(paySwitch)) { |
| | | mchPassword = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_MCH_ID); |
| | | parameters.put("mch_id", mchPassword);//商户号 |
| | | parameters.put("sub_mch_id", onlinePayDtos.get(0).getMchId());//商户号 |
| | | } |
| | | parameters.put("nonce_str", PayUtil.makeUUID(32));//随机数 |
| | | parameters.put("out_trade_no", onlinePayDtos.get(0).getOrderId());//商户订单号 |
| | | parameters.put("out_refund_no", onlinePayDtos.get(0).getPayId());//我们自己设定的退款申请号,约束为UK |
| | |
| | | ByteArrayInputStream inputStream = new ByteArrayInputStream(getPkcs12(certData)); |
| | | try { |
| | | //这里写密码..默认是你的MCHID |
| | | keyStore.load(inputStream, onlinePayDtos.get(0).getMchId().toCharArray()); |
| | | keyStore.load(inputStream, mchPassword.toCharArray()); |
| | | } finally { |
| | | inputStream.close(); |
| | | } |
| | | |
| | | SSLContext sslcontext = SSLContexts.custom() |
| | | //这里也是写密码的 |
| | | .loadKeyMaterial(keyStore, onlinePayDtos.get(0).getMchId().toCharArray()) |
| | | .loadKeyMaterial(keyStore, mchPassword.toCharArray()) |
| | | .build(); |
| | | SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( |
| | | sslcontext, |