记得上下班打卡 | git大法好,push需谨慎

Commit 0b1e53aa authored by jiangxiulong's avatar jiangxiulong

Merge remote-tracking branch 'origin/dev' into dev

parents 10f97724 f113c785
package com.liquidnet.service.dragon.service;
import java.math.BigDecimal;
public interface IDragonOrderRefundsService {
void sendRedisQueue();
/**
*
* @param trade_no => refund_code
* @param out_trade_no => pay_code
* @param reason
* @param returnUrl
* @param price 退款金额
*/
void dragonRefund(String trade_no, String out_trade_no, String reason, String returnUrl, BigDecimal price);
void weyPayRefund();
void aliPayRefund(String trade_no, String out_trade_no, String reason, String returnUrl, BigDecimal price);
}
......@@ -62,25 +62,25 @@ public class AdamEntersController {
break;
case 2:
if (!Pattern.matches(LnsRegex.Valid.CN_ID_CARD_HM, parameter.getIdCard())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "港澳居民来往内地通行证号码不合规");
return ResponseDto.failure(ErrorMapping.get("10107"));
}
break;
case 3:
if (!Pattern.matches(LnsRegex.Valid.CN_ID_CARD_TW, parameter.getIdCard())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "台湾居民来往大陆通行证号码不合规");
return ResponseDto.failure(ErrorMapping.get("10108"));
}
break;
case 4:
if (Pattern.matches(LnsRegex.Valid.CN_ID_CARD_PP, parameter.getIdCard())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "不支持中国大陆护照");
return ResponseDto.failure(ErrorMapping.get("10109"));
}
if (!Pattern.matches(LnsRegex.Valid.CN_ID_CARD_PP_NON, parameter.getIdCard())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "护照号码不合规");
return ResponseDto.failure(ErrorMapping.get("10110"));
}
break;
case 5:
if (!Pattern.matches(LnsRegex.Valid.CN_ID_CARD_MO, parameter.getIdCard())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "军官证号不合规");
return ResponseDto.failure(ErrorMapping.get("10111"));
}
break;
}
......
......@@ -31,6 +31,11 @@
10104=身份证号码不合规
10105=入场人不存在
10106=收获地址不存在
10107=港澳居民来往内地通行证号码不合规
10108=台湾居民来往大陆通行证号码不合规
10109=不支持中国大陆护照
10110=护照号码不合规
10111=军官证号不合规
10200=仅限从未购买过会员的用户使用
......
......@@ -30,6 +30,11 @@
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.15.6.ALL</version>
</dependency>
</dependencies>
......
package com.liquidnet.service.dragon.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import com.liquidnet.service.dragon.utils.PayUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.ByteArrayOutputStream;
@RestController
@RequestMapping("refund")
public class RefundController {
......@@ -26,10 +17,18 @@ public class RefundController {
IDragonOrderRefundsService orderRefundsService;
@PostMapping("preTest")
@ApiOperation("发送测试退款redis")
@ApiOperation("微信退款")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> checkCanOrder() {
orderRefundsService.sendRedisQueue();
return ResponseDto.success();
}
@PostMapping("refundAliPay")
@ApiOperation("支付宝退款")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> refundAliPay() {
// orderRefundsService.aliPayRefund();
return ResponseDto.success();
}
}
package com.liquidnet.service.dragon.service.impl;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import com.liquidnet.service.dragon.utils.PayUtils;
import com.liquidnet.service.dragon.utils.PayAlipayUtils;
import com.liquidnet.service.dragon.utils.PayWepayUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.math.BigDecimal;
@Service
public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService {
......@@ -36,7 +38,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
// }
try {
PayUtils payUtils = new PayUtils();
PayWepayUtils payWepayUtils = new PayWepayUtils();
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi");
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-type", "application/json; charset=utf-8");
......@@ -53,18 +55,46 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
rootNode.putObject("amount")
.put("total", 1);
rootNode.putObject("payer")
.put("openid", "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o");
.put("openid", "oUpkkuHUgiyTYE4ZU8Y5Sga-znWQ");
objectMapper.writeValue(bos, rootNode);
httpPost.setEntity(new StringEntity(bos.toString("UTF-8"), "UTF-8"));
CloseableHttpResponse response = payUtils.getHttpClient().execute(httpPost);
CloseableHttpResponse response = payWepayUtils.getHttpClient().execute(httpPost);
String bodyAsString = EntityUtils.toString(response.getEntity());
System.out.println(bodyAsString);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void dragonRefund(String trade_no, String out_trade_no, String reason, String returnUrl, BigDecimal price) {
}
@Override
public void weyPayRefund() {
}
@Override
public void aliPayRefund(String trade_no, String out_trade_no, String reason, String returnUrl, BigDecimal price) {
PayAlipayUtils payAlipayUtils = new PayAlipayUtils();
try {
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();//创建API对应的request类
request.setBizContent("{" +
"\"out_trade_no\":\"20210708171331569350143233340P\"," +
"\"trade_no\":\"2021070822001417381433077659\"," +
"\"out_request_no\":\"20210708145709112413077422058T\"," +
"\"refund_amount\":\"0.01\"}"); //设置业务参数
AlipayTradeRefundResponse response = PayAlipayUtils.getHttpClient().execute(request);//通过alipayClient调用API,获得对应的response类
System.out.print(response.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.liquidnet.service.dragon.utils;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.FileInputStream;
import java.net.URL;
import java.security.PrivateKey;
public class PayAlipayUtils {
private static AlipayClient httpClient;
private static PayAlipayUtils instance = new PayAlipayUtils();
private String appId = "2019082866535131";
private String merchant_pub_key = "MIIBIjANBgkq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+/VQjzZR3KXu5kQR9MloURILDsdxE1AyA4AkIXd4eMszEjA4Dv6CQK/jjrsgQKBgQDIiCt1OGmV2sqDBSn4nZNH7BzY3Hdnf+qsYUi+TXKhnQaT8XPKWZpKE/AcqsIKnANmO4sX0NL7ACBe7Rl1RcU9Mq5XuHhnkveFBVRRIHindzUfEN0WgdLy23qmJ2N+1i4FigelY0E5T2lojVb7wycAgAc6vflwE+eYf8W3968q0QKBgQCkRgsVCWWNMSLZeB0V9LV3Om2/UPWY/ovadTxAQtxg0Z75V6Wdu8u0hrYaPSeUK2ryaoE6HKgp7U8NiJGzgm2wpj7D2ysrPmhX5+CjiWkDMCuvWytVT7hLqhhLp7frZT39u8VhyfC8lE0xA67gAPsGSl1sBoZPwvvsmNAQ/h6rlQKBgQCtCtw9be2m88M3JnieYhOax8Po2u5qsLZoBBcKqLhXf7ISbhPWNFXwwJ29jxicoR5J1O3lIj09fVFxuLX0Pb3DXn2VksjLz8Wp0vx8eUHEeRis8xdleaf4C68du/WemOHjw8VvUWQSOVWjc/vwiumYA+K5LQAXWAXM0c1jP+e3UQKBgEWY/1z8TDATn0Yvo3MH6FIJSTIDJOqa/bmibdJ0AVZruUS+o4Y+aEGlyUU4n6og8wCdqv5p4b1Rs2pyb/hzy/FJndHw60s495A2x2/B6eHV6Mw0fhl42wYDnKOA/WUX0bnMcgXKPtpGoqWff9mb0L6LhyUbZpAodf95hr2MTIY5AoGBAIyPtYP6jRyR980h/Ud1MS0fBxymjQrR+kg3GWjnw0ZJJ8yFEXxDqLV8uLyXQKc89HGbI0cClWgZBTjfIPJ5U4Gl19Xlwx1SFrdgg5mGUqnMARTg7w1TG5QLSqNhZo2jgBM5FCJRbDUCO/MzLcFhTeGNva9yP7E7gW5/Dott9D7d";
private String sign_type = "RSA2";
private String charset = "utf-8";
private String gatewayUrl = "https://openapi.alipay.com/gateway.do";
public PayAlipayUtils() {
httpClient = new DefaultAlipayClient(gatewayUrl, appId, merchant_private_key, "json", charset,
merchant_pub_key, sign_type); //获得初始化的AlipayClient
}
private static PayAlipayUtils getInstance() {
return instance;
}
public static AlipayClient getHttpClient() {
return httpClient;
}
}
......@@ -6,27 +6,30 @@ import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.FileInputStream;
import java.net.URL;
import java.security.PrivateKey;
import java.util.Objects;
public class PayUtils {
public class PayWepayUtils {
private CloseableHttpClient httpClient;
// private static PayUtils instance = new PayUtils();
private String merchantId = "1551961491";
private String merchantSerialNumber = "6D25ECC819EAE0BCEA7DB18F143F0752431D9295";
// private static PayUtils instance = new PayUtils();
private CloseableHttpClient httpClient;
private String openId = "wx3498304dda39c5a1";
private String appId = "wx3498304dda39c5a1";
public PayUtils() {
public PayWepayUtils() {
System.out.println("1");
try {
URL path = PayWepayUtils.class.getClassLoader().getResource("payCert/wepay/wepay_apiclient_key.pem");
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(
Objects.requireNonNull(PayUtils.class.getClassLoader().getResourceAsStream("wepay_apiclient_key.pem"))
new FileInputStream(path.getPath())
);
CloseableHttpClient httpClientTemp = WechatPayHttpClientBuilder.create()
......
......@@ -43,7 +43,7 @@ public class OrderUtils {
} else {
integers = roadShowOrderLimit(userId, idCard, performanceId, ticketId, performanceBuyCount, ticketBuyCount, isTrueName);
}
return judgeMemberType(performanceLimitCount, performanceMemberLimitCount, ticketLimitCount, ticketMemberLimitCount, memberType, integers[0], integers[1]);
return judgeMemberType(performanceLimitCount, performanceMemberLimitCount, ticketLimitCount, ticketMemberLimitCount, memberType, integers[0], integers[1], isTrueName);
}
public Integer[] roadShowOrderLimit(
......@@ -85,20 +85,20 @@ public class OrderUtils {
return new Integer[]{performanceBuyCount, ticketBuyCount};
}
public String judgeMemberType(int performanceLimitCount, int performanceMemberLimitCount, int ticketLimitCount, int ticketMemberLimitCount, int memberType, int performanceBuyCount, int ticketBuyCount) {
public String judgeMemberType(int performanceLimitCount, int performanceMemberLimitCount, int ticketLimitCount, int ticketMemberLimitCount, int memberType, int performanceBuyCount, int ticketBuyCount, int isTrueName) {
if (memberType == 1 || memberType == 2) {
if (performanceBuyCount > performanceMemberLimitCount && performanceMemberLimitCount != 0) {
return "该演出只能购买" + performanceMemberLimitCount + "张";//超过演出维度购买量
return (1 == isTrueName ? "实名制" : "本场") + "演出限购" + performanceMemberLimitCount + "张,已超出";//超过演出维度购买量
}
if (ticketBuyCount > ticketMemberLimitCount && ticketMemberLimitCount != 0) {
return "该票种只能购买" + ticketMemberLimitCount + "张";//超过票维度购买量
return (1 == isTrueName ? "实名制" : "该") + "票种限购" + ticketMemberLimitCount + "张,已超出";//超过票维度购买量
}
} else {//非会员区间
if (performanceBuyCount > performanceLimitCount && performanceLimitCount != 0) {
return "该演出只能购买" + performanceLimitCount + "张";//超过演出维度购买量
return (1 == isTrueName ? "实名制" : "本场") + "演出限购" + performanceLimitCount + "张,已超出";//超过演出维度购买量
}
if (ticketBuyCount > ticketLimitCount && ticketLimitCount != 0) {
return "该票种只能购买" + ticketLimitCount + "张";//超过票维度购买量
return (1 == isTrueName ? "实名制" : "该") + "票种限购" + ticketLimitCount + "张,已超出";//超过票维度购买量
}
}
return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment