|
|
@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -45,7 +46,7 @@ public class LaKaLaTradeSeparateService { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (tradeOrderProfitSharing.getStatus().equals(ProfitSharingStatusEnum.status0.getNumber())) { |
|
|
|
if (!tradeOrderProfitSharing.getStatus().equals(ProfitSharingStatusEnum.status0.getNumber())) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "业务不处于待处理状态"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "业务不处于待处理状态"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 查询交易详情
|
|
|
|
// 查询交易详情
|
|
|
@ -61,9 +62,9 @@ public class LaKaLaTradeSeparateService { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("merchant_no", tradeOrder.getPlatformMerNo()); |
|
|
|
map.put("merchant_no", tradeOrder.getPlatformMerNo()); |
|
|
|
map.put("log_no", tradeOrder.getPlatformLogNo()); |
|
|
|
map.put("log_no", tradeOrder.getPlatformLogNo()); |
|
|
|
map.put("log_date", DateUtil.date2String(tradeOrder.getPayTime(), "yyyy-MM-dd")); |
|
|
|
map.put("log_date", DateUtil.date2String(tradeOrder.getPayTime(), "yyyyMMdd")); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("total_amt", tradeOrderProfitSharing.getProfitSharingAmoun()); |
|
|
|
map.put("total_amt", tradeOrderProfitSharing.getProfitSharingAmoun().multiply(new BigDecimal("100")).longValue()); |
|
|
|
map.put("lkl_org_no", "1"); |
|
|
|
map.put("lkl_org_no", "1"); |
|
|
|
map.put("cal_type", "0"); |
|
|
|
map.put("cal_type", "0"); |
|
|
|
|
|
|
|
|
|
|
@ -72,14 +73,14 @@ public class LaKaLaTradeSeparateService { |
|
|
|
|
|
|
|
|
|
|
|
for (BsTradeOrderProfitSharingReceiver receiver : profitSharingReceiverList) { |
|
|
|
for (BsTradeOrderProfitSharingReceiver receiver : profitSharingReceiverList) { |
|
|
|
recvDatasMap = new HashMap<>(); |
|
|
|
recvDatasMap = new HashMap<>(); |
|
|
|
recvDatasMap.put("recv_merchant_no", receiver.getReceiverAccount()); |
|
|
|
recvDatasMap.put("recv_no", receiver.getReceiverAccount()); |
|
|
|
recvDatasMap.put("separate_value", receiver.getProfitSharingAmount()); |
|
|
|
recvDatasMap.put("separate_value", receiver.getReceiverAmount().multiply(new BigDecimal("100")).longValue()); |
|
|
|
recvDatasMapList.add(recvDatasMap); |
|
|
|
recvDatasMapList.add(recvDatasMap); |
|
|
|
} |
|
|
|
} |
|
|
|
commonParam.put("recv_datas", recvDatasMapList); |
|
|
|
map.put("recv_datas", recvDatasMapList); |
|
|
|
commonParam.put("reqData", map); |
|
|
|
commonParam.put("req_data", map); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV3(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
// 头部参数
|
|
|
|
// 头部参数
|
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
@ -88,7 +89,7 @@ public class LaKaLaTradeSeparateService { |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
|
|
|
|
|
|
|
|
if (!responseBody.getString("retCode").equals("000000")) { |
|
|
|
if (!responseBody.getString("code").equals("SACS0000")) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,6 +122,41 @@ public class LaKaLaTradeSeparateService { |
|
|
|
return responseBody; |
|
|
|
return responseBody; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject queryAmt(String profitSharingOrderNo) { |
|
|
|
|
|
|
|
// 交易订单分账
|
|
|
|
|
|
|
|
BsTradeOrderProfitSharing tradeOrderProfitSharing = tradeOrderProfitSharingService.getDetailByProfitSharingOrderNo(profitSharingOrderNo); |
|
|
|
|
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询交易详情
|
|
|
|
|
|
|
|
BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderProfitSharing.getTradeOrderId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> commonParam = new HashMap<>(); |
|
|
|
|
|
|
|
commonParam.put("req_time", DateUtil.format(new Date(), "yyyyMMddHHmmss")); |
|
|
|
|
|
|
|
commonParam.put("version", "3.0"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
|
|
|
|
map.put("log_no", tradeOrder.getPlatformLogNo()); |
|
|
|
|
|
|
|
map.put("log_date", DateUtil.date2String(tradeOrder.getPayTime(), "yyyyMMdd")); |
|
|
|
|
|
|
|
commonParam.put("req_data", map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV3(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
|
|
|
|
// 头部参数
|
|
|
|
|
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
|
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/queryAmt", commonParam, heard); |
|
|
|
|
|
|
|
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")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); |
|
|
|
|
|
|
|
tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); |
|
|
|
|
|
|
|
return responseBody; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分账撤销 |
|
|
|
* 分账撤销 |
|
|
|
* @param profitSharingOrderNo |
|
|
|
* @param profitSharingOrderNo |
|
|
@ -132,22 +168,18 @@ public class LaKaLaTradeSeparateService { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (tradeOrderProfitSharing.getStatus().equals(ProfitSharingStatusEnum.status0.getNumber())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "业务不处于待处理状态"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> commonParam = new HashMap<>(); |
|
|
|
Map<String, Object> commonParam = new HashMap<>(); |
|
|
|
commonParam.put("req_time", DateUtil.format(new Date(), "yyyyMMddHHmmss")); |
|
|
|
commonParam.put("req_time", DateUtil.format(new Date(), "yyyyMMddHHmmss")); |
|
|
|
commonParam.put("version", "3.0"); |
|
|
|
commonParam.put("version", "3.0"); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("origin_separate_no", tradeOrderProfitSharing.getOriginProfitSharingOrderNo()); |
|
|
|
map.put("origin_out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()+"1"); |
|
|
|
map.put("total_amt", tradeOrderProfitSharing.getProfitSharingAmoun()); |
|
|
|
map.put("total_amt", tradeOrderProfitSharing.getProfitSharingAmoun().multiply(new BigDecimal("100")).longValue()); |
|
|
|
commonParam.put("reqData", map); |
|
|
|
commonParam.put("req_data", map); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV3(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
// 头部参数
|
|
|
|
// 头部参数
|
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
@ -155,8 +187,8 @@ public class LaKaLaTradeSeparateService { |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/cancel", commonParam, heard); |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/cancel", commonParam, heard); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
if (!responseBody.getString("retCode").equals("000000")) { |
|
|
|
if (!responseBody.getString("code").equals("SACS0000")) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("msg")); |
|
|
|
} |
|
|
|
} |
|
|
|
tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); |
|
|
|
tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); |
|
|
|
tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); |
|
|
|
tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); |
|
|
@ -164,6 +196,7 @@ public class LaKaLaTradeSeparateService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* todo 目前未开发,目前的场景用不到 |
|
|
|
* 分账回退 |
|
|
|
* 分账回退 |
|
|
|
* @param profitSharingOrderNo 交易订单号 |
|
|
|
* @param profitSharingOrderNo 交易订单号 |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -174,9 +207,6 @@ public class LaKaLaTradeSeparateService { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
if (null == tradeOrderProfitSharing) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到交易分账记录"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (tradeOrderProfitSharing.getStatus().equals(ProfitSharingStatusEnum.status0.getNumber())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "业务不处于待处理状态"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> commonParam = new HashMap<>(); |
|
|
|
Map<String, Object> commonParam = new HashMap<>(); |
|
|
|
commonParam.put("req_time", DateUtil.format(new Date(), "yyyyMMddHHmmss")); |
|
|
|
commonParam.put("req_time", DateUtil.format(new Date(), "yyyyMMddHHmmss")); |
|
|
@ -184,12 +214,20 @@ public class LaKaLaTradeSeparateService { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("origin_separate_no", tradeOrderProfitSharing.getOriginProfitSharingOrderNo()); |
|
|
|
map.put("origin_out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()+"1"); |
|
|
|
map.put("total_amt", tradeOrderProfitSharing.getProfitSharingAmoun()); |
|
|
|
map.put("total_amt", "24"); |
|
|
|
commonParam.put("reqData", map); |
|
|
|
|
|
|
|
|
|
|
|
// 回退分账金额,只能回退一个商户
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
List<Map<String, Object>> originRecvDatas = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String, Object> originRecv = new HashMap<>(); |
|
|
|
|
|
|
|
originRecv.put("recv_no", "SR2023042415050"); |
|
|
|
|
|
|
|
originRecv.put("amt", "24"); |
|
|
|
|
|
|
|
originRecvDatas.add(originRecv); |
|
|
|
|
|
|
|
map.put("origin_recv_datas", originRecvDatas); |
|
|
|
|
|
|
|
commonParam.put("req_data", map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV3(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
// 头部参数
|
|
|
|
// 头部参数
|
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
@ -197,8 +235,8 @@ public class LaKaLaTradeSeparateService { |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/fallback", commonParam, heard); |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/fallback", commonParam, heard); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
if (!responseBody.getString("retCode").equals("000000")) { |
|
|
|
if (!responseBody.getString("code").equals("SACS0000")) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("msg")); |
|
|
|
} |
|
|
|
} |
|
|
|
tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); |
|
|
|
tradeOrderProfitSharing.setStatus(ProfitSharingStatusEnum.status2.getNumber()); |
|
|
|
tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); |
|
|
|
tradeOrderProfitSharingService.editData(tradeOrderProfitSharing); |
|
|
@ -223,10 +261,10 @@ public class LaKaLaTradeSeparateService { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("merchant_no", tradeOrderProfitSharing.getPlatformMerNo()); |
|
|
|
map.put("separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
map.put("out_separate_no", tradeOrderProfitSharing.getProfitSharingOrderNo()); |
|
|
|
commonParam.put("reqData", map); |
|
|
|
commonParam.put("req_data", map); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV3(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); |
|
|
|
// 头部参数
|
|
|
|
// 头部参数
|
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
Map<String, Object> heard = new HashMap<>(); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
|
heard.put("Authorization", reqParam.get("Authorization")); |
|
|
@ -234,8 +272,8 @@ public class LaKaLaTradeSeparateService { |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/query", commonParam, heard); |
|
|
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/sacs/query", commonParam, heard); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("body:" + JSONObject.toJSONString(commonParam)); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
System.out.println("response:" + responseBody.toJSONString()); |
|
|
|
if (!responseBody.getString("retCode").equals("000000")) { |
|
|
|
if (!responseBody.getString("code").equals("SACS0000")) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("msg")); |
|
|
|
} |
|
|
|
} |
|
|
|
return responseBody.getJSONObject("resp_data"); |
|
|
|
return responseBody.getJSONObject("resp_data"); |
|
|
|
} |
|
|
|
} |
|
|
|