|
|
@ -1,11 +1,10 @@ |
|
|
|
package org.jeecg.modules.hotelbalancelog.controller; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.security.GeneralSecurityException; |
|
|
|
import java.security.cert.X509Certificate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
@ -17,14 +16,11 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.wechat.pay.contrib.apache.httpclient.util.RsaCryptoUtil; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
import org.jeecg.common.exception.JeecgBootException; |
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
import org.jeecg.common.util.HttpRequestUtil; |
|
|
|
import org.jeecg.common.util.MoneyUtil; |
|
|
|
import org.jeecg.common.util.RedisUtil; |
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
import org.jeecg.common.util.*; |
|
|
|
import org.jeecg.common.util.pay.WeChatPayConfig2; |
|
|
|
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
|
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; |
|
|
@ -32,6 +28,8 @@ import org.jeecg.modules.hotelbalancelog.entity.HotelBalanceLog; |
|
|
|
import org.jeecg.modules.hotelbalancelog.req.AuditReq; |
|
|
|
import org.jeecg.modules.hotelbalancelog.req.TransferBatchesDetailsRequest; |
|
|
|
import org.jeecg.modules.hotelbalancelog.req.TransferBatchesRequest; |
|
|
|
import org.jeecg.modules.hotelbalancelog.resp.TransferBatchResourceDataResp; |
|
|
|
import org.jeecg.modules.hotelbalancelog.resp.TransferBatchesNotifyResp; |
|
|
|
import org.jeecg.modules.hotelbalancelog.resp.TransferBatchesResp; |
|
|
|
import org.jeecg.modules.hotelbalancelog.service.IHotelBalanceLogService; |
|
|
|
|
|
|
@ -89,6 +87,10 @@ public class HotelBalanceLogController extends JeecgController<HotelBalanceLog, |
|
|
|
private String mchId; |
|
|
|
@Value("${weixin.serialNo}") |
|
|
|
private String wxsSerialNo; |
|
|
|
@Value("${wxpay.withdrawalNotifyUrl}") |
|
|
|
private String withdrawalNotifyUrl; |
|
|
|
@Value("${wxpay.apiV3Key}") |
|
|
|
private String apiV3Key; |
|
|
|
@Resource |
|
|
|
private WeChatPayConfig2 weChatPayConfig2; |
|
|
|
|
|
|
@ -300,7 +302,8 @@ public class HotelBalanceLogController extends JeecgController<HotelBalanceLog, |
|
|
|
transferBatchesRequest.setOutBillNo(idStr); |
|
|
|
transferBatchesRequest.setTransferRemark("商家提现"); |
|
|
|
transferBatchesRequest.setOpenid(hanHaiMember.getAppletOpenid()); |
|
|
|
transferBatchesRequest.setTransferSceneId("1000"); |
|
|
|
transferBatchesRequest.setTransferSceneId("1005"); |
|
|
|
transferBatchesRequest.setNotifyUrl(withdrawalNotifyUrl); |
|
|
|
String serialNo = null; |
|
|
|
try { |
|
|
|
X509Certificate certificate = weChatPayConfig2.getVerifier().getValidCertificate(); |
|
|
@ -315,32 +318,78 @@ public class HotelBalanceLogController extends JeecgController<HotelBalanceLog, |
|
|
|
transferBatchesRequest.setTransferAmount(MoneyUtil.Yuan2Fen(hotelBalanceLog.getBalance().doubleValue())); |
|
|
|
List<TransferBatchesDetailsRequest> transferBatchesDetailsRequests = new ArrayList<>(); |
|
|
|
TransferBatchesDetailsRequest transferBatchesDetailsRequest = new TransferBatchesDetailsRequest(); |
|
|
|
transferBatchesDetailsRequest.setInfoType("1000-现金营销"); |
|
|
|
transferBatchesDetailsRequest.setInfoContent("商品返利"); |
|
|
|
|
|
|
|
transferBatchesDetailsRequest.setInfoType("岗位类型"); |
|
|
|
transferBatchesDetailsRequest.setInfoContent("销售员"); |
|
|
|
TransferBatchesDetailsRequest transferBatchesDetailsRequest2 = new TransferBatchesDetailsRequest(); |
|
|
|
transferBatchesDetailsRequest2.setInfoType("报酬说明"); |
|
|
|
transferBatchesDetailsRequest2.setInfoContent("销售佣金"); |
|
|
|
|
|
|
|
|
|
|
|
transferBatchesDetailsRequests.add(transferBatchesDetailsRequest); |
|
|
|
transferBatchesDetailsRequests.add(transferBatchesDetailsRequest2); |
|
|
|
transferBatchesRequest.setTransferDetailList(transferBatchesDetailsRequests); |
|
|
|
String jsonString = JSONObject.toJSONString(transferBatchesRequest); |
|
|
|
|
|
|
|
log.info("请求数据:"+jsonString); |
|
|
|
|
|
|
|
String postTransBatRequest = HttpRequestUtil.postTransBatRequest(transferBatchUrl, jsonString, serialNo, wxsSerialNo, mchId, pemPath); |
|
|
|
log.error("返回结果1:" + postTransBatRequest); |
|
|
|
TransferBatchesResp transferBatchesResp = JSON.parseObject(postTransBatRequest, TransferBatchesResp.class); |
|
|
|
log.error("返回结果2:" + transferBatchesResp); |
|
|
|
if (transferBatchesResp == null || org.apache.commons.lang3.StringUtils.isBlank(transferBatchesResp.getBatchId())) { |
|
|
|
if (transferBatchesResp == null || org.apache.commons.lang3.StringUtils.isBlank(transferBatchesResp.getOutBillNo())|| StringUtils.equals(transferBatchesResp.getState(),"FAIL")) { |
|
|
|
throw new JeecgBootException("打款失败"); |
|
|
|
} |
|
|
|
|
|
|
|
HotelBalanceLog hotelBalanceLog1 = new HotelBalanceLog(); |
|
|
|
hotelBalanceLog1.setId(hotelBalanceLog.getId()); |
|
|
|
hotelBalanceLog1.setStatus(2); |
|
|
|
hotelBalanceLog1.setOutBatchNo(transferBatchesResp.getOutBatchNo()); |
|
|
|
hotelBalanceLog1.setBatchId(transferBatchesResp.getBatchId()); |
|
|
|
hotelBalanceLog1.setStatus(4); |
|
|
|
hotelBalanceLog1.setOutBatchNo(transferBatchesResp.getTransferBillNo()); |
|
|
|
hotelBalanceLog1.setBatchId(transferBatchesResp.getOutBillNo()); |
|
|
|
hotelBalanceLog1.setPackageInfo(transferBatchesResp.getPackageInfo()); |
|
|
|
hotelBalanceLogService.updateById(hotelBalanceLog1); |
|
|
|
|
|
|
|
return Result.OK(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/withdrawal/notify") |
|
|
|
public Object withdrawalNotify(@RequestBody TransferBatchesNotifyResp transferBatchesNotifyResp) throws GeneralSecurityException, IOException { |
|
|
|
|
|
|
|
log.info("回调内容:"+transferBatchesNotifyResp.toString()); |
|
|
|
String associatedData = "mch_payment"; |
|
|
|
String decryptToString = new AesUtil(apiV3Key.getBytes(StandardCharsets.UTF_8)).decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), transferBatchesNotifyResp.getResource().getNonce().getBytes(StandardCharsets.UTF_8), transferBatchesNotifyResp.getResource().getCiphertext()); |
|
|
|
|
|
|
|
log.info("解密内容:"+decryptToString); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransferBatchResourceDataResp transferBatchResourceDataResp = JSON.parseObject(decryptToString, TransferBatchResourceDataResp.class); |
|
|
|
|
|
|
|
log.info("解密内容转换:"+transferBatchResourceDataResp.toString()); |
|
|
|
|
|
|
|
HotelBalanceLog hotelBalanceLog = hotelBalanceLogService.lambdaQuery().eq(HotelBalanceLog::getBatchId, transferBatchResourceDataResp.getOutBillNo()).one(); |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
if(hotelBalanceLog == null){ |
|
|
|
log.error("失败,未查找到数据"); |
|
|
|
map.put("code","FAIL"); |
|
|
|
map.put("message","未查找到数据"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
HotelBalanceLog hotelBalanceLog1 = new HotelBalanceLog(); |
|
|
|
hotelBalanceLog1.setId(hotelBalanceLog.getId()); |
|
|
|
hotelBalanceLog1.setStatus(2); |
|
|
|
hotelBalanceLogService.updateById(hotelBalanceLog1); |
|
|
|
|
|
|
|
map.put("code","SUCCESS"); |
|
|
|
map.put("message","SUCCESS"); |
|
|
|
return map; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |