新增模拟支付渠道,通知查询为空bug 修改
parent
6c174d9c83
commit
6a38738760
@ -0,0 +1,64 @@
|
|||||||
|
package cn.iocoder.yudao.framework.pay.core.client.impl.mock;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模拟支付的 PayClient 实现类, 模拟支付返回结果都是成功
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
public class MockPayClient extends AbstractPayClient<MockPayClientConfig> {
|
||||||
|
|
||||||
|
private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS";
|
||||||
|
|
||||||
|
public MockPayClient(Long channelId, MockPayClientConfig config) {
|
||||||
|
super(channelId, PayChannelEnum.MOCK.getCode(), config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) {
|
||||||
|
// 模拟支付渠道订单号为空
|
||||||
|
return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayOrderRespDTO doGetOrder(String outTradeNo) {
|
||||||
|
// 模拟支付渠道订单号为空
|
||||||
|
return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), outTradeNo, MOCK_RESP_SUCCESS_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) {
|
||||||
|
// 模拟支付渠道退款单号为空
|
||||||
|
return PayRefundRespDTO.successOf("", LocalDateTime.now(), reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) {
|
||||||
|
// 模拟支付渠道退款单号为空
|
||||||
|
return PayRefundRespDTO.successOf("", LocalDateTime.now(), outRefundNo, MOCK_RESP_SUCCESS_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayRefundRespDTO doParseRefundNotify(Map<String, String> params, String body) {
|
||||||
|
throw new UnsupportedOperationException("模拟支付无退款回调");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PayOrderRespDTO doParseOrderNotify(Map<String, String> params, String body) {
|
||||||
|
throw new UnsupportedOperationException("模拟支付无支付回调");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package cn.iocoder.yudao.framework.pay.core.client.impl.mock;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模拟支付的 PayClientConfig 实现类
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MockPayClientConfig implements PayClientConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置名称,如果不加任何属性, JsonUtils.parseObject2 解析会报错. 暂时加个名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Validator validator) {
|
||||||
|
// 模拟支付配置无需校验
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dialog :visible.sync="dialogVisible" :title="title" @closed="close" append-to-body width="800px">
|
||||||
|
<el-form ref="form" :model="formData" :rules="rules" size="medium" label-width="100px" v-loading="formLoading">
|
||||||
|
<el-form-item label-width="180px" label="渠道状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status" size="medium">
|
||||||
|
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)"
|
||||||
|
:label="parseInt(dict.value)">
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label-width="180px" label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" :style="{width: '100%'}"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="close">取消</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { createChannel, getChannel, updateChannel } from "@/api/pay/channel";
|
||||||
|
import { CommonStatusEnum } from "@/utils/constants";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "mockChannelForm",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
formLoading: false,
|
||||||
|
title:'',
|
||||||
|
formData: {
|
||||||
|
appId: '',
|
||||||
|
code: '',
|
||||||
|
status: undefined,
|
||||||
|
feeRate: 0,
|
||||||
|
remark: '',
|
||||||
|
config: {
|
||||||
|
name: 'mock-conf'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
status: [{ required: true, message: '渠道状态不能为空', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
open(appId, code) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.formLoading = true;
|
||||||
|
this.reset(appId, code);
|
||||||
|
getChannel(appId, code).then(response => {
|
||||||
|
if (response.data && response.data.id) {
|
||||||
|
this.formData = response.data;
|
||||||
|
this.formData.config = JSON.parse(response.data.config);
|
||||||
|
}
|
||||||
|
this.title = !this.formData.id ? '创建支付渠道' : '编辑支付渠道'
|
||||||
|
}).finally(() => {
|
||||||
|
this.formLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.reset(undefined, undefined);
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
this.$refs['form'].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const data = { ...this.formData };
|
||||||
|
data.config = JSON.stringify(this.formData.config);
|
||||||
|
if (!data.id) {
|
||||||
|
createChannel(data).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.$emit('success')
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
updateChannel(data).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.$emit('success')
|
||||||
|
this.close();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 重置表单 */
|
||||||
|
reset(appId, code) {
|
||||||
|
this.formData = {
|
||||||
|
appId: appId,
|
||||||
|
code: code,
|
||||||
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
remark: '',
|
||||||
|
feeRate: 0,
|
||||||
|
config: {
|
||||||
|
name: 'mock-conf'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue