fix: 支付货币对接
This commit is contained in:
@@ -294,15 +294,12 @@ CREATE TABLE `sys_menu` (
|
||||
-- Records of sys_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_menu` VALUES (1, 'menu.system.management', 0, 1001, '/manage', 'layout.base', '', 1, 0, 'M', '0', '0', '', 'carbon:cloud-service-management', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:46:57', '系统管理目录', 'manage');
|
||||
INSERT INTO `sys_menu` VALUES (3, 'menu.system.tools', 0, 1003, '/tool', NULL, '', 1, 0, 'M', '0', '0', '', 'carbon:user-role', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:46:57', '系统工具目录', 'tool');
|
||||
INSERT INTO `sys_menu` VALUES (100, 'menu.system.account.management', 1, 1, '/manage/user', 'view.manage_user', '', 1, 0, 'C', '0', '0', 'system:user:list', 'ic:round-manage-accounts', 'admin', '2024-05-08 21:50:55', 'admin', '2024-12-04 10:21:07', '用户管理菜单', 'manage_user');
|
||||
INSERT INTO `sys_menu` VALUES (101, 'menu.system.role.management', 1, 2, '/manage/role', 'view.manage_role', '', 1, 0, 'C', '0', '0', 'system:role:list', 'carbon:user-role', 'admin', '2024-05-08 21:50:55', '', NULL, '角色管理菜单', 'manage_role');
|
||||
INSERT INTO `sys_menu` VALUES (102, 'menu.system.menu.management', 1, 3, '/manage/menu', 'view.manage_menu', '', 1, 0, 'C', '0', '0', 'system:menu:list', 'material-symbols:route', 'admin', '2024-05-08 21:50:55', 'admin', '2024-05-12 23:46:12', '菜单管理菜单', 'manage_menu');
|
||||
INSERT INTO `sys_menu` VALUES (103, 'menu.system.department.management', 1, 4, '/manage/dept', 'view.manage_dept', '', 1, 0, 'C', '0', '0', 'system:dept:list', 'carbon:box', 'admin', '2024-05-08 21:50:55', 'ryadmin', '2024-12-04 10:20:07', '部门管理菜单', 'manage_dept');
|
||||
INSERT INTO `sys_menu` VALUES (104, 'menu.system.position.management', 1, 5, '/manage/post', 'view.manage_post', NULL, 1, 0, 'C', '0', '0', 'system:post:list', 'carbon:group', 'admin', '2024-06-02 22:18:48', '', '2024-12-04 10:20:12', '', 'manage_post');
|
||||
INSERT INTO `sys_menu` VALUES (105, 'menu.system.dict.management', 1, 6, '/manage/dict', 'view.manage_dict', NULL, 1, 0, 'C', '0', '0', 'system:dict:list', 'carbon:volume-block-storage', 'admin', '2024-06-02 23:13:40', '', NULL, '', 'manage_dict');
|
||||
INSERT INTO `sys_menu` VALUES (115, 'menu.system.code.generator', 3, 2, '/gen', 'tool.gen', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'carbon:box', 'admin', '2024-11-21 18:47:51', '', NULL, '代码生成菜单', 'tool_gen');
|
||||
INSERT INTO `sys_menu` VALUES (116, 'menu.system.interface', 3, 3, 'http://localhost:8080/swagger-ui/index.html', '', '', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'carbon:box', 'admin', '2024-11-21 18:47:51', '', NULL, '系统接口菜单', 'tool_swagger');
|
||||
INSERT INTO `sys_menu` VALUES (1000, 'menu.action.user.query', 100, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin', '2024-05-08 21:50:55', '', '2024-12-11 11:46:34', '', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (1001, 'menu.action.user.add', 100, 2, '', '', '', 1, 0, 'F', '0', '0', 'system:user:add', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (1002, 'menu.action.user.modify', 100, 3, '', '', '', 1, 0, 'F', '0', '0', 'system:user:edit', '#', 'admin', '2024-05-08 21:50:55', '', NULL, '', NULL);
|
||||
|
||||
@@ -37,4 +37,6 @@ public class UOrderVo {
|
||||
private Long updateBy;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private String currency;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.wfc.payment.pay.paypal.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.paypal.sdk.PaypalServerSdkClient;
|
||||
import com.paypal.sdk.controllers.OrdersController;
|
||||
import com.paypal.sdk.exceptions.ApiException;
|
||||
@@ -37,7 +38,12 @@ public class PaypalServiceImpl implements IPayPalService {
|
||||
|
||||
@Override
|
||||
public Order createOrder(Long orderId) throws IOException, ApiException {
|
||||
String amount = getAmountByOrder(orderId);
|
||||
UOrderVo orderVo = getAmountByOrder(orderId);
|
||||
String amount = orderVo.getOrderAmount().setScale(2, RoundingMode.HALF_UP).toString();
|
||||
String currency = "USD";
|
||||
if (StrUtil.isNotBlank(orderVo.getCurrency())) {
|
||||
currency = orderVo.getCurrency();
|
||||
}
|
||||
CreateOrderInput createOrderInput = new CreateOrderInput.Builder(
|
||||
null,
|
||||
new OrderRequest.Builder(
|
||||
@@ -45,7 +51,7 @@ public class PaypalServiceImpl implements IPayPalService {
|
||||
Arrays.asList(
|
||||
new PurchaseUnitRequest.Builder(
|
||||
new AmountWithBreakdown.Builder(
|
||||
"USD",
|
||||
currency,
|
||||
amount)
|
||||
.build())
|
||||
.build()))
|
||||
@@ -59,13 +65,9 @@ public class PaypalServiceImpl implements IPayPalService {
|
||||
return apiResponse.getResult();
|
||||
}
|
||||
|
||||
private String getAmountByOrder(Long orderId) {
|
||||
private UOrderVo getAmountByOrder(Long orderId) {
|
||||
R<UOrderVo> orderRes = remoteUUserService.getOrderById(orderId);
|
||||
UOrderVo orderVo = orderRes.getData();
|
||||
if (orderVo == null) {
|
||||
return null;
|
||||
}
|
||||
return orderVo.getOrderAmount().setScale(2, RoundingMode.HALF_UP).toString();
|
||||
return orderRes.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.wfc.payment.pay.stripe.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.stripe.Stripe;
|
||||
import com.stripe.exception.SignatureVerificationException;
|
||||
import com.stripe.exception.StripeException;
|
||||
@@ -53,6 +54,10 @@ public class StripeServiceImpl implements IStripeService {
|
||||
Long totalFee = orderVo.getOrderAmount().multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
||||
String productName = orderVo.getType() == 0 ? "Package" : "Recharge";
|
||||
|
||||
String currency = "usd";
|
||||
if (StrUtil.isNotBlank(orderVo.getCurrency())) {
|
||||
currency = orderVo.getCurrency().toLowerCase();
|
||||
}
|
||||
SessionCreateParams params =
|
||||
SessionCreateParams.builder()
|
||||
.setMode(SessionCreateParams.Mode.PAYMENT)
|
||||
@@ -64,7 +69,7 @@ public class StripeServiceImpl implements IStripeService {
|
||||
.setQuantity(1L)
|
||||
.setPriceData(
|
||||
SessionCreateParams.LineItem.PriceData.builder()
|
||||
.setCurrency("usd")
|
||||
.setCurrency(currency)
|
||||
.setUnitAmount(totalFee)
|
||||
.setProductData(
|
||||
SessionCreateParams.LineItem.PriceData.ProductData.builder()
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
|
||||
private static final String DEFAULT_SYS_PAY_CURRENCY_VALUE = "USD";
|
||||
private static final String DEFAULT_SYS_PAY_CURRENCY_SYMBOL_VALUE = "$";
|
||||
private static final String[] DEFAULT_SYS_PAY_PAYMENT_METHOD_VALUE = {"paypal"};
|
||||
private static final String[] DEFAULT_SYS_PAY_PAYMENT_METHOD_VALUE = {"paypal, stripe"};
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化参数到缓存
|
||||
|
||||
@@ -12,10 +12,12 @@ import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.constant.CacheConstants;
|
||||
import org.wfc.common.core.domain.R;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.common.redis.service.RedisService;
|
||||
import org.wfc.common.security.annotation.InnerAuth;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.user.domain.UOrder;
|
||||
@@ -47,6 +49,9 @@ public class UOrderController extends BaseController {
|
||||
@Autowired
|
||||
private IURateLimitService uRateLimitService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo page(UOrder uOrder) {
|
||||
startPage();
|
||||
@@ -59,8 +64,19 @@ public class UOrderController extends BaseController {
|
||||
startPage();
|
||||
List<UOrder> list = uOrderService.list(Wrappers.<UOrder>lambdaQuery()
|
||||
.eq(UOrder::getUserId, SecurityUtils.getUserId()).eq(UOrder::getType, 1)
|
||||
.eq(UOrder::getStatus, 1)
|
||||
.orderByDesc(UOrder::getCreateTime));
|
||||
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/packagePage")
|
||||
public TableDataInfo packagePage() {
|
||||
startPage();
|
||||
List<UOrder> list = uOrderService.list(Wrappers.<UOrder>lambdaQuery()
|
||||
.eq(UOrder::getUserId, SecurityUtils.getUserId()).eq(UOrder::getType, 0)
|
||||
.eq(UOrder::getStatus, 1)
|
||||
.orderByDesc(UOrder::getCreateTime));
|
||||
for (UOrder uOrder : list) {
|
||||
if (ObjectUtil.isNull(uOrder.getPackageId())) {
|
||||
continue;
|
||||
@@ -74,22 +90,6 @@ public class UOrderController extends BaseController {
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/packagePage")
|
||||
public TableDataInfo packagePage() {
|
||||
startPage();
|
||||
List<UOrder> list = uOrderService.list(Wrappers.<UOrder>lambdaQuery()
|
||||
.eq(UOrder::getUserId, SecurityUtils.getUserId()).eq(UOrder::getType, 0)
|
||||
.orderByDesc(UOrder::getCreateTime));
|
||||
for (UOrder uOrder : list) {
|
||||
if (ObjectUtil.isNull(uOrder.getPackageId())) {
|
||||
continue;
|
||||
}
|
||||
UPackage uPackage = uPackageService.getById(uOrder.getPackageId());
|
||||
uOrder.setUPackage(uPackage);
|
||||
}
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(UOrder uOrder) {
|
||||
List<UOrder> list = uOrderService.list();
|
||||
@@ -98,7 +98,12 @@ public class UOrderController extends BaseController {
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getById(@PathVariable("id") Long id) {
|
||||
return success(uOrderService.getById(id));
|
||||
Object cacheMapValue = redisService.getCacheMapValue(CacheConstants.SYS_PAY_CONFIG_KEY, CacheConstants.SYS_PAY_CURRENCY_KEY);
|
||||
UOrder order = uOrderService.getById(id);
|
||||
if (cacheMapValue != null) {
|
||||
order.setCurrency(cacheMapValue.toString());
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
|
||||
@@ -48,4 +48,7 @@ public class UOrder extends BaseData {
|
||||
|
||||
@TableField(exist = false)
|
||||
private UPackage uPackage;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String currency;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user