diff --git a/open-api/src/main/java/com/api/controller/v1/NotifyController.java b/open-api/src/main/java/com/api/controller/v1/NotifyController.java index c3a1dac..6dd5f24 100644 --- a/open-api/src/main/java/com/api/controller/v1/NotifyController.java +++ b/open-api/src/main/java/com/api/controller/v1/NotifyController.java @@ -48,7 +48,8 @@ public class NotifyController { @ApiOperation(value = "拉卡拉交易通知") public void lakala(@RequestBody String reqBody, HttpServletResponse response) { try { - log.info("拉卡拉交易通知:", reqBody); + log.info("========= Start 拉卡拉交易通知 Start ==========="); + log.info("平台接收拉卡拉交易通知:", reqBody); System.out.println(reqBody); JSONObject body = JSONObject.parseObject(reqBody); @@ -86,7 +87,11 @@ public class NotifyController { responseQueryTradeModel.setPayTime(tradeOrder.getPayTime()); responseQueryTradeModel.setAttach(tradeOrder.getAttach()); responseQueryTradeModel.setSign(SignatureUtil.createSign(responseQueryTradeModel, merKeyService.getKeyByMerNo(tradeOrder.getMerNo()))); + + log.info("发送URL:", order.getPayNotifyUrl()); + log.info("发送参数:", JSONObject.toJSONString(responseQueryTradeModel)); JSONObject result = HttpsUtils.doPost(order.getPayNotifyUrl(), JSONObject.toJSONString(responseQueryTradeModel)); + log.info("响应参数:", result); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); out.write(result.toJSONString().getBytes()); out.flush(); @@ -94,7 +99,9 @@ public class NotifyController { } } catch (Exception e) { - log.error("login error!",e); + log.info("出现异常", e); + } finally { + log.info("========= END 拉卡拉交易通知 END ==========="); } } diff --git a/open-api/src/main/resources/dev/logback.xml b/open-api/src/main/resources/dev/logback.xml index 6011524..604f1ad 100644 --- a/open-api/src/main/resources/dev/logback.xml +++ b/open-api/src/main/resources/dev/logback.xml @@ -112,4 +112,67 @@ + + + + log/requestV1.log + + log/requestV1/requestV1.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + log/laklalog.log + + log/laklalog/laklalog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + + log/lklTradeNotify.log + + log/lklTradeNotify/lklTradeNotify.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/open-api/src/main/resources/prod/logback.xml b/open-api/src/main/resources/prod/logback.xml index 60947fa..c1ce5a6 100644 --- a/open-api/src/main/resources/prod/logback.xml +++ b/open-api/src/main/resources/prod/logback.xml @@ -91,6 +91,7 @@ + log/hsg.log @@ -111,4 +112,47 @@ + + + + log/requestV1.log + + log/requestV1/requestV1.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + + log/lklTradeNotify.log + + log/lklTradeNotify/lklTradeNotify.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java index c42a13a..9413fc5 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java @@ -15,6 +15,8 @@ import com.hfkj.model.MerBasisModel; import com.hfkj.service.*; import com.hfkj.sysenum.*; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -28,6 +30,8 @@ import java.util.*; @Service public class LaKaLaTradeSeparateService { + private static Logger log = LoggerFactory.getLogger(LaKaLaTradeSeparateService.class); + @Resource private BsTradeOrderService tradeOrderService; @Resource @@ -43,6 +47,7 @@ public class LaKaLaTradeSeparateService { * @return */ public BsTradeOrderProfitSharing separate(String profitSharingOrderNo) { + log.info("========= Start 分账 Start ==========="); // 交易分账 BsTradeOrderProfitSharing tradeOrderProfitSharing = tradeOrderProfitSharingService.getDetailByProfitSharingOrderNo(profitSharingOrderNo); if (null == tradeOrderProfitSharing) { @@ -90,7 +95,9 @@ public class LaKaLaTradeSeparateService { Map heard = new HashMap<>(); heard.put("Authorization", reqParam.get("Authorization")); + log.info("请求参数:",JSONObject.toJSONString(commonParam)); JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/separate", commonParam, heard); + log.info("响应参数:", responseBody.toJSONString()); System.out.println("body:" + JSONObject.toJSONString(commonParam)); System.out.println("response:" + responseBody.toJSONString()); @@ -124,7 +131,7 @@ public class LaKaLaTradeSeparateService { tradeOrderProfitSharingReceiverService.editData(receiver); } } - + log.info("========= END 分账 END ==========="); return tradeOrderProfitSharing; } @@ -169,6 +176,7 @@ public class LaKaLaTradeSeparateService { * @return */ public JSONObject cancel(String profitSharingOrderNo) { + log.info("========= Start 分账撤销 Start ==========="); // 交易订单分账 BsTradeOrderProfitSharing tradeOrderProfitSharing = tradeOrderProfitSharingService.getDetailByProfitSharingOrderNo(profitSharingOrderNo); if (null == tradeOrderProfitSharing) { @@ -190,7 +198,9 @@ public class LaKaLaTradeSeparateService { Map heard = new HashMap<>(); heard.put("Authorization", reqParam.get("Authorization")); + log.info("请求参数:",JSONObject.toJSONString(commonParam)); JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/cancel", commonParam, heard); + log.info("响应参数:", responseBody.toJSONString()); System.out.println("body:" + JSONObject.toJSONString(commonParam)); System.out.println("response:" + responseBody.toJSONString()); if (!responseBody.getString("code").equals("SACS0000")) { @@ -199,6 +209,7 @@ public class LaKaLaTradeSeparateService { tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); tradeOrderProfitSharing.setPlatformProfitSharingOrderNo(responseBody.getJSONObject("resp_data").getString("separate_no")); tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); + log.info("========= end 分账撤销 end ==========="); return responseBody.getJSONObject("resp_data"); } @@ -256,6 +267,7 @@ public class LaKaLaTradeSeparateService { * @return */ public JSONObject query(String profitSharingOrderNo) { + log.info("========= Start 分账结果查询 Start ==========="); // 交易订单分账 BsTradeOrderProfitSharing tradeOrderProfitSharing = tradeOrderProfitSharingService.getDetailByProfitSharingOrderNo(profitSharingOrderNo); if (null == tradeOrderProfitSharing) { @@ -276,12 +288,15 @@ public class LaKaLaTradeSeparateService { Map heard = new HashMap<>(); heard.put("Authorization", reqParam.get("Authorization")); + log.info("请求参数:",JSONObject.toJSONString(commonParam)); JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/query", commonParam, heard); + log.info("响应参数:", responseBody.toJSONString()); System.out.println("body:" + JSONObject.toJSONString(commonParam)); System.out.println("response:" + responseBody.toJSONString()); if (!responseBody.getString("code").equals("SACS0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("msg")); } + log.info("========= end 分账结果查询 end ==========="); return responseBody.getJSONObject("resp_data"); } diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java index 1a06b2e..c2c72fe 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java @@ -12,6 +12,8 @@ import com.hfkj.channel.lakala.config.LaKaLaConfig; import com.hfkj.service.*; import com.hfkj.sysenum.*; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -25,6 +27,8 @@ import java.util.*; @Service("lklTradeService") public class LaKaLaTradeService { + private static Logger log = LoggerFactory.getLogger(LaKaLaTradeService.class); + @Resource private BsTradeOrderService tradeOrderService; @@ -173,6 +177,7 @@ public class LaKaLaTradeService { * @param tradeNo 订单号 */ public Map preorder(String tradeNo) { + log.info("========= Start 交易【主扫】 Start ==========="); // 查询交易订单 BsTradeOrder order = tradeOrderService.getOrderByOutTradeNo(tradeNo); if (order == null) { @@ -246,6 +251,7 @@ public class LaKaLaTradeService { heard.put("Authorization", reqParam.get("Authorization")); // 请求记录 + log.info("请求参数:", JSONObject.toJSONString(commonParam)); Map requestMap = new HashMap<>(); requestMap.put("Authorization", reqParam.get("Authorization")); requestMap.put("req_data", JSONObject.toJSONString(commonParam)); @@ -257,6 +263,7 @@ public class LaKaLaTradeService { // 请求拉卡拉接口 JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/labs/trans/preorder", commonParam, heard); + log.info("响应参数:", JSONObject.toJSONString(responseBody)); orderMsg.setResponseContent(responseBody.toJSONString()); tradeOrderMsgService.editTradeOrderMsg(orderMsg); @@ -269,6 +276,8 @@ public class LaKaLaTradeService { returnMap.put("payMode", order.getPayMode()); returnMap.put("platformType", PlatformTypeEnum.type1.getNumber()); returnMap.put("payParam", responseBody.getJSONObject("resp_data")); + log.info("========= END 交易【主扫】 END ==========="); + return returnMap; } @@ -278,6 +287,7 @@ public class LaKaLaTradeService { * @param refundNo 订单号 */ public Map refund(String refundNo,BigDecimal refundAmount) { + log.info("========= Start 交易退款 Start ==========="); // 查询交易订单 BsTradeOrderRefund orderRefund = tradeOrderRefundService.getRefundByRefundNo(refundNo); if (orderRefund == null) { @@ -330,6 +340,7 @@ public class LaKaLaTradeService { heard.put("Authorization", reqParam.get("Authorization")); // 请求记录 + log.info("请求参数:", JSONObject.toJSONString(commonParam)); Map requestMap = new HashMap<>(); requestMap.put("Authorization", reqParam.get("Authorization")); requestMap.put("req_data", JSONObject.toJSONString(commonParam)); @@ -350,6 +361,7 @@ public class LaKaLaTradeService { // 请求拉卡拉退款接口 JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/labs/relation/refund", commonParam, heard); + log.info("响应参数:", JSONObject.toJSONString(responseBody)); orderMsg.setResponseContent(responseBody.toJSONString()); tradeOrderMsgService.editTradeOrderMsg(orderMsg); @@ -376,6 +388,7 @@ public class LaKaLaTradeService { Map returnMap = new HashMap<>(); returnMap.put("order", order); returnMap.put("orderRefund", orderRefund); + log.info("========= END 交易退款 END ==========="); return returnMap; } diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java index b4c2304..1d96640 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java @@ -8,8 +8,13 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.GenerateUtil; import com.hfkj.common.utils.HttpsUtils; import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsMer; +import com.hfkj.entity.BsMerPlatformNo; +import com.hfkj.service.BsMerPlatformNoService; +import com.hfkj.service.BsMerService; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; @@ -22,12 +27,24 @@ import java.util.Map; @Service("laKaLaWalletService") public class LaKaLaWalletService { + @Resource + private BsMerPlatformNoService merPlatformNoService; + @Resource + private BsMerService merService; + /** * 商户开通主动结算业务 * @param merCupNo * @return */ public JSONObject activeSettleApply(String merCupNo) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -38,7 +55,7 @@ public class LaKaLaWalletService { Map map = new HashMap<>(); map.put("version", "1.0"); map.put("orderNo", System.currentTimeMillis()+""); - map.put("orgCode", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("orgCode", mer.getOrgNo()); map.put("merCupNo", merCupNo); param.put("reqData", map); @@ -65,6 +82,13 @@ public class LaKaLaWalletService { * @return */ public JSONObject ewalletWithdrawD1(String merCupNo, BigDecimal drawAmt, String remark) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -73,7 +97,7 @@ public class LaKaLaWalletService { param.put("reqId", new Date().getTime()); Map map = new HashMap<>(); - map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("orgNo", mer.getOrgNo()); map.put("merchantNo", merCupNo); map.put("drawAmt", drawAmt); map.put("notifyUrl", ""); @@ -105,6 +129,13 @@ public class LaKaLaWalletService { * @return */ public JSONObject ewalletBalanceQuery(String merCupNo, String payNo, String payType) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -113,7 +144,7 @@ public class LaKaLaWalletService { param.put("reqId", new Date().getTime()); Map map = new HashMap<>(); - map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("orgNo", mer.getOrgNo()); map.put("merchantNo", merCupNo); map.put("payNo", payNo); map.put("payType", payType); @@ -142,6 +173,13 @@ public class LaKaLaWalletService { * @return */ public JSONObject ewalletWithdrawQuery(String merCupNo,String drawJnl) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -150,7 +188,7 @@ public class LaKaLaWalletService { param.put("reqId", new Date().getTime()); Map map = new HashMap<>(); - map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("orgNo", mer.getOrgNo()); map.put("merchantNo", merCupNo); map.put("drawJnl", drawJnl); param.put("reqData", map); @@ -180,6 +218,13 @@ public class LaKaLaWalletService { * @return */ public JSONObject ewalletSettleProfile(String merCupNo, String settleType, String settleTime) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -188,7 +233,7 @@ public class LaKaLaWalletService { param.put("reqId", new Date().getTime()); Map map = new HashMap<>(); - map.put("bmcpNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("bmcpNo", mer.getOrgNo()); map.put("mercId", merCupNo); map.put("settleType", settleType); map.put("settleTime", settleTime); @@ -218,6 +263,13 @@ public class LaKaLaWalletService { * @return */ public JSONObject ewalletSettleQuery(String merCupNo) { + // 查询平台商户号 + BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNoByCupNo(merCupNo); + if (merPlatform == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到平台商户号"); + } + BsMer mer = merService.getMer(merPlatform.getMerId()); + // 请求参数 Map param = new HashMap<>(); param.put("timestamp", new Date().getTime()); @@ -226,7 +278,7 @@ public class LaKaLaWalletService { param.put("reqId", new Date().getTime()); Map map = new HashMap<>(); - map.put("bmcpNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("bmcpNo", mer.getOrgNo()); map.put("mercId", merCupNo); param.put("reqData", map); diff --git a/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java index f164eba..de5ec41 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java @@ -421,6 +421,7 @@ public class BsMerServiceImpl implements BsMerService { } @Override + @Cached(cacheType = CacheType.REMOTE, name="MER:", key = "#merId") public BsMer getMer(Long merId) { return merMapper.selectByPrimaryKey(merId); }