diff --git a/common/config/config.go b/common/config/config.go index b80d49c..ea672d7 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -38,10 +38,11 @@ type Redis struct { type QyWeixin struct { Corpid string `toml:"corpid"` - CheckinAgent string `toml:"checkin_agent"` - CheckinSecret string `toml:"checkin_secret"` - CheckinGroup string `toml:"checkin_group"` - CheckinPayThresold float64 `toml:"checkin_pay_thresold"` + CheckinAgent string `toml:"checkin_agent"` + CheckinSecret string `toml:"checkin_secret"` + CheckinGroup string `toml:"checkin_group"` + CheckinPayThresold float64 `toml:"checkin_pay_thresold"` + CheckinOndutyPayDay string `toml:"checkin_onduty_pay_day"` EnterpriseAgent string `toml:"enterprise_agent"` EnterpriseSecret string `toml:"enterprise_secret"` diff --git a/conf/server.conf.dev b/conf/server.conf.dev index b6ec906..5843755 100644 --- a/conf/server.conf.dev +++ b/conf/server.conf.dev @@ -28,6 +28,7 @@ checkin_agent = "3010011" checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU" checkin_group = "1,2" checkin_pay_thresold = 11 +checkin_onduty_pay_day = "" pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4" pay_agent = "3010046" diff --git a/conf/server.conf.prod b/conf/server.conf.prod index d8c2354..5134d51 100644 --- a/conf/server.conf.prod +++ b/conf/server.conf.prod @@ -27,6 +27,7 @@ checkin_agent = "3010011" checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU" checkin_group = "1,2" checkin_pay_thresold = 11 +checkin_onduty_pay_day = "" pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4" pay_agent = "3010046" diff --git a/worker/autopay.go b/worker/autopay.go index 949c3e0..914f161 100644 --- a/worker/autopay.go +++ b/worker/autopay.go @@ -46,7 +46,9 @@ func NotifyCheckinOnDuty(checkin *model.Checkin) { if payMoney == 0 { payMoney = 2000 } - autoPayMoney(checkin, checkOndutyName, payMoney) + if payMoney > 0 { + autoPayMoney(checkin, checkOndutyName, payMoney) + } } } @@ -70,12 +72,15 @@ func NotifyCheckinOffDuty(checkin *model.Checkin) { return } - payMoney := cast.ToInt64(userConfig.Get(model.CheckinOffdutyMoney)) - if payMoney == 0 { - payMoney = 2000 + if isOffdutyPay(checkin, userConfig) { + payMoney := cast.ToInt64(userConfig.Get(model.CheckinOffdutyMoney)) + if payMoney == 0 { + payMoney = 2000 + } + if payMoney > 0 { + autoPayMoney(checkin, checkOffdutyName, payMoney) + } } - autoPayMoney(checkin, checkOffdutyName, payMoney) - } func isOndutyPay(checkin *model.Checkin, userConfig *model.UserConfig) bool { @@ -90,13 +95,22 @@ func isOndutyPay(checkin *model.Checkin, userConfig *model.UserConfig) bool { } // 周六加班也直接发放 - if time.Now().Weekday() == time.Saturday { + if int(time.Now().Weekday()) == cast.ToInt(config.GetConfig().QyWeixin.CheckinOndutyPayDay) { return true } return false } +func isOffdutyPay(checkin *model.Checkin, userConfig *model.UserConfig) bool { + // 没有配置了下班打卡的不发放 + if cast.ToBool(userConfig.Get(model.CheckinOffdutyMoneyEnable)) == false { + return false + } + + return true +} + func autoPayMoney(checkin *model.Checkin, checkinType string, payMoney int64) error { //cfg := config.GetConfig()