parent
407e746d57
commit
2b2c027697
@ -0,0 +1,64 @@ |
|||||||
|
package com.api.controller.v1; |
||||||
|
|
||||||
|
import com.hfkj.channel.lakala.LaKaLaConfigService; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: MerController |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/23 |
||||||
|
**/ |
||||||
|
@Controller |
||||||
|
@Api(value = "公共") |
||||||
|
@RequestMapping(value = "/v1/mer") |
||||||
|
public class MerController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(MerController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private LaKaLaConfigService laKaLaConfigService; |
||||||
|
|
||||||
|
@RequestMapping(value="/wechatParamConf",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "wechatParamConf") |
||||||
|
public ResponseData wechatParamConf(@RequestParam(value = "merCupNo" , required = true) String merCupNo, |
||||||
|
@RequestParam(value = "subMchId" , required = true) String subMchId, |
||||||
|
@RequestParam(value = "subAppid" , required = true) String subAppid, |
||||||
|
@RequestParam(value = "jsapiPath" , required = true) String jsapiPath) { |
||||||
|
try { |
||||||
|
// return ResponseMsgUtil.success(laKaLaConfigService.wechatParamConf("822690053111ERC", "569999133","wxf30043187dc90829", "http://api2.ctpark.cn/"));
|
||||||
|
return ResponseMsgUtil.success(laKaLaConfigService.wechatParamConf(merCupNo, subMchId,subAppid, jsapiPath)); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error(e.getMessage(), e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/querySubMerInfo",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "querySubMerInfo") |
||||||
|
public ResponseData querySubMerInfo(@RequestParam(value = "merCupNo" , required = true) String merCupNo) { |
||||||
|
try { |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(laKaLaConfigService.querySubMerInfo(merCupNo)); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error(e.getMessage(), e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,115 @@ |
|||||||
|
package com.hfkj.channel.lakala; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.channel.lakala.config.LaKaLaConfig; |
||||||
|
import com.hfkj.channel.saas.utils.SaasCommon; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.utils.DateUtil; |
||||||
|
import com.hfkj.common.utils.GenerateUtil; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.hfkj.entity.*; |
||||||
|
import com.hfkj.model.MerBasisModel; |
||||||
|
import com.hfkj.service.*; |
||||||
|
import com.hfkj.sysenum.MerAttachType; |
||||||
|
import com.hfkj.sysenum.PlatformTypeEnum; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.io.File; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 拉卡拉配置 服务 |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
@Service("laKaLaConfigService") |
||||||
|
public class LaKaLaConfigService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 微信参数配置 |
||||||
|
* @param merCupNo 银联商户号 |
||||||
|
* @param subMchId 微信子商户号 |
||||||
|
* @param subAppid 关联APPID 绑定特约商户或渠道公众号、小程序、APP支付等对应的APPID |
||||||
|
* @param jsapiPath 授权目录 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public JSONObject wechatParamConf(String merCupNo,String subMchId,String subAppid,String jsapiPath) { |
||||||
|
// 请求参数
|
||||||
|
Map<String, Object> 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<String, Object> map = new HashMap<>(); |
||||||
|
map.put("merCupNo", merCupNo); |
||||||
|
map.put("channlId", "24006513"); // 微信渠道号 (仅支持拉卡拉渠道配置)
|
||||||
|
// map.put("channlId", "167048649"); // 微信渠道号 (仅支持拉卡拉渠道配置)
|
||||||
|
map.put("subMchId", subMchId); |
||||||
|
map.put("subAppid", subAppid); |
||||||
|
map.put("jsapiPath", jsapiPath); |
||||||
|
map.put("confType", "SUB_APPID"); |
||||||
|
param.put("reqData", map); |
||||||
|
|
||||||
|
// 生成签名
|
||||||
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); |
||||||
|
|
||||||
|
// 头部参数
|
||||||
|
Map<String, Object> heard = new HashMap<>(); |
||||||
|
heard.put("Authorization", reqParam.get("Authorization")); |
||||||
|
|
||||||
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/mms/openApi/wechatParamConf", 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; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 商户报备结果查询 |
||||||
|
* @param merCupNo |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public JSONObject querySubMerInfo(String merCupNo) { |
||||||
|
// 请求参数
|
||||||
|
Map<String, Object> 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<String, Object> map = new HashMap<>(); |
||||||
|
map.put("version", "1.0"); |
||||||
|
map.put("orderNo", new Date().getTime()); |
||||||
|
map.put("orgCode", CommonSysConst.getSysConfig().getLkl_org_code()); |
||||||
|
map.put("merCupNo", merCupNo); |
||||||
|
map.put("registerStatus", "SUCCESS"); |
||||||
|
param.put("reqData", map); |
||||||
|
|
||||||
|
// 生成签名
|
||||||
|
Map<String, Object> reqParam = LaKaLaConfig.generateSignParamsV2(JSONObject.parseObject(JSONObject.toJSONString(param))); |
||||||
|
|
||||||
|
// 头部参数
|
||||||
|
Map<String, Object> heard = new HashMap<>(); |
||||||
|
heard.put("Authorization", reqParam.get("Authorization")); |
||||||
|
|
||||||
|
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v2/mms/openApi/querySubMerInfo", 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"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue