diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index 7bb8050..dd7f051 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -110,6 +110,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/common/*") .excludePathPatterns("/mer/*") .excludePathPatterns("/tradeOrder/calculation") + .excludePathPatterns("/tradeOrder/getLkLUnionUserId") .excludePathPatterns("/login/*") .excludePathPatterns("/test/*") .excludePathPatterns("/sms/*") diff --git a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java index 3ac5b2c..198eb06 100644 --- a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java +++ b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java @@ -3,6 +3,7 @@ package com.cweb.controller; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.hfkj.channel.lakala.LaKaLaTradeService; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -62,6 +63,15 @@ public class BsTradeOrderController { @Resource private BsPayQrCodeService payQrCodeService; + @Resource + private BsMerPlatformNoService platformNoService; + + @Resource + private BsMerPlatformTermService platformTermService; + + @Resource + private LaKaLaTradeService laKaLaTradeService; + @RequestMapping(value="/calculation",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "计算支付金额") @@ -431,4 +441,53 @@ public class BsTradeOrderController { } } + @RequestMapping(value="/getLkLUnionUserId",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取拉卡拉银联用户id") + public ResponseData getLkLUnionUserId(@RequestBody JSONObject body) { + try { + if (body == null + || StringUtils.isBlank(body.getString("serialNumber")) + || StringUtils.isBlank(body.getString("userAuthCode")) + || StringUtils.isBlank(body.getString("appUpIdentifier"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.PASSWORD_ERROR, ""); + } + // 查询二维码 + BsPayQrCode qrCode = payQrCodeService.getDetailBySN(body.getString("serialNumber")); + if (qrCode == null) { + log.error("BsPayQrCodeController error!","未找到支付码信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到支付码信息"); + } + if (qrCode.getStoreId() == null) { + log.error("BsPayQrCodeController error!","支付码未绑定门店"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付码未绑定门店"); + } + if (!qrCode.getStatus().equals(PayQrCodeStatusEnum.status1.getNumber())) { + log.error("BsPayQrCodeController error!","支付码已被停用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付码已被停用"); + } + // 查询商户号 + BsMerPlatformNo platformNo = platformNoService.getPlatformNo(qrCode.getMerId(), PlatformTypeEnum.type1); + if (platformNo == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户号"); + } + // 查询终端号 + BsMerPlatformTerm merPlatformTerm = platformTermService.getMerPlatformTerm(platformNo.getId(), "WECHAT_PAY"); + if (merPlatformTerm == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户终端号"); + } + return ResponseMsgUtil.success(laKaLaTradeService.openidQuery( + platformNo.getCupNo(), + merPlatformTerm.getTermNo(), + body.getString("userAuthCode"), + "030304", + null, + body.getString("appUpIdentifier") + )); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } } 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 c2c72fe..d003f1a 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java @@ -212,7 +212,7 @@ public class LaKaLaTradeService { map.put("term_no", merPlatformTerm.getTermNo()); map.put("out_trade_no", order.getOutTradeNo()); map.put("account_type", order.getPayMode()); - map.put("trans_type", "51"); + map.put("trans_type", 51); map.put("total_amount", order.getTradeActualAmount().multiply(new BigDecimal("100")).intValue()); map.put("settle_type", order.getProfitSharingStatus()==true?1:0); if (StringUtils.isNotBlank(order.getSubject())) { @@ -281,7 +281,6 @@ public class LaKaLaTradeService { return returnMap; } - /** * 退款 * @param refundNo 订单号 @@ -468,4 +467,41 @@ public class LaKaLaTradeService { return returnMap; } + /** + * opendId查询 + * @param mercId 商户号 + * @param termNo 终端号 + * @param authCode 微信付款码 微信:付款码 银联二维码:付款方返回的临时授权码,一次有效 + * @param tradeCode 交易码 微信:010304 银联:030304 + * @param subAppid 微信子商户公众号id + * @param appUpIdentifier 银联支付标识,获取银联钱包userId时,必传 + */ + public Map openidQuery(String mercId,String termNo,String authCode, String tradeCode,String subAppid,String appUpIdentifier) { + Map commonParam = new HashMap<>(); + commonParam.put("timestamp", DateUtil.format(new Date(), "yyyyMMddHHmmss")); + commonParam.put("ver", "1.0.0"); + commonParam.put("reqId", LaKaLaConfig.makeNonStr()); + + Map map = new HashMap<>(); + map.put("mercId", mercId); + map.put("termNo", termNo); + map.put("authCode", authCode); + map.put("tradeCode", tradeCode); + map.put("subAppid", subAppid); + map.put("appUpIdentifier", appUpIdentifier); + + commonParam.put("reqData", map); + Map reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(commonParam))); + + System.out.println(JSONObject.toJSONString(commonParam)); + + // 头部参数 + Map heard = new HashMap<>(); + heard.put("Authorization", reqParam.get("Authorization")); + + // 请求拉卡拉接口 + JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/saas/query/wx_openid_query", commonParam, heard); + return responseBody; + } + }