consts.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package charge_utils
  2. import (
  3. "time"
  4. )
  5. const (
  6. BillPeriodMonth = 1
  7. BillPeriodThreeMonth = 2
  8. BillPeriodSixMonth = 3
  9. BillPeriodYear = 4
  10. )
  11. const (
  12. ObjTypeHouse = 1
  13. ObjTypeSpace = 2
  14. ObjTypeVehicle = 3
  15. )
  16. const (
  17. PayStatusUnPay = 1 // 待支付
  18. PayStatusPayed = 2 // 已支付
  19. )
  20. const (
  21. ChargeBasisArea = 1
  22. ChargeBasisUsedArea = 2
  23. ChargeBasisSpaceArea = 3
  24. ChargeBasisUsed = 4
  25. ChargeBasisFix = 5
  26. ChargeBasisSelf = 6
  27. )
  28. const (
  29. // 周期
  30. ChargeTimeTypePeriod = 1
  31. // 一次性
  32. ChargeTimeTypeOne = 2
  33. )
  34. const (
  35. // 预付
  36. ChargePayTypeBefor = 1
  37. // 后付
  38. ChargePayTypeAfter = 2
  39. )
  40. //1 现金 2 微信 3 支付宝 4 pos 5 转账
  41. const (
  42. ChargePayModeCash = 1
  43. ChargePayModeWx = 2
  44. ChargePayModeAli = 3
  45. ChargePayModePos = 4
  46. ChargePayModeCard = 5
  47. )
  48. const (
  49. // 单价
  50. ChargeValuationByUnit = 1
  51. // 阶梯价
  52. ChargeValuationByStep = 2
  53. )
  54. const (
  55. // 不催缴
  56. UrgeTypeNone = 1
  57. // 每年1月1号
  58. UrgeTypeYearMonthDay = 2
  59. // 每月1月1号
  60. UrgeTypeMonthDay = 3
  61. // 每日
  62. UrgeTypeDay = 4
  63. )
  64. var BillPeriodM = map[int32]string{
  65. BillPeriodMonth : "按月",
  66. BillPeriodThreeMonth: "按季度",
  67. BillPeriodSixMonth: "按半年",
  68. BillPeriodYear : "按一年",
  69. }
  70. var ChargeBasisM = map[int32]string{
  71. ChargeBasisArea: "按房屋面积",
  72. ChargeBasisUsedArea: "按使用面积",
  73. ChargeBasisSpaceArea: "按车位面积",
  74. ChargeBasisUsed: "按使用量",
  75. ChargeBasisFix:"固定费用",
  76. ChargeBasisSelf:"自定义",
  77. }
  78. var ChargeTypeM = map[int32]string{
  79. ChargeTypeProperty: "物业费",
  80. ChargeTypeWater: "水费",
  81. ChargeTypeElectricity: "电费",
  82. ChargeTypeGas: "气费",
  83. ChargeTypeSpace: "车位管理费",
  84. ChargeTypeVehicle: "月租停车费",
  85. ChargeTypeOther: "其他",
  86. }
  87. var IsPowerChargeType = map[int32]bool{
  88. ChargeTypeProperty: false,
  89. ChargeTypeWater: true,
  90. ChargeTypeElectricity: true,
  91. ChargeTypeGas: true,
  92. ChargeTypeSpace: false,
  93. ChargeTypeVehicle: false,
  94. ChargeTypeOther: false,
  95. }
  96. var IsOtherChargeType = map[int32]bool{
  97. ChargeTypeProperty: false,
  98. ChargeTypeWater: false,
  99. ChargeTypeElectricity: false,
  100. ChargeTypeGas: false,
  101. ChargeTypeSpace: false,
  102. ChargeTypeVehicle: false,
  103. ChargeTypeOther: true,
  104. }
  105. const (
  106. ChargeTypeProperty = 1
  107. ChargeTypeWater = 2
  108. ChargeTypeElectricity = 3
  109. ChargeTypeGas = 4
  110. ChargeTypeSpace = 5
  111. ChargeTypeVehicle = 6
  112. ChargeTypeOther = 99
  113. )
  114. var ChargeTimeTypeM = map[int32]string{
  115. 1: "周期收费",
  116. 2: "一次收费",
  117. }
  118. var ChargePayTypeM = map[int32]string{
  119. 1: "预付费",
  120. 2: "后付费",
  121. }
  122. var UrgeTypeM = map[int32]string{
  123. 1: "不催缴",
  124. 2: "每年1月1日",
  125. 3: "每月1月1日",
  126. 4: "每日",
  127. }
  128. var ValuationTypeM = map[int32]string{
  129. 1: "按单价",
  130. 2: "按阶梯价",
  131. }
  132. var UrgeMsgTypeM = map[int32]string{
  133. 1: "短信",
  134. 2: "微信",
  135. 3: "app、小程序",
  136. }
  137. var ChargeModeM = map[int32]string{
  138. 1: "现金",
  139. 2: "微信",
  140. 3: "支付宝",
  141. 4: "pos",
  142. 5: "转账",
  143. }
  144. // 缴费集合的前缀
  145. const ChargeCachePrefix = "PropertyChargePay_"
  146. // 催缴集合的前缀
  147. const UrgeDayCachePrefix = "PropertyChargeUrgeDay"
  148. // 催缴集合的前缀
  149. const UrgeMonthCachePrefix = "PropertyChargeUrgeMonth"
  150. // 催缴集合的前缀
  151. const UrgeYearCachePrefix = "PropertyChargeUrgeYear"
  152. // 周期性缴费的缴费结束时间
  153. //const ChargeEndTimePrefix = "PropertyChargeEndTime_"
  154. func GetChargeEnd(start int64, months int64) int64 {
  155. startT := time.Unix(start, 0)
  156. day := startT.Day()
  157. month := int(startT.Month())
  158. year := startT.Year()
  159. if months == 0 {
  160. return start
  161. }
  162. // 普通日期
  163. if day < 28 {
  164. return startT.AddDate(0, int(months), 0).Unix()
  165. }
  166. for i := months; i > 0; i-- {
  167. month += 1
  168. if month > 12 {
  169. month = 1
  170. year += 1
  171. }
  172. }
  173. // 目标月份的最后一天
  174. monthLastDay := time.Date(year, time.Month(month+1), 1, 0, 0, 0, 0, startT.Location()).AddDate(0, 0, -1).Day()
  175. if day > monthLastDay {
  176. day = monthLastDay
  177. }
  178. return time.Date(year, time.Month(month), day, startT.Hour(), startT.Minute(), startT.Second(), startT.Nanosecond(), startT.Location()).Unix()
  179. }