esoftplay-event
Version:
event module on esoftplay framework
34 lines (24 loc) • 756 B
text/typescript
// useLibs
import { UserClass } from 'esoftplay/cache/user/class/import';
import useGlobalState, { useGlobalReturn } from 'esoftplay/global';
export interface EventTransactionArgs {
}
export interface EventTransactionProps {
}
export interface EventTransactionReturn {
getTrxId: () => string
}
const stateTrxId = useGlobalState<number>(undefined, { persistKey: 'event/transaction' })
export function state(): useGlobalReturn<any> {
return stateTrxId
}
export function createTrxId() {
let user = UserClass.state().get()
let time = (new Date().getTime() / 1000).toFixed()
return time + "" + user?.id + "" + (Math.random() * 101).toFixed(0)
}
export default function m(): EventTransactionReturn {
return {
getTrxId: createTrxId
}
}