mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-01-19 20:28:12 +00:00
新增支付宝demo,优化编译,加快编译速度
This commit is contained in:
parent
37a60ccccb
commit
b9e36076da
22
package.json
22
package.json
@ -4,7 +4,7 @@
|
|||||||
"description": "cool-admin 一个很酷的通用后台管理系统",
|
"description": "cool-admin 一个很酷的通用后台管理系统",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cool-midway/alipay": "^4.0.3",
|
"@cool-midway/alipay": "^4.0.4",
|
||||||
"@cool-midway/core": "^4.0.12",
|
"@cool-midway/core": "^4.0.12",
|
||||||
"@cool-midway/es": "^4.0.2",
|
"@cool-midway/es": "^4.0.2",
|
||||||
"@cool-midway/oss": "^4.0.2",
|
"@cool-midway/oss": "^4.0.2",
|
||||||
@ -12,13 +12,13 @@
|
|||||||
"@cool-midway/redis": "^4.0.3",
|
"@cool-midway/redis": "^4.0.3",
|
||||||
"@cool-midway/socket": "^4.0.2",
|
"@cool-midway/socket": "^4.0.2",
|
||||||
"@cool-midway/wxpay": "^4.0.3",
|
"@cool-midway/wxpay": "^4.0.3",
|
||||||
"@midwayjs/bootstrap": "^2.13.4",
|
"@midwayjs/bootstrap": "^2.14.0",
|
||||||
"@midwayjs/core": "^2.13.4",
|
"@midwayjs/core": "^2.14.0",
|
||||||
"@midwayjs/decorator": "^2.13.2",
|
"@midwayjs/decorator": "^2.14.0",
|
||||||
"@midwayjs/orm": "^2.13.4",
|
"@midwayjs/orm": "^2.14.0",
|
||||||
"@midwayjs/view-nunjucks": "^2.13.4",
|
"@midwayjs/view-nunjucks": "^2.14.0",
|
||||||
"@midwayjs/web": "^2.13.4",
|
"@midwayjs/web": "^2.13.4",
|
||||||
"egg": "^2.32.0",
|
"egg": "^2.33.1",
|
||||||
"egg-scripts": "^2.15.2",
|
"egg-scripts": "^2.15.2",
|
||||||
"ipip-ipdb": "^0.6.0",
|
"ipip-ipdb": "^0.6.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
@ -31,17 +31,17 @@
|
|||||||
"typeorm": "^0.2.41"
|
"typeorm": "^0.2.41"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@midwayjs/cli": "^1.2.91",
|
"@midwayjs/cli": "^1.2.92",
|
||||||
"@midwayjs/egg-ts-helper": "^1.2.1",
|
"@midwayjs/egg-ts-helper": "^1.2.1",
|
||||||
"@midwayjs/luckyeye": "^1.0.3",
|
"@midwayjs/luckyeye": "^1.0.3",
|
||||||
"@midwayjs/mock": "^2.13.4",
|
"@midwayjs/mock": "^2.14.0",
|
||||||
"@types/jest": "^27.0.3",
|
"@types/jest": "^27.0.3",
|
||||||
"@types/jsonwebtoken": "^8.5.6",
|
"@types/jsonwebtoken": "^8.5.6",
|
||||||
"@types/node": "16",
|
"@types/node": "16",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"jest": "^27.3.1",
|
"jest": "^27.4.3",
|
||||||
"mwts": "^1.3.0",
|
"mwts": "^1.3.0",
|
||||||
"ts-jest": "^27.0.7",
|
"ts-jest": "^27.1.0",
|
||||||
"typescript": "^4.5.2"
|
"typescript": "^4.5.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { App, Inject, Post, Provide } from '@midwayjs/decorator';
|
import { ALL, App, Body, Inject, Post, Provide } from '@midwayjs/decorator';
|
||||||
import { IMidwayWebApplication } from '@midwayjs/web';
|
import { IMidwayWebApplication } from '@midwayjs/web';
|
||||||
import { Context } from 'egg';
|
import { Context } from 'egg';
|
||||||
import { CoolController, BaseController } from '@cool-midway/core';
|
import { CoolController, BaseController } from '@cool-midway/core';
|
||||||
import { ICoolWxPay } from '@cool-midway/wxpay';
|
import { ICoolWxPay } from '@cool-midway/wxpay';
|
||||||
import { parseString } from 'xml2js';
|
import { parseString } from 'xml2js';
|
||||||
|
import { ICoolAliPay } from '@cool-midway/alipay';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付示例
|
* 支付示例
|
||||||
@ -15,6 +16,10 @@ export class DemoPayController extends BaseController {
|
|||||||
@Inject('wxpay:sdk')
|
@Inject('wxpay:sdk')
|
||||||
wxPay: ICoolWxPay;
|
wxPay: ICoolWxPay;
|
||||||
|
|
||||||
|
// 支付宝支付
|
||||||
|
@Inject('alipay:sdk')
|
||||||
|
aliPay: ICoolAliPay;
|
||||||
|
|
||||||
@Inject()
|
@Inject()
|
||||||
ctx: Context;
|
ctx: Context;
|
||||||
|
|
||||||
@ -22,12 +27,10 @@ export class DemoPayController extends BaseController {
|
|||||||
app: IMidwayWebApplication;
|
app: IMidwayWebApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码支付
|
* 微信扫码支付
|
||||||
*/
|
*/
|
||||||
@Post('/wx')
|
@Post('/wx')
|
||||||
async wx() {
|
async wx() {
|
||||||
// const a = this.app.getApplicationContext().registry.keys();
|
|
||||||
// console.log(a);
|
|
||||||
const orderNum = await this.wxPay.createOrderNum();
|
const orderNum = await this.wxPay.createOrderNum();
|
||||||
const data = await this.wxPay.getInstance().unifiedOrder({
|
const data = await this.wxPay.getInstance().unifiedOrder({
|
||||||
out_trade_no: orderNum,
|
out_trade_no: orderNum,
|
||||||
@ -70,4 +73,37 @@ export class DemoPayController extends BaseController {
|
|||||||
'<xml><return_msg>OK</return_msg><return_code>SUCCESS</return_code></xml>';
|
'<xml><return_msg>OK</return_msg><return_code>SUCCESS</return_code></xml>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝app支付
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
@Post('/alipay')
|
||||||
|
async alipay() {
|
||||||
|
const orderNum = await this.aliPay.createOrderNum();
|
||||||
|
// app支付
|
||||||
|
const params = await this.aliPay.getInstance().appPay({
|
||||||
|
subject: '测试商品',
|
||||||
|
body: '测试商品描述',
|
||||||
|
outTradeId: orderNum,
|
||||||
|
timeout: '10m',
|
||||||
|
amount: '10.00',
|
||||||
|
goodsType: '0',
|
||||||
|
});
|
||||||
|
return this.ok(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝支付回调
|
||||||
|
*/
|
||||||
|
@Post('/aliNotify')
|
||||||
|
async aliNotify(@Body(ALL) body: any) {
|
||||||
|
const { trade_status, out_trade_no } = body;
|
||||||
|
const check = await this.aliPay.signVerify(body);
|
||||||
|
if (check && trade_status === 'TRADE_SUCCESS') {
|
||||||
|
// 处理逻辑
|
||||||
|
console.log('支付宝支付成功', out_trade_no);
|
||||||
|
}
|
||||||
|
this.ctx.body = 'success';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
import { EntityModel } from '@midwayjs/orm';
|
|
||||||
import { BaseEntity, CoolEntityCrud } from '@cool-midway/core';
|
|
||||||
import { Column } from 'typeorm';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实体类crud demo
|
|
||||||
*/
|
|
||||||
@CoolEntityCrud()
|
|
||||||
@EntityModel('demo_crud')
|
|
||||||
export class DemoCrudEntity extends BaseEntity {
|
|
||||||
@Column({ comment: '头像' })
|
|
||||||
headImg: string;
|
|
||||||
|
|
||||||
@Column({ comment: '姓名' })
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@Column({ comment: '年龄' })
|
|
||||||
age: number;
|
|
||||||
|
|
||||||
@Column({ comment: '出生日期' })
|
|
||||||
birthDate: Date;
|
|
||||||
|
|
||||||
@Column({ comment: '出生日期1' })
|
|
||||||
birthTime: Date;
|
|
||||||
|
|
||||||
@Column({ comment: '出生日期2' })
|
|
||||||
startTime: Date;
|
|
||||||
|
|
||||||
@Column({ comment: '出生日期e' })
|
|
||||||
endTime: Date;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'tinyint',
|
|
||||||
comment: '性别 0-未知 1-男 2-女',
|
|
||||||
default: 0,
|
|
||||||
})
|
|
||||||
type: number;
|
|
||||||
|
|
||||||
@Column({ comment: '备注', nullable: true })
|
|
||||||
remark: string;
|
|
||||||
}
|
|
||||||
@ -29,7 +29,7 @@ import * as oss from '@cool-midway/oss';
|
|||||||
// 微信支付
|
// 微信支付
|
||||||
//wxpay,
|
//wxpay,
|
||||||
// 支付宝支付
|
// 支付宝支付
|
||||||
//alipay,
|
// alipay,
|
||||||
// socket
|
// socket
|
||||||
//socket,
|
//socket,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"stripInternal": true,
|
"stripInternal": true,
|
||||||
"pretty": true,
|
"pretty": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"typeRoots": [ "./typings", "./node_modules/@types"],
|
"typeRoots": [ "./typings", "./node_modules/@types"],
|
||||||
"outDir": "dist"
|
"outDir": "dist"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user