config.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package entity
  2. import (
  3. "app.yhyue.com/moapp/jybase/mysql"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. )
  6. const (
  7. Pay = "base_pay"
  8. )
  9. var (
  10. Mysql *mysql.Mysql
  11. JyMysql *mysql.Mysql
  12. )
  13. //支付配置
  14. var PayConf map[string]interface{}
  15. var AliPayConf map[string]interface{}
  16. var WxPayConf map[string]interface{}
  17. type CallBackParam struct {
  18. TotalFee int //订单价格
  19. CashFee int //支付金额
  20. OutTradeno string //订单号(微信支付宝支付使用)
  21. TimeEnd string //支付时间
  22. TransactionId string //商户单号(微信支付宝支付)
  23. Openid string //位置用户标识(仅微信有)
  24. OrderCode string //线下支付使用
  25. }
  26. func init() {
  27. //qutil.ReadConfig("./pay_config.json", &PayConf)
  28. //AliPayConf = PayConf["aliPay"].(map[string]interface{})
  29. //WxPayConf = PayConf["wxPay"].(map[string]interface{})
  30. }
  31. func InitMysql(m, n *mysql.Mysql) {
  32. Mysql = &mysql.Mysql{
  33. Address: m.Address,
  34. UserName: m.UserName,
  35. PassWord: m.PassWord,
  36. DBName: m.DBName,
  37. MaxOpenConns: m.MaxOpenConns,
  38. MaxIdleConns: m.MaxIdleConns,
  39. }
  40. Mysql.Init()
  41. JyMysql = &mysql.Mysql{
  42. Address: n.Address,
  43. UserName: n.UserName,
  44. PassWord: n.PassWord,
  45. DBName: n.DBName,
  46. MaxOpenConns: n.MaxOpenConns,
  47. MaxIdleConns: n.MaxIdleConns,
  48. }
  49. JyMysql.Init()
  50. logx.Info("初始化mysql")
  51. }
  52. // func (param *CallBackParam) SaveWxPayRecord() (insert bool) {
  53. // pay_count := util.Mysql.Count("weixin_pay", map[string]interface{}{
  54. // "transaction_id": param.TransactionId,
  55. // "out_trade_no": param.OutTradeno,
  56. // "user_openid": param.Openid,
  57. // })
  58. // if pay_count == 0 {
  59. // now := time.Now()
  60. // insert = util.Mysql.Insert("weixin_pay", map[string]interface{}{
  61. // "transaction_id": param.TransactionId,
  62. // "out_trade_no": param.OutTradeno,
  63. // "user_openid": param.Openid,
  64. // "create_time": qutil.FormatDate(&now, qutil.Date_Full_Layout),
  65. // "total_fee": param.TotalFee,
  66. // "cash_fee": param.CashFee,
  67. // "time_end": param.TimeEnd,
  68. // }) > 0
  69. // } else if pay_count > 0 {
  70. // insert = true
  71. // }
  72. // return
  73. // }
  74. // func (param *CallBackParam) SaveAliPayRecord() (insert bool) {
  75. // //支付完成插入
  76. // pay_count := util.Mysql.Count("ali_pay", map[string]interface{}{
  77. // "transaction_id": param.TransactionId,
  78. // "out_trade_no": param.OutTradeno,
  79. // })
  80. // if pay_count == 0 {
  81. // now := time.Now()
  82. // insert = util.Mysql.Insert("ali_pay", map[string]interface{}{
  83. // "transaction_id": param.TransactionId,
  84. // "out_trade_no": param.OutTradeno,
  85. // "create_time": qutil.FormatDate(&now, qutil.Date_Full_Layout),
  86. // "total_fee": param.TotalFee,
  87. // "cash_fee": param.CashFee,
  88. // "time_end": param.TimeEnd,
  89. // }) > 0
  90. // } else {
  91. // insert = true
  92. // }
  93. // return
  94. // }