|
@@ -11,7 +11,7 @@ import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
|
|
|
-import com.rongwei.zhsw.system.config.WeChatLoginApiPara;
|
|
|
+import com.rongwei.zhsw.system.config.WeChatAboutApiPara;
|
|
|
import com.rongwei.zhsw.system.dao.CommonBusinessDao;
|
|
|
import com.rongwei.zhsw.system.service.impl.SwBillingRecordServiceImpl;
|
|
|
import com.rongwei.zhsw.system.service.impl.SwEnterpriseConfigInfoServiceImpl;
|
|
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.crypto.Cipher;
|
|
|
import javax.crypto.spec.GCMParameterSpec;
|
|
@@ -46,7 +45,7 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
@Autowired
|
|
|
private SwEnterpriseConfigInfoServiceImpl swEnterpriseConfigInfoService;
|
|
|
@Autowired
|
|
|
- private WeChatLoginApiPara weChatLoginApiPara;
|
|
|
+ private WeChatAboutApiPara weChatAboutApiPara;
|
|
|
@Autowired
|
|
|
private RedisServiceImpl redisService;
|
|
|
@Autowired
|
|
@@ -101,7 +100,7 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
throw new CustomException("商户支付配置错误,请联系系统管理员!");
|
|
|
}
|
|
|
|
|
|
- WxPayApi wxPayApi = new WxPayApi(merchantid, merchantprivatekey, merchantserialnumber, merchantsecretkey, weChatLoginApiPara.getAppid());
|
|
|
+ WxPayApi wxPayApi = new WxPayApi(merchantid, merchantprivatekey, merchantserialnumber, merchantsecretkey, weChatAboutApiPara.getAppid(), weChatAboutApiPara.getPaymentCallbackUrl());
|
|
|
wxPayApi.initMerchant();
|
|
|
// 生成订单号 规则
|
|
|
String nonceStr = UUID.randomUUID().toString().replaceAll("-", "");
|
|
@@ -122,16 +121,15 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
- public R prepayNotice(PrepayNoticeVo prepayNoticeVo,String dskey) {
|
|
|
+ public R prepayNotice(PrepayNoticeVo prepayNoticeVo, String dskey) {
|
|
|
log.info("获取到的回调信息接口:{}", prepayNoticeVo);
|
|
|
List<String> dsKeys;
|
|
|
- if(StringUtils.isBlank(dskey)){
|
|
|
+ if (StringUtils.isBlank(dskey)) {
|
|
|
List<TenantDo> tenantList = (List<TenantDo>) redisService.getRedisCatchObj("allTenants");
|
|
|
// 获取 所有的主库信息
|
|
|
- dsKeys= tenantList.stream().map(TenantDo::getDskey).collect(Collectors.toList());
|
|
|
- }else{
|
|
|
- dsKeys= Collections.singletonList(dskey);
|
|
|
+ dsKeys = tenantList.stream().map(TenantDo::getDskey).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ dsKeys = Collections.singletonList(dskey);
|
|
|
}
|
|
|
dsKeys.remove("incontrol");
|
|
|
// 获取所有商户的密钥
|
|
@@ -139,14 +137,12 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
String analysisStr = null;
|
|
|
String deKey = null;
|
|
|
for (SwEnterpriseConfigInfoDo swEnterpriseConfigInfoDo : secretKeyList) {
|
|
|
- byte[] apiV3Key = Base64.getDecoder().decode(swEnterpriseConfigInfoDo.getMerchantsecretkey());
|
|
|
- byte[] nonce = Base64.getDecoder().decode(prepayNoticeVo.getResource().getNonce());
|
|
|
- byte[] ciphertext = Base64.getDecoder().decode(prepayNoticeVo.getResource().getCiphertext());
|
|
|
- byte[] associatedData = Base64.getDecoder().decode(prepayNoticeVo.getResource().getAssociated_data());
|
|
|
- log.error("微信回调函数");
|
|
|
- Cipher cipher = null;
|
|
|
try {
|
|
|
- cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
|
+ byte[] apiV3Key = swEnterpriseConfigInfoDo.getMerchantsecretkey().getBytes("UTF8");
|
|
|
+ byte[] nonce = prepayNoticeVo.getResource().getNonce().getBytes("UTF8");
|
|
|
+ String ciphertext = prepayNoticeVo.getResource().getCiphertext();
|
|
|
+ byte[] associatedData = prepayNoticeVo.getResource().getAssociated_data().getBytes("UTF8");
|
|
|
+ Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
|
SecretKeySpec key = new SecretKeySpec(apiV3Key, "AES");
|
|
|
GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
|
|
|
cipher.init(Cipher.DECRYPT_MODE, key, spec);
|
|
@@ -157,7 +153,7 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
break;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("解密异常");
|
|
|
+ log.error("当前租户:{}解密异常",swEnterpriseConfigInfoDo.getTenantid());
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isBlank(analysisStr)) {
|
|
@@ -169,7 +165,7 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
transaction = mapper.readValue(analysisStr, WeChatPayTransactionVo.class);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("JSON转换异常");
|
|
|
+ log.error("JSON转换异常");
|
|
|
return R.error();
|
|
|
}
|
|
|
// 微信订单号
|
|
@@ -177,7 +173,7 @@ public class PayMentServiceImpl implements PayMentService {
|
|
|
// 商户号
|
|
|
String outTradeNo = transaction.getOutTradeNo();
|
|
|
// 更新缴费记录相关信息
|
|
|
- swBillingRecordService.getBaseMapper().updateWeChatPayInfo(deKey,outTradeNo,transactionId,analysisStr);
|
|
|
+ swBillingRecordService.getBaseMapper().updateWeChatPayInfo(deKey, outTradeNo, transactionId, analysisStr);
|
|
|
return R.ok();
|
|
|
}
|
|
|
}
|