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

@ -42,6 +42,7 @@ type QyWeixin struct {
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"`

View File

@ -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"

View File

@ -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"

View File

@ -46,9 +46,11 @@ func NotifyCheckinOnDuty(checkin *model.Checkin) {
if payMoney == 0 {
payMoney = 2000
}
if payMoney > 0 {
autoPayMoney(checkin, checkOndutyName, payMoney)
}
}
}
func NotifyCheckinOffDuty(checkin *model.Checkin) {
if checkin.Exception != "" {
@ -70,12 +72,15 @@ func NotifyCheckinOffDuty(checkin *model.Checkin) {
return
}
if isOffdutyPay(checkin, userConfig) {
payMoney := cast.ToInt64(userConfig.Get(model.CheckinOffdutyMoney))
if payMoney == 0 {
payMoney = 2000
}
if payMoney > 0 {
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()