json.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. package config
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "log"
  6. "os"
  7. "time"
  8. slog "bet24.com/log"
  9. uuid "github.com/satori/go.uuid"
  10. )
  11. var Server struct {
  12. LogLevel string
  13. FileLevel string
  14. LogPath string
  15. Port int
  16. Login string
  17. Password string
  18. Database string
  19. Datasource string
  20. ChannelUrl string
  21. ChannelPassword string
  22. RedisDB int
  23. PaymentID string
  24. MonitorPort int
  25. WSAddr string
  26. CertFile string
  27. KeyFile string
  28. MaxConnNum int
  29. LastDay int
  30. WebPort int
  31. WebKey string
  32. TlsPort int // HTTPS 端口
  33. TlsCert string // HTTPS 证书FILE
  34. TlsKey string // HTTPS 证书KEY
  35. ServiceAddr string
  36. Updates []UpdateInfo
  37. Cropay // 第三方支付信息
  38. ZShuiPay // 聚合支付信息
  39. KayaPay // Kaya支付信息
  40. LetsPay // lets支付信息
  41. LiuPay // liu支付信息
  42. TopPay // toppay 支付信息
  43. FlashPay // flash 支付信息
  44. PayerMax // payerMax 支付信息
  45. DingpeiPay // dingpei 支付信息
  46. CrushPay // crush 支付信息
  47. OPay // oPay 支付信息
  48. PayMob // payMob 支付信息
  49. Fawry // fawry 支付信息
  50. Coda // coda 支付信息
  51. LaPay // la 支付信息
  52. Huawei //华为支付配置信息
  53. PackageName string
  54. Facebooks []Facebook `json:"facebook"` // facebook 信息
  55. Facebook_KEY string `json:"facebook.key"`
  56. Facebook_STATUS_URL string `json:"facebook.status_url"`
  57. // 头像
  58. UploadDir string // 上传存储路径 "d:/wwwroot/domino.ss2007.com/face"
  59. UploadUrl string // 访问路径 "http://domino.ss2007.com/face"
  60. }
  61. type UpdateInfo struct {
  62. Version int
  63. PartnerId string
  64. Title string
  65. Desc string
  66. Url string
  67. }
  68. // cropay 第三方支付信息
  69. type Cropay struct {
  70. Merchant_id int `json:"cropay.merchant_id"`
  71. Order_hash string `json:"cropay.order_hash"`
  72. Url_pay_order string `json:"cropay.url_pay_order"`
  73. Url_sync string `json:"cropay.url_sync"`
  74. Url_succ_back string `json:"cropay.url_succ_back"`
  75. Url_fail_back string `json:"cropay.url_fail_back"`
  76. Url_referrer_domain string `json:"cropay.url_referrer_domain"`
  77. Url_resultPay string `json:"cropay.url_resultPay"`
  78. }
  79. // 聚合支付
  80. type ZShuiPay struct {
  81. GymchtId string `json:"zshuipay.gymchtId"`
  82. GymKey string `json:"zshuipay.gymKey"`
  83. Url_pay_order string `json:"zshuipay.url_pay_order"`
  84. Url_pay_callback string `json:"zshuipay.url_pay_callback"`
  85. Url_pay_notify string `json:"zshuipay.url_pay_notify"`
  86. Url_withdraw_order string `json:"zshuipay.url_withdraw_order"`
  87. Url_withdraw_notify string `json:"zshuipay.url_withdraw_notify"`
  88. Url_withdraw_queryAccount string `json:"zshuipay.url_withdraw_queryAccount"`
  89. }
  90. // kaya支付
  91. type KayaPay struct {
  92. MerchantCode string `json:"kayapay.merchantCode"`
  93. PLAT_PUBLIC_KEY string `json:"kayapay.platform_pubKey"`
  94. MCH_PRIVATE_KEY string `json:"kayapay.merchant_priKey"`
  95. Url_pay_order string `json:"kayapay.url_pay_order"`
  96. Url_pay_notify string `json:"kayapay.url_pay_notify"`
  97. Url_withdraw_order string `json:"kayapay.url_withdraw_order"`
  98. Url_withdraw_notify string `json:"kayapay.url_withdraw_notify"`
  99. Url_queryAccount string `json:"kayapay.url_queryAccount"`
  100. }
  101. // lets支付
  102. type LetsPay struct {
  103. MchId string `json:"letspay.mchId"`
  104. MD5Key string `json:"letspay.key"`
  105. Url_pay_order string `json:"letspay.url_pay_order"`
  106. Url_pay_notify string `json:"letspay.url_pay_notify"`
  107. Url_pay_return string `json:"letspay.url_pay_return"`
  108. Url_withdraw_order string `json:"letspay.url_withdraw_order"`
  109. Url_witdraw_notify string `json:"letspay.url_withdraw_notify"`
  110. Url_queryAccount string `json:"letspay.url_queryAccount"`
  111. }
  112. // liu 支付
  113. type LiuPay struct {
  114. MerchantCode string `json:"liupay.merchantCode"`
  115. MD5Key string `json:"liupay.key"`
  116. Url_pay_order string `json:"liupay.url_pay_order"`
  117. Url_pay_notify string `json:"liupay.url_pay_notify"`
  118. Url_pay_page string `json:"liupay.url_pay_page"`
  119. Url_withdraw_order string `json:"liupay.url_withdraw_order"`
  120. Url_withdraw_search string `json:"liupay.url_withdraw_search"`
  121. }
  122. // topPay 支付
  123. type TopPay struct {
  124. MerchantCode string `json:"toppay.merchantCode"`
  125. PLAT_PUBLIC_KEY string `json:"toppay.platform_pubKey"`
  126. MCH_PRIVATE_KEY string `json:"toppay.merchant_priKey"`
  127. Url_pay_order string `json:"toppay.url_pay_order"`
  128. Url_pay_notify string `json:"toppay.url_pay_notify"`
  129. Url_withdraw_order string `json:"toppay.url_withdraw_order"`
  130. Url_withdraw_notify string `json:"toppay.url_withdraw_notify"`
  131. Url_queryAccount string `json:"toppay.url_queryAccount"`
  132. }
  133. // facebook
  134. type Facebook struct {
  135. APP_ID string `json:"app_id"`
  136. APP_SECRET string `json:"app_secret"`
  137. }
  138. // Flash支付
  139. type FlashPay struct {
  140. MerchantCode string `json:"flashpay.merchantCode"`
  141. PLAT_PUBLIC_KEY string `json:"flashpay.platform_pubKey"`
  142. MCH_PRIVATE_KEY string `json:"flashpay.merchant_priKey"`
  143. Url_pay_order string `json:"flashpay.url_pay_order"`
  144. Url_pay_notify string `json:"flashpay.url_pay_notify"`
  145. Url_withdraw_order string `json:"flashpay.url_withdraw_order"`
  146. Url_withdraw_notify string `json:"flashpay.url_withdraw_notify"`
  147. Url_queryAccount string `json:"flashpay.url_queryAccount"`
  148. }
  149. // payerMax支付
  150. type PayerMax struct {
  151. MerchantAppId string `json:"payerMax.merchantAppId"`
  152. MerchantNo string `json:"payerMax.merchantNo"`
  153. PLAT_PUBLIC_KEY string `json:"payerMax.platform_pubKey"`
  154. MCH_PRIVATE_KEY string `json:"payerMax.merchant_priKey"`
  155. Url_pay_order string `json:"payerMax.url_pay_order"`
  156. Url_pay_Notify string `json:"payerMax.url_pay_notify"`
  157. Url_withdraw_order string `json:"payerMax.url_withdraw_order"`
  158. Url_withdraw_Notify string `json:"payerMax.url_withdraw_notify"`
  159. FrontCallbackUrl string `json:"payerMax.frontCallbackUrl"`
  160. }
  161. // Dingpei 支付
  162. type DingpeiPay struct {
  163. MerchantNo string `json:"dingpeipay.merchantNo"`
  164. MD5Key string `json:"dingpeipay.key"`
  165. Type string `json:"dingpeipay.type"`
  166. Url_pay_order string `json:"dingpeipay.url_pay_order"`
  167. Url_pay_notify string `json:"dingpeipay.url_pay_notify"`
  168. Url_pay_page string `json:"dingpeipay.url_pay_page"`
  169. Url_withdraw_order string `json:"dingpeipay.url_withdraw_order"`
  170. Url_withdraw_notify string `json:"dingpeipay.url_withdraw_notify"`
  171. Url_withdraw_search string `json:"dingpeipay.url_withdraw_search"`
  172. }
  173. // crush支付
  174. type CrushPay struct {
  175. MerchantAppId string `json:"crushpay.merchantAppId"`
  176. MerchantKey string `json:"crushpay.merchantKey"`
  177. Url_pay_order string `json:"crushpay.url_pay_order"`
  178. Url_pay_Notify string `json:"crushpay.url_pay_notify"`
  179. Url_withdraw_order string `json:"crushpay.url_withdraw_order"`
  180. Url_withdraw_Notify string `json:"crushpay.url_withdraw_notify"`
  181. }
  182. // OPay 支付
  183. type OPay struct {
  184. MerchantId string `json:"oPay.merchantId"`
  185. SecretKey string `json:"oPay.secretKey"`
  186. PublicKey string `json:"oPay.publicKey"`
  187. Url_pay_order string `json:"oPay.url_pay_order"`
  188. Url_pay_Notify string `json:"oPay.url_pay_notify"`
  189. Url_pay_Return string `json:"oPay.url_pay_return"`
  190. }
  191. // PayMob 支付
  192. type PayMob struct {
  193. HMAC string `json:"payMob.HMAC"`
  194. Api_Key string `json:"payMob.api_key"`
  195. Integration_Id int `json:"payMob.integration_id"`
  196. Url_Auth_Token string `json:"payMob.url_auth_token"`
  197. Url_Order_Register string `json:"payMob.url_order_register"`
  198. Url_Payment_Token string `json:"payMob.url_payment_token"`
  199. Url_Payment_CashPay string `json:"payMob.url_payment_cashPay"`
  200. }
  201. // fawry 支付
  202. type Fawry struct {
  203. MerchantCode string `json:"fawry.merchantCode"`
  204. SecureKey string `json:"fawry.secureKey"`
  205. Url_pay_order string `json:"fawry.url_pay_order"`
  206. }
  207. // coda 支付
  208. type Coda struct {
  209. ApiKeys []CodaKey `json:"coda.apiKeys"`
  210. Url_pay_init string `json:"coda.url_pay_init"`
  211. Url_pay_begin string `json:"coda.url_pay_begin"`
  212. Url_pay_Notify string `json:"coda.url_pay_notify"`
  213. Url_pay_Return string `json:"coda.url_pay_return"`
  214. }
  215. type CodaKey struct {
  216. Currency string `json:"currency"`
  217. CountryCode int `json:"countryCode"`
  218. CurrencyCode int `json:"currencyCode"`
  219. ApiKey string `json:"apiKey"`
  220. PaymentTypes []int `json:"paymentTypes"`
  221. }
  222. // laPay 支付
  223. type LaPay struct {
  224. MerchantNo string `json:"lapay.merchantNo"`
  225. MerchantCode string `json:"lapay.merchantCode"`
  226. PlatPublicKey string `json:"lapay.platPublicKey"`
  227. MchPrivateKey string `json:"lapay.mchPrivateKey"`
  228. UrlPayOrder string `json:"lapay.urlPayOrder"`
  229. UrlPayNotify string `json:"lapay.urlPayNotify"`
  230. CallbackUrl string `json:"LaPay.CallbackUrl"`
  231. }
  232. // 华为支付配置信息
  233. type Huawei struct {
  234. ClientSecret string `json:"huawei.ClientSecret"`
  235. ClientId string `json:"huawei.ClientId"`
  236. TokenUrl string `json:"huawei.TokenUrl"`
  237. ApplicationPublicKey string `json:"huawei.ApplicationPublicKey"`
  238. }
  239. func Run() {
  240. data, err := os.ReadFile("fishconf/payment.json")
  241. if err != nil {
  242. log.Fatalf("%v", err)
  243. }
  244. fmt.Println(string(data))
  245. err = json.Unmarshal(data, &Server)
  246. if err != nil {
  247. log.Fatalf("%v", err)
  248. }
  249. logger, err := slog.New(Server.LogLevel, Server.FileLevel, Server.LogPath, log.LstdFlags)
  250. if err == nil {
  251. slog.Export(logger)
  252. }
  253. id, _ := uuid.NewV4()
  254. Server.PaymentID = id.String()
  255. //slog.Debug("Server.PaymentID = %v", Server.PaymentID)
  256. if Server.MonitorPort == 0 {
  257. Server.MonitorPort = Server.WebPort + 100
  258. }
  259. if Server.PackageName == "" {
  260. Server.PackageName = "com.shengsheng.domino"
  261. }
  262. now := time.Now()
  263. Server.LastDay = now.Day()
  264. refreshLogFile()
  265. }
  266. func refreshLogFile() {
  267. time.AfterFunc(10*time.Minute, refreshLogFile)
  268. doRefreshLogFile()
  269. }
  270. func doRefreshLogFile() {
  271. if Server.LogPath != "" {
  272. now := time.Now()
  273. if now.Day() != Server.LastDay {
  274. Server.LastDay = now.Day()
  275. slog.RecreateFileLog(Server.LogPath, log.LstdFlags)
  276. }
  277. }
  278. }