This commit is contained in:
jiangyong27 2023-08-10 19:26:09 +08:00
parent faf93253c7
commit 44a0938bee
7 changed files with 12 additions and 8 deletions

View File

@ -53,7 +53,7 @@ func (d *CheckinDao) Get(id int64) (*model.Checkin, error) {
func (d *CheckinDao) GetByDay(userId, day string) (*model.Checkin, error) { func (d *CheckinDao) GetByDay(userId, day string) (*model.Checkin, error) {
var u model.Checkin var u model.Checkin
tx := GetDB().Table(d.TableName()) tx := GetDB().Table(d.TableName())
tx = tx.Where("user_id = ?", userId) tx = tx.Where("username = ?", userId)
tx = tx.Where("day = ?", day) tx = tx.Where("day = ?", day)
res := tx.First(&u) res := tx.First(&u)
if res.Error == gorm.ErrRecordNotFound { if res.Error == gorm.ErrRecordNotFound {

View File

@ -53,7 +53,7 @@ func (d *CheckinMoneyDao) Get(id int64) (*model.CheckinMoney, error) {
func (d *CheckinMoneyDao) GetByDay(userId, day, checkinType string) (*model.CheckinMoney, error) { func (d *CheckinMoneyDao) GetByDay(userId, day, checkinType string) (*model.CheckinMoney, error) {
var u model.CheckinMoney var u model.CheckinMoney
tx := GetDB().Table(d.TableName()) tx := GetDB().Table(d.TableName())
tx = tx.Where("userid = ?", userId) tx = tx.Where("username = ?", userId)
tx = tx.Where("checkin_type = ?", checkinType) tx = tx.Where("checkin_type = ?", checkinType)
tx = tx.Where("day = ?", day) tx = tx.Where("day = ?", day)
res := tx.First(&u) res := tx.First(&u)

View File

@ -2,7 +2,7 @@ package model
type Checkin struct { type Checkin struct {
Id int64 Id int64
UserId string Username string
Day string Day string
Exception string Exception string
Rawdata string Rawdata string

View File

@ -3,7 +3,7 @@ package model
type CheckinMoney struct { type CheckinMoney struct {
Id int64 Id int64
Day string Day string
Userid string Username string
CheckinId int64 CheckinId int64
CheckinType string CheckinType string
BillNo string BillNo string

View File

@ -106,3 +106,7 @@
{"L":"INFO","timestamp":"2023-08-04T20:37:39+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:39 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8Zqcc9a3pPFNE2EIUjzzr4BJ5Sra7bU6A8ahRGfm1-WIb1iQ\"}"} {"L":"INFO","timestamp":"2023-08-04T20:37:39+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:39 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8Zqcc9a3pPFNE2EIUjzzr4BJ5Sra7bU6A8ahRGfm1-WIb1iQ\"}"}
{"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=nAuabeJOqc1PHjn0lCMX5uCxj3osUyg5q7wtH6Kn7J_FrJFNcgbWbfDn4O6TYgx_VadjZjbJ3hmxFBwazJAjhG0S-xkOKW5iPjWZHTNWv23hNmDZmAD95Sl6cWF-LDBwP1VWHVGpxNP5NU0yHT7Jf15derzTPW9R0iTc_v848liReFvyWgrfZ_kr80nUpsRUwmUz8AWiX2Xx04y5py1NqA request header: { Accept:*/*Content-Type:application/json} request body:{\"touser\":\"jiangyong\",\"toparty\":\"\",\"totag\":\"\",\"msgtype\":\"text\",\"agentid\":1000009,\"safe\":0,\"enable_id_trans\":0,\"enable_duplicate_check\":0,\"duplicate_check_interval\":0,\"text\":{\"content\":\"员工名称zhengdaquan\\n考勤日期2023-07-05\\n开始时间2023-07-05 09:05:34\\n结束时间2023-07-05 21:36:42\\n工作时长12h31m8s\"}}\n"} {"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=nAuabeJOqc1PHjn0lCMX5uCxj3osUyg5q7wtH6Kn7J_FrJFNcgbWbfDn4O6TYgx_VadjZjbJ3hmxFBwazJAjhG0S-xkOKW5iPjWZHTNWv23hNmDZmAD95Sl6cWF-LDBwP1VWHVGpxNP5NU0yHT7Jf15derzTPW9R0iTc_v848liReFvyWgrfZ_kr80nUpsRUwmUz8AWiX2Xx04y5py1NqA request header: { Accept:*/*Content-Type:application/json} request body:{\"touser\":\"jiangyong\",\"toparty\":\"\",\"totag\":\"\",\"msgtype\":\"text\",\"agentid\":1000009,\"safe\":0,\"enable_id_trans\":0,\"enable_duplicate_check\":0,\"duplicate_check_interval\":0,\"text\":{\"content\":\"员工名称zhengdaquan\\n考勤日期2023-07-05\\n开始时间2023-07-05 09:05:34\\n结束时间2023-07-05 21:36:42\\n工作时长12h31m8s\"}}\n"}
{"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:58 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8ZqcfLmG5EqOZFqmKXL_mUad7VVnqa32Oux8MLMAa_8Gv-JQ\"}"} {"L":"INFO","timestamp":"2023-08-04T20:37:58+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 124\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Fri, 04 Aug 2023 12:37:58 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"msgid\":\"Dv0oBVNA9p2BIWPODPqgktwXhcYb7kcDd7Z2ta8ZqcfLmG5EqOZFqmKXL_mUad7VVnqa32Oux8MLMAa_8Gv-JQ\"}"}
{"L":"INFO","timestamp":"2023-08-09T22:04:07+08:00","M":"GET https://qyapi.weixin.qq.com/cgi-bin/gettoken?appid=ww43c49db2e88a17f8&corpid=ww43c49db2e88a17f8&corpsecret=oMB24UhKe50-XPTg7vhnwoTuhEXaq5XeiHPAUtF4hOs&neededText=&secret=oMB24UhKe50-XPTg7vhnwoTuhEXaq5XeiHPAUtF4hOs request header: { Accept:*/*} "}
{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 277\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Wed, 09 Aug 2023 14:04:15 GMT\r\nError-Code: 0\r\nError-Msg: ok\r\nServer: nginx\r\n\r\n{\"errcode\":0,\"errmsg\":\"ok\",\"access_token\":\"VABmBihsSVl7GgZ2C7yxe2u1k3wrSxgdjaLyx8PS_aXI3V6-SeOJ-cbBb6SEXxkzy6Ua_lOC3ZlP7wsJy0wx5jAyY20yJPXPYGdYZEhCSDOkgt2VdF8dnd9TSql-uceMf-c7h53osEx7v4kbeGXTyXH73CfRAxXLbrBhke8VJ2eosvrRtkrWj70SHgTajNboV2J5rv0gqewEU10hCmd74Q\",\"expires_in\":7200}"}
{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=VABmBihsSVl7GgZ2C7yxe2u1k3wrSxgdjaLyx8PS_aXI3V6-SeOJ-cbBb6SEXxkzy6Ua_lOC3ZlP7wsJy0wx5jAyY20yJPXPYGdYZEhCSDOkgt2VdF8dnd9TSql-uceMf-c7h53osEx7v4kbeGXTyXH73CfRAxXLbrBhke8VJ2eosvrRtkrWj70SHgTajNboV2J5rv0gqewEU10hCmd74Q request header: { Content-Type:application/jsonAccept:*/*} request body:{\"touser\":\"jiangyong\",\"toparty\":\"\",\"totag\":\"\",\"msgtype\":\"text\",\"agentid\":1000009,\"safe\":0,\"enable_id_trans\":0,\"enable_duplicate_check\":0,\"duplicate_check_interval\":0,\"text\":{\"content\":\"【上班提醒】\\n员工名称jiangyong\\n考勤日期2023-08-09\\n开始时间2023-08-09 09:59:18\"}}\n"}
{"L":"INFO","timestamp":"2023-08-09T22:04:08+08:00","M":"------------------response content:HTTP/2.0 200 OK\r\nContent-Length: 188\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Wed, 09 Aug 2023 14:04:15 GMT\r\nError-Code: 60020\r\nError-Msg: not allow to access from your ip, hint: [1691589855612133624589115], from ip: 113.249.227.9, more info at https://open.work.weixin.qq.com/devtool/query?e=60020\r\nServer: nginx\r\n\r\n{\"errcode\":60020,\"errmsg\":\"not allow to access from your ip, hint: [1691589855612133624589115], from ip: 113.249.227.9, more info at https://open.work.weixin.qq.com/devtool/query?e=60020\"}"}

View File

@ -31,7 +31,7 @@ func NotifyCheckinOffDuty(checkin *model.Checkin) {
func NotifyCheckinOnDuty(checkin *model.Checkin) { func NotifyCheckinOnDuty(checkin *model.Checkin) {
message := make([]string, 0) message := make([]string, 0)
message = append(message, "【上班提醒】") message = append(message, "【上班提醒】")
message = append(message, fmt.Sprintf("员工名称:%s", checkin.UserId)) message = append(message, fmt.Sprintf("员工名称:%s", checkin.Username))
message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day)) message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day))
message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime))) message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime)))
@ -44,7 +44,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string) error {
cfg := config.GetConfig() cfg := config.GetConfig()
checkinMoneyDao := dao.NewCheckinMoneyDao() checkinMoneyDao := dao.NewCheckinMoneyDao()
checkinMoney, err := checkinMoneyDao.GetByDay(checkin.UserId, checkin.Day, checkinType) checkinMoney, err := checkinMoneyDao.GetByDay(checkin.Username, checkin.Day, checkinType)
if err != nil { if err != nil {
log.Errorf("db error :%s", err.Error()) log.Errorf("db error :%s", err.Error())
return err return err
@ -66,7 +66,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string) error {
message := make([]string, 0) message := make([]string, 0)
duration := checkin.EndTime - checkin.StartTime duration := checkin.EndTime - checkin.StartTime
message = append(message, "【下班提醒】") message = append(message, "【下班提醒】")
message = append(message, fmt.Sprintf("员工名称:%s", checkin.UserId)) message = append(message, fmt.Sprintf("员工名称:%s", checkin.Username))
message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day)) message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day))
message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime))) message = append(message, fmt.Sprintf("开始时间:%s", goutil.TimeToDateTime(checkin.StartTime)))
message = append(message, fmt.Sprintf("结束时间:%s", goutil.TimeToDateTime(checkin.EndTime))) message = append(message, fmt.Sprintf("结束时间:%s", goutil.TimeToDateTime(checkin.EndTime)))

View File

@ -29,7 +29,7 @@ func SyncCheckin(day string) error {
if checkin == nil { if checkin == nil {
checkin = new(model.Checkin) checkin = new(model.Checkin)
checkin.Day = day checkin.Day = day
checkin.UserId = user checkin.Username = user
isNew = true isNew = true
} }