CheckinOndutyPayDay

This commit is contained in:
jiangyong27 2023-10-07 12:42:52 +08:00
parent 20382e133a
commit 9eeeed8e2b
4 changed files with 28 additions and 11 deletions

View File

@ -38,10 +38,11 @@ type Redis struct {
type QyWeixin struct { type QyWeixin struct {
Corpid string `toml:"corpid"` Corpid string `toml:"corpid"`
CheckinAgent string `toml:"checkin_agent"` CheckinAgent string `toml:"checkin_agent"`
CheckinSecret string `toml:"checkin_secret"` CheckinSecret string `toml:"checkin_secret"`
CheckinGroup string `toml:"checkin_group"` CheckinGroup string `toml:"checkin_group"`
CheckinPayThresold float64 `toml:"checkin_pay_thresold"` CheckinPayThresold float64 `toml:"checkin_pay_thresold"`
CheckinOndutyPayDay string `toml:"checkin_onduty_pay_day"`
EnterpriseAgent string `toml:"enterprise_agent"` EnterpriseAgent string `toml:"enterprise_agent"`
EnterpriseSecret string `toml:"enterprise_secret"` EnterpriseSecret string `toml:"enterprise_secret"`

View File

@ -28,6 +28,7 @@ checkin_agent = "3010011"
checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU" checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU"
checkin_group = "1,2" checkin_group = "1,2"
checkin_pay_thresold = 11 checkin_pay_thresold = 11
checkin_onduty_pay_day = ""
pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4" pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4"
pay_agent = "3010046" pay_agent = "3010046"

View File

@ -27,6 +27,7 @@ checkin_agent = "3010011"
checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU" checkin_secret = "6ljYNGt4DonZLmr9SCtgkTlOvtqmsOchBrTWwGl_GpU"
checkin_group = "1,2" checkin_group = "1,2"
checkin_pay_thresold = 11 checkin_pay_thresold = 11
checkin_onduty_pay_day = ""
pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4" pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4"
pay_agent = "3010046" pay_agent = "3010046"

View File

@ -46,7 +46,9 @@ func NotifyCheckinOnDuty(checkin *model.Checkin) {
if payMoney == 0 { if payMoney == 0 {
payMoney = 2000 payMoney = 2000
} }
autoPayMoney(checkin, checkOndutyName, payMoney) if payMoney > 0 {
autoPayMoney(checkin, checkOndutyName, payMoney)
}
} }
} }
@ -70,12 +72,15 @@ func NotifyCheckinOffDuty(checkin *model.Checkin) {
return return
} }
payMoney := cast.ToInt64(userConfig.Get(model.CheckinOffdutyMoney)) if isOffdutyPay(checkin, userConfig) {
if payMoney == 0 { payMoney := cast.ToInt64(userConfig.Get(model.CheckinOffdutyMoney))
payMoney = 2000 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 { 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 true
} }
return false 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 { func autoPayMoney(checkin *model.Checkin, checkinType string, payMoney int64) error {
//cfg := config.GetConfig() //cfg := config.GetConfig()