123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- package charge_utils
- import (
- "time"
- )
- const (
- BillPeriodMonth = 1
- BillPeriodThreeMonth = 2
- BillPeriodSixMonth = 3
- BillPeriodYear = 4
- )
- const (
- ObjTypeHouse = 1
- ObjTypeSpace = 2
- ObjTypeVehicle = 3
- )
- const (
- PayStatusUnPay = 1 // 待支付
- PayStatusPayed = 2 // 已支付
- )
- const (
- ChargeBasisArea = 1
- ChargeBasisUsedArea = 2
- ChargeBasisSpaceArea = 3
- ChargeBasisUsed = 4
- ChargeBasisFix = 5
- ChargeBasisSelf = 6
- )
- const (
- // 周期
- ChargeTimeTypePeriod = 1
- // 一次性
- ChargeTimeTypeOne = 2
- )
- const (
- // 预付
- ChargePayTypeBefor = 1
- // 后付
- ChargePayTypeAfter = 2
- )
- //1 现金 2 微信 3 支付宝 4 pos 5 转账
- const (
- ChargePayModeCash = 1
- ChargePayModeWx = 2
- ChargePayModeAli = 3
- ChargePayModePos = 4
- ChargePayModeCard = 5
- )
- const (
- // 单价
- ChargeValuationByUnit = 1
- // 阶梯价
- ChargeValuationByStep = 2
- )
- const (
- // 不催缴
- UrgeTypeNone = 1
- // 每年1月1号
- UrgeTypeYearMonthDay = 2
- // 每月1月1号
- UrgeTypeMonthDay = 3
- // 每日
- UrgeTypeDay = 4
- )
- var BillPeriodM = map[int32]string{
- BillPeriodMonth : "按月",
- BillPeriodThreeMonth: "按季度",
- BillPeriodSixMonth: "按半年",
- BillPeriodYear : "按一年",
- }
- var ChargeBasisM = map[int32]string{
- ChargeBasisArea: "按房屋面积",
- ChargeBasisUsedArea: "按使用面积",
- ChargeBasisSpaceArea: "按车位面积",
- ChargeBasisUsed: "按使用量",
- ChargeBasisFix:"固定费用",
- ChargeBasisSelf:"自定义",
- }
- var ChargeTypeM = map[int32]string{
- ChargeTypeProperty: "物业费",
- ChargeTypeWater: "水费",
- ChargeTypeElectricity: "电费",
- ChargeTypeGas: "气费",
- ChargeTypeSpace: "车位管理费",
- ChargeTypeVehicle: "月租停车费",
- ChargeTypeOther: "其他",
- }
- var IsPowerChargeType = map[int32]bool{
- ChargeTypeProperty: false,
- ChargeTypeWater: true,
- ChargeTypeElectricity: true,
- ChargeTypeGas: true,
- ChargeTypeSpace: false,
- ChargeTypeVehicle: false,
- ChargeTypeOther: false,
- }
- var IsOtherChargeType = map[int32]bool{
- ChargeTypeProperty: false,
- ChargeTypeWater: false,
- ChargeTypeElectricity: false,
- ChargeTypeGas: false,
- ChargeTypeSpace: false,
- ChargeTypeVehicle: false,
- ChargeTypeOther: true,
- }
- const (
- ChargeTypeProperty = 1
- ChargeTypeWater = 2
- ChargeTypeElectricity = 3
- ChargeTypeGas = 4
- ChargeTypeSpace = 5
- ChargeTypeVehicle = 6
- ChargeTypeOther = 99
- )
- var ChargeTimeTypeM = map[int32]string{
- 1: "周期收费",
- 2: "一次收费",
- }
- var ChargePayTypeM = map[int32]string{
- 1: "预付费",
- 2: "后付费",
- }
- var UrgeTypeM = map[int32]string{
- 1: "不催缴",
- 2: "每年1月1日",
- 3: "每月1月1日",
- 4: "每日",
- }
- var ValuationTypeM = map[int32]string{
- 1: "按单价",
- 2: "按阶梯价",
- }
- var UrgeMsgTypeM = map[int32]string{
- 1: "短信",
- 2: "微信",
- 3: "app、小程序",
- }
- var ChargeModeM = map[int32]string{
- 1: "现金",
- 2: "微信",
- 3: "支付宝",
- 4: "pos",
- 5: "转账",
- }
- // 缴费集合的前缀
- const ChargeCachePrefix = "PropertyChargePay_"
- // 催缴集合的前缀
- const UrgeDayCachePrefix = "PropertyChargeUrgeDay"
- // 催缴集合的前缀
- const UrgeMonthCachePrefix = "PropertyChargeUrgeMonth"
- // 催缴集合的前缀
- const UrgeYearCachePrefix = "PropertyChargeUrgeYear"
- // 周期性缴费的缴费结束时间
- //const ChargeEndTimePrefix = "PropertyChargeEndTime_"
- func GetChargeEnd(start int64, months int64) int64 {
- startT := time.Unix(start, 0)
- day := startT.Day()
- month := int(startT.Month())
- year := startT.Year()
- if months == 0 {
- return start
- }
- // 普通日期
- if day < 28 {
- return startT.AddDate(0, int(months), 0).Unix()
- }
- for i := months; i > 0; i-- {
- month += 1
- if month > 12 {
- month = 1
- year += 1
- }
- }
- // 目标月份的最后一天
- monthLastDay := time.Date(year, time.Month(month+1), 1, 0, 0, 0, 0, startT.Location()).AddDate(0, 0, -1).Day()
- if day > monthLastDay {
- day = monthLastDay
- }
- return time.Date(year, time.Month(month), day, startT.Hour(), startT.Minute(), startT.Second(), startT.Nanosecond(), startT.Location()).Unix()
- }
|