telecom.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package telecom
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/library/log"
  6. xtime "go-common/library/time"
  7. )
  8. type TelecomJSON struct {
  9. FlowpackageID int `json:"flowPackageId"`
  10. FlowPackageSize int `json:"flowPackageSize"`
  11. FlowPackageType int `json:"flowPackageType"`
  12. TrafficAttribution int `json:"trafficAttribution"`
  13. BeginTime string `json:"beginTime"`
  14. EndTime string `json:"endTime"`
  15. IsMultiplyOrder int `json:"isMultiplyOrder"`
  16. SettlementType int `json:"settlementType"`
  17. Operator int `json:"operator"`
  18. OrderStatus int `json:"orderStatus"`
  19. RemainedRebindNum int `json:"remainedRebindNum"`
  20. MaxbindNum int `json:"maxBindNum"`
  21. OrderID string `json:"orderId"`
  22. SignNo string `json:"signNo"`
  23. AccessToken string `json:"accessToken"`
  24. PhoneID string `json:"phoneId"`
  25. IsRepeatOrder int `json:"isRepeatOrder"`
  26. PayStatus int `json:"payStatus"`
  27. PayTime string `json:"payTime"`
  28. PayChannel int `json:"payChannel"`
  29. SignStatus string `json:"signStatus "`
  30. RefundStatus int `json:"refundStatus"`
  31. PayResult *PayResultJSON `json:"payResult,omitempty"`
  32. }
  33. type PayResultJSON struct {
  34. IsRepeatOrder int `json:"isRepeatOrder"`
  35. RefundStatus int `json:"refundStatus"`
  36. PayStatus int `json:"payStatus"`
  37. PayChannel int `json:"payChannel"`
  38. }
  39. type TelecomOrderJson struct {
  40. RequestNo string `json:"requestNo"`
  41. ResultType int `json:"resultType"`
  42. Detail *TelecomJSON `json:"detail"`
  43. }
  44. type TelecomRechargeJson struct {
  45. RequestNo string `json:"requestNo"`
  46. ResultType int `json:"resultType"`
  47. Detail *RechargeJSON `json:"detail"`
  48. }
  49. type RechargeJSON struct {
  50. RequestNo string `json:"requestNo"`
  51. FcRechargeNo string `json:"fcRechargeNo"`
  52. RechargeStatus int `json:"rechargeStatus"`
  53. OrderTotalSize int `json:"orderTotalSize"`
  54. FlowBalance int `json:"flowBalance"`
  55. }
  56. type OrderInfo struct {
  57. PhoneID int `json:"phone"`
  58. OrderID int64 `json:"orderid"`
  59. OrderState int `json:"order_status"`
  60. IsRepeatorder int `json:"isrepeatorder"`
  61. SignNo string `json:"sign_no"`
  62. Begintime xtime.Time `json:"begintime"`
  63. Endtime xtime.Time `json:"endtime"`
  64. }
  65. type Pay struct {
  66. OrderID int64 `json:"orderid"`
  67. RequestNo int64 `json:"requestno,omitempty"`
  68. PayURL string `json:"pay_url,omitempty"`
  69. }
  70. type SucOrder struct {
  71. FlowPackageID string `json:"flowPackageId,omitempty"`
  72. Domain string `json:"domain"`
  73. Port string `json:"port,omitempty"`
  74. PortInt int `json:"portInt"`
  75. KeyEffectiveDuration int `json:"keyEffectiveDuration"`
  76. OrderKey string `json:"orderKey"`
  77. FlowBalance int `json:"flowBalance"`
  78. FlowPackageSize int `json:"flowPackageSize"`
  79. AccessToken string `json:"accessToken"`
  80. OrderIDStr string `json:"orderId,omitempty"`
  81. OrderID int64 `json:"orderid"`
  82. }
  83. type OrderFlow struct {
  84. FlowBalance int `json:"flowBalance"`
  85. }
  86. type PhoneConsent struct {
  87. Consent int `json:"consent"`
  88. }
  89. type TelecomMessageJSON struct {
  90. PhoneID string `json:"phoneId"`
  91. ResultType int `json:"resultType"`
  92. ResultMessage string `json:"resultMsg"`
  93. }
  94. type OrderState struct {
  95. FlowBalance int `json:"flowBalance,omitempty"`
  96. FlowSize int `json:"flow_size"`
  97. OrderState int `json:"order_state"`
  98. Endtime xtime.Time `json:"endtime,omitempty"`
  99. IsRepeatorder int `json:"is_repeatorder"`
  100. }
  101. type OrderPhoneState struct {
  102. FlowPackageID int `json:"flowPackageId"`
  103. FlowSize int `json:"flowPackageSize"`
  104. OrderState int `json:"orderStatus"`
  105. PhoneStr string `json:"phoneId"`
  106. }
  107. func (s *TelecomJSON) TelecomJSONChange() {
  108. if s.PayResult != nil {
  109. s.IsRepeatOrder = s.PayResult.IsRepeatOrder
  110. s.RefundStatus = s.PayResult.RefundStatus
  111. s.PayStatus = s.PayResult.PayStatus
  112. s.PayChannel = s.PayResult.PayChannel
  113. }
  114. }
  115. func (t *OrderInfo) OrderInfoJSONChange(tjson *TelecomJSON) {
  116. t.PhoneID, _ = strconv.Atoi(tjson.PhoneID)
  117. t.OrderID, _ = strconv.ParseInt(tjson.OrderID, 10, 64)
  118. t.OrderState = tjson.OrderStatus
  119. t.IsRepeatorder = tjson.IsRepeatOrder
  120. t.SignNo = tjson.SignNo
  121. t.Begintime = timeStrToInt(tjson.BeginTime)
  122. t.Endtime = timeStrToInt(tjson.EndTime)
  123. t.TelecomChange()
  124. }
  125. // timeStrToInt
  126. func timeStrToInt(timeStr string) (timeInt xtime.Time) {
  127. var err error
  128. timeLayout := "2006-01-02 15:04:05"
  129. loc, _ := time.LoadLocation("Local")
  130. theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
  131. if err = timeInt.Scan(theTime); err != nil {
  132. log.Error("timeInt.Scan error(%v)", err)
  133. }
  134. return
  135. }
  136. // TelecomChange
  137. func (t *OrderInfo) TelecomChange() {
  138. if t.Begintime.Time().IsZero() {
  139. t.Begintime = 0
  140. }
  141. if t.Endtime.Time().IsZero() {
  142. t.Endtime = 0
  143. }
  144. }