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

Commit 02c2ab15 authored by anjiabin's avatar anjiabin

提交支付宝支付

parent b9d95beb
......@@ -15,13 +15,13 @@ public class DragonConstant {
public static final String REFUND_TYPE_JS_WEPAY="JSWEPAY";//,"微信内网页、微信公众号"),
public static final String REFUND_TYPE_APPLET_WEPAY="APPLETWEPAY";//,"微信小程序");
public enum payChannelEnum{
public enum PayChannelEnum{
ALIPAY("alipay","支付宝"),
WEPAY ("wePay","微信"),
CLOUDPAY("cloudPay","云闪付");
private String code;
private String message;
payChannelEnum(String code, String message) {
PayChannelEnum(String code, String message) {
this.code = code;
this.message = message;
}
......@@ -29,7 +29,7 @@ public class DragonConstant {
/**
* 支付状态
*/
public enum payStatusEnum{
public enum PayStatusEnum{
STATUS_UNPAID("0","未支付,或支付中"),
STATUS_PAID("1","已支付"),
STATUS_SUCCESS("2","已支付,通知成功,交易结束"),
......@@ -38,16 +38,30 @@ public class DragonConstant {
private String code;
private String message;
payStatusEnum(String code, String message) {
PayStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public PayStatusEnum getEnumByCode(String code){
PayStatusEnum[] arry = PayStatusEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
}
/**
* 退款状态
*/
public enum refundStatusEnum{
public enum RefundStatusEnum{
STATUS_UNFILLED("0","未处理"),
STATUS_REFUNDED("1","退款成功"),
STATUS_SUCCESS("2","退款成功,通知成功,交易结束"),
......@@ -61,7 +75,7 @@ public class DragonConstant {
private String code;
private String message;
refundStatusEnum(String code, String message) {
RefundStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
......@@ -74,7 +88,7 @@ public class DragonConstant {
/**
* 支付业务类型
*/
public enum bussinessTypeEnum{
public enum BussinessTypeEnum{
TYPE_TICKET("TICKET","票务购买(实物购买)"),
TYPE_PRODUCT("PRODUCT","商品购买(实物购买)"),
TYPE_COST("COST","活动资费(活动成本费、活动报名费)"),
......@@ -87,16 +101,20 @@ public class DragonConstant {
private String code;
private String message;
bussinessTypeEnum(String code, String message) {
BussinessTypeEnum(String code, String message) {
this.code = code;
this.message = message;
}
public String getCode() {
return code;
}
}
/**
* 支付类型
*/
public enum payTypeEnum{
public enum PayTypeEnum{
PAYMENT_TYPE_APP_ALIPAY("APPALIPAY","App内支付宝支付"),
PAYMENT_TYPE_APP_WEPAY("APPWEPAY","App内微信支付"),
PAYMENT_TYPE_APP_IAP("APPIAP","App内IAP(In-App Purchase)支付,iOS虚拟道具支付"),
......@@ -109,16 +127,20 @@ public class DragonConstant {
private String code;
private String message;
payTypeEnum(String code, String message) {
PayTypeEnum(String code, String message) {
this.code = code;
this.message = message;
}
public String getCode() {
return code;
}
}
/**
* 退款类型
*/
public enum refundTypeEnum{
public enum RefundTypeEnum{
REFUND_TYPE_APP_ALIPAY("APPALIPAY","App内支付宝支付"),
REFUND_TYPE_APP_WEPAY("APPWEPAY","App内微信支付"),
REFUND_TYPE_APP_IAP("APPIAP","App内IAP(In-App Purchase)支付,iOS虚拟道具支付"),
......@@ -131,7 +153,7 @@ public class DragonConstant {
private String code;
private String message;
refundTypeEnum(String code, String message) {
RefundTypeEnum(String code, String message) {
this.code = code;
this.message = message;
}
......@@ -144,14 +166,14 @@ public class DragonConstant {
/**
* MYSQL_REDIS_QUEUE
*/
public enum mysqlRedisQueueEnum{
public enum MysqlRedisQueueEnum{
DRAGON_PAY_KEY("dragon-pay","同步数据-支付"),
DRAGON_REFUND_KEY ("dragon-refund","同步数据-退款"),
DRAGON_PAY_GROUP("dragon-pay-group","同步数据-支付-组"),
DRAGON_REFUND_GROUP ("dragon-refund-group","同步数据-退款-组");
private String code;
private String message;
mysqlRedisQueueEnum(String code, String message) {
MysqlRedisQueueEnum(String code, String message) {
this.code = code;
this.message = message;
}
......@@ -164,7 +186,7 @@ public class DragonConstant {
/**
* CHANNEL_REDIS_QUEUE
*/
public enum channelRedisQueueEnum{
public enum ChannelRedisQueueEnum{
WECHAT_PAY_KEY("wechat-pay","微信-支付-回调"),
WECHAT_REFUND_KEY("wechat-pay","微信-退款-回调"),
ALIPAY_PAY_KEY("alipay-pay","支付宝-支付-回调"),
......@@ -175,7 +197,7 @@ public class DragonConstant {
ALIPAY_REFUND_GROUP ("alipay-refund-group","支付宝-退款-回调-组");
private String code;
private String message;
channelRedisQueueEnum(String code, String message) {
ChannelRedisQueueEnum(String code, String message) {
this.code = code;
this.message = message;
}
......@@ -184,7 +206,7 @@ public class DragonConstant {
/**
* CHANNEL_REFUND_URL
*/
public enum channelRefundUrlEnum{
public enum ChannelRefundUrlEnum{
JSAPI_REFUND_URL("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","JSAPI-退款-接口"),
APP_REFUND_URL("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","APP-退款-接口"),
H5_REFUND_URL("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","H5-退款-接口"),
......@@ -192,7 +214,7 @@ public class DragonConstant {
MCH_REFUND_URL("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","小程序-退款-接口");
private String code;
private String message;
channelRefundUrlEnum(String code, String message) {
ChannelRefundUrlEnum(String code, String message) {
this.code = code;
this.message = message;
}
......
package com.liquidnet.service.dragon.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -13,11 +15,10 @@ import javax.validation.constraints.NotNull;
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 10:56
*/
@Data
public class DragonPayBaseReqDto {
@ApiModelProperty(position = 14, required = true, value = "性别[32]", example = "{\"val\":\"MS00\",\"desc\":\"其他性别\"}")
@NotNull(message = "性别不能为空")
private String type;
private String price;
private BigDecimal price;
private String name;
private String detail;
private String orderCode;
......
package com.liquidnet.service.dragon.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonRefundAppDto;
import java.math.BigDecimal;
public interface IDragonOrdersService {
void sendRedisQueue();
ResponseDto<DragonPayBaseRespDto> alipay(DragonPayBaseReqDto dragonPayBaseReqDto);
}
......@@ -47,6 +47,13 @@ public class IDGenerator {
return orderCode;
}
public static String payCode(){
String refundCode = System.currentTimeMillis()+"";
int randomCode = RandomUtil.getRandomInt(0,10000);
StringUtils.leftPad(refundCode, 3, "0");
return refundCode.concat(StringUtils.leftPad(randomCode+"", (randomCode/10), "0")+"R");
}
public static String refundCode(){
String refundCode = System.currentTimeMillis()+"";
int randomCode = RandomUtil.getRandomInt(0,10000);
......
......@@ -22,3 +22,5 @@ liquidnet:
mongodb:
sslEnabled: false
database: dev_ln_scene
dragon:
alipay-gataway-url: https://openapi.alipay.com/gateway.do
......@@ -92,4 +92,9 @@ public class DragonOrders implements Serializable {
*/
private LocalDateTime updatedAt;
/**
* deleted_at
*/
private LocalDateTime deletedAt;
}
......@@ -32,8 +32,8 @@ public class RedisStreamConfig {
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.mysqlRedisQueueEnum.DRAGON_PAY_GROUP.getCode(), "dragon-pay-0"),
StreamOffset.create(DragonConstant.mysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayReceiver);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_GROUP.getCode(), "dragon-pay-0"),
StreamOffset.create(DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayReceiver);
listenerContainer.start();
return subscription;
}
......@@ -46,8 +46,8 @@ public class RedisStreamConfig {
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.mysqlRedisQueueEnum.DRAGON_PAY_GROUP.getCode(), "dragon-pay-1"),
StreamOffset.create(DragonConstant.mysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayReceiver);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_GROUP.getCode(), "dragon-pay-1"),
StreamOffset.create(DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayReceiver);
listenerContainer.start();
return subscription;
}
......@@ -60,8 +60,8 @@ public class RedisStreamConfig {
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_GROUP.getCode(), "dragon-refund-0"),
StreamOffset.create(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode(), ReadOffset.lastConsumed()), redisRefundReceiver);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_GROUP.getCode(), "dragon-refund-0"),
StreamOffset.create(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode(), ReadOffset.lastConsumed()), redisRefundReceiver);
listenerContainer.start();
return subscription;
}
......@@ -74,8 +74,8 @@ public class RedisStreamConfig {
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_GROUP.getCode(), "dragon-refund-1"),
StreamOffset.create(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode(), ReadOffset.lastConsumed()), redisRefundReceiver);
var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_GROUP.getCode(), "dragon-refund-1"),
StreamOffset.create(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode(), ReadOffset.lastConsumed()), redisRefundReceiver);
listenerContainer.start();
return subscription;
}
......
package com.liquidnet.service.consumer.dragon.service.processor;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.consumer.dragon.service.IBaseDao;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerPayProcessor
* @Package com.liquidnet.service.consumer.dragon.service.processor
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/8 10:59
*/
@Slf4j
@Component
public class ConsumerPayProcessor implements StreamListener<String, MapRecord<String, String, String>> {
@Resource
IBaseDao baseDao;
@Override
public void onMessage(MapRecord<String, String, String> message) {
log.info("接受到来自redis PAY 的消息");
System.out.println("message id "+message.getId());
System.out.println("stream "+message.getStream());
System.out.println("body "+message.getValue());
}
private void consumerSqlDaoHandler(Message msg, Channel channel) {
MessageProperties properties = msg.getMessageProperties();
String consumerQueue = properties.getConsumerQueue();
long deliveryTag = properties.getDeliveryTag();
log.info("CONSUMER SQL ==> [consumerQueue:{},deliveryTag:{}]", consumerQueue, deliveryTag);
SqlMapping.SqlMessage sqlMessage = JsonUtils.fromJson(new String(msg.getBody()), SqlMapping.SqlMessage.class);
log.debug("CONSUMER SQL ==> Preparing:{}", JsonUtils.toJson(sqlMessage.getSqls()));
log.debug("CONSUMER SQL ==> Parameters:{}", JsonUtils.toJson(sqlMessage.getArgs()));
try {
Boolean rstBatchSqls = baseDao.batchSqls(sqlMessage.getSqls(), sqlMessage.getArgs());
log.debug("CONSUMER SQL result of execution:{}", rstBatchSqls);
if (rstBatchSqls) {
channel.basicAck(deliveryTag, false);
} else {
log.warn("###CONSUMER SQL[consumerQueue:{},deliveryTag={},sqlMessage:{}]", consumerQueue, deliveryTag, JsonUtils.toJson(sqlMessage));
channel.basicAck(deliveryTag, false);
}
} catch (IOException e) {
log.error("CONSUMER SQL[consumerQueue:{},deliveryTag:{},sqlMessage:{}]", consumerQueue, deliveryTag, JsonUtils.toJson(sqlMessage), e);
}
}
}
package com.liquidnet.service.consumer.dragon.service.processor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.stereotype.Component;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerRefundProcessor
* @Package com.liquidnet.service.consumer.dragon.service.processor
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/8 10:59
*/
@Slf4j
@Component
public class ConsumerRefundProcessor implements StreamListener<String, MapRecord<String, String, String>> {
@Override
public void onMessage(MapRecord<String, String, String> message) {
log.info("接受到来自redis REFUND 的消息");
System.out.println("message id "+message.getId());
System.out.println("stream "+message.getStream());
System.out.println("body "+message.getValue());
}
}
......@@ -61,7 +61,7 @@ public class RedisRefundReceiver implements StreamListener<String, MapRecord<Str
try {
HashMap<String, String> map = new HashMap<>();
map.put("message", msg);
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode());
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode());
stringRedisTemplate.opsForStream().add(record);
return true;
} catch (Exception e) {
......
package com.liquidnet.service.dragon.channel.alipay.config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.Properties;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayUtil
* @Package com.liquidnet.service.dragon.channel.alipay.config
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
public class AlipayConfigUtil {
private static final Log LOG = LogFactory.getLog(AlipayConfigUtil.class);
/**
* 通过静态代码块读取上传文件的验证格式配置文件,静态代码块只执行一次(单例)
*/
private static Properties properties = new Properties();
/**
* 私有构造方法
**/
private AlipayConfigUtil() {
}
static {
try {
// 从类路径下读取属性文件
properties.load(AlipayConfigUtil.class.getClassLoader()
.getResourceAsStream("alipay_config.properties"));
} catch (IOException e) {
LOG.error(e);
}
}
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
// 合作身份者ID,签约账号,以2088开头由16位纯数字组成的字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm
public static final String partner = (String) properties.get("partner");
// 收款支付宝账号,以2088开头由16位纯数字组成的字符串,一般情况下收款账号就是签约账号
public static final String seller_id = (String) properties.get("seller_id");
// MD5密钥,安全检验码,由数字和字母组成的32位字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm
public static final String key = (String) properties.get("key");
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public static final String notify_url = (String) properties.get("notify_url");
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public static final String return_url = (String) properties.get("return_url");
// 签名方式
public static final String sign_type = (String) properties.get("sign_type");
// 调试用,创建TXT日志文件夹路径,见AlipayCore.java类中的logResult(String sWord)打印方法。
public static final String log_path = (String) properties.get("log_path");
// 字符编码格式 目前支持 gbk 或 utf-8
public static final String input_charset = (String) properties.get("input_charset");
// 支付类型 ,无需修改
public static final String payment_type = (String) properties.get("payment_type");
// 调用的接口名,无需修改
public static final String service = (String) properties.get("service");
//支付宝被扫地址
public static final String trade_pay_url = (String) properties.get("trade_pay_url");
//支付宝交易查询地址
public static final String trade_query_url = (String) properties.get("trade_query_url");
//app_id
public static final String app_id = (String) properties.get("app_id");
//商户私钥
public static final String mch_private_key = (String) properties.get("mch_private_key");
//支付宝公钥
public static final String ali_public_key = (String) properties.get("ali_public_key");
// 防钓鱼时间戳 若要使用请调用类文件submit中的query_timestamp函数
public static final String anti_phishing_key = "";
// 客户端的IP地址 非局域网的外网IP地址,如:221.0.0.1
public static final String exter_invoke_ip = "";
}
package com.liquidnet.service.dragon.channel.alipay.req;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayTradePayReq
* @Package com.liquidnet.service.dragon.channel.alipay.req
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 17:50
*/
@Data
public class AlipayTradePayReq {
private String productCode;
private BigDecimal totalAmount;
private String subject;
private String body;
private String outTradeNo;
private String timeExpire;
@Override
public String toString(){
return JSON.toJSONString(this);
}
}
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.liquidnet.service.dragon.channel.alipay.sign;
import org.apache.commons.codec.digest.DigestUtils;
import java.io.UnsupportedEncodingException;
import java.security.SignatureException;
/**
* 签名加密MD%
*/
public class MD5 {
/**
* 签名字符串
* @param text 需要签名的字符串
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static String sign(String text, String key, String input_charset) {
text = text + key;
return DigestUtils.md5Hex(getContentBytes(text, input_charset));
}
/**
* 签名字符串
* @param text 需要签名的字符串
* @param sign 签名结果
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static boolean verify(String text, String sign, String key, String input_charset) {
text = text + key;
String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset));
if(mysign.equals(sign)) {
return true;
}
else {
return false;
}
}
/**
* @param content
* @param charset
* @return
* @throws SignatureException
* @throws UnsupportedEncodingException
*/
private static byte[] getContentBytes(String content, String charset) {
if (charset == null || "".equals(charset)) {
return content.getBytes();
}
try {
return content.getBytes(charset);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
}
}
}
\ No newline at end of file
package com.liquidnet.service.dragon.channel.alipay.util;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayUtil
* @Package com.liquidnet.service.dragon.channel.alipay.util
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradePayRequest;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.alipay.api.response.AlipayTradePayResponse;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.dragon.channel.alipay.config.AlipayConfigUtil;
import com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq;
import com.liquidnet.service.dragon.channel.alipay.sign.MD5;
import com.liquidnet.service.dragon.utils.PayAlipayUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.*;
@Slf4j
public class AlipayUtil {
private static final Logger logger = LoggerFactory.getLogger(AlipayUtil.class);
private AlipayUtil() {
}
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public static Map<String, Object> tradePagePay(AlipayTradePayReq alipayTradePayReq) {
logger.info("AlipayUtil.tradePay-->> req : {}",alipayTradePayReq.toString());
String timeExpress = "5m";// 支付超时,线下扫码交易定义为5分钟
AlipayClient alipayClient = PayAlipayUtils.getHttpClient();
SortedMap<String, Object> paramMap = new TreeMap<>();
paramMap.put("product_code", alipayTradePayReq.getProductCode());
paramMap.put("total_amount", alipayTradePayReq.getTotalAmount().toString());
paramMap.put("subject", alipayTradePayReq.getSubject());
paramMap.put("body", alipayTradePayReq.getBody());
paramMap.put("out_trade_no", alipayTradePayReq.getOutTradeNo());
paramMap.put("timeout_express", timeExpress);
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
request.setNotifyUrl("https://testpay.zhengzai.tv");
// request.setTimestamp(DateUtil.now());
logger.info("bizContent :{}",JSONObject.toJSONString(paramMap));
request.setBizContent(JSONObject.toJSONString(paramMap));
try {
AlipayTradePagePayResponse response = alipayClient.sdkExecute(request);
JSONObject responseJSON = JSONObject.parseObject(JSONObject.toJSONString(response));
logger.info("支付宝返回结果:{}", responseJSON);
return responseJSON;
} catch (AlipayApiException e) {
logger.error("支付宝支付异常:{}", e);
JSONObject resultJSON = new JSONObject();
resultJSON.put("outTradeNo", alipayTradePayReq.getOutTradeNo());
resultJSON.put("totalAmount", alipayTradePayReq.getTotalAmount().toString());
resultJSON.put("errorCode", "9999");
return resultJSON;
}
}
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public static Map<String, Object> tradeWapPay(AlipayTradePayReq alipayTradePayReq) {
logger.info("AlipayUtil.tradePay-->> req : {}",alipayTradePayReq.toString());
String timeExpress = "5m";// 支付超时,线下扫码交易定义为5分钟
AlipayClient alipayClient = PayAlipayUtils.getHttpClient();
SortedMap<String, Object> paramMap = new TreeMap<>();
paramMap.put("product_code", alipayTradePayReq.getProductCode());
paramMap.put("total_amount", alipayTradePayReq.getTotalAmount().toString());
paramMap.put("subject", alipayTradePayReq.getSubject());
paramMap.put("body", alipayTradePayReq.getBody());
paramMap.put("out_trade_no", alipayTradePayReq.getOutTradeNo());
paramMap.put("timeout_express", timeExpress);
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
request.setNotifyUrl("https://testpay.zhengzai.tv");
// request.setTimestamp(DateUtil.now());
logger.info("bizContent :{}",JSONObject.toJSONString(paramMap));
request.setBizContent(JSONObject.toJSONString(paramMap));
try {
AlipayTradeWapPayResponse response = alipayClient.sdkExecute(request);
if(response.isSuccess()){
}
JSONObject responseJSON = JSONObject.parseObject(JSONObject.toJSONString(response));
logger.info("支付宝返回结果:{}", responseJSON);
return responseJSON;
} catch (AlipayApiException e) {
logger.error("支付宝支付异常:{}", e);
JSONObject resultJSON = new JSONObject();
resultJSON.put("outTradeNo", alipayTradePayReq.getOutTradeNo());
resultJSON.put("totalAmount", alipayTradePayReq.getTotalAmount().toString());
resultJSON.put("errorCode", "9999");
return resultJSON;
}
}
/**
* 订单查询
*
* @return
*/
public static Map<String, Object> tradeQuery(String outTradeNo) {
logger.info("======>支付宝交易查询");
String charset = "UTF-8";
String format = "json";
String signType = "RSA2";
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfigUtil.trade_query_url, AlipayConfigUtil.app_id, AlipayConfigUtil.mch_private_key, format, charset, AlipayConfigUtil.ali_public_key, signType);
SortedMap<String, Object> bizContentMap = new TreeMap<>();
bizContentMap.put("out_trade_no", outTradeNo);
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
request.setBizContent(JSONObject.toJSONString(bizContentMap));
try {
AlipayTradeQueryResponse response = alipayClient.execute(request);
JSONObject responseJSON = JSONObject.parseObject(JSONObject.toJSONString(response));
logger.info("支付宝订单查询返回结果:{}", responseJSON);
return responseJSON;
} catch (AlipayApiException e) {
logger.error("支付宝交易查询异常:{}", e);
return null;
}
}
private static String getSign(SortedMap<String, String> paramMap, String key) {
StringBuilder signBuilder = new StringBuilder();
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
if (!"sign".equals(entry.getKey()) && !"sign_type".equals(entry.getKey()) && !StringUtil.isEmpty(entry.getValue())) {
signBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
}
return MD5.sign(signBuilder.substring(0, signBuilder.length() - 1), key, "UTF-8");
}
}
package com.liquidnet.service.dragon.channel.wepay.util;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: WepayUtil
* @Package com.liquidnet.service.dragon.channel.wepay.util
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
public class WepayUtil {
}
package com.liquidnet.service.dragon.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: PayController
* @Package com.liquidnet.service.dragon.controller
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 12:29
*/
@RestController
@RequestMapping("pay")
public class PayController {
@Autowired
IDragonOrdersService dragonOrdersService;
private IDragonOrdersService dragonOrdersService;
/**
* 电脑网页支付宝支付
* @return
*/
@PostMapping("/web/alipay")
@ApiOperation("支付宝web支付")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "支付类型:TICKET,PRODUCT,COST,MBEANS,LIVE,VIDEO,VIP,CLUB,STRAWBERRY", example = "TICKET"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "price", value = "支付金额", example = "0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "name", value = "订单名称", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "detail", value = "订单描述", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderCode", value = "订单编号", example = "ORDER0001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "clientIp", value = "客户端ip", example = "127.0.0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "notifyUrl", value = "通知url", example = "pay.zhengzai.tv"),
})
public ResponseDto<DragonPayBaseRespDto> webAlipay(@RequestParam(value = "type") @NotNull(message = "支付类型不能为空") String type,
@RequestParam(value = "price") @NotNull(message = "支付金额不能为空") BigDecimal price,
@RequestParam(value = "name") @NotNull(message = "订单名称不能为空") String name,
@RequestParam(value = "detail") @NotNull(message = "订单描述不能为空") String detail,
@RequestParam(value = "orderCode") @NotNull(message = "订单编号不能为空") String orderCode,
@RequestParam(value = "clientIp") @NotNull(message = "客户端ip不能为空") String clientIp,
@RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl,
@RequestParam(value = "returnUrl",required = false) String returnUrl,
@RequestParam(value = "quitUrl",required = false) String quitUrl,
@RequestParam(value = "showUrl",required = false) String showUrl,
@RequestParam(value = "code",required = false) String code,
@RequestParam(value = "createDate",required = false) String createDate,
@RequestParam(value = "expireTime",required = false) String expireTime){
DragonPayBaseReqDto dragonPayBaseReqDto = new DragonPayBaseReqDto();
dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setPrice(price);
dragonPayBaseReqDto.setName(name);
dragonPayBaseReqDto.setDetail(detail);
dragonPayBaseReqDto.setOrderCode(orderCode);
dragonPayBaseReqDto.setClientIp(clientIp);
dragonPayBaseReqDto.setNotifyUrl(notifyUrl);
return dragonOrdersService.alipay(dragonPayBaseReqDto);
}
/**
* 手机网页支付宝支付
* @return
*/
@PostMapping("/wap/alipay")
@ApiOperation("支付宝wap支付")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "支付类型:TICKET,PRODUCT,COST,MBEANS,LIVE,VIDEO,VIP,CLUB,STRAWBERRY", example = "TICKET"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "price", value = "支付金额", example = "0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "name", value = "订单名称", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "detail", value = "订单描述", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderCode", value = "订单编号", example = "ORDER0001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "clientIp", value = "客户端ip", example = "127.0.0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "notifyUrl", value = "通知url", example = "pay.zhengzai.tv"),
})
public ResponseDto<DragonPayBaseRespDto> wapAlipay(@RequestParam(value = "type") @NotNull(message = "支付类型不能为空") String type,
@RequestParam(value = "price") @NotNull(message = "支付金额不能为空") BigDecimal price,
@RequestParam(value = "name") @NotNull(message = "订单名称不能为空") String name,
@RequestParam(value = "detail") @NotNull(message = "订单描述不能为空") String detail,
@RequestParam(value = "orderCode") @NotNull(message = "订单编号不能为空") String orderCode,
@RequestParam(value = "clientIp") @NotNull(message = "客户端ip不能为空") String clientIp,
@RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl,
@RequestParam(value = "returnUrl",required = false) String returnUrl,
@RequestParam(value = "quitUrl",required = false) String quitUrl,
@RequestParam(value = "showUrl",required = false) String showUrl,
@RequestParam(value = "code",required = false) String code,
@RequestParam(value = "createDate",required = false) String createDate,
@RequestParam(value = "expireTime",required = false) String expireTime){
DragonPayBaseReqDto dragonPayBaseReqDto = new DragonPayBaseReqDto();
dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setPrice(price);
dragonPayBaseReqDto.setName(name);
dragonPayBaseReqDto.setDetail(detail);
dragonPayBaseReqDto.setOrderCode(orderCode);
dragonPayBaseReqDto.setClientIp(clientIp);
dragonPayBaseReqDto.setNotifyUrl(notifyUrl);
return dragonOrdersService.alipay(dragonPayBaseReqDto);
}
// /**
// * 电脑网页微信支付
// * @return
// */
// @PostMapping("/web/wepay")
// @ApiOperation("微信web支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto webWepay(){
// return null;
// }
//
//
// /**
// * 手机网页微信支付
// * @return
// */
// @PostMapping("/wap/wepay")
// @ApiOperation("微信wap支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto wapWepay(){
// return null;
// }
//
// /**
// * App内支付宝支付
// * @return
// */
// @PostMapping("/app/alipay")
// @ApiOperation("支付宝app支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto appAlipay(){
// return null;
// }
//
// /**
// * App内微信支付
// * @return
// */
// @PostMapping("/app/wepay")
// @ApiOperation("微信app支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto appWepay(){
// return null;
// }
//
// /**
// * Apple(In-App Purchase) 支付
// * @return
// */
// @PostMapping("/app/iappay")
// @ApiOperation("Apple支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto appIappay(){
// return null;
// }
//
// /**
// * 微信内网页、公众号支付
// * @return
// */
// @PostMapping("/js/wepay")
// @ApiOperation("微信内网页、公众号支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto jsWepay(){
// return null;
// }
//
// /**
// * 微信小程序支付
// * @return
// */
// @PostMapping("/applet/wepay")
// @ApiOperation("微信小程序支付")
// @ApiResponse(code = 200, message = "接口返回对象参数")
// public DragonPayBaseRespDto appletWepay(){
// return null;
// }
}
......@@ -132,7 +132,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
if (response.getFundChange().equals("N") || response.getFundChange() == null) {
try {
String refundError = "";
refundStatus = DragonConstant.refundStatusEnum.STATUS_ERROR.getCode();
refundStatus = DragonConstant.RefundStatusEnum.STATUS_ERROR.getCode();
if (null == response.getSubMsg()) {
refundError = "退款失败,原因未知";
} else {
......@@ -170,10 +170,10 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
try {
String refundAt = "";
if (response.getFundChange().equals("Y")) {
refundStatus = DragonConstant.refundStatusEnum.STATUS_REFUNDED.getCode();
refundStatus = DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode();
refundAt = DateUtil.format(response.getGmtRefundPay(), DateUtil.Formatter.yyyyMMddHHmmss);
} else {
refundStatus = DragonConstant.refundStatusEnum.STATUS_REFUNDING.getCode();
refundStatus = DragonConstant.RefundStatusEnum.STATUS_REFUNDING.getCode();
}
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
......@@ -220,7 +220,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
HashMap<String, String> map = new HashMap<>();
map.put("message", sqlData);
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey(DragonConstant.mysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode());
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey(DragonConstant.MysqlRedisQueueEnum.DRAGON_REFUND_KEY.getCode());
stringRedisTemplate.opsForStream().add(record);
return true;
} catch (Exception e) {
......
package com.liquidnet.service.dragon.service.impl;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq;
import com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil;
import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.entity.DragonOrders;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
@Service
public class DragonOrdersServiceImpl implements IDragonOrdersService {
@Autowired
StringRedisTemplate stringRedisTemplate;
@Value("liquidnet.dragon.alipay-gataway-url")
private String alipayGatewayUrl;
@Override
public void sendRedisQueue() {
......@@ -25,4 +40,83 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
e.printStackTrace();
}
}
@Override
public ResponseDto<DragonPayBaseRespDto> alipay(DragonPayBaseReqDto dragonPayBaseReqDto) {
AlipayTradePayReq alipayTradePayReq = new AlipayTradePayReq();
alipayTradePayReq.setProductCode("QUICK_WAP_PAY");
alipayTradePayReq.setTotalAmount(dragonPayBaseReqDto.getPrice());
alipayTradePayReq.setSubject(dragonPayBaseReqDto.getName());
alipayTradePayReq.setBody(dragonPayBaseReqDto.getDetail());
//dragon中支付编号
alipayTradePayReq.setOutTradeNo(IDGenerator.payCode());
alipayTradePayReq.setTimeExpire(dragonPayBaseReqDto.getExpireTime());
Map<String, Object> result = AlipayUtil.tradeWapPay(alipayTradePayReq);
DragonPayBaseRespDto respDto = new DragonPayBaseRespDto();
respDto.setCode(alipayTradePayReq.getOutTradeNo());
respDto.setOrder_code(dragonPayBaseReqDto.getOrderCode());
DragonPayBaseRespDto.PayData payData = new DragonPayBaseRespDto.PayData();
payData.setRedirectUrl(alipayGatewayUrl + result.get("body"));
respDto.setPay_data(payData);
//支付订单持久化
this.buildPayOrders(dragonPayBaseReqDto,respDto);
return ResponseDto.success(respDto);
}
private DragonOrders buildPayOrders(DragonPayBaseReqDto dragonPayBaseReqDto,DragonPayBaseRespDto respDto){
DragonOrders orders = new DragonOrders();
// orders.setMid();
orders.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_UNPAID.getCode()));
orders.setCode(respDto.getCode());
orders.setType(dragonPayBaseReqDto.getType());
orders.setPrice(dragonPayBaseReqDto.getPrice());
orders.setName(dragonPayBaseReqDto.getName());
orders.setDetail(dragonPayBaseReqDto.getDetail());
orders.setOrderCode(dragonPayBaseReqDto.getOrderCode());
orders.setClientIp(dragonPayBaseReqDto.getClientIp());
orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setPaymentType(DragonConstant.PayTypeEnum.PAYMENT_TYPE_APP_IAP.getCode());
// orders.setPaymentId();
orders.setPaymentAt(LocalDateTime.now());
// orders.setFinishedAt();
orders.setCreatedAt(LocalDateTime.now());
// orders.setUpdatedAt();
// 修改退款订单
boolean insertResult = sendMySqlRedis(
SqlMapping.get("dragon_orders.insert"),
new Object[]{orders.getStatus(), orders.getCode(), orders.getType()
, orders.getPrice(), orders.getName(), orders.getDetail()
, orders.getOrderCode(), orders.getClientIp()
, orders.getNotifyUrl(), orders.getPaymentType(),
orders.getPaymentId(), orders.getPaymentAt()
, orders.getFinishedAt(), orders.getCreatedAt()
, orders.getUpdatedAt()}
);
return orders;
}
/**
* 给 REDIS 队列发送消息 数据库相关
*
* @param sql sql语句
* @param data 需要操作的数据
* @return
*/
private boolean sendMySqlRedis(String sql, Object[] data) {
try {
LinkedList<String> sqls = new LinkedList<>();
sqls.add(sql);
LinkedList<Object[]> sqlsData = new LinkedList();
sqlsData.add(data);
String sqlData = SqlMapping.gets(sqls, sqlsData);
HashMap<String, String> map = new HashMap<>();
map.put("message", sqlData);
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey(DragonConstant.MysqlRedisQueueEnum.DRAGON_PAY_KEY.getCode());
stringRedisTemplate.opsForStream().add(record);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
......@@ -21,18 +21,17 @@ import java.net.URL;
import java.security.PrivateKey;
public class PayAlipayUtils {
private static AlipayClient httpClient;
private static AlipayClient httpClient = null;
private static PayAlipayUtils instance = new PayAlipayUtils();
private String appId = "2019082866535131";
private String merchant_pub_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmePaETscydypY3rV4mXa8MtcQIL5zjP1KxdusNkHpePeU61hAZxKn0Z8pDB1wNaTK72wgEWaORXeRp4YTbf4usHlW562Pe5wdiSutb3iT6EMJ5eBD4HLI9wWDgYBtwfHwS5JJFhf0eptP4R1XluLiMhmMynLwJvHepgkVrS3mN+jmoPRmKFhZHGIYDoWypBMbUKiFHWiToHK1n0NYHHIi4WgK2wt4Wj7nexQGD69W7ofRCirYmz35c/cNFUA1lqzOEKu2z7PpjA6jQV2GJolnJ4xXPJ8Dpgp4g/dgsGqRydlmFqZD71i/pDDpF0RfRKHL+WhWVhI1hqe6jLtvJE+zQIDAQAB";
private String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCArhnBTpcAww8wSYBTwGp6oBvenzCCYFrugERgxJDZ7YnBZ3ZdiAaHjJ9PI0WymkpDr27FSg9czVbiH7G91zPq+8s9onrZi/l6cBZ2VjrwQ9BQPN2a8zHy8D6BfoKEV+PIicGz6hNPA7lgf04NgsXeWjeXnYD/IBTLZmnCxB2sPYo/0EN32mlSG9snO63HlPkoqn8ycw71a1cBrlQ+Y22fFnJAk/vrGoou8E0UHfL5zVE/up+ToOYW/eOKMFL/DSceCy32t9Za0RmpV3i2E9s8gBDewzT10Yf4+4mPUiTR6AhcLjqafAy2IaKPK57WZ6cGF9cGs9yq8bSTRpeNC4alAgMBAAECggEAH0Ms+qvPP94j6IVS6gYLWHNhkfp23JXwQZVkB2Z6EpgFKbmrJhoQDAp8Acv9+OBHPp52ePP/O3qfqxwsIIUSFfrKa9T3p7a8C6UDsAhPFWRETdobtLN05SK87NUBfImly2i8aKtruXycIveKzPmCfPzKGMmpN1Jh+vCMrUbcNqX8OUcxmhGvJwnQuBW4QEiepzl89Nl91iSwFmxaZoqLaB9lYUKke/z7FDHTpTWpZvtvxlZ0gvMVNLVp9NBNazolQ8eEjBG2PsQGD2cLUbM33mLTz+/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";
private static String appId = "2019082866535131";
private static String merchant_pub_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmePaETscydypY3rV4mXa8MtcQIL5zjP1KxdusNkHpePeU61hAZxKn0Z8pDB1wNaTK72wgEWaORXeRp4YTbf4usHlW562Pe5wdiSutb3iT6EMJ5eBD4HLI9wWDgYBtwfHwS5JJFhf0eptP4R1XluLiMhmMynLwJvHepgkVrS3mN+jmoPRmKFhZHGIYDoWypBMbUKiFHWiToHK1n0NYHHIi4WgK2wt4Wj7nexQGD69W7ofRCirYmz35c/cNFUA1lqzOEKu2z7PpjA6jQV2GJolnJ4xXPJ8Dpgp4g/dgsGqRydlmFqZD71i/pDDpF0RfRKHL+WhWVhI1hqe6jLtvJE+zQIDAQAB";
private static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCArhnBTpcAww8wSYBTwGp6oBvenzCCYFrugERgxJDZ7YnBZ3ZdiAaHjJ9PI0WymkpDr27FSg9czVbiH7G91zPq+8s9onrZi/l6cBZ2VjrwQ9BQPN2a8zHy8D6BfoKEV+PIicGz6hNPA7lgf04NgsXeWjeXnYD/IBTLZmnCxB2sPYo/0EN32mlSG9snO63HlPkoqn8ycw71a1cBrlQ+Y22fFnJAk/vrGoou8E0UHfL5zVE/up+ToOYW/eOKMFL/DSceCy32t9Za0RmpV3i2E9s8gBDewzT10Yf4+4mPUiTR6AhcLjqafAy2IaKPK57WZ6cGF9cGs9yq8bSTRpeNC4alAgMBAAECggEAH0Ms+qvPP94j6IVS6gYLWHNhkfp23JXwQZVkB2Z6EpgFKbmrJhoQDAp8Acv9+OBHPp52ePP/O3qfqxwsIIUSFfrKa9T3p7a8C6UDsAhPFWRETdobtLN05SK87NUBfImly2i8aKtruXycIveKzPmCfPzKGMmpN1Jh+vCMrUbcNqX8OUcxmhGvJwnQuBW4QEiepzl89Nl91iSwFmxaZoqLaB9lYUKke/z7FDHTpTWpZvtvxlZ0gvMVNLVp9NBNazolQ8eEjBG2PsQGD2cLUbM33mLTz+/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 static String sign_type = "RSA2";
private static String charset = "utf-8";
private static 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);
}
private static PayAlipayUtils getInstance() {
......@@ -40,6 +39,10 @@ public class PayAlipayUtils {
}
public static AlipayClient getHttpClient() {
if(httpClient == null){
httpClient = new DefaultAlipayClient(gatewayUrl, appId, merchant_private_key, "json", charset,
merchant_pub_key, sign_type);
}
return httpClient;
}
}
......@@ -5,3 +5,8 @@ dragon_order_refund_error.update=UPDATE `dragon_order_refunds` SET updated_at =
dragon_order_refund_success.update=UPDATE `dragon_order_refunds` SET updated_at = ? , refund_at=? , status=? WHERE order_refund_id = ?
# ------------------------创建退款订单日志----------------------------
dragon_order_refund_log.insert=INSERT INTO `dragon_order_refunds`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert=INSERT INTO DRAGON_ORDERS (ID, STATUS, CODE, TYPE, PRICE, NAME, DETAIL, ORDER_CODE, CLIENT_IP, NOTIFY_URL, PAYMENT_TYPE,PAYMENT_ID, PAYMENT_AT, FINISHED_AT, CREATED_AT, UPDATED_AT, DELETED_AT)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert=INSERT INTO DRAGON_ORDER_LOGS (ID, ORDER_ID, PAYMENT_TYPE, CONTENT, CREATED_AT, UPDATED_AT, DELETED_AT) VALUES(?,?,?,?,?,?,?)
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