微信小程序点歌接口

This commit is contained in:
2024-07-09 17:16:11 +08:00
parent 71bc50e8bd
commit ec0dbc3337
22 changed files with 1294 additions and 7 deletions

View File

@@ -32,6 +32,8 @@ public class WxScanPayReq implements Serializable {
private String returnUrl;
private String extParam;
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
@@ -46,4 +48,20 @@ public class WxScanPayReq implements Serializable {
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl, String extParam) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.subAppid = subAppid;
this.userId = userId;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
this.extParam = extParam;
}
}

View File

@@ -100,6 +100,33 @@ public class ThirdPayService {
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
try {
String str = JSONUtil.toJSONString(sortFields(scanPayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(ltpay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<WxScanPayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),WxScanPayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public PublicResp<WxScanPayResp> scanpay(String url,String appId, String subject, String body, Long amount,String payType, String subAppId, String userId,
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
String key, String extParam){
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl, extParam);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
try {
String str = JSONUtil.toJSONString(sortFields(scanPayReq));
param.setBizData(str);