AlipayHK 回调及相关数据处理
This commit is contained in:
9
files/COD-public-key.txt
Normal file
9
files/COD-public-key.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAymkBAWixxUi9IAeMWgsq
|
||||||
|
K92AzFbe0qzzYPdkoh15ymL2A5MkYH7asnhFwclgdiFmd9a0TbZP+t/SzWW8UUzN
|
||||||
|
1pXoEp48R+eguGTt5xkJwb10+H6quVXF/Ezzid5yzVW3dcYRp8qUlFr0XBpvkK9l
|
||||||
|
FpPzh2+mwVEAsgBMXq/K50ZiX2dlkPZ7ffkVPWaK2ESIo3YgfM6dmiiza0hPWJ35
|
||||||
|
UgTH5rwJ7vN3IdOJTlkQOvrIrj2ocPcrudeEwqybIbCGhgRBwQSBsXQOO4U//rE4
|
||||||
|
VU+0LF/3uQgXkvVY1+a1JLiTncZYKGEQ/NtxM+dGtYWV2gPhQRyJ7Z77OX0XCbcn
|
||||||
|
zwIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
@@ -50,6 +50,9 @@ public class AlipayHKEncryptionUtil {
|
|||||||
@Value("${alipayHK.rsaPublicKey}")
|
@Value("${alipayHK.rsaPublicKey}")
|
||||||
private String publicKeyPath;
|
private String publicKeyPath;
|
||||||
|
|
||||||
|
@Value("${alipayHK.CODPublicKey}")
|
||||||
|
private String CODPublicKeyPath;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
@@ -70,7 +73,8 @@ public class AlipayHKEncryptionUtil {
|
|||||||
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
||||||
// 使用私钥创建数字签名
|
// 使用私钥创建数字签名
|
||||||
// Mode, aes-128-cbc for 128bit key
|
// Mode, aes-128-cbc for 128bit key
|
||||||
String mode = "aes-128-cbc";
|
// String mode = "aes-128-cbc";
|
||||||
|
String mode = "aes-256-cbc";
|
||||||
// Padding mode
|
// Padding mode
|
||||||
String padding = "pkcs7";
|
String padding = "pkcs7";
|
||||||
// signature alogrithm
|
// signature alogrithm
|
||||||
@@ -84,14 +88,6 @@ public class AlipayHKEncryptionUtil {
|
|||||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
||||||
// HashMap<String, Object> param = new HashMap<>();
|
// HashMap<String, Object> param = new HashMap<>();
|
||||||
requestMessage.setParameters(param);
|
requestMessage.setParameters(param);
|
||||||
/*String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
||||||
param.put("order_ref", orderRef);
|
|
||||||
param.put("amount", 208.12);
|
|
||||||
param.put("subject", "四月帳單 April Bill");
|
|
||||||
param.put("wallet", "ALIPAYHK");
|
|
||||||
param.put("segment_id", segmentId);
|
|
||||||
param.put("payment_solution", "WAP");*/
|
|
||||||
|
|
||||||
|
|
||||||
// Serialize message body
|
// Serialize message body
|
||||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
@@ -342,18 +338,25 @@ public class AlipayHKEncryptionUtil {
|
|||||||
Base64.Decoder decoder = Base64.getDecoder();
|
Base64.Decoder decoder = Base64.getDecoder();
|
||||||
// Verify key
|
// Verify key
|
||||||
try {
|
try {
|
||||||
// PublicKey publicKey = readPublicKey(new File(publicKeyPath));
|
// 从指定的路径读取公钥文件
|
||||||
InputStreamReader isrPub = new InputStreamReader(new FileInputStream(publicKeyPath));
|
InputStreamReader isrPub = new InputStreamReader(new FileInputStream(CODPublicKeyPath));
|
||||||
PEMParser pemParserPub = new PEMParser(isrPub);
|
PEMParser pemParserPub = new PEMParser(isrPub);
|
||||||
|
// 使用 PEMParser 解析公钥文件
|
||||||
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();
|
SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject();
|
||||||
|
// 从 SubjectPublicKeyInfo 创建 AsymmetricKeyParameter 对象
|
||||||
AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo);
|
AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo);
|
||||||
// Verifying
|
// Verifying; 创建 RSADigestSigner 对象并使用 SHA-256 作为摘要算法
|
||||||
RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest());
|
RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest());
|
||||||
|
// 初始化 RSADigestSigner,设置为验证模式并提供公钥参数
|
||||||
verifier.init(false, pubKey);
|
verifier.init(false, pubKey);
|
||||||
byte[] signMessageForVerifing = data.getBytes();
|
// 将要验证的数据转换为字节数组
|
||||||
byte[] signatureBase64ForVerifing = decoder.decode(signatureBase64);
|
byte[] signMessageForVerifying = data.getBytes();
|
||||||
verifier.update(signMessageForVerifing, 0, signMessageForVerifing.length);
|
// 将 Base64 编码的签名转换为字节数组
|
||||||
Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifing);
|
byte[] signatureBase64ForVerifying = decoder.decode(signatureBase64);
|
||||||
|
// 使用签名器更新要验证的数据
|
||||||
|
verifier.update(signMessageForVerifying, 0, signMessageForVerifying.length);
|
||||||
|
// 验证签名并返回结果
|
||||||
|
Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifying);
|
||||||
return verifyResult;
|
return verifyResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class AlipayHKRequestUtil {
|
public class AlipayHKRequestUtil {
|
||||||
|
|
||||||
public String requestAlipayHK(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
|
public String requestAlipayHK(AlipayHKRequestDTO alipayHKRequestDTO) {
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
@@ -29,7 +29,7 @@ public class AlipayHKRequestUtil {
|
|||||||
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
|
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
|
||||||
|
|
||||||
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
|
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
|
||||||
log.info(jsonString);
|
// log.info(jsonString);
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RestController
|
@RestController
|
||||||
@@ -29,8 +28,9 @@ public class AlipayHKController {
|
|||||||
|
|
||||||
@ApiOperation("支付通知")
|
@ApiOperation("支付通知")
|
||||||
@PostMapping("/trade/notify")
|
@PostMapping("/trade/notify")
|
||||||
public String callback(@RequestParam Map<String, String> params){
|
public String callback(@RequestBody String paramString){
|
||||||
return alipayHKService.callback(params);
|
log.info("alipay-hk callback parameter : {}", paramString);
|
||||||
|
return alipayHKService.callback(paramString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("订单查询")
|
@ApiOperation("订单查询")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class PaymentInfo extends BaseEntity{
|
|||||||
|
|
||||||
private String tradeState;//交易状态
|
private String tradeState;//交易状态
|
||||||
|
|
||||||
private Long payerTotal;//支付金额(元)
|
private Float payerTotal;//支付金额(元)
|
||||||
|
|
||||||
private String content;//通知参数
|
private String content;//通知参数
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class AlipayHKCallbackDTO {
|
|||||||
|
|
||||||
private String transaction_id;
|
private String transaction_id;
|
||||||
|
|
||||||
private Long amount;
|
private Float amount;
|
||||||
|
|
||||||
private String currency;
|
private String currency;
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ package com.ai.da.service;
|
|||||||
|
|
||||||
import com.ai.da.model.dto.AlipayHKCallbackDTO;
|
import com.ai.da.model.dto.AlipayHKCallbackDTO;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface AlipayHKService {
|
public interface AlipayHKService {
|
||||||
|
|
||||||
String createOrder(Integer amount, String wallet);
|
String createOrder(Integer amount, String wallet);
|
||||||
|
|
||||||
String callback(Map<String, String> params);
|
String callback(String paramString);
|
||||||
|
|
||||||
void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO);
|
void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public interface CreditsService extends IService<CreditsDetail> {
|
|||||||
|
|
||||||
void initCredits();
|
void initCredits();
|
||||||
|
|
||||||
Boolean buyCredits(Long accountId, Integer quantity);
|
Boolean buyCredits(Long accountId, Float quantity);
|
||||||
|
|
||||||
void creditsIncrease(Long accountId, String event);
|
void creditsIncrease(Long accountId, String event);
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class AliPayServiceImpl implements AliPayService {
|
|||||||
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
||||||
"positive");
|
"positive");
|
||||||
// 更新积分
|
// 更新积分
|
||||||
creditsService.buyCredits(orderByOrderNo.getAccountId(),Integer.parseInt(totalAmount) / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
|
creditsService.buyCredits(orderByOrderNo.getAccountId(),Float.parseFloat(totalAmount) / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()));
|
||||||
} finally {
|
} finally {
|
||||||
//要主动释放锁
|
//要主动释放锁
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -318,7 +318,7 @@ public class AliPayServiceImpl implements AliPayService {
|
|||||||
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
||||||
"positive");
|
"positive");
|
||||||
// 更新积分
|
// 更新积分
|
||||||
creditsService.buyCredits(orderByOrderNo.getAccountId(),(int)(orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue())));
|
creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
// ALIPAYHK 或者 ALIPAYCN
|
// ALIPAYHK 或者 ALIPAYCN
|
||||||
param.put("wallet", wallet);
|
param.put("wallet", wallet);
|
||||||
param.put("segment_id", segmentId);
|
param.put("segment_id", segmentId);
|
||||||
param.put("payment_solution", "WAP");
|
// param.put("payment_solution", "WAP");
|
||||||
|
param.put("payment_solution", "PC2MOBILE");
|
||||||
log.info("alipay-hk 创建订单,参数信息: {}", param);
|
log.info("alipay-hk 创建订单,参数信息: {}", param);
|
||||||
// 生成订单
|
// 生成订单
|
||||||
log.info("创建订单");
|
log.info("创建订单");
|
||||||
@@ -125,44 +126,46 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步回调
|
* 异步回调
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String callback(Map<String, String> params){
|
public String callback(String paramString){
|
||||||
log.info("支付通知正在执行");
|
log.info("支付宝(HK)通知正在执行");
|
||||||
log.info("通知参数 ===> {}", params);
|
Map<String, String> params = JSONObject.parseObject(paramString, Map.class);
|
||||||
|
|
||||||
String result = "failure";
|
String result = "failure";
|
||||||
|
|
||||||
String data = params.get("data");
|
String data = params.get("data");
|
||||||
String signature = params.get("signature");
|
String signature = params.get("signature");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 异步回调验签
|
// 异步回调验签
|
||||||
Boolean verification = alipayHKEncryptionUtil.signatureVerification(data, signature);
|
Boolean verification = alipayHKEncryptionUtil.signatureVerification(data, signature);
|
||||||
|
|
||||||
if (!verification){
|
if (!verification){
|
||||||
log.error("alipay-hk 验签失败");
|
log.error("Alipay-hk 验签失败");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
log.info("Alipay-HK 验签成功");
|
||||||
|
|
||||||
AlipayHKCallbackDTO alipayHKCallbackDTO = JSONObject.parseObject(data, AlipayHKCallbackDTO.class);
|
String dataString = data.replace("\\\"", "\"")
|
||||||
|
.replace("\"{", "{")
|
||||||
|
.replace("}\"", "}");
|
||||||
|
|
||||||
|
AlipayHKCallbackDTO alipayHKCallbackDTO = JSONObject.parseObject(dataString, AlipayHKCallbackDTO.class);
|
||||||
//按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,
|
//按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,
|
||||||
//1 商户需要验证该通知数据中的 out_trade_no 是否为商户系统中创建的订单号
|
//1 商户需要验证该通知数据中的 out_trade_no 是否为商户系统中创建的订单号
|
||||||
String outTradeNo = alipayHKCallbackDTO.getOut_trade_no();
|
String outTradeNo = alipayHKCallbackDTO.getOut_trade_no();
|
||||||
OrderInfo order = orderInfoService.getOrderByOrderNo(outTradeNo);
|
OrderInfo order = orderInfoService.getOrderByOrderNo(outTradeNo);
|
||||||
if(order == null){
|
if(order == null){
|
||||||
log.error("订单不存在");
|
log.error("订单:{} 不存在",outTradeNo);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额)
|
//2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额)
|
||||||
Long totalAmount = alipayHKCallbackDTO.getAmount();
|
Float totalAmount = alipayHKCallbackDTO.getAmount();
|
||||||
Long totalFee = order.getTotalFee().longValue();
|
Float totalFee = order.getTotalFee();
|
||||||
if(!Objects.equals(totalAmount, totalFee)){
|
if(!Objects.equals(totalAmount, totalFee)){
|
||||||
log.error("金额校验失败");
|
log.error("金额校验失败,回调中金额为:{},实际金额为:{}", totalAmount, totalFee);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +173,7 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
String sellerId = alipayHKCallbackDTO.getMerchant_id();
|
String sellerId = alipayHKCallbackDTO.getMerchant_id();
|
||||||
String sellerIdProperty = merchantId;
|
String sellerIdProperty = merchantId;
|
||||||
if(!sellerId.equals(sellerIdProperty)){
|
if(!sellerId.equals(sellerIdProperty)){
|
||||||
log.error("商家pid校验失败");
|
log.error("商家merchantId校验失败,回调中merchantId为:{},实际merchantId为:{}", sellerId, sellerIdProperty);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +181,7 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
String segId = alipayHKCallbackDTO.getSegment_id();
|
String segId = alipayHKCallbackDTO.getSegment_id();
|
||||||
String segmentIdProperty = segmentId;
|
String segmentIdProperty = segmentId;
|
||||||
if(!segId.equals(segmentIdProperty)){
|
if(!segId.equals(segmentIdProperty)){
|
||||||
log.error("segmentId校验失败");
|
log.error("segmentId校验失败,回调中segmentId为:{},实际segmentId为:{}", segId, segmentIdProperty);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +193,14 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Alipay-HK参数二次校验成功,进入数据处理与存储");
|
||||||
processOrder(alipayHKCallbackDTO);
|
processOrder(alipayHKCallbackDTO);
|
||||||
result = "success";
|
result = "success";
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Alipay-HK 回调处理结果:{}", result);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -226,21 +230,25 @@ public class AlipayHKServiceImpl implements AlipayHKService {
|
|||||||
// String orderStatus = orderInfoService.getOrderStatus(orderNo);
|
// String orderStatus = orderInfoService.getOrderStatus(orderNo);
|
||||||
OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderNo);
|
OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderNo);
|
||||||
String orderStatus = orderByOrderNo.getOrderStatus();
|
String orderStatus = orderByOrderNo.getOrderStatus();
|
||||||
// 当订单状态处于未支付或超时已关闭时,更新订单状态
|
// 当订单状态处于未支付或超时已关闭时,更新订单状态,其他状态均不更新订单状态
|
||||||
if (!OrderStatusEnum.NOT_PAY.getType().equals(orderStatus) || !OrderStatusEnum.TIMEOUT_CLOSED.getType().equals(orderStatus)) {
|
if (!OrderStatusEnum.NOT_PAY.getType().equals(orderStatus) && !OrderStatusEnum.TIMEOUT_CLOSED.getType().equals(orderStatus)) {
|
||||||
|
log.info("订单状态 : {}", orderStatus);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//更新订单状态
|
//更新订单状态
|
||||||
orderInfoService.updateStatusByOrderNo(orderNo, OrderStatusEnum.SUCCESS);
|
orderInfoService.updateStatusByOrderNo(orderNo, OrderStatusEnum.SUCCESS);
|
||||||
|
log.info("Alipay-HK 订单:{} 状态更新成功",orderNo);
|
||||||
//记录支付日志
|
//记录支付日志
|
||||||
paymentInfoService.createPaymentInfoForAliPayHK(alipayHKCallbackDTO);
|
paymentInfoService.createPaymentInfoForAliPayHK(alipayHKCallbackDTO);
|
||||||
|
log.info("Alipay-HK 订单:{} 支付信息状态更新成功",orderNo);
|
||||||
// 添加积分变更记录
|
// 添加积分变更记录
|
||||||
creditsService.insertToCreditsDetail(orderByOrderNo.getAccountId(),
|
creditsService.insertToCreditsDetail(orderByOrderNo.getAccountId(),
|
||||||
CreditsEventsEnum.BUY_CREDITS.getName() + "--AlipayHK",
|
CreditsEventsEnum.BUY_CREDITS.getName() + "--AlipayHK",
|
||||||
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
||||||
"positive");
|
"positive");
|
||||||
// 更新积分
|
// 更新积分
|
||||||
creditsService.buyCredits(orderByOrderNo.getAccountId(),Integer.parseInt(totalAmount) / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
|
creditsService.buyCredits(orderByOrderNo.getAccountId(),Float.parseFloat(totalAmount) / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()));
|
||||||
|
log.info("用户:{} 积分信息更新成功",orderByOrderNo.getAccountId());
|
||||||
} finally {
|
} finally {
|
||||||
//要主动释放锁
|
//要主动释放锁
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean buyCredits(Long accountId, Integer quantity) {
|
public Boolean buyCredits(Long accountId, Float quantity) {
|
||||||
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
||||||
BigDecimal newCredits = new BigDecimal(CreditsEventsEnum.BUY_CREDITS.getValue()).multiply(new BigDecimal(quantity));
|
BigDecimal newCredits = new BigDecimal(CreditsEventsEnum.BUY_CREDITS.getValue()).multiply(new BigDecimal(quantity));
|
||||||
BigDecimal added = existingCredits.add(newCredits);
|
BigDecimal added = existingCredits.add(newCredits);
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService {
|
|||||||
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
CreditsEventsEnum.BUY_CREDITS.getValue(),
|
||||||
"positive");
|
"positive");
|
||||||
// 更新积分
|
// 更新积分
|
||||||
creditsService.buyCredits(orderInfo.getAccountId(), (int)(orderInfo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue())));
|
creditsService.buyCredits(orderInfo.getAccountId(), orderInfo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +635,7 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService {
|
|||||||
"positive");
|
"positive");
|
||||||
// 更新积分
|
// 更新积分
|
||||||
// creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
|
// creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Integer.parseInt(CreditsEventsEnum.PRICE.getValue()));
|
||||||
creditsService.buyCredits(orderByOrderNo.getAccountId(),(int)(orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue())));
|
creditsService.buyCredits(orderByOrderNo.getAccountId(),orderByOrderNo.getTotalFee() / Float.parseFloat(CreditsEventsEnum.PRICE.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
paymentInfo.setTransactionId(transactionId);
|
paymentInfo.setTransactionId(transactionId);
|
||||||
paymentInfo.setTradeType(tradeType);
|
paymentInfo.setTradeType(tradeType);
|
||||||
paymentInfo.setTradeState(tradeState);
|
paymentInfo.setTradeState(tradeState);
|
||||||
// 原来的单位是:分 Int 现改为:元 Long
|
// 原来的单位是:分 Int 现改为:元 Float
|
||||||
paymentInfo.setPayerTotal(payerTotal / 100L);
|
paymentInfo.setPayerTotal(payerTotal / 100.0F);
|
||||||
paymentInfo.setContent(plainText);
|
paymentInfo.setContent(plainText);
|
||||||
|
|
||||||
baseMapper.insert(paymentInfo);
|
baseMapper.insert(paymentInfo);
|
||||||
@@ -83,7 +83,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
paymentInfo.setTradeType("电脑网站支付");
|
paymentInfo.setTradeType("电脑网站支付");
|
||||||
paymentInfo.setTradeState(tradeStatus);
|
paymentInfo.setTradeState(tradeStatus);
|
||||||
// 原来的单位是分 Int 现改为元 Long
|
// 原来的单位是分 Int 现改为元 Long
|
||||||
paymentInfo.setPayerTotal(totalAmountInt / 100L);
|
paymentInfo.setPayerTotal(totalAmountInt / 100.0F);
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(params, HashMap.class);
|
String json = gson.toJson(params, HashMap.class);
|
||||||
@@ -98,7 +98,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
log.info("记录支付日志");
|
log.info("记录支付日志");
|
||||||
|
|
||||||
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
|
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
|
||||||
Long totalAmountInt = new BigDecimal(order.purchaseUnits().get(0).payments().captures().get(0).amount().value()).longValue();
|
Float totalAmountFloat = new BigDecimal(order.purchaseUnits().get(0).payments().captures().get(0).amount().value()).floatValue();
|
||||||
|
|
||||||
PaymentInfo paymentInfo = new PaymentInfo();
|
PaymentInfo paymentInfo = new PaymentInfo();
|
||||||
paymentInfo.setOrderNo(order.id());
|
paymentInfo.setOrderNo(order.id());
|
||||||
@@ -107,7 +107,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
paymentInfo.setTradeType("电脑网站支付");
|
paymentInfo.setTradeType("电脑网站支付");
|
||||||
paymentInfo.setTradeState(order.status());
|
paymentInfo.setTradeState(order.status());
|
||||||
// todo 确认这里的数据单位是不是元
|
// todo 确认这里的数据单位是不是元
|
||||||
paymentInfo.setPayerTotal(totalAmountInt);
|
paymentInfo.setPayerTotal(totalAmountFloat);
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(order, Order.class);
|
String json = gson.toJson(order, Order.class);
|
||||||
@@ -130,7 +130,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
//交易金额
|
//交易金额
|
||||||
String totalAmount = alipayHKCallbackDTO.getAmount().toString();
|
String totalAmount = alipayHKCallbackDTO.getAmount().toString();
|
||||||
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
|
// int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
|
||||||
Long totalAmountInt = new BigDecimal(totalAmount).longValue();
|
Float totalAmountFloat = new BigDecimal(totalAmount).floatValue();
|
||||||
|
|
||||||
PaymentInfo paymentInfo = new PaymentInfo();
|
PaymentInfo paymentInfo = new PaymentInfo();
|
||||||
paymentInfo.setOrderNo(orderNo);
|
paymentInfo.setOrderNo(orderNo);
|
||||||
@@ -138,7 +138,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
|||||||
paymentInfo.setTransactionId(transactionId);
|
paymentInfo.setTransactionId(transactionId);
|
||||||
paymentInfo.setTradeType("电脑网站支付");
|
paymentInfo.setTradeType("电脑网站支付");
|
||||||
paymentInfo.setTradeState(tradeStatus);
|
paymentInfo.setTradeState(tradeStatus);
|
||||||
paymentInfo.setPayerTotal(totalAmountInt);
|
paymentInfo.setPayerTotal(totalAmountFloat);
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(alipayHKCallbackDTO);
|
String json = gson.toJson(alipayHKCallbackDTO);
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ alipay.notify-url=http://18.167.251.121:10090/api/ali-pay/trade/notify
|
|||||||
|
|
||||||
alipayHK.merchantId=2088841167357411
|
alipayHK.merchantId=2088841167357411
|
||||||
alipayHK.segmentId=1771653121
|
alipayHK.segmentId=1771653121
|
||||||
alipayHK.AESKey=uTEbeOZBgXKbSqGz
|
#alipayHK.AESKey=uTEbeOZBgXKbSqGz
|
||||||
|
alipayHK.AESKey=BwDWX4o7ORUxYwBNjRMAY2unnLkJeACj
|
||||||
alipayHK.rsaPrivateKey=files/Code-Create Limited-2088841167357411-merchant.private.key.txt
|
alipayHK.rsaPrivateKey=files/Code-Create Limited-2088841167357411-merchant.private.key.txt
|
||||||
alipayHK.rsaPublicKey=files/Code-Create Limited.merchant.aqs.public.key.pem
|
alipayHK.rsaPublicKey=files/Code-Create Limited.merchant.aqs.public.key.pem
|
||||||
|
alipayHK.CODPublicKey=files/COD-public-key.txt
|
||||||
alipayHK.api.url=https://aqs-api.sandbox-codpayment.com/
|
alipayHK.api.url=https://aqs-api.sandbox-codpayment.com/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,3 +84,7 @@ redis.key.SRExceptionMap=SRExceptionMap
|
|||||||
redis.key.taskList=TaskList
|
redis.key.taskList=TaskList
|
||||||
redis.key.credits.pre-deduction=Credits:PreDeduction
|
redis.key.credits.pre-deduction=Credits:PreDeduction
|
||||||
redis.key.generateResult=Generate:Result
|
redis.key.generateResult=Generate:Result
|
||||||
|
|
||||||
|
aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ
|
||||||
|
aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8
|
||||||
|
aws.s3.regionName=ap-east-1
|
||||||
Reference in New Issue
Block a user