添加设备商城支付

This commit is contained in:
韩鹏辉
2023-09-12 15:17:50 +08:00
parent b7e17826ac
commit 9bed9bee68
5 changed files with 17 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ public interface ApiPayService {
JSONObject pay(String json,String ip); JSONObject pay(String json,String ip);
Result<Object> orderPay(String userId, String orderNumber); Result<Object> orderPay(String userId, String orderNumber,String appId);
/** /**
* @description:退款 * @description:退款

View File

@@ -652,7 +652,7 @@ public class ApiPayServiceImpl implements ApiPayService {
} }
@Override @Override
public Result<Object> orderPay(String userId, String orderNumber) { public Result<Object> orderPay(String userId, String orderNumber,String appId) {
if(StringUtil.isEmpty(userId)){ if(StringUtil.isEmpty(userId)){
return ResultGenerator.genFailResult("缺失参数!"); return ResultGenerator.genFailResult("缺失参数!");
} }
@@ -698,11 +698,15 @@ public class ApiPayServiceImpl implements ApiPayService {
if(mercOrderNew == null){ if(mercOrderNew == null){
order = oldPay(userId,orderNumber,order); order = oldPay(userId,orderNumber,order);
} }
Long cTime = order.getCreateDt().getTime();
Long nowTime = System.currentTimeMillis(); if(ObjectUtil.isNotEmpty(order)){
if(nowTime - cTime >= 1000 * 60 * 1000){ Long cTime = order.getCreateDt().getTime();
return ResultGenerator.genFailResult("订单已超时,请重新下单!"); Long nowTime = System.currentTimeMillis();
if(nowTime - cTime >= 1000 * 60 * 1000){
return ResultGenerator.genFailResult("订单已超时,请重新下单!");
}
} }
if(StringUtil.isNotEmpty(order.getPayData())){ if(StringUtil.isNotEmpty(order.getPayData())){
return ResultGenerator.genSuccessResult("获取成功",JSONObject.parseObject(order.getPayData())); return ResultGenerator.genSuccessResult("获取成功",JSONObject.parseObject(order.getPayData()));
} }
@@ -730,6 +734,7 @@ public class ApiPayServiceImpl implements ApiPayService {
// TODO 测试金额上线会删除 // TODO 测试金额上线会删除
order.setConsumeFee(mercOrderNew.getActualAmt().doubleValue()); order.setConsumeFee(mercOrderNew.getActualAmt().doubleValue());
order.setAppletsAppid(appId);
JSONObject result = sxfPayService.tradePay(order, channel,merchant); JSONObject result = sxfPayService.tradePay(order, channel,merchant);

View File

@@ -190,7 +190,7 @@ public class AliPayController {
@PostMapping("/orderPay") @PostMapping("/orderPay")
@ResponseBody @ResponseBody
public Result<Object> orderPay(String authCode,String orderNumber) { public Result<Object> orderPay(String authCode,String orderNumber,String appId) {
if(StringUtil.isEmpty(authCode)){ if(StringUtil.isEmpty(authCode)){
return ResultGenerator.genFailResult("授权码信息为空"); return ResultGenerator.genFailResult("授权码信息为空");
} }
@@ -198,7 +198,7 @@ public class AliPayController {
return ResultGenerator.genFailResult("订单号为空"); return ResultGenerator.genFailResult("订单号为空");
} }
AlipaySystemOauthTokenResponse tokenResponse = AliUtil.getAliUserIdV2(authCode, ParametersUtil.ZY_PRI, ParametersUtil.ZY_PUB, ParametersUtil.ZY_ALI_APP_ID); AlipaySystemOauthTokenResponse tokenResponse = AliUtil.getAliUserIdV2(authCode, ParametersUtil.ZY_PRI, ParametersUtil.ZY_PUB, ParametersUtil.ZY_ALI_APP_ID);
return apiPayService.orderPay(tokenResponse.getUserId(),orderNumber); return apiPayService.orderPay(tokenResponse.getUserId(),orderNumber,appId);
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -199,7 +199,8 @@ public class ApiPayController {
public Result<Object> orderPay(@RequestBody JSONObject params) { public Result<Object> orderPay(@RequestBody JSONObject params) {
String userId = params.getString("userId"); String userId = params.getString("userId");
String orderNumber = params.getString("orderNumber"); String orderNumber = params.getString("orderNumber");
return apiPayService.orderPay(userId,orderNumber);
return apiPayService.orderPay(userId,orderNumber,null);
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -485,7 +485,8 @@ public class WechantController {
System.out.println("openid"+openid); System.out.println("openid"+openid);
String orderNumber = params.getString("orderNumber"); String orderNumber = params.getString("orderNumber");
System.out.println("orderNumber"+orderNumber); System.out.println("orderNumber"+orderNumber);
return apiPayService.orderPay(openid,orderNumber); String appId=params.containsKey("appId")?params.getString("appId"):null;
return apiPayService.orderPay(openid,orderNumber,appId);
} }
@PostMapping("/getAddress") @PostMapping("/getAddress")