coinexchange.go 844 B

12345678910111213141516171819202122232425
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/service/live/wallet/model"
  6. )
  7. const (
  8. _newCoinExchange = "insert into %s (uid, transaction_id, src_type,src_num,dest_type,dest_num,status,exchange_time) values(?,?,?,?,?,?,?,?)"
  9. )
  10. func getCoinExchangeTableIndex(uid int64) string {
  11. return fmt.Sprintf("%02d", uid%10)
  12. }
  13. func getCoinExchangeTable(uid int64) string {
  14. return fmt.Sprintf("t_coin_exchange_%s", getCoinExchangeTableIndex(uid))
  15. }
  16. func (d *Dao) NewCoinExchangeRecord(c context.Context, record *model.CoinExchangeRecord) (int64, error) {
  17. s := fmt.Sprintf(_newCoinExchange, getCoinExchangeTable(record.Uid))
  18. date := model.GetWalletFormatTime(record.ExchangeTime)
  19. return execSqlWithBindParams(d, c, &s, record.Uid, record.TransactionId, record.SrcType, record.SrcNum, record.DestType, record.DestNum, record.Status, date)
  20. }