Compare commits
No commits in common. "b9cf0bcb9fc0ce26c09f509fbbe40135cb1fd631" and "0f03ad32f21da9807f27710aa52a53d2733b7497" have entirely different histories.
b9cf0bcb9f
...
0f03ad32f2
2 changed files with 137 additions and 127 deletions
258
src/DB.hs
258
src/DB.hs
|
@ -22,162 +22,178 @@ import Control.Exception (throwIO)
|
|||
import Control.Monad (forM_, when)
|
||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
import Data.Aeson
|
||||
import Data.Bifunctor (bimap)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.HexString
|
||||
import Data.List (group, sort)
|
||||
import Data.Maybe (catMaybes, fromJust, isJust)
|
||||
import Data.Pool (Pool)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import Data.Time (UTCTime(..))
|
||||
import Data.UUID (UUID)
|
||||
import Data.Word
|
||||
import Database.Esqueleto.Experimental
|
||||
import qualified Database.Persist.MySQL as PM
|
||||
import qualified Database.Persist.Sqlite as PS
|
||||
import Database.Persist.TH
|
||||
|
||||
newtype UuidDB = UuidDB
|
||||
{ getUUID :: UUID
|
||||
} deriving newtype (Eq, Show, Read, ToJSON, FromJSON)
|
||||
|
||||
derivePersistFieldJSON "UuidDB"
|
||||
|
||||
newtype HexStringDB = HexStringDB
|
||||
{ getHex :: HexString
|
||||
} deriving newtype (Eq, Show, Read)
|
||||
|
||||
derivePersistField "HexStringDB"
|
||||
|
||||
share
|
||||
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
||||
[persistLowerCase|
|
||||
ZgoBlock json
|
||||
confs Int default=0
|
||||
network String default=""
|
||||
height Int default=0
|
||||
time Int default=0
|
||||
ZgoBlock
|
||||
block_id Int --Block Id number
|
||||
block_confs Int default=0 -- Block confirnations
|
||||
block_network String default="" -- Block Network
|
||||
block_height Int default=0 -- Block Height
|
||||
block_time Int default=0 -- Block time
|
||||
UniqueBlock block_id
|
||||
deriving Show Eq
|
||||
ZgoBlockTx
|
||||
blocktx_block_id Int
|
||||
blocktx_id Int
|
||||
blocktx_txid String
|
||||
ZgoBlockTx
|
||||
blocktx_block_id Int --'Block Tx parent
|
||||
blocktx_id Int -- Block Tx record Id
|
||||
blocktx_txid String -- Block Tx Id
|
||||
UniqueBlockTx blocktx_block_id blocktx_id
|
||||
deriving Show Eq
|
||||
ZgoCountry json
|
||||
code T.Text
|
||||
name T.Text
|
||||
UniqueCountryCode code
|
||||
ZgoCountry
|
||||
country_code String -- Two Character Country Code
|
||||
country_name String -- Country unique name
|
||||
UniqueCountryCode country_code
|
||||
deriving Show Eq
|
||||
ZgoItem json
|
||||
owner_id Int
|
||||
name T.Text
|
||||
description T.Text default=""
|
||||
cost Double default=0.0
|
||||
ZgoItem
|
||||
item_owner_id Int -- Owner Id
|
||||
item_id String -- Item Id
|
||||
item_name String -- Item name',
|
||||
item_description T.Text default="" -- Item description
|
||||
item_cost Float default=0.0 -- Item Unit price
|
||||
UniqueItemId item_owner item_id
|
||||
deriving Show Eq
|
||||
ZgoLanguages
|
||||
encode_id T.Text
|
||||
name T.Text default-""
|
||||
element T.Text default=""
|
||||
element_text T.Text default=""
|
||||
encode_id String -- Language encoding id
|
||||
view_name String default-"" -- View name that use this language'
|
||||
view_element String default="" -- 'Element name
|
||||
view_element_text T.Text default="" -- Text to be displayed'
|
||||
UniqueLanguage encode_id view_name view_element
|
||||
deriving Show Eq
|
||||
ZgoOrder json
|
||||
owner ZgoOwnerId
|
||||
session ZgoUserId
|
||||
timestamp Int
|
||||
closed Word8
|
||||
currency T.Text
|
||||
price Double
|
||||
total Double
|
||||
totalzec Double
|
||||
paid Bool
|
||||
token T.Text default=""
|
||||
externalInvoice T.Text default=""
|
||||
shortcode T.Text
|
||||
taxamount Double
|
||||
tipamount Double
|
||||
vatamount Double
|
||||
ZgoOrders
|
||||
order_id Int -- Order Id
|
||||
order_zaddress T.Text -- Order zcash address
|
||||
order_session T.Text -- Order session id
|
||||
order_timestamp Int -- Order timestamp
|
||||
order_closed Word8 -- Order closed flag
|
||||
order_currency String -- Order currency
|
||||
order_price Float default=0.0 -- Order ZEC price
|
||||
order_total Float default=0.0 -- Order total amount
|
||||
order_totalzec Float default=0.0 -- Order total in ZEC
|
||||
order_paid Word8 default=0 -- Order paid status
|
||||
order_token String default="" -- Order token
|
||||
order_extinv String default="" -- Order External Invoice
|
||||
order_shortcode String default='' -- Order invoice shortcode
|
||||
order_taxamount Float default=0.0 -- Order tax amount
|
||||
order_tipamount Float default=0.0 -- Order tip amount
|
||||
order_vatamount Float default=0.0 -- Orcer VAT amount'
|
||||
UniqueOrderId order_id
|
||||
deriving Show Eq
|
||||
ZgoOrderLines
|
||||
orderId ZgoOrderId
|
||||
qty Int default=0
|
||||
name T.Text default=""
|
||||
cost Double default=0.0
|
||||
orderline_orderid Int default=0 -- Orderlines Order Id
|
||||
orderline_line Int default=0 -- Orderlines Line number
|
||||
orderline_qty Int default=0 -- Orderline item qty
|
||||
orderline_name T.Text default="" -- Orderline item description
|
||||
orderline_cost Float default=0.0 -- Orderline item cost
|
||||
UniqueOrderLine orderline_orderid orderline_line
|
||||
deriving Show Eq
|
||||
ZgoOwner
|
||||
co_name T.Text
|
||||
firstname T.Text
|
||||
lastname T.Text
|
||||
email T.Text
|
||||
street T.Text
|
||||
city T.Text
|
||||
state T.Text
|
||||
zipcode T.Text
|
||||
phone T.Text
|
||||
country T.Text
|
||||
website T.Text
|
||||
currency T.Text
|
||||
zcaddress T.Text
|
||||
usezats Bool
|
||||
crmtoken T.Text
|
||||
usetax Bool
|
||||
taxvalue Double
|
||||
usevat Bool
|
||||
vat Double
|
||||
payconf Bool
|
||||
viewkey T.Text
|
||||
invoices Bool
|
||||
tips Bool
|
||||
paid Bool
|
||||
expiration UTCTime
|
||||
owner_id Int --'Owner ID number
|
||||
owner_co_name String default="" -- Company''s name
|
||||
owner_firstname String -- Owner's first name
|
||||
owner_lastname String -- Owner's last name
|
||||
owner_email String -- Owner's email address
|
||||
owner_street String -- Owner's street
|
||||
owner_city String -- Owner's city
|
||||
owner_state String -- Owner's state
|
||||
owner_zipcode String -- Owner's zip code
|
||||
owner_phone String -- Owner's phone number
|
||||
owner_country String -- Owner's country
|
||||
owner_website String -- Owner's website URL
|
||||
owner_currency String -- Owner's currency',
|
||||
owner_zcaddress String -- Owner's zcash address
|
||||
owner_usezats Word8 -- Use zats for display
|
||||
owner_crmtoken T.Text -- Owner's crm token
|
||||
owner_usetax Word8 -- Use tax flag
|
||||
owner_taxvalue Float -- Tax rate to use
|
||||
owner_usevat Word8 -- Use vat flag
|
||||
owner_vat Float -- Vat rate to use
|
||||
owner_payconf Word8 -- Confirm payment flag
|
||||
owner_viewkey T.Text -- Viewing Key for payment confirmation
|
||||
owner_invoices Word8 -- Use zgo invoices
|
||||
owner_tips Word8 -- Activate tips
|
||||
owner_paid Word8 -- True if account is paid
|
||||
owner_expiration Int -- Expiration date-time
|
||||
UniqueOwnerId owner_id
|
||||
UniqueOwnerZcashAddr owner_zcaddress
|
||||
deriving Show Eq
|
||||
ZgoPayment
|
||||
delta Int
|
||||
done Bool
|
||||
zaddress T.Text
|
||||
session UuidDB
|
||||
blocktime Int default=0
|
||||
amount Double default=0.0
|
||||
txid HexStringDB
|
||||
memo T.Text
|
||||
payment_id Int -- Payment Id
|
||||
payment_delta Int -- Payment delta
|
||||
payment_done Word8 -- Payment done flag
|
||||
payment_zaddress T.Text -- Payment zcash address
|
||||
payment_session String default="" -- Payment session
|
||||
payment_blocktime Int default=0 -- Payment blocktime
|
||||
payment_amount Float default=0.0 -- Payment amount
|
||||
payment_txid String default ="" -- Payment transaction id
|
||||
payment_memo T.Text default="" -- Payment Memo
|
||||
UniquePaymentId payment_id
|
||||
deriving Show Eq
|
||||
ZgoPrice
|
||||
price_delta Int default=0
|
||||
price_done Bool default=0
|
||||
price_zaddress T.Text default=""
|
||||
price_session String default=""
|
||||
price_blocktime Int default=0
|
||||
price_amount Double default=0.0
|
||||
price_txid String default=""
|
||||
price_memo T.Text default=""
|
||||
price_id Int -- Price Id
|
||||
price_delta Int default=0 -- Price delta
|
||||
price_done Word8 default=0 -- Price done flag
|
||||
price_zaddress T.Text default="" -- Price zcash address
|
||||
price_session String default="" -- Price session
|
||||
price_blocktime Int default=0 -- Price blocktime
|
||||
price_amount Float default=0.0 -- Price amount
|
||||
price_txid String default="" -- Price transaction id
|
||||
price_memo T.Text default="" -- Price Memo
|
||||
UniquePriceId price_id
|
||||
deriving Show Eq
|
||||
ZgoProsession
|
||||
zaddress T.Text default=""
|
||||
expiration UTCTime
|
||||
closed Bool
|
||||
pro_id Int -- Prosession record id
|
||||
pro_zaddress T.Text default="" -- Prosession zcash address
|
||||
pro_expiration Int default=0 -- Prosession expiration date/time
|
||||
pro_closed Word8 default=0 -- Prosession closed flag
|
||||
UniqueProSesId pro_id
|
||||
UniqueProSesZad pro_zaddress
|
||||
deriving Show Eq
|
||||
ZgoTransaction
|
||||
zaddress T.Text default=""
|
||||
expiration Int default=0
|
||||
closed Word8 default=0
|
||||
tx_id Int -- Transaction ID
|
||||
tx_zaddress T.Text default="" -- Transaction Zcash Address
|
||||
tx_expiration Int default=0 -- Transaction Expiration Date/Time
|
||||
tx_closed Word8 default=0 -- Transaction Closed flag
|
||||
UniqueTxId tx_id
|
||||
deriving Show Eq
|
||||
ZgoUser json
|
||||
owner ZgoOwnerId
|
||||
session UuidDB
|
||||
blocktime Int
|
||||
pin T.Text
|
||||
validated Bool
|
||||
ZgoUser
|
||||
user_id Int -- User Id
|
||||
user_zaddress T.Text -- User zcash address,
|
||||
user_session String -- User session id
|
||||
user_blocktime Int -- User block time
|
||||
user_pin String -- User pin
|
||||
user_validated Word8 default=0 -- User validated flag
|
||||
UniqueUserId user_id
|
||||
UniqueUserZad user_zaddress
|
||||
deriving Show Eq
|
||||
ZgoXero
|
||||
client_id T.Text default=""
|
||||
client_secret T.Text default=""
|
||||
xero_id Int -- Xero Id
|
||||
xero_client_id String default="" -- Xero client id
|
||||
xero_client_secret String default="" -- Xero client secret word
|
||||
UniqueXeroId xero_id
|
||||
UniqueXeroClientId xero_client_id
|
||||
deriving Show Eq
|
||||
ZgoXeroToken
|
||||
zaddress T.Text
|
||||
access_token T.Text
|
||||
expires Int
|
||||
refreshtoken T.Text
|
||||
accexpires Int
|
||||
accCode T.Text
|
||||
refexpires Int
|
||||
xerotoken_id Int -- Xero account id
|
||||
xerotoken_zaddress T.Text -- Xero zcash address
|
||||
xerotoken_access_token T.Text -- Xero account access token
|
||||
xerotoken_expires Int -- Xero token expiration date/time
|
||||
xerotoken_refreshtoken String -- Xero refresh token
|
||||
xerotoken_accexpires Int -- Xero account expire date/time
|
||||
xerotoken_accCode String -- Xero account code
|
||||
xerotoken_refexpires Int -- Xero reference expire date/time
|
||||
UniqueXeroTokenId xerotoken_id
|
||||
deriving Show Eq
|
||||
|]
|
||||
|
|
@ -33,7 +33,6 @@ library
|
|||
Xero
|
||||
ZGoBackend
|
||||
ZGoTx
|
||||
DB
|
||||
hs-source-dirs:
|
||||
src
|
||||
build-depends:
|
||||
|
@ -48,10 +47,6 @@ library
|
|||
, configurator
|
||||
, containers
|
||||
, crypto-rng
|
||||
, esqueleto
|
||||
, persistent
|
||||
, persistent-mysql
|
||||
, persistent-template
|
||||
, ghc-prim
|
||||
, hexstring
|
||||
, http-conduit
|
||||
|
@ -59,7 +54,6 @@ library
|
|||
, jwt
|
||||
, megaparsec
|
||||
, memory
|
||||
, monad-logger
|
||||
, mongoDB
|
||||
, network
|
||||
, quickcheck-instances
|
||||
|
|
Loading…
Reference in a new issue