提交代码

yy_dev
胡锐 1 year ago
parent 1fe94e9d24
commit d83f6f06ae
  1. 11
      open-api/src/main/java/com/api/controller/v1/NotifyController.java
  2. 63
      open-api/src/main/resources/dev/logback.xml
  3. 44
      open-api/src/main/resources/prod/logback.xml
  4. 17
      service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeSeparateService.java
  5. 13
      service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java
  6. 64
      service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java
  7. 1
      service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.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 ===========");
}
}

@ -112,4 +112,67 @@
<appender-ref ref="hsglog" />
</logger>
<appender name="requestV1log" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/requestV1.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/requestV1/requestV1.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.api.controller.v1" level="INFO">
<appender-ref ref="requestV1log" />
</logger>
<appender name="laklalog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/laklalog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/laklalog/laklalog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.channel.lakala" level="INFO">
<appender-ref ref="laklalog" />
</logger>
<appender name="lklTradeNotify" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/lklTradeNotify.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/lklTradeNotify/lklTradeNotify.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.api.controller.v1.NotifyController" level="INFO">
<appender-ref ref="lklTradeNotify" />
</logger>
</configuration>

@ -91,6 +91,7 @@
<appender-ref ref="alipaylog" />
</logger>
<appender name="hsglog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/hsg.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
@ -111,4 +112,47 @@
<appender-ref ref="hsglog" />
</logger>
<appender name="requestV1log" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/requestV1.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/requestV1/requestV1.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.api.controller.v1" level="INFO">
<appender-ref ref="requestV1log" />
</logger>
<appender name="lklTradeNotify" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/lklTradeNotify.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/lklTradeNotify/lklTradeNotify.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.api.controller.v1.NotifyController" level="INFO">
<appender-ref ref="lklTradeNotify" />
</logger>
</configuration>

@ -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<String, Object> 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<String, Object> 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<String, Object> 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");
}

@ -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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> returnMap = new HashMap<>();
returnMap.put("order", order);
returnMap.put("orderRefund", orderRefund);
log.info("========= END 交易退款 END ===========");
return returnMap;
}

@ -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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -38,7 +55,7 @@ public class LaKaLaWalletService {
Map<String, Object> 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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -73,7 +97,7 @@ public class LaKaLaWalletService {
param.put("reqId", new Date().getTime());
Map<String, Object> 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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -113,7 +144,7 @@ public class LaKaLaWalletService {
param.put("reqId", new Date().getTime());
Map<String, Object> 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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -150,7 +188,7 @@ public class LaKaLaWalletService {
param.put("reqId", new Date().getTime());
Map<String, Object> 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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -188,7 +233,7 @@ public class LaKaLaWalletService {
param.put("reqId", new Date().getTime());
Map<String, Object> 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<String, Object> param = new HashMap<>();
param.put("timestamp", new Date().getTime());
@ -226,7 +278,7 @@ public class LaKaLaWalletService {
param.put("reqId", new Date().getTime());
Map<String, Object> map = new HashMap<>();
map.put("bmcpNo", CommonSysConst.getSysConfig().getLkl_org_code());
map.put("bmcpNo", mer.getOrgNo());
map.put("mercId", merCupNo);
param.put("reqData", map);

@ -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);
}

Loading…
Cancel
Save