v2
xiaojunnuo 2024-12-20 18:04:32 +08:00
parent 5d568efac3
commit d70e2b66a3
7 changed files with 107 additions and 11 deletions

View File

@ -25,7 +25,7 @@ export abstract class BaseController {
* @param msg
* @param code
*/
fail(msg: string, code: any) {
fail(msg: string, code?: any) {
return {
code: code ? code : Constants.res.error.code,
msg: msg ? msg : Constants.res.error.code,

View File

@ -5,6 +5,7 @@ import commons from "./util.common";
import * as mitt from "./util.mitt";
import { routerUtils } from "./util.router";
import { treeUtils } from "./util.tree";
import { hashUtils } from "./util.hash";
export const util = {
...envs,
...sites,
@ -12,5 +13,6 @@ export const util = {
...commons,
...mitt,
router: routerUtils,
tree: treeUtils
tree: treeUtils,
hash: hashUtils
};

View File

@ -0,0 +1,5 @@
export const hashUtils = {
md5(data: string) {
throw new Error("Not implemented");
}
};

View File

@ -19,7 +19,9 @@
<div class="flex-o mt-5">
支付方式
<a-select v-model:value="formRef.payType">
<a-select-option value="yizhifu">易支付</a-select-option>
<a-select-option value="alipay">支付宝</a-select-option>
<a-select-option value="wxpay">微信支付</a-select-option>
</a-select>
</div>
</div>
@ -27,10 +29,12 @@
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import { durationDict, OrderModalOpenReq, TradeCreate, TradeCreateReq } from "/@/views/certd/suite/api";
import { ref } from "vue";
import { durationDict, OrderModalOpenReq, TradeCreate } from "/@/views/certd/suite/api";
import SuiteValue from "/@/views/sys/suite/product/suite-value.vue";
import PriceInput from "/@/views/sys/suite/product/price-input.vue";
import { notification } from "ant-design-vue";
import modal from "/@/views/certd/notification/notification-selector/modal/index.vue";
const openRef = ref(false);
@ -51,7 +55,7 @@ async function open(opts: OrderModalOpenReq) {
async function orderCreate() {
console.log("orderCreate", formRef.value);
const res = await TradeCreate({
const paymentReq = await TradeCreate({
productId: formRef.value.productId,
duration: formRef.value.duration,
num: formRef.value.num ?? 1,
@ -59,6 +63,64 @@ async function orderCreate() {
});
//
// http://pay.docmirror.cn/submit.php
//
if (formRef.value.payType === "yizhifu") {
doYizhifu(paymentReq);
} else {
//
window.open(paymentReq);
}
modal.open({
title: "支付",
content: "请在新页面完成支付",
onOk: () => {
openRef.value = false;
},
cancelText: "取消支付",
onText: "已完成支付"
});
}
function doYizhifu(paymentReq: any) {
console.log("doYizhifu", paymentReq);
/**
* 商户ID pid Int 1001
* 支付方式 type String alipay 支付方式列表
* 商户订单号 out_trade_no String 20160806151343349
* 异步通知地址 notify_url String http://www.pay.com/notify_url.php
* 跳转通知地址 return_url String http://www.pay.com/return_url.php
* 商品名称 name String VIP会员 如超过127个字节会自动截取
* 商品金额 money String 1.00 单位最大2位小数
* 业务扩展参数 param String 没有请留空 支付后原样返回
* 签名字符串 sign String 202cb962ac59075b964b07152d234b70 签名算法点此查看
* 签名类型 sign_type String MD5 默认为MD5
*/
const form = document.createElement("form");
form.action = paymentReq.api;
form.method = "post";
form.target = "_blank";
// form.style.display = "none";
document.body.appendChild(form);
function createInput(name: string, value: any) {
const input = document.createElement("input");
input.type = "input";
input.name = name;
input.value = value;
form.appendChild(input);
}
const body = paymentReq.body;
const keys = Object.keys(body);
keys.forEach((key) => {
createInput(key, body[key]);
});
form.submit();
//delete form
document.body.removeChild(form);
}
defineExpose({

View File

@ -0,0 +1,13 @@
<template>
<div>
<h1>支付成功</h1>
<div>
<a-button type="primary" @click="handleBack"></a-button>
</div>
</div>
</template>
<script lang="ts" setup>
function handleBack() {
window.location.href = "/";
}
</script>

View File

@ -34,22 +34,28 @@ CREATE TABLE "cd_payment"
CREATE TABLE "cd_trade"
(
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"trade_no" varchar(100),
"user_id" integer,
"product_id" integer,
"title" varchar(100),
"count" integer,
"title" varchar(1024),
"desc" varchar(2048),
"num" integer,
"duration" integer,
"price" integer,
"amount" integer,
"remark" varchar(100),
"remark" varchar(2048),
"status" varchar(100),
"pay_id" integer,
"pay_type" varchar(50),
"pay_time" integer,
"pay_type" varchar(100),
"pay_no" varchar(100),
"end_time" integer,
"create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE INDEX "index_trade_user_id" ON "cd_trade" ("user_id");
CREATE UNIQUE INDEX "index_trade_trade_no" ON "cd_trade" ("trade_no");
CREATE INDEX "index_trade_pay_no" ON "cd_trade" ("pay_type","pay_no");
CREATE TABLE "cd_user_suite"
@ -69,5 +75,12 @@ CREATE TABLE "cd_user_suite"
"update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE INDEX "index_user_suite_user_id" ON "cd_user_suite" ("user_id");
DROP TABLE IF EXISTS "cd_cert";
DROP TABLE IF EXISTS "cd_cert_apply_history";
DROP TABLE IF EXISTS "cd_cert_issuer";
DROP TABLE IF EXISTS "cd_task";
DROP TABLE IF EXISTS "cd_task_history";

View File

@ -19,7 +19,8 @@ export class NamesiloAccess extends BaseAccess {
component: {
placeholder: 'api key',
},
helper: '前往 [获取API Key](https://www.namesilo.com/account/api-manager)',
helper:
'前往 [获取API Key](https://www.namesilo.com/account/api-manager)\n不要勾选第一项Generate key for read-only access\n勾选第二项Submitting this form...\n然后点击Generate按钮',
required: true,
encrypt: true,
})