mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 14:30:08 +08:00
update 汇付协议
This commit is contained in:
@@ -141,7 +141,6 @@ public class PayController extends BaseController {
|
||||
} else if (StringUtils.equals(dto.getRequestSource(), AdapayPayChannelEnum.ALIPAY_LITE.getValue())) {
|
||||
dto.setAlipayAppId(appId);
|
||||
}
|
||||
|
||||
map = orderService.payOrderV2(dto);
|
||||
}
|
||||
response = new RestApiResponse<>(map);
|
||||
|
||||
@@ -1090,6 +1090,7 @@ public class OrderService {
|
||||
private void paymentSucceeded(String data) throws JsonProcessingException {
|
||||
// 验签成功 保存到回调记录表中
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
log.info("adapay支付成功回调:{}", jsonObject.toJSONString());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
@@ -1120,6 +1121,9 @@ public class OrderService {
|
||||
// 支付金额
|
||||
BigDecimal amount = adapayCallbackRecord.getPayAmt();
|
||||
|
||||
// 支付渠道
|
||||
adapayCallbackRecord.setPayChannel(jsonObject.getString("pay_channel"));
|
||||
|
||||
// 保存到数据库
|
||||
adapayCallbackRecordService.saveAdapayCallbackRecord(adapayCallbackRecord);
|
||||
|
||||
|
||||
@@ -1080,8 +1080,8 @@ public class SpringBootTestController {
|
||||
*/
|
||||
@Test
|
||||
public void createPaymentReverseRequestTest() {
|
||||
String paymentId = "002212024061717243610648707836701741056";
|
||||
BigDecimal refundAmount = new BigDecimal("46.49");
|
||||
String paymentId = "002212024080614142410666779361873702912";
|
||||
BigDecimal refundAmount = new BigDecimal("0.64");
|
||||
String memberId = null;
|
||||
|
||||
// 延迟分账未确认调撤销调撤销接口退款
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.jsowell.common;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 友电电单车充电桩协议工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class YouDianUtils {
|
||||
|
||||
/**
|
||||
* 校验方法
|
||||
* 整个数据包中的每个字节(不包括校验字段本身),将它们的数值累加起来。然后取累加和的低2字节(16位),作为校验字段的值
|
||||
*/
|
||||
public static boolean validateChecksum(byte[] bytes) {
|
||||
if (bytes.length < 2) {
|
||||
return false; // 校验字段长度不足时返回 false
|
||||
}
|
||||
|
||||
// 计算累加和
|
||||
int sum = 0;
|
||||
for (int i = 0; i < bytes.length - 2; i++) {
|
||||
sum += (bytes[i] & 0xFF); // 将每个字节视为无符号值进行累加
|
||||
}
|
||||
|
||||
// 取累加和的低 2 字节(16 位)
|
||||
int calculatedChecksum = sum & 0xFFFF;
|
||||
|
||||
// 读取校验字段的值
|
||||
byte[] checksumBytes = {bytes[bytes.length - 2], bytes[bytes.length - 1]};
|
||||
int receivedChecksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
||||
|
||||
// 比较计算的校验值和接收到的校验值
|
||||
log.info("计算的校验值:{}, 接收到的校验值:{}", calculatedChecksum, receivedChecksum);
|
||||
return calculatedChecksum == receivedChecksum;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,29 @@
|
||||
package com.jsowell.common.enums.adapay;
|
||||
|
||||
public enum AdapayPayChannelEnum {
|
||||
WX_LITE("wx_lite", "微信小程序支付"),
|
||||
|
||||
alipay("alipay", "支付宝 App 支付"),
|
||||
alipay_qr("alipay_qr", "支付宝正扫"),
|
||||
alipay_wap("alipay_wap", "支付宝 H5 支付"),
|
||||
ALIPAY_LITE("alipay_lite", "支付宝小程序支付"),
|
||||
alipay_pub("alipay_pub", "支付宝生活号支付"),
|
||||
alipay_scan("alipay_scan", "支付宝反扫"),
|
||||
|
||||
wx_pub("wx_pub", "微信公众号支付"),
|
||||
WX_LITE("wx_lite", "微信小程序支付"),
|
||||
wx_scan("wx_scan", "微信反扫"),
|
||||
|
||||
union("union", "银联云闪付 App"),
|
||||
union_qr("union_qr", "银联云闪付正扫"),
|
||||
union_wap("union_wap", "银联云闪付 H5 支付"),
|
||||
union_scan("union_scan", "银联云闪付反扫"),
|
||||
union_online("union_online", "银联 H5 支付"),
|
||||
union_checkout("union_checkout", "银联统一收银台支付"),
|
||||
|
||||
fast_pay("fast_pay", "快捷支付"),
|
||||
b2c("b2c", "个人网银支付"),
|
||||
b2b("b2b", "企业网银支付"),
|
||||
|
||||
;
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
public class MessageDecode extends ByteToMessageDecoder {
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
log.info("MessageDecode.decode");
|
||||
// log.info("MessageDecode.decode");
|
||||
// 检查是否有足够的字节可以读取
|
||||
if (in.readableBytes() < 14) { // 最小长度(包头3 + 长度2 + 物理ID4 + 消息ID2 + 命令1 + 校验2)
|
||||
return;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class StartAndLengthFieldFrameDecoder extends ByteToMessageDecoder {
|
||||
public StartAndLengthFieldFrameDecoder() {}
|
||||
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
|
||||
log.info("StartAndLengthFieldFrameDecoder.decode");
|
||||
// log.info("StartAndLengthFieldFrameDecoder.decode");
|
||||
// 记录包头开始的index
|
||||
int beginReader;
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ public class ChargingPileMessage {
|
||||
|
||||
// 从字节数组解析消息
|
||||
public static ChargingPileMessage parseMessage(byte[] messageBytes) {
|
||||
boolean b = validateChecksum(messageBytes);
|
||||
ChargingPileMessage message = new ChargingPileMessage();
|
||||
// log.info("parseMessage:{}", BytesUtil.binary(messageBytes, 16));
|
||||
// 读取包头
|
||||
@@ -87,31 +86,4 @@ public class ChargingPileMessage {
|
||||
log.info("报文:{}, parseMessage:{}", BytesUtil.binary(messageBytes, 16), message.toString());
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验方法
|
||||
* 整个数据包中的每个字节(不包括校验字段本身),将它们的数值累加起来。然后取累加和的低2字节(16位),作为校验字段的值
|
||||
*/
|
||||
public static boolean validateChecksum(byte[] bytes) {
|
||||
if (bytes.length < 2) {
|
||||
return false; // 校验字段长度不足时返回 false
|
||||
}
|
||||
|
||||
// 计算累加和
|
||||
int sum = 0;
|
||||
for (int i = 0; i < bytes.length - 2; i++) {
|
||||
sum += (bytes[i] & 0xFF); // 将每个字节视为无符号值进行累加
|
||||
}
|
||||
|
||||
// 取累加和的低 2 字节(16 位)
|
||||
int calculatedChecksum = sum & 0xFFFF;
|
||||
|
||||
// 读取校验字段的值
|
||||
byte[] checksumBytes = {bytes[bytes.length - 2], bytes[bytes.length - 1]};
|
||||
int receivedChecksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
||||
|
||||
// 比较计算的校验值和接收到的校验值
|
||||
log.info("计算的校验值:{}, 接收到的校验值:{}", calculatedChecksum, receivedChecksum);
|
||||
return calculatedChecksum == receivedChecksum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ public class AdapayCallbackRecord implements Serializable {
|
||||
|
||||
private BigDecimal payAmt;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
private String payChannel;
|
||||
|
||||
private BigDecimal realAmt;
|
||||
|
||||
Reference in New Issue
Block a user