From b71c6eb31155b48440c450fa478e855a8351848e Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 2 Jun 2023 11:29:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/TestController.java | 26 +- .../channel/lakala/LaKaLaConfigService.java | 1 + .../channel/lakala/LaKaLaWalletService.java | 250 ++++++++++++++++++ 3 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java index 3121e63..d23ba54 100644 --- a/cweb/src/main/java/com/cweb/controller/TestController.java +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -8,10 +8,7 @@ import com.alipay.api.request.AlipaySystemOauthTokenRequest; import com.alipay.api.response.AlipaySystemOauthTokenResponse; import com.hfkj.channel.alipay.utils.AlipayRequest; import com.hfkj.channel.alipay.utils.AlipayUtils; -import com.hfkj.channel.lakala.LaKaLaLedgerService; -import com.hfkj.channel.lakala.LaKaLaMerService; -import com.hfkj.channel.lakala.LaKaLaTradeSeparateService; -import com.hfkj.channel.lakala.LaKaLaTradeService; +import com.hfkj.channel.lakala.*; import com.hfkj.channel.lakala.config.LaKaLaConfig; import com.hfkj.channel.saas.SaasActivityService; import com.hfkj.channel.saas.SaasMerService; @@ -106,6 +103,9 @@ public class TestController { @Resource private LaKaLaLedgerService laKaLaLedgerService; + @Resource + private LaKaLaWalletService laKaLaWalletService; + @RequestMapping(value="/refreshMerStatus",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "refreshMerStatus") @@ -202,6 +202,24 @@ public class TestController { } } + @RequestMapping(value="/lklWithdraw",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "lklWithdraw") + public ResponseData lklWithdraw() { + try { + + // return ResponseMsgUtil.success(laKaLaWalletService.ewalletBalanceQuery("8221210701101SB", null,null)); + // return ResponseMsgUtil.success(laKaLaWalletService.ewalletWithdrawD1("8221210701101SB", new BigDecimal("0.01"),"测试提现功能")); + // return ResponseMsgUtil.success(laKaLaWalletService.ewalletSettleProfile("8221210701101SB", "02","08")); + // return ResponseMsgUtil.success(laKaLaWalletService.ewalletSettleQuery("8221210701101SB")); + return ResponseMsgUtil.success(laKaLaWalletService.activeSettleApply("8221210701101SB")); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/saasGetToken",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "saasGetToken") diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaConfigService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaConfigService.java index ff2815a..d86209d 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaConfigService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaConfigService.java @@ -10,6 +10,7 @@ import com.hfkj.common.utils.HttpsUtils; import com.hfkj.config.CommonSysConst; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.*; /** diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java new file mode 100644 index 0000000..f977efa --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaWalletService.java @@ -0,0 +1,250 @@ +package com.hfkj.channel.lakala; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.lakala.config.LaKaLaConfig; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.GenerateUtil; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.config.CommonSysConst; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 拉卡拉钱包 + * @author hurui + */ +@Service("laKaLaWalletService") +public class LaKaLaWalletService { + + /** + * 商户开通主动结算业务 + * @param merCupNo + * @return + */ + public JSONObject activeSettleApply(String merCupNo) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("version", "1.0"); + map.put("orderNo", System.currentTimeMillis()+""); + map.put("orgCode", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("merCupNo", merCupNo); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/mms/openApi/activeSettle/apply", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + + /** + * 账管家提现D1 + * @param merCupNo + * @return + */ + public JSONObject ewalletWithdrawD1(String merCupNo, BigDecimal drawAmt, String remark) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("merchantNo", merCupNo); + map.put("drawAmt", drawAmt); + map.put("notifyUrl", ""); + map.put("remark", remark); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/laep/industry/ewalletWithdrawD1", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + + /** + * 账管家余额查询 + * @param merCupNo 商户号 + * @param payNo 账号 + * @param payType 账号类型(01:收款账户,02:付款账户,03:分账商户账户,04:分账接收方账户,05:充值代付账户,06:结算代付账户)- 未上送则默认为01 + * @return + */ + public JSONObject ewalletBalanceQuery(String merCupNo, String payNo, String payType) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("merchantNo", merCupNo); + map.put("payNo", payNo); + map.put("payType", payType); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/laep/industry/ewalletBalanceQuery", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + + /** + * 账管家提现结果查询 + * @param merCupNo + * @return + */ + public JSONObject ewalletWithdrawQuery(String merCupNo,String merOrderNo) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("orgNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("merchantNo", merCupNo); + map.put("drawJnl", merOrderNo); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/laep/industry/ewalletWithdrawQuery", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + + /** + * 账管家提款模式设置 + * @param merCupNo 商户号 + * @param settleType 提款模式(01主动提款 02自动结算) + * @param settleTime 结算时间(小时)- 默认值:06。如08:00-09:00到账,则传入08 + * @return + */ + public JSONObject ewalletSettleProfile(String merCupNo, String settleType, String settleTime) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("bmcpNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("mercId", merCupNo); + map.put("settleType", settleType); + map.put("settleTime", settleTime); + map.put("notifyUrl", null); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/laep/industry/ewallet/settleProfile", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + + /** + * 账管家提款模式查询 + * @param merCupNo 商户号 + * @return + */ + public JSONObject ewalletSettleQuery(String merCupNo) { + // 请求参数 + Map param = new HashMap<>(); + param.put("timestamp", new Date().getTime()); + param.put("rnd", GenerateUtil.generateRandomString(18)); + param.put("ver", "1.0.0"); + param.put("reqId", new Date().getTime()); + + Map map = new HashMap<>(); + map.put("bmcpNo", CommonSysConst.getSysConfig().getLkl_org_code()); + map.put("mercId", merCupNo); + param.put("reqData", map); + + // 生成签名 + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/laep/industry/ewallet/settleQuery", param, heard); + System.out.println("Authorization" + JSONObject.toJSONString(reqParam.get("Authorization"))); + System.out.println("request:" + JSONObject.toJSONString(param)); + System.out.println("response:" + responseBody.toJSONString()); + if (!responseBody.getString("retCode").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseBody.getString("retMsg")); + } + return responseBody.getJSONObject("respData"); + } + +}