fix:完善后台管理页面wechat模块,修复自动配置类的加载条件等
This commit is contained in:
+2
-1
@@ -61,14 +61,15 @@ public class SysWechatConfigController {
|
|||||||
@Operation(summary = "保存微信配置")
|
@Operation(summary = "保存微信配置")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result<Boolean> saveConfig(@RequestBody WechatConfig config) {
|
public Result<Boolean> saveConfig(@RequestBody WechatConfig config) {
|
||||||
|
if (config.getId() == null) {
|
||||||
config.setTenantId(TenantContextHolder.getTenant());
|
config.setTenantId(TenantContextHolder.getTenant());
|
||||||
|
}
|
||||||
return Result.succeed(wechatConfigService.saveConfig(config));
|
return Result.succeed(wechatConfigService.saveConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新微信配置")
|
@Operation(summary = "更新微信配置")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result<Boolean> updateConfig(@RequestBody WechatConfig config) {
|
public Result<Boolean> updateConfig(@RequestBody WechatConfig config) {
|
||||||
config.setTenantId(TenantContextHolder.getTenant());
|
|
||||||
return Result.succeed(wechatConfigService.updateConfig(config));
|
return Result.succeed(wechatConfigService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -20,22 +20,22 @@ public class TencentAuthenticationToken extends BaseAuthenticationToken {
|
|||||||
private final Object principal;
|
private final Object principal;
|
||||||
private final String encryptedData;
|
private final String encryptedData;
|
||||||
private final String iv;
|
private final String iv;
|
||||||
private final String appId;
|
private final String appCode;
|
||||||
|
|
||||||
public TencentAuthenticationToken(String code, String encryptedData, String iv, String appId) {
|
public TencentAuthenticationToken(String code, String encryptedData, String iv, String appCode) {
|
||||||
super(GRANT_TYPE);
|
super(GRANT_TYPE);
|
||||||
this.principal = code;
|
this.principal = code;
|
||||||
this.encryptedData = encryptedData;
|
this.encryptedData = encryptedData;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
this.appId = appId;
|
this.appCode = appCode;
|
||||||
super.setAuthenticated(true);
|
super.setAuthenticated(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TencentAuthenticationToken(UserDetails user, Collection<? extends GrantedAuthority> authorities, String encryptedData, String iv, String appId) {
|
public TencentAuthenticationToken(UserDetails user, Collection<? extends GrantedAuthority> authorities, String encryptedData, String iv, String appCode) {
|
||||||
super(authorities);
|
super(authorities);
|
||||||
this.principal = user;
|
this.principal = user;
|
||||||
this.encryptedData = encryptedData;
|
this.encryptedData = encryptedData;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
this.appId = appId;
|
this.appCode = appCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -19,6 +19,7 @@ import com.wechat.pay.java.service.refund.RefundService;
|
|||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -34,6 +35,7 @@ public class WechatAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public WxMpService wxMpService(WechatConfigService configService) {
|
public WxMpService wxMpService(WechatConfigService configService) {
|
||||||
return new WxMpServiceImpl() {
|
return new WxMpServiceImpl() {
|
||||||
@Override
|
@Override
|
||||||
@@ -49,8 +51,16 @@ public class WechatAutoConfiguration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这个配置类在启动时可能会遇到问题,因为:
|
||||||
|
* WechatAutoConfiguration是一个自动配置类
|
||||||
|
* 它依赖于WechatConfigService这个Feign客户端
|
||||||
|
* 如果Feign客户端还没有被创建,就会导致注入失败
|
||||||
|
* 因此使用@ConditionalOnBean注解确保配置类只在Feign客户端可用时才创建相关Bean
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public WxMaService wxMaService(WechatConfigService configService) {
|
public WxMaService wxMaService(WechatConfigService configService) {
|
||||||
return new WxMaServiceImpl() {
|
return new WxMaServiceImpl() {
|
||||||
@Override
|
@Override
|
||||||
@@ -88,6 +98,7 @@ public class WechatAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public Config wxPayConfig(WechatConfigService configService, PrivateKeyService privateKeyService) {
|
public Config wxPayConfig(WechatConfigService configService, PrivateKeyService privateKeyService) {
|
||||||
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
||||||
String privateKey = privateKeyService.getPrivateKey(getCurrentTenantId(), "PAY");
|
String privateKey = privateKeyService.getPrivateKey(getCurrentTenantId(), "PAY");
|
||||||
@@ -113,6 +124,7 @@ public class WechatAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public NotificationConfig notificationConfig(WechatConfigService configService, PrivateKeyService privateKeyService) {
|
public NotificationConfig notificationConfig(WechatConfigService configService, PrivateKeyService privateKeyService) {
|
||||||
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
||||||
String privateKey = privateKeyService.getPrivateKey(getCurrentTenantId(), "PAY");
|
String privateKey = privateKeyService.getPrivateKey(getCurrentTenantId(), "PAY");
|
||||||
@@ -138,6 +150,7 @@ public class WechatAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public SettleInfo settleInfo(WechatConfigService configService) {
|
public SettleInfo settleInfo(WechatConfigService configService) {
|
||||||
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
||||||
SettleInfo settleInfo = new SettleInfo();
|
SettleInfo settleInfo = new SettleInfo();
|
||||||
@@ -147,6 +160,7 @@ public class WechatAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(WechatConfigService.class)
|
||||||
public Executor profitSharingExecutor(WechatConfigService configService) {
|
public Executor profitSharingExecutor(WechatConfigService configService) {
|
||||||
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
WechatConfig config = configService.getConfig("PAY", getCurrentTenantId());
|
||||||
if (!config.getAsyncEnabled()) {
|
if (!config.getAsyncEnabled()) {
|
||||||
|
|||||||
+3
-3
@@ -72,10 +72,10 @@ public class TencentAuthenticationProvider extends BaseAuthenticationProvider {
|
|||||||
String code = (String) authToken.getPrincipal();
|
String code = (String) authToken.getPrincipal();
|
||||||
String encryptedData = authToken.getEncryptedData();
|
String encryptedData = authToken.getEncryptedData();
|
||||||
String iv = authToken.getIv();
|
String iv = authToken.getIv();
|
||||||
String appid = authToken.getAppId(); // 前端需传递
|
String appCode = authToken.getAppCode(); // 前端需传递
|
||||||
|
|
||||||
// 1. 根据appid查找配置
|
// 1. 根据appid查找配置
|
||||||
WechatConfig config = userDetailsServiceFactory.getService(authToken).loadMiniAppConfig(appid);
|
WechatConfig config = userDetailsServiceFactory.getService(authToken).loadMiniAppConfig(appCode);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
throw new CustomOAuth2AuthenticationException("不支持的appid");
|
throw new CustomOAuth2AuthenticationException("不支持的appid");
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ public class TencentAuthenticationProvider extends BaseAuthenticationProvider {
|
|||||||
|
|
||||||
throw new CustomOAuth2AuthenticationException("用户登录信息待处理,请重新登录");
|
throw new CustomOAuth2AuthenticationException("用户登录信息待处理,请重新登录");
|
||||||
}
|
}
|
||||||
return new TencentAuthenticationToken(userDetails, userDetails.getAuthorities(),encryptedData, iv,appid);
|
return new TencentAuthenticationToken(userDetails, userDetails.getAuthorities(),encryptedData, iv,appCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,23 +9,23 @@
|
|||||||
export default {
|
export default {
|
||||||
dev: {
|
dev: {
|
||||||
'/api-uaa/': {
|
'/api-uaa/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-user/': {
|
'/api-user/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-log/': {
|
'/api-log/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-search/': {
|
'/api-search/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-generator/': {
|
'/api-generator/': {
|
||||||
@@ -34,18 +34,18 @@
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-file/': {
|
'/api-file/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-order/': {
|
'/api-order/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-device/': {
|
'/api-device/': {
|
||||||
target: 'http://119.45.169.13:9900',
|
// target: 'http://119.45.169.13:9900',
|
||||||
// target: 'http://127.0.0.1:9900',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+96
-12
@@ -3,13 +3,21 @@ import {
|
|||||||
ProForm,
|
ProForm,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
|
ProFormSwitch,
|
||||||
|
ProFormDigit,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const STATUS_OPTIONS = [
|
const STATUS_OPTIONS = [
|
||||||
{ label: '启用', value: 1 },
|
{ label: '启用', value: 1 },
|
||||||
{ label: '禁用', value: 0 },
|
{ label: '禁用', value: 0 },
|
||||||
] as const;
|
];
|
||||||
|
|
||||||
|
const TYPE_OPTIONS = [
|
||||||
|
{ label: '公众号', value: 'MP' },
|
||||||
|
{ label: '小程序', value: 'MINI' },
|
||||||
|
{ label: '支付', value: 'PAY' },
|
||||||
|
];
|
||||||
|
|
||||||
interface UpdateFormProps {
|
interface UpdateFormProps {
|
||||||
onSubmit: (values: any) => Promise<void>;
|
onSubmit: (values: any) => Promise<void>;
|
||||||
@@ -21,7 +29,7 @@ interface UpdateFormProps {
|
|||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="修改小程序"
|
title="修改微信配置"
|
||||||
width={600}
|
width={600}
|
||||||
visible={props.updateModalVisible}
|
visible={props.updateModalVisible}
|
||||||
onVisibleChange={props.onVisibleChange}
|
onVisibleChange={props.onVisibleChange}
|
||||||
@@ -30,23 +38,94 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '小程序名称不能为空' }]}
|
rules={[{ required: true, message: '配置类型不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="name"
|
name="type"
|
||||||
label="小程序名称"
|
label="配置类型"
|
||||||
|
options={TYPE_OPTIONS}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[{ required: true, message: 'AppID不能为空' }]}
|
rules={[{ required: true, message: '商户ID不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="appid"
|
name="merchantId"
|
||||||
label="AppID"
|
label="商户ID"
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[{ required: true, message: 'Secret不能为空' }]}
|
rules={[{ required: true, message: '应用ID不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="secret"
|
name="appId"
|
||||||
label="Secret"
|
label="应用ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[{ required: true, message: '应用密钥不能为空' }]}
|
||||||
|
width="md"
|
||||||
|
name="appSecret"
|
||||||
|
label="应用密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="mchKey"
|
||||||
|
label="商户API密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="mchSerialNo"
|
||||||
|
label="商户证书序列号"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="privateKeyPath"
|
||||||
|
label="商户私钥文件路径"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="apiV3Key"
|
||||||
|
label="APIv3密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="notifyUrl"
|
||||||
|
label="支付回调地址"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="token"
|
||||||
|
label="微信公众号token"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="aesKey"
|
||||||
|
label="微信公众号aesKey"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="paymentSuccessTemplateId"
|
||||||
|
label="支付成功通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="videoCompleteTemplateId"
|
||||||
|
label="视频处理完成通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="videoFailTemplateId"
|
||||||
|
label="视频处理失败通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormSwitch
|
||||||
|
name="profitSharingEnabled"
|
||||||
|
label="启用分账"
|
||||||
|
/>
|
||||||
|
<ProFormSwitch
|
||||||
|
name="asyncEnabled"
|
||||||
|
label="启用异步处理"
|
||||||
|
/>
|
||||||
|
<ProFormDigit
|
||||||
|
name="asyncPoolSize"
|
||||||
|
label="异步处理线程池大小"
|
||||||
|
min={1}
|
||||||
|
max={100}
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '状态不能为空' }]}
|
rules={[{ required: true, message: '状态不能为空' }]}
|
||||||
@@ -55,6 +134,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
label="状态"
|
label="状态"
|
||||||
options={STATUS_OPTIONS}
|
options={STATUS_OPTIONS}
|
||||||
/>
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="remark"
|
||||||
|
label="备注"
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
ExportOutlined,
|
|
||||||
ImportOutlined,
|
|
||||||
DownloadOutlined,
|
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
@@ -11,18 +8,26 @@ import {
|
|||||||
ProForm,
|
ProForm,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
|
ProFormSwitch,
|
||||||
|
ProFormDigit,
|
||||||
ProTable,
|
ProTable,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Button, message, Space, Tag } from 'antd';
|
import { Button, message, Space, Tag } from 'antd';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { getMiniAppList, saveOrUpdateMiniApp, deleteMiniApp } from '@/services/system/api';
|
import { getMiniAppList, saveMiniApp, updateMiniApp, deleteMiniApp } from '@/services/system/api';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
const STATUS_OPTIONS = [
|
const STATUS_OPTIONS: { label: string; value: number }[] = [
|
||||||
{ label: '启用', value: 1 },
|
{ label: '启用', value: 1 },
|
||||||
{ label: '禁用', value: 0 },
|
{ label: '禁用', value: 0 },
|
||||||
] as const;
|
];
|
||||||
|
|
||||||
|
const TYPE_OPTIONS: { label: string; value: string }[] = [
|
||||||
|
{ label: '公众号', value: 'MP' },
|
||||||
|
{ label: '小程序', value: 'MINI' },
|
||||||
|
{ label: '支付', value: 'PAY' },
|
||||||
|
];
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [searchParams, setSearchParams] = useState<Record<string, string | number>>({});
|
const [searchParams, setSearchParams] = useState<Record<string, string | number>>({});
|
||||||
@@ -62,18 +67,23 @@ const TableList: React.FC = () => {
|
|||||||
width: 48,
|
width: 48,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '小程序名称',
|
title: '配置类型',
|
||||||
dataIndex: 'name',
|
dataIndex: 'type',
|
||||||
|
valueType: 'select',
|
||||||
|
valueEnum: {
|
||||||
|
MP: { text: '公众号' },
|
||||||
|
MINI: { text: '小程序' },
|
||||||
|
PAY: { text: '支付' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '商户ID',
|
||||||
|
dataIndex: 'merchantId',
|
||||||
copyable: true,
|
copyable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'AppCode',
|
title: '应用ID',
|
||||||
dataIndex: 'appid',
|
dataIndex: 'appId',
|
||||||
copyable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'AppID',
|
|
||||||
dataIndex: 'appid',
|
|
||||||
copyable: true,
|
copyable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,6 +100,16 @@ const TableList: React.FC = () => {
|
|||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '分账功能',
|
||||||
|
dataIndex: 'profitSharingEnabled',
|
||||||
|
valueType: 'switch',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '异步处理',
|
||||||
|
dataIndex: 'asyncEnabled',
|
||||||
|
valueType: 'switch',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
@@ -141,23 +161,94 @@ const TableList: React.FC = () => {
|
|||||||
// 表单字段定义
|
// 表单字段定义
|
||||||
const renderModalContent = () => (
|
const renderModalContent = () => (
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '小程序名称不能为空' }]}
|
rules={[{ required: true, message: '配置类型不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="name"
|
name="type"
|
||||||
label="小程序名称"
|
label="配置类型"
|
||||||
|
options={TYPE_OPTIONS}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[{ required: true, message: 'AppID不能为空' }]}
|
rules={[{ required: true, message: '商户ID不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="appid"
|
name="merchantId"
|
||||||
label="AppID"
|
label="商户ID"
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[{ required: true, message: 'Secret不能为空' }]}
|
rules={[{ required: true, message: '应用ID不能为空' }]}
|
||||||
width="md"
|
width="md"
|
||||||
name="secret"
|
name="appId"
|
||||||
label="Secret"
|
label="应用ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[{ required: true, message: '应用密钥不能为空' }]}
|
||||||
|
width="md"
|
||||||
|
name="appSecret"
|
||||||
|
label="应用密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="mchKey"
|
||||||
|
label="商户API密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="mchSerialNo"
|
||||||
|
label="商户证书序列号"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="privateKeyPath"
|
||||||
|
label="商户私钥文件路径"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="apiV3Key"
|
||||||
|
label="APIv3密钥"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="notifyUrl"
|
||||||
|
label="支付回调地址"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="token"
|
||||||
|
label="微信公众号token"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="aesKey"
|
||||||
|
label="微信公众号aesKey"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="paymentSuccessTemplateId"
|
||||||
|
label="支付成功通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="videoCompleteTemplateId"
|
||||||
|
label="视频处理完成通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="videoFailTemplateId"
|
||||||
|
label="视频处理失败通知模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormSwitch
|
||||||
|
name="profitSharingEnabled"
|
||||||
|
label="启用分账"
|
||||||
|
/>
|
||||||
|
<ProFormSwitch
|
||||||
|
name="asyncEnabled"
|
||||||
|
label="启用异步处理"
|
||||||
|
/>
|
||||||
|
<ProFormDigit
|
||||||
|
name="asyncPoolSize"
|
||||||
|
label="异步处理线程池大小"
|
||||||
|
min={1}
|
||||||
|
max={100}
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '状态不能为空' }]}
|
rules={[{ required: true, message: '状态不能为空' }]}
|
||||||
@@ -167,11 +258,16 @@ const TableList: React.FC = () => {
|
|||||||
options={STATUS_OPTIONS}
|
options={STATUS_OPTIONS}
|
||||||
initialValue={1}
|
initialValue={1}
|
||||||
/>
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="remark"
|
||||||
|
label="备注"
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ subTitle: '管理系统中的小程序配置' }}>
|
<PageContainer header={{ subTitle: '管理系统中的微信配置' }}>
|
||||||
<QueryFilter
|
<QueryFilter
|
||||||
defaultCollapsed
|
defaultCollapsed
|
||||||
split
|
split
|
||||||
@@ -181,8 +277,9 @@ const TableList: React.FC = () => {
|
|||||||
name="searchKey"
|
name="searchKey"
|
||||||
label="搜索"
|
label="搜索"
|
||||||
valueEnum={{
|
valueEnum={{
|
||||||
name: '小程序名称',
|
type: '配置类型',
|
||||||
appid: 'AppID',
|
merchantId: '商户ID',
|
||||||
|
appId: '应用ID',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ProFormText name="searchValue" placeholder="请输入关键字" />
|
<ProFormText name="searchValue" placeholder="请输入关键字" />
|
||||||
@@ -190,15 +287,15 @@ const TableList: React.FC = () => {
|
|||||||
|
|
||||||
<ProTable<SYSTEM.MiniApp>
|
<ProTable<SYSTEM.MiniApp>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="小程序管理"
|
headerTitle="微信配置管理"
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
request={async (params, sorter, filter) => {
|
request={async (params, sorter, filter) => {
|
||||||
const res = await getMiniAppList({
|
const res = await getMiniAppList({
|
||||||
page: params.current,
|
page: params.current || 1,
|
||||||
limit: params.pageSize,
|
limit: params.pageSize || 10,
|
||||||
searchKey: params.searchKey,
|
searchKey: params.searchKey,
|
||||||
searchValue: params.searchValue,
|
searchValue: params.searchValue,
|
||||||
});
|
}) as any;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: res.data || [],
|
data: res.data || [],
|
||||||
@@ -221,13 +318,19 @@ const TableList: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="新增小程序"
|
title="新增微信配置"
|
||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={handleModalVisible}
|
onVisibleChange={handleModalVisible}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
const success = await handleRequest(
|
const success = await handleRequest(
|
||||||
() => saveOrUpdateMiniApp(values),
|
() => saveMiniApp({
|
||||||
|
...values,
|
||||||
|
id: currentRow?.id,
|
||||||
|
appId: values.appId,
|
||||||
|
appSecret: values.appSecret,
|
||||||
|
status: values.status,
|
||||||
|
} as SYSTEM.MiniApp),
|
||||||
'正在添加',
|
'正在添加',
|
||||||
'添加成功'
|
'添加成功'
|
||||||
);
|
);
|
||||||
@@ -245,7 +348,7 @@ const TableList: React.FC = () => {
|
|||||||
<UpdateForm
|
<UpdateForm
|
||||||
onSubmit={async (values) => {
|
onSubmit={async (values) => {
|
||||||
const success = await handleRequest(
|
const success = await handleRequest(
|
||||||
() => saveOrUpdateMiniApp({ ...values, id: currentRow?.id }),
|
() => updateMiniApp({ ...values, id: currentRow?.id }),
|
||||||
'正在更新',
|
'正在更新',
|
||||||
'更新成功'
|
'更新成功'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -254,21 +254,33 @@ export async function getMiniAppList(params: {
|
|||||||
searchKey?: string;
|
searchKey?: string;
|
||||||
searchValue?: string;
|
searchValue?: string;
|
||||||
}) {
|
}) {
|
||||||
return request<API.OptionalResult<SYSTEM.MiniApp[]>>('/api-user/miniApp/list', {
|
return request<{
|
||||||
|
data: SYSTEM.MiniApp[];
|
||||||
|
count: number;
|
||||||
|
resp_code: number;
|
||||||
|
resp_msg?: string;
|
||||||
|
}>('/api-user/wechat/config', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveOrUpdateMiniApp(data: SYSTEM.MiniApp) {
|
export async function saveMiniApp(data: SYSTEM.MiniApp) {
|
||||||
return request<API.OptionalResult<any>>('/api-user/miniApp/saveOrUpdate', {
|
return request<API.OptionalResult<any>>('/api-user/wechat/config', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateMiniApp(data: SYSTEM.MiniApp) {
|
||||||
|
return request<API.OptionalResult<any>>('/api-user/wechat/config', {
|
||||||
|
method: 'PUT',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteMiniApp(id: number) {
|
export async function deleteMiniApp(id: number) {
|
||||||
return request<API.OptionalResult<any>>(`/api-user/miniApp/delete/${id}`, {
|
return request<API.OptionalResult<any>>(`/api-user/wechat/config/${id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,11 +104,36 @@ declare namespace SYSTEM {
|
|||||||
|
|
||||||
interface MiniApp {
|
interface MiniApp {
|
||||||
id: number;
|
id: number;
|
||||||
appid: string;
|
tenantId?: string;
|
||||||
secret: string;
|
type?: string;
|
||||||
name: string;
|
merchantId?: string;
|
||||||
|
appId: string;
|
||||||
|
appSecret: string;
|
||||||
|
mchKey?: string;
|
||||||
|
mchSerialNo?: string;
|
||||||
|
privateKeyPath?: string;
|
||||||
|
apiV3Key?: string;
|
||||||
|
notifyUrl?: string;
|
||||||
|
token?: string;
|
||||||
|
aesKey?: string;
|
||||||
|
paymentSuccessTemplateId?: string;
|
||||||
|
videoCompleteTemplateId?: string;
|
||||||
|
videoFailTemplateId?: string;
|
||||||
|
profitSharingEnabled?: boolean;
|
||||||
|
asyncEnabled?: boolean;
|
||||||
|
asyncPoolSize?: number;
|
||||||
status: number;
|
status: number;
|
||||||
createTime: string;
|
remark?: string;
|
||||||
updateTime: string;
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace API {
|
||||||
|
interface OptionalResult<T> {
|
||||||
|
data: T;
|
||||||
|
count: number;
|
||||||
|
resp_code: number;
|
||||||
|
resp_msg?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user