diff --git a/es/aspects/withdraw.d.ts b/es/aspects/withdraw.d.ts index 5d27ce2e..d2a27766 100644 --- a/es/aspects/withdraw.d.ts +++ b/es/aspects/withdraw.d.ts @@ -12,8 +12,8 @@ export declare function getWithdrawCreateData(params: { creatorId: string; creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -26,8 +26,8 @@ export declare function getWithdrawCreateData(params: { creator?: undefined; creatorId: string; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -40,8 +40,8 @@ export declare function getWithdrawCreateData(params: { creatorId: string; creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -54,8 +54,8 @@ export declare function getWithdrawCreateData(params: { creator?: undefined; creatorId: string; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; diff --git a/es/components/AbstractComponents.d.ts b/es/components/AbstractComponents.d.ts index 852d9e50..0c48143a 100644 --- a/es/components/AbstractComponents.d.ts +++ b/es/components/AbstractComponents.d.ts @@ -18,7 +18,7 @@ declare const List: (props: ReactComponentProps[]; loading: boolean; tablePagination?: React.ReactNode; - rowSelection?: import("antd/es/table/interface").TableRowSelection> | undefined; + rowSelection?: any; hideHeader?: boolean | undefined; disableSerialNumber?: boolean | undefined; size?: "small" | "middle" | "large" | undefined; @@ -46,21 +46,16 @@ declare const ListPro: (props: { data: RowWithActions[]; loading?: boolean | undefined; tablePagination?: any; - rowSelection?: import("antd/es/table/interface").TableRowSelection> | undefined; + rowSelection?: any; disableSerialNumber?: boolean | undefined; size?: "small" | "middle" | "large" | undefined; - scroll?: ({ - x?: string | number | true | undefined; - y?: string | number | undefined; - } & { - scrollToFirstRowOnChange?: boolean | undefined; - }) | undefined; + scroll?: any; empty?: any; opWidth?: number | undefined; oakPath?: string | undefined; }) => React.ReactElement; declare const Detail: (props: ReactComponentProps | undefined; + column?: number | Record | undefined; entity: T; attributes: OakAbsAttrDef[]; data: Partial; diff --git a/es/components/AbstractComponents.js b/es/components/AbstractComponents.js index 45f55231..38db9750 100644 --- a/es/components/AbstractComponents.js +++ b/es/components/AbstractComponents.js @@ -1,7 +1,3 @@ -/** - * 抽象组件在业务层根据EntityDict的重新声明 - * by Xc 20230807 - */ import AbsFilterPanel from 'oak-frontend-base/es/components/filterPanel'; import AbsList from 'oak-frontend-base/es/components/list'; import AbsListPro from 'oak-frontend-base/es/components/listPro'; diff --git a/es/components/account/detail/index.js b/es/components/account/detail/index.js index 0d6c4036..ba3afaf6 100644 --- a/es/components/account/detail/index.js +++ b/es/components/account/detail/index.js @@ -189,7 +189,7 @@ export default OakComponent({ onDepositModalClose() { this.setDepositOpen(false); this.setDepPrice(null); - this.setDepositChannel(undefined); + this.setDepositChannel(null); }, onUfModalClose() { this.setUfOpen(false); @@ -219,7 +219,7 @@ export default OakComponent({ depositOpen: false, ufOpen: false, depPrice: null, - depositChannel: undefined, + depositChannel: null, depositLoss: [0, '', {}], depositing: false, setDepPriceMp(price) { this.setDepPrice(price); }, diff --git a/es/components/account/detail/index.json b/es/components/account/detail/index.json index 0c6bd2de..7ed5501d 100644 --- a/es/components/account/detail/index.json +++ b/es/components/account/detail/index.json @@ -2,7 +2,6 @@ "usingComponents": { "l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index", "l-popup": "@oak-frontend-base/miniprogram_npm/lin-ui/popup/index", - "l-arc-popup": "@oak-frontend-base/miniprogram_npm/lin-ui/arc-popup/index", "l-dialog": "@oak-frontend-base/miniprogram_npm/lin-ui/dialog/index", "deposit-new": "../../deposit/new/index" } diff --git a/es/components/account/detail/index.less b/es/components/account/detail/index.less index efa43b55..369754d1 100644 --- a/es/components/account/detail/index.less +++ b/es/components/account/detail/index.less @@ -91,8 +91,8 @@ .ad-container { padding: 24rpx; background-color: white; - // .safe-area-inset-bottom(); - height: 40vh; + .safe-area-inset-bottom(); + // height: 40vh; .btnBox { position: fixed; diff --git a/es/components/deposit/new/index.js b/es/components/deposit/new/index.js index f09737cf..4a9de191 100644 --- a/es/components/deposit/new/index.js +++ b/es/components/deposit/new/index.js @@ -13,6 +13,7 @@ export default OakComponent({ }, data: { onChooseChannelMp(channel) { this.onChooseChannel(channel); }, + cursorSpacing: 100, }, formData({ data, features }) { const payChannels = features.pay.getPayChannels('deposit'); @@ -38,9 +39,41 @@ export default OakComponent({ listeners: { price() { this.reRender(); + if (process.env.OAK_PLATFORM === 'wechatMp') { + wx.createSelectorQuery().in(this).selectAll('#channel,#loss').boundingClientRect(rect => { + let height = 0; + if (rect instanceof Array) { + for (const r of rect) { + height += r.height; + } + } + if (height > 0) { + const cursorSpacing = height + 100; + this.setState({ + cursorSpacing, + }); + } + }).exec(); + } }, loss() { this.reRender(); + if (process.env.OAK_PLATFORM === 'wechatMp') { + wx.createSelectorQuery().in(this).selectAll('#channel,#loss').boundingClientRect(rect => { + let height = 0; + if (rect instanceof Array) { + for (const r of rect) { + height += r.height; + } + } + if (height > 0) { + const cursorSpacing = height + 100; + this.setState({ + cursorSpacing, + }); + } + }).exec(); + } } }, methods: { diff --git a/es/components/deposit/new/index.xml b/es/components/deposit/new/index.xml index 9a682e9b..7987f725 100644 --- a/es/components/deposit/new/index.xml +++ b/es/components/deposit/new/index.xml @@ -1,20 +1,10 @@ - - - {{t('common::pay.symbol')}} + + {{t('common::pay.symbol')}} - - + + - - - + + + - + diff --git a/es/components/pay/detail/index.d.ts b/es/components/pay/detail/index.d.ts index 21219ee6..ac8f7c2e 100644 --- a/es/components/pay/detail/index.d.ts +++ b/es/components/pay/detail/index.d.ts @@ -4,6 +4,9 @@ import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay"; export declare function registerFrontendPayRoutine(entity: keyof ED, routine: StartPayRoutine, projection: ED['pay']['Selection']['data'], judgeCanPay: JudgeCanPay): void; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; + onPaid: () => void; + onPayFailure: () => void; disableAutoPay: boolean; + closeWhenFailure: boolean; }>) => React.ReactElement; export default _default; diff --git a/es/components/pay/detail/index.js b/es/components/pay/detail/index.js index 600133e8..23a5336f 100644 --- a/es/components/pay/detail/index.js +++ b/es/components/pay/detail/index.js @@ -5,6 +5,7 @@ import { isWeiXin } from 'oak-frontend-base/es/utils/utils'; import { merge } from "oak-domain/lib/utils/lodash"; import { canStartPay } from "../../../utils/wpProductFrontend"; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; +import { StartPayFailure } from "../../../types/Exception"; const PayRoutineDict = { wpProduct: { projection: { @@ -20,21 +21,22 @@ const PayRoutineDict = { if (process.env.OAK_PLATFORM === 'wechatMp') { const { prepayMeta } = meta; if (prepayMeta) { - const result = await wx.requestPayment(prepayMeta); - process.env.NODE_ENV === 'development' && console.log(result); + try { + const result = await wx.requestPayment(prepayMeta); + process.env.NODE_ENV === 'development' && console.log(result); + } + catch (err) { + throw new StartPayFailure(err.errMsg.includes('cancel') + ? features.locales.t('startPayError.userCancel') + : features.locales.t('startPayError.unknown')); + } } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.illegaPayData'), - }); + throw new StartPayFailure(features.locales.t('startPayError.illegalPrepayData')); } } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.falseEnv', { env: 'wechatMp' }), - }); + throw new StartPayFailure(features.locales.t('startPayError.falseEnv', { env: 'wechatMp' })); } return; } @@ -50,10 +52,7 @@ const PayRoutineDict = { }); } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.illegaPayData'), - }); + throw new StartPayFailure(features.locales.t('startPayError.illegalPrepayData')); } } } @@ -111,7 +110,10 @@ export default OakComponent({ }, properties: { onClose: () => undefined, + onPaid: () => undefined, + onPayFailure: () => undefined, disableAutoPay: false, + closeWhenFailure: false, }, data: { showCloseConfirmMp: false, @@ -202,32 +204,45 @@ export default OakComponent({ async confirmCloseMp() { await this.execute('close'); this.cancelCloseMp(); + const { onClose } = this.props; + onClose && onClose(); }, goBack() { this.navigateBack(); }, async startPay() { + const { onPaid, onClose, onPayFailure } = this.props; const { pay } = this.state; - await PayRoutineDict[pay.entity].routine(pay, this.features); + try { + await PayRoutineDict[pay.entity].routine(pay, this.features); + onPaid && onPaid(); + } + catch (err) { + if (this.props.closeWhenFailure) { + await this.execute(undefined, undefined, undefined, [ + { + entity: 'pay', + operation: { + id: await generateNewIdAsync(), + action: 'close', + data: {}, + filter: { + id: this.props.oakId, + }, + }, + } + ]); + onClose && onClose(); + } + else { + onPayFailure && onPayFailure(); + } + this.features.message.setMessage({ + type: 'warning', + content: err.message, + }); + } }, - /* async onWxBridgeReady(payMetaData: any): Promise { - return new Promise( - (resolve, reject) => { - WeixinJSBridge.invoke('getBrandWCPayRequest', payMetaData, - function (res: { err_msg: string }) { - if (res.err_msg == "get_brand_wcpay_request:ok") { - // 使用以上方式判断前端返回,微信团队郑重提示: - //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 - resolve(undefined as void); - } - else { - reject(res.err_msg); - } - } - ); - } - ); - } */ openChannelSelectMp() { this.setState({ showChannelSelectMp: true, diff --git a/es/components/pay/detail/index.less b/es/components/pay/detail/index.less index 21bf199c..61213780 100644 --- a/es/components/pay/detail/index.less +++ b/es/components/pay/detail/index.less @@ -196,4 +196,5 @@ display: grid; grid-template-columns: 1fr 1fr; gap: 32rpx; + flex: 1; } \ No newline at end of file diff --git a/es/components/pay/detail/index.xml b/es/components/pay/detail/index.xml index 9adce943..0e509105 100644 --- a/es/components/pay/detail/index.xml +++ b/es/components/pay/detail/index.xml @@ -106,57 +106,62 @@ - - - {{t('pay')}} - - - - + + - {{t('common::action.update')}} - + type="error" + size="long" + bind:lintap="closeMp" + style="flex:1;" + > + {{t('pay:action.close')}} + + + + - {{t('common::reset')}} - - - - - - {{t('pay:action.close')}} - - - - - - {{t('common::back')}} - - + size="long" + bind:lintap="startPay" + type="success" + style="flex:1;" + > + {{t('pay')}} + + + + + + {{t('common::reset')}} + + + {{t('common::action.update')}} + + + + + + {{t('common::back')}} + + + \ No newline at end of file diff --git a/es/components/pay/detail/locales/zh-CN.json b/es/components/pay/detail/locales/zh-CN.json index 74c7003f..d4f80dbc 100644 --- a/es/components/pay/detail/locales/zh-CN.json +++ b/es/components/pay/detail/locales/zh-CN.json @@ -16,7 +16,9 @@ "wechatPay": "微信支付", "startPayError": { "illegalPrepayData": "没有有效的预支付数据,可能后台是运行在开发环境,请检查", - "falseEnv": "该订单渠道【%{env}】不匹配当前环境" + "falseEnv": "该订单渠道【%{env}】不匹配当前环境", + "userCancel": "用户取消支付", + "unknown": "用户支付失败" }, "type": { "label": "支付类型", diff --git a/es/components/pay/detail/web.js b/es/components/pay/detail/web.js index 2073c0a1..b35589bd 100644 --- a/es/components/pay/detail/web.js +++ b/es/components/pay/detail/web.js @@ -152,7 +152,18 @@ export default function Render(props) { const { t, update, execute, clean, goBack, startPay } = props.methods; if (pay) { const { iState, price, entity } = pay; - let BtnPart = startPayable ? () : startPayable ? () : oakExecutable === true ? (<>
@@ -165,18 +176,7 @@ export default function Render(props) { {t('common::reset')}
- ) : closable ? () : (); return (
diff --git a/es/context/BackendRuntimeContext.d.ts b/es/context/BackendRuntimeContext.d.ts index 11c2072c..e8536354 100644 --- a/es/context/BackendRuntimeContext.d.ts +++ b/es/context/BackendRuntimeContext.d.ts @@ -15,7 +15,7 @@ export declare class BackendRuntimeContext | undefined; + config?: number | import("oak-domain/lib/types").JsonProjection | undefined; style?: number | import("oak-domain/lib/types").JsonProjection | undefined; domainId?: number | undefined; domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined; diff --git a/es/data/i18n.js b/es/data/i18n.js index 546844fb..03d6ad64 100644 --- a/es/data/i18n.js +++ b/es/data/i18n.js @@ -197,7 +197,9 @@ const i18ns = [ "wechatPay": "微信支付", "startPayError": { "illegalPrepayData": "没有有效的预支付数据,可能后台是运行在开发环境,请检查", - "falseEnv": "该订单渠道【%{env}】不匹配当前环境" + "falseEnv": "该订单渠道【%{env}】不匹配当前环境", + "userCancel": "用户取消支付", + "unknown": "用户支付失败" }, "type": { "label": "支付类型", diff --git a/es/oak-app-domain/ExtraFile/Schema.d.ts b/es/oak-app-domain/ExtraFile/Schema.d.ts index 12496818..0df40da1 100644 --- a/es/oak-app-domain/ExtraFile/Schema.d.ts +++ b/es/oak-app-domain/ExtraFile/Schema.d.ts @@ -10,7 +10,7 @@ import * as ArticleMenu from "../ArticleMenu/Schema"; import * as SessionMessage from "../SessionMessage/Schema"; import * as User from "../User/Schema"; export type OpSchema = EntityShape & { - origin: "qiniu" | "wechat" | "unknown" | "ctyun"; + origin: "qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown"; type: "image" | "video" | "audio" | "file"; bucket?: String<32> | null; objectId?: String<64> | null; @@ -33,7 +33,7 @@ export type OpSchema = EntityShape & { }; export type OpAttr = keyof OpSchema; export type Schema = EntityShape & { - origin: "qiniu" | "wechat" | "unknown" | "ctyun"; + origin: "qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown"; type: "image" | "video" | "audio" | "file"; bucket?: String<32> | null; objectId?: String<64> | null; @@ -66,7 +66,7 @@ type AttrFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - origin: Q_EnumValue<"qiniu" | "wechat" | "unknown" | "ctyun">; + origin: Q_EnumValue<"qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown">; type: Q_EnumValue<"image" | "video" | "audio" | "file">; bucket: Q_StringValue; objectId: Q_StringValue; diff --git a/es/oak-app-domain/ExtraFile/Storage.js b/es/oak-app-domain/ExtraFile/Storage.js index ec1831be..6ea1f326 100644 --- a/es/oak-app-domain/ExtraFile/Storage.js +++ b/es/oak-app-domain/ExtraFile/Storage.js @@ -4,7 +4,7 @@ export const desc = { origin: { notNull: true, type: "enum", - enumeration: ["qiniu", "wechat", "unknown", "ctyun"] + enumeration: ["qiniu", "wechat", "ctyun", "aliyun", "tencent", "unknown"] }, type: { notNull: true, @@ -120,8 +120,8 @@ export const desc = { }, { name: '$$deleteAt$$', - } - ] + }, + ], } ] }; diff --git a/es/oak-app-domain/ExtraFile/Style.js b/es/oak-app-domain/ExtraFile/Style.js index 9f63c41c..e9fe5a41 100644 --- a/es/oak-app-domain/ExtraFile/Style.js +++ b/es/oak-app-domain/ExtraFile/Style.js @@ -1,9 +1,11 @@ export const style = { color: { origin: { - qiniu: '#0000FF', - wechat: '#008000', - ctyun: '#6495ED', + qiniu: '#37caff', + wechat: '#2aae67', + ctyun: '#ff0000', + aliyun: '#1677ff', + tencent: '#0052d9', unknown: '#A9A9A9', }, type: { @@ -16,6 +18,6 @@ export const style = { success: '#008000', failed: '#FF0000', uploading: '#0000FF', - } - } + }, + }, }; diff --git a/es/oak-app-domain/ExtraFile/locales/zh_CN.json b/es/oak-app-domain/ExtraFile/locales/zh_CN.json index 26be8608..4f126e82 100644 --- a/es/oak-app-domain/ExtraFile/locales/zh_CN.json +++ b/es/oak-app-domain/ExtraFile/locales/zh_CN.json @@ -1 +1 @@ -{ "name": "文件", "attr": { "origin": "源", "type": "类型", "bucket": "桶", "objectId": "对象编号", "tag1": "标签一", "tag2": "标签二", "filename": "文件名", "md5": "md5", "entity": "关联对象", "entityId": "关联对象id", "extra1": "额外信息", "extra2": "非结构化额外信息", "extension": "后缀名", "size": "文件大小", "sort": "排序", "fileType": "文件类型", "isBridge": "是否桥接访问", "uploadState": "上传状态", "uploadMeta": "上传需要的metadata", "application": "来源应用" }, "v": { "origin": { "qiniu": "七牛云", "ctyun": "天翼云", "wechat": "微信", "unknown": "未知" }, "type": { "image": "图像", "video": "视频", "audio": "音频", "file": "文件" }, "uploadState": { "success": "上传成功", "failed": "上传失败", "uploading": "上传中" } } } +{ "name": "文件", "attr": { "origin": "源", "type": "类型", "bucket": "桶", "objectId": "对象编号", "tag1": "标签一", "tag2": "标签二", "filename": "文件名", "md5": "md5", "entity": "关联对象", "entityId": "关联对象id", "extra1": "额外信息", "extra2": "非结构化额外信息", "extension": "后缀名", "size": "文件大小", "sort": "排序", "fileType": "文件类型", "isBridge": "是否桥接访问", "uploadState": "上传状态", "uploadMeta": "上传需要的metadata", "application": "来源应用" }, "v": { "origin": { "qiniu": "七牛云", "ctyun": "天翼云", "wechat": "微信", "aliyun": "阿里云", "tencent": "腾讯云", "unknown": "未知" }, "type": { "image": "图像", "video": "视频", "audio": "音频", "file": "文件" }, "uploadState": { "success": "上传成功", "failed": "上传失败", "uploading": "上传中" } } } diff --git a/es/oak-app-domain/System/Storage.js b/es/oak-app-domain/System/Storage.js index 2395d60b..c61a6659 100644 --- a/es/oak-app-domain/System/Storage.js +++ b/es/oak-app-domain/System/Storage.js @@ -34,7 +34,8 @@ export const desc = { : { type: "object" }, - entity: { + entity // 如果为true,则按照渠道taxLossRatio和refundCompensateRatio进行扣取(如果因为depositLossRatio已经大于taxLossRatio,则全额退款) + : { type: "varchar", params: { length: 32 diff --git a/es/types/Exception.d.ts b/es/types/Exception.d.ts index 2b2e4c78..67b988a8 100644 --- a/es/types/Exception.d.ts +++ b/es/types/Exception.d.ts @@ -16,4 +16,7 @@ export declare class ExternalPayUtilException extends Oak export declare class RefundExceedMax extends OakException { constructor(message?: string); } +export declare class StartPayFailure extends OakException { + constructor(message: string); +} export declare function makeException(msg: string | object): OakException | undefined; diff --git a/es/types/Exception.js b/es/types/Exception.js index 1d0a098b..589829d6 100644 --- a/es/types/Exception.js +++ b/es/types/Exception.js @@ -19,6 +19,11 @@ export class RefundExceedMax extends OakException { super(message || '可退款的总额不足'); } } +export class StartPayFailure extends OakException { + constructor(message) { + super(message); + } +} export function makeException(msg) { const data = typeof msg === 'string' ? JSON.parse(msg) : msg; let exception = makeDepedentException(data); diff --git a/es/utils/application.d.ts b/es/utils/application.d.ts index e7c4620e..260f0950 100644 --- a/es/utils/application.d.ts +++ b/es/utils/application.d.ts @@ -14,7 +14,7 @@ export declare const mergedProjection: { type?: number | undefined; systemId?: number | undefined; system?: import("../oak-app-domain/System/Schema").Projection | undefined; - config?: number | import("oak-domain/lib/types").JsonProjection | undefined; + config?: number | import("oak-domain/lib/types").JsonProjection | undefined; style?: number | import("oak-domain/lib/types").JsonProjection | undefined; domainId?: number | undefined; domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined; diff --git a/es/utils/payClazz/WechatPay/WechatPay.js b/es/utils/payClazz/WechatPay/WechatPay.js index 6c9d4fa5..015cc370 100644 --- a/es/utils/payClazz/WechatPay/WechatPay.js +++ b/es/utils/payClazz/WechatPay/WechatPay.js @@ -20,6 +20,7 @@ const REFUND_STATE_MATRIX = { "ABNORMAL": "refunding", "PROCESSING": 'refunding', }; +const PREPAY_TIMEOUT = 15 * 60 * 1000; // 默认订单15分钟过期 export default class WechatPay extends WechatPayDebug { wechatPay; refundGapDays; @@ -169,6 +170,8 @@ export default class WechatPay extends WechatPayDebug { throw new Error('本支付方法还没来的及实现呢'); } } + // pay加一个过期时间,到期自动close + data.timeoutAt = Date.now() + PREPAY_TIMEOUT; } async getState(pay) { const outTradeNo = compressTo32(pay.id); diff --git a/es/watchers/pay.js b/es/watchers/pay.js index 79f782a8..0e829cb9 100644 --- a/es/watchers/pay.js +++ b/es/watchers/pay.js @@ -48,6 +48,23 @@ const watchers = [ actionData: { refundable: false, } + }, + { + name: '当pay达到禁止退款期限时,关闭退款允许', + entity: 'pay', + filter: () => { + const now = Date.now(); + return { + iState: { + $in: ['unpaid', 'paying'], + }, + timeoutAt: { + $lt: now, + }, + }; + }, + action: 'close', + actionData: {}, } ]; export default watchers; diff --git a/lib/aspects/withdraw.d.ts b/lib/aspects/withdraw.d.ts index 5d27ce2e..d2a27766 100644 --- a/lib/aspects/withdraw.d.ts +++ b/lib/aspects/withdraw.d.ts @@ -12,8 +12,8 @@ export declare function getWithdrawCreateData(params: { creatorId: string; creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -26,8 +26,8 @@ export declare function getWithdrawCreateData(params: { creator?: undefined; creatorId: string; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -40,8 +40,8 @@ export declare function getWithdrawCreateData(params: { creatorId: string; creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; @@ -54,8 +54,8 @@ export declare function getWithdrawCreateData(params: { creator?: undefined; creatorId: string; } & { - refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; - withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + refund$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; + withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit[]> | (import("oak-domain/lib/types").Operation, Omit> | import("oak-domain/lib/types").Operation<"create", Omit>)[] | undefined; modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit[]> | import("oak-domain/lib/types").Operation<"create", Omit>[] | undefined; diff --git a/lib/components/pay/detail/index.d.ts b/lib/components/pay/detail/index.d.ts index 21219ee6..ac8f7c2e 100644 --- a/lib/components/pay/detail/index.d.ts +++ b/lib/components/pay/detail/index.d.ts @@ -4,6 +4,9 @@ import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay"; export declare function registerFrontendPayRoutine(entity: keyof ED, routine: StartPayRoutine, projection: ED['pay']['Selection']['data'], judgeCanPay: JudgeCanPay): void; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; + onPaid: () => void; + onPayFailure: () => void; disableAutoPay: boolean; + closeWhenFailure: boolean; }>) => React.ReactElement; export default _default; diff --git a/lib/components/pay/detail/index.js b/lib/components/pay/detail/index.js index 019d08eb..17e8f6d4 100644 --- a/lib/components/pay/detail/index.js +++ b/lib/components/pay/detail/index.js @@ -9,6 +9,7 @@ const utils_1 = require("oak-frontend-base/es/utils/utils"); const lodash_1 = require("oak-domain/lib/utils/lodash"); const wpProductFrontend_1 = require("../../../utils/wpProductFrontend"); const uuid_1 = require("oak-domain/lib/utils/uuid"); +const Exception_1 = require("../../../types/Exception"); const PayRoutineDict = { wpProduct: { projection: { @@ -24,21 +25,22 @@ const PayRoutineDict = { if (process.env.OAK_PLATFORM === 'wechatMp') { const { prepayMeta } = meta; if (prepayMeta) { - const result = await wx.requestPayment(prepayMeta); - process.env.NODE_ENV === 'development' && console.log(result); + try { + const result = await wx.requestPayment(prepayMeta); + process.env.NODE_ENV === 'development' && console.log(result); + } + catch (err) { + throw new Exception_1.StartPayFailure(err.errMsg.includes('cancel') + ? features.locales.t('startPayError.userCancel') + : features.locales.t('startPayError.unknown')); + } } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.illegaPayData'), - }); + throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData')); } } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.falseEnv', { env: 'wechatMp' }), - }); + throw new Exception_1.StartPayFailure(features.locales.t('startPayError.falseEnv', { env: 'wechatMp' })); } return; } @@ -54,10 +56,7 @@ const PayRoutineDict = { }); } else { - features.message.setMessage({ - type: 'error', - content: features.locales.t('startPayError.illegaPayData'), - }); + throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData')); } } } @@ -116,7 +115,10 @@ exports.default = OakComponent({ }, properties: { onClose: () => undefined, + onPaid: () => undefined, + onPayFailure: () => undefined, disableAutoPay: false, + closeWhenFailure: false, }, data: { showCloseConfirmMp: false, @@ -207,32 +209,45 @@ exports.default = OakComponent({ async confirmCloseMp() { await this.execute('close'); this.cancelCloseMp(); + const { onClose } = this.props; + onClose && onClose(); }, goBack() { this.navigateBack(); }, async startPay() { + const { onPaid, onClose, onPayFailure } = this.props; const { pay } = this.state; - await PayRoutineDict[pay.entity].routine(pay, this.features); + try { + await PayRoutineDict[pay.entity].routine(pay, this.features); + onPaid && onPaid(); + } + catch (err) { + if (this.props.closeWhenFailure) { + await this.execute(undefined, undefined, undefined, [ + { + entity: 'pay', + operation: { + id: await (0, uuid_1.generateNewIdAsync)(), + action: 'close', + data: {}, + filter: { + id: this.props.oakId, + }, + }, + } + ]); + onClose && onClose(); + } + else { + onPayFailure && onPayFailure(); + } + this.features.message.setMessage({ + type: 'warning', + content: err.message, + }); + } }, - /* async onWxBridgeReady(payMetaData: any): Promise { - return new Promise( - (resolve, reject) => { - WeixinJSBridge.invoke('getBrandWCPayRequest', payMetaData, - function (res: { err_msg: string }) { - if (res.err_msg == "get_brand_wcpay_request:ok") { - // 使用以上方式判断前端返回,微信团队郑重提示: - //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 - resolve(undefined as void); - } - else { - reject(res.err_msg); - } - } - ); - } - ); - } */ openChannelSelectMp() { this.setState({ showChannelSelectMp: true, diff --git a/lib/context/BackendRuntimeContext.d.ts b/lib/context/BackendRuntimeContext.d.ts index 11c2072c..e8536354 100644 --- a/lib/context/BackendRuntimeContext.d.ts +++ b/lib/context/BackendRuntimeContext.d.ts @@ -15,7 +15,7 @@ export declare class BackendRuntimeContext | undefined; + config?: number | import("oak-domain/lib/types").JsonProjection | undefined; style?: number | import("oak-domain/lib/types").JsonProjection | undefined; domainId?: number | undefined; domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined; diff --git a/lib/data/i18n.js b/lib/data/i18n.js index 5bff0e4a..4db7bdca 100644 --- a/lib/data/i18n.js +++ b/lib/data/i18n.js @@ -199,7 +199,9 @@ const i18ns = [ "wechatPay": "微信支付", "startPayError": { "illegalPrepayData": "没有有效的预支付数据,可能后台是运行在开发环境,请检查", - "falseEnv": "该订单渠道【%{env}】不匹配当前环境" + "falseEnv": "该订单渠道【%{env}】不匹配当前环境", + "userCancel": "用户取消支付", + "unknown": "用户支付失败" }, "type": { "label": "支付类型", diff --git a/lib/oak-app-domain/ExtraFile/Schema.d.ts b/lib/oak-app-domain/ExtraFile/Schema.d.ts index 12496818..0df40da1 100644 --- a/lib/oak-app-domain/ExtraFile/Schema.d.ts +++ b/lib/oak-app-domain/ExtraFile/Schema.d.ts @@ -10,7 +10,7 @@ import * as ArticleMenu from "../ArticleMenu/Schema"; import * as SessionMessage from "../SessionMessage/Schema"; import * as User from "../User/Schema"; export type OpSchema = EntityShape & { - origin: "qiniu" | "wechat" | "unknown" | "ctyun"; + origin: "qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown"; type: "image" | "video" | "audio" | "file"; bucket?: String<32> | null; objectId?: String<64> | null; @@ -33,7 +33,7 @@ export type OpSchema = EntityShape & { }; export type OpAttr = keyof OpSchema; export type Schema = EntityShape & { - origin: "qiniu" | "wechat" | "unknown" | "ctyun"; + origin: "qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown"; type: "image" | "video" | "audio" | "file"; bucket?: String<32> | null; objectId?: String<64> | null; @@ -66,7 +66,7 @@ type AttrFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - origin: Q_EnumValue<"qiniu" | "wechat" | "unknown" | "ctyun">; + origin: Q_EnumValue<"qiniu" | "wechat" | "ctyun" | "aliyun" | "tencent" | "unknown">; type: Q_EnumValue<"image" | "video" | "audio" | "file">; bucket: Q_StringValue; objectId: Q_StringValue; diff --git a/lib/oak-app-domain/ExtraFile/Storage.js b/lib/oak-app-domain/ExtraFile/Storage.js index 4ed2b924..97edb473 100644 --- a/lib/oak-app-domain/ExtraFile/Storage.js +++ b/lib/oak-app-domain/ExtraFile/Storage.js @@ -7,7 +7,7 @@ exports.desc = { origin: { notNull: true, type: "enum", - enumeration: ["qiniu", "wechat", "unknown", "ctyun"] + enumeration: ["qiniu", "wechat", "ctyun", "aliyun", "tencent", "unknown"] }, type: { notNull: true, @@ -123,8 +123,8 @@ exports.desc = { }, { name: '$$deleteAt$$', - } - ] + }, + ], } ] }; diff --git a/lib/oak-app-domain/ExtraFile/Style.js b/lib/oak-app-domain/ExtraFile/Style.js index 35b0e923..7aa23805 100644 --- a/lib/oak-app-domain/ExtraFile/Style.js +++ b/lib/oak-app-domain/ExtraFile/Style.js @@ -4,9 +4,11 @@ exports.style = void 0; exports.style = { color: { origin: { - qiniu: '#0000FF', - wechat: '#008000', - ctyun: '#6495ED', + qiniu: '#37caff', + wechat: '#2aae67', + ctyun: '#ff0000', + aliyun: '#1677ff', + tencent: '#0052d9', unknown: '#A9A9A9', }, type: { @@ -19,6 +21,6 @@ exports.style = { success: '#008000', failed: '#FF0000', uploading: '#0000FF', - } - } + }, + }, }; diff --git a/lib/oak-app-domain/ExtraFile/locales/zh_CN.json b/lib/oak-app-domain/ExtraFile/locales/zh_CN.json index 26be8608..4f126e82 100644 --- a/lib/oak-app-domain/ExtraFile/locales/zh_CN.json +++ b/lib/oak-app-domain/ExtraFile/locales/zh_CN.json @@ -1 +1 @@ -{ "name": "文件", "attr": { "origin": "源", "type": "类型", "bucket": "桶", "objectId": "对象编号", "tag1": "标签一", "tag2": "标签二", "filename": "文件名", "md5": "md5", "entity": "关联对象", "entityId": "关联对象id", "extra1": "额外信息", "extra2": "非结构化额外信息", "extension": "后缀名", "size": "文件大小", "sort": "排序", "fileType": "文件类型", "isBridge": "是否桥接访问", "uploadState": "上传状态", "uploadMeta": "上传需要的metadata", "application": "来源应用" }, "v": { "origin": { "qiniu": "七牛云", "ctyun": "天翼云", "wechat": "微信", "unknown": "未知" }, "type": { "image": "图像", "video": "视频", "audio": "音频", "file": "文件" }, "uploadState": { "success": "上传成功", "failed": "上传失败", "uploading": "上传中" } } } +{ "name": "文件", "attr": { "origin": "源", "type": "类型", "bucket": "桶", "objectId": "对象编号", "tag1": "标签一", "tag2": "标签二", "filename": "文件名", "md5": "md5", "entity": "关联对象", "entityId": "关联对象id", "extra1": "额外信息", "extra2": "非结构化额外信息", "extension": "后缀名", "size": "文件大小", "sort": "排序", "fileType": "文件类型", "isBridge": "是否桥接访问", "uploadState": "上传状态", "uploadMeta": "上传需要的metadata", "application": "来源应用" }, "v": { "origin": { "qiniu": "七牛云", "ctyun": "天翼云", "wechat": "微信", "aliyun": "阿里云", "tencent": "腾讯云", "unknown": "未知" }, "type": { "image": "图像", "video": "视频", "audio": "音频", "file": "文件" }, "uploadState": { "success": "上传成功", "failed": "上传失败", "uploading": "上传中" } } } diff --git a/lib/types/Exception.d.ts b/lib/types/Exception.d.ts index 2b2e4c78..67b988a8 100644 --- a/lib/types/Exception.d.ts +++ b/lib/types/Exception.d.ts @@ -16,4 +16,7 @@ export declare class ExternalPayUtilException extends Oak export declare class RefundExceedMax extends OakException { constructor(message?: string); } +export declare class StartPayFailure extends OakException { + constructor(message: string); +} export declare function makeException(msg: string | object): OakException | undefined; diff --git a/lib/types/Exception.js b/lib/types/Exception.js index c7e0148d..e5a3bbbb 100644 --- a/lib/types/Exception.js +++ b/lib/types/Exception.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeException = exports.RefundExceedMax = exports.ExternalPayUtilException = void 0; +exports.makeException = exports.StartPayFailure = exports.RefundExceedMax = exports.ExternalPayUtilException = void 0; const tslib_1 = require("tslib"); const types_1 = require("oak-domain/lib/types"); const DependentExceptions_1 = tslib_1.__importDefault(require("./DependentExceptions")); @@ -25,6 +25,12 @@ class RefundExceedMax extends types_1.OakException { } } exports.RefundExceedMax = RefundExceedMax; +class StartPayFailure extends types_1.OakException { + constructor(message) { + super(message); + } +} +exports.StartPayFailure = StartPayFailure; function makeException(msg) { const data = typeof msg === 'string' ? JSON.parse(msg) : msg; let exception = (0, DependentExceptions_1.default)(data); diff --git a/lib/utils/application.d.ts b/lib/utils/application.d.ts index e7c4620e..260f0950 100644 --- a/lib/utils/application.d.ts +++ b/lib/utils/application.d.ts @@ -14,7 +14,7 @@ export declare const mergedProjection: { type?: number | undefined; systemId?: number | undefined; system?: import("../oak-app-domain/System/Schema").Projection | undefined; - config?: number | import("oak-domain/lib/types").JsonProjection | undefined; + config?: number | import("oak-domain/lib/types").JsonProjection | undefined; style?: number | import("oak-domain/lib/types").JsonProjection | undefined; domainId?: number | undefined; domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined; diff --git a/lib/utils/payClazz/WechatPay/WechatPay.js b/lib/utils/payClazz/WechatPay/WechatPay.js index 4e526c42..b0124f95 100644 --- a/lib/utils/payClazz/WechatPay/WechatPay.js +++ b/lib/utils/payClazz/WechatPay/WechatPay.js @@ -23,6 +23,7 @@ const REFUND_STATE_MATRIX = { "ABNORMAL": "refunding", "PROCESSING": 'refunding', }; +const PREPAY_TIMEOUT = 15 * 60 * 1000; // 默认订单15分钟过期 class WechatPay extends WechatPay_debug_1.default { wechatPay; refundGapDays; @@ -172,6 +173,8 @@ class WechatPay extends WechatPay_debug_1.default { throw new Error('本支付方法还没来的及实现呢'); } } + // pay加一个过期时间,到期自动close + data.timeoutAt = Date.now() + PREPAY_TIMEOUT; } async getState(pay) { const outTradeNo = (0, uuid_1.compressTo32)(pay.id); diff --git a/lib/watchers/pay.js b/lib/watchers/pay.js index 89e66d4c..e05ef328 100644 --- a/lib/watchers/pay.js +++ b/lib/watchers/pay.js @@ -50,6 +50,23 @@ const watchers = [ actionData: { refundable: false, } + }, + { + name: '当pay达到禁止退款期限时,关闭退款允许', + entity: 'pay', + filter: () => { + const now = Date.now(); + return { + iState: { + $in: ['unpaid', 'paying'], + }, + timeoutAt: { + $lt: now, + }, + }; + }, + action: 'close', + actionData: {}, } ]; exports.default = watchers; diff --git a/package.json b/package.json index c76a4e49..d5df20b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oak-pay-business", - "version": "2.2.9", + "version": "2.2.10", "description": "", "files": [ "lib/**/*", @@ -30,8 +30,8 @@ "classnames": "^2.3.1", "dayjs": "^1.11.5", "oak-domain": "~5.0.15", - "oak-frontend-base": "~5.2.10", - "oak-general-business": "~5.2.5", + "oak-frontend-base": "~5.2.11", + "oak-general-business": "~5.2.6", "wechat-pay-nodejs": "^0.2.3" }, "peerDependencies": { diff --git a/src/components/AbstractComponents.ts b/src/components/AbstractComponents.ts index 4d1d18a8..8f5a1a45 100644 --- a/src/components/AbstractComponents.ts +++ b/src/components/AbstractComponents.ts @@ -2,7 +2,6 @@ * 抽象组件在业务层根据EntityDict的重新声明 * by Xc 20230807 */ - // @ts-nocheck import React from 'react'; import { EntityDict } from '../oak-app-domain'; diff --git a/src/components/account/detail/index.less b/src/components/account/detail/index.less index efa43b55..369754d1 100644 --- a/src/components/account/detail/index.less +++ b/src/components/account/detail/index.less @@ -91,8 +91,8 @@ .ad-container { padding: 24rpx; background-color: white; - // .safe-area-inset-bottom(); - height: 40vh; + .safe-area-inset-bottom(); + // height: 40vh; .btnBox { position: fixed; diff --git a/src/components/account/detail/index.ts b/src/components/account/detail/index.ts index bec8a7a2..b8f54991 100644 --- a/src/components/account/detail/index.ts +++ b/src/components/account/detail/index.ts @@ -144,7 +144,7 @@ export default OakComponent({ setDepPrice(depPrice: null | number) { this.setState({ depPrice }, () => this.setDepositLoss()); }, - setDepositChannel(depositChannel: PayChannel | undefined) { + setDepositChannel(depositChannel: PayChannel | null) { this.setState({ depositChannel }, () => this.setDepositLoss()); }, setDepositLoss() { @@ -193,7 +193,7 @@ export default OakComponent({ onDepositModalClose() { this.setDepositOpen(false); this.setDepPrice(null); - this.setDepositChannel(undefined); + this.setDepositChannel(null); }, onUfModalClose() { this.setUfOpen(false); @@ -223,11 +223,11 @@ export default OakComponent({ depositOpen: false, ufOpen: false, depPrice: null as null | number, - depositChannel: undefined as PayChannel | undefined, + depositChannel: null as PayChannel | null, depositLoss: [0, '', {}] as [number, string, any], depositing: false, setDepPriceMp(price: number | null) { this.setDepPrice(price) }, - setDepositChannelMp(depositChannel: PayChannel | undefined) { this.setDepositChannel(depositChannel) }, + setDepositChannelMp(depositChannel: PayChannel | null) { this.setDepositChannel(depositChannel) }, focus: false, }, lifetimes: { diff --git a/src/components/deposit/new/index.ts b/src/components/deposit/new/index.ts index a1a4e524..6fffcf42 100644 --- a/src/components/deposit/new/index.ts +++ b/src/components/deposit/new/index.ts @@ -16,6 +16,7 @@ export default OakComponent({ }, data: { onChooseChannelMp(channel: PayChannel) { this.onChooseChannel(channel) }, + cursorSpacing: 100, }, formData({ data, features }) { const payChannels = features.pay.getPayChannels('deposit'); @@ -41,9 +42,41 @@ export default OakComponent({ listeners: { price() { this.reRender(); + if (process.env.OAK_PLATFORM === 'wechatMp') { + wx.createSelectorQuery().in(this as any).selectAll('#channel,#loss').boundingClientRect(rect => { + let height = 0; + if (rect instanceof Array) { + for (const r of rect) { + height += r.height; + } + } + if (height > 0) { + const cursorSpacing = height + 100; + this.setState({ + cursorSpacing, + }) + } + }).exec(); + } }, loss() { this.reRender(); + if (process.env.OAK_PLATFORM === 'wechatMp') { + wx.createSelectorQuery().in(this as any).selectAll('#channel,#loss').boundingClientRect(rect => { + let height = 0; + if (rect instanceof Array) { + for (const r of rect) { + height += r.height; + } + } + if (height > 0) { + const cursorSpacing = height + 100; + this.setState({ + cursorSpacing, + }) + } + }).exec(); + } } }, methods: { diff --git a/src/components/deposit/new/index.xml b/src/components/deposit/new/index.xml index 9a682e9b..7987f725 100644 --- a/src/components/deposit/new/index.xml +++ b/src/components/deposit/new/index.xml @@ -1,20 +1,10 @@ - - - {{t('common::pay.symbol')}} + + {{t('common::pay.symbol')}} - - + + - - - + + + - + diff --git a/src/components/pay/detail/index.less b/src/components/pay/detail/index.less index 21bf199c..61213780 100644 --- a/src/components/pay/detail/index.less +++ b/src/components/pay/detail/index.less @@ -196,4 +196,5 @@ display: grid; grid-template-columns: 1fr 1fr; gap: 32rpx; + flex: 1; } \ No newline at end of file diff --git a/src/components/pay/detail/index.ts b/src/components/pay/detail/index.ts index 1296e5d2..31995716 100644 --- a/src/components/pay/detail/index.ts +++ b/src/components/pay/detail/index.ts @@ -8,6 +8,7 @@ import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay"; import { merge } from "oak-domain/lib/utils/lodash"; import { canStartPay } from "../../../utils/wpProductFrontend"; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; +import { StartPayFailure } from "../../../types/Exception"; const PayRoutineDict: Record undefined as void, + onPaid: () => undefined as void, + onPayFailure: () => undefined as void, disableAutoPay: false, + closeWhenFailure: false, }, data: { showCloseConfirmMp: false, @@ -228,32 +232,45 @@ export default OakComponent({ async confirmCloseMp() { await this.execute('close'); this.cancelCloseMp(); + const { onClose } = this.props; + onClose && onClose(); }, goBack() { this.navigateBack(); }, async startPay() { + const { onPaid, onClose, onPayFailure } = this.props; const { pay } = this.state; - await PayRoutineDict[pay!.entity].routine(pay as EntityDict['pay']['Schema'], this.features); + try { + await PayRoutineDict[pay!.entity].routine(pay as EntityDict['pay']['Schema'], this.features); + onPaid && onPaid(); + } + catch (err: any) { + if (this.props.closeWhenFailure) { + await this.execute(undefined, undefined, undefined, [ + { + entity: 'pay', + operation: { + id: await generateNewIdAsync(), + action: 'close', + data: {}, + filter: { + id: this.props.oakId!, + }, + }, + } + ]); + onClose && onClose(); + } + else { + onPayFailure && onPayFailure(); + } + this.features.message.setMessage({ + type: 'warning', + content: err.message, + }); + } }, - /* async onWxBridgeReady(payMetaData: any): Promise { - return new Promise( - (resolve, reject) => { - WeixinJSBridge.invoke('getBrandWCPayRequest', payMetaData, - function (res: { err_msg: string }) { - if (res.err_msg == "get_brand_wcpay_request:ok") { - // 使用以上方式判断前端返回,微信团队郑重提示: - //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 - resolve(undefined as void); - } - else { - reject(res.err_msg); - } - } - ); - } - ); - } */ openChannelSelectMp() { this.setState({ showChannelSelectMp: true, diff --git a/src/components/pay/detail/index.xml b/src/components/pay/detail/index.xml index 9adce943..0e509105 100644 --- a/src/components/pay/detail/index.xml +++ b/src/components/pay/detail/index.xml @@ -106,57 +106,62 @@ - - - {{t('pay')}} - - - - + + - {{t('common::action.update')}} - + type="error" + size="long" + bind:lintap="closeMp" + style="flex:1;" + > + {{t('pay:action.close')}} + + + + - {{t('common::reset')}} - - - - - - {{t('pay:action.close')}} - - - - - - {{t('common::back')}} - - + size="long" + bind:lintap="startPay" + type="success" + style="flex:1;" + > + {{t('pay')}} + + + + + + {{t('common::reset')}} + + + {{t('common::action.update')}} + + + + + + {{t('common::back')}} + + + \ No newline at end of file diff --git a/src/components/pay/detail/locales/zh-CN.json b/src/components/pay/detail/locales/zh-CN.json index e1dd2fb4..80819e18 100644 --- a/src/components/pay/detail/locales/zh-CN.json +++ b/src/components/pay/detail/locales/zh-CN.json @@ -16,7 +16,9 @@ "wechatPay": "微信支付", "startPayError": { "illegalPrepayData": "没有有效的预支付数据,可能后台是运行在开发环境,请检查", - "falseEnv": "该订单渠道【%{env}】不匹配当前环境" + "falseEnv": "该订单渠道【%{env}】不匹配当前环境", + "userCancel": "用户取消支付", + "unknown": "用户支付失败" }, "type": { "label": "支付类型", diff --git a/src/components/pay/detail/web.tsx b/src/components/pay/detail/web.tsx index 82ce4112..39da609b 100644 --- a/src/components/pay/detail/web.tsx +++ b/src/components/pay/detail/web.tsx @@ -291,7 +291,24 @@ export default function Render(props: WebComponentProps { + Modal.confirm({ + title: t('cc.title'), + content: t('cc.content'), + onConfirm: async () => { + await execute('close'); + onClose(); + } + }); + }} + > + {t('pay:action.close')} + + ) : startPayable ? (
- ) : closable ? ( - ) : (