|
@@ -2,7 +2,6 @@ package book
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"errors"
|
5
|
|
- "fmt"
|
6
|
5
|
"spaceofcheng/services/models"
|
7
|
6
|
"spaceofcheng/services/models/book"
|
8
|
7
|
"spaceofcheng/services/models/customer"
|
|
@@ -416,64 +415,72 @@ func (s *BookServ) DeleteBook(bookId string) error {
|
416
|
415
|
return nil
|
417
|
416
|
}
|
418
|
417
|
|
419
|
|
-func (s *BookServ) SendMessageToCustomer() error {
|
420
|
|
- weekList, err := s.dao.GetAllOneWeekRecord()
|
421
|
|
- if err != nil {
|
422
|
|
- utils.LogError("发送消息失败失败: " + err.Error())
|
423
|
|
- return errors.New("发送消息失败失败")
|
424
|
|
- }
|
425
|
|
- lateList, err := s.dao.GetAllLateRecord()
|
426
|
|
- if err != nil {
|
427
|
|
- utils.LogError("发送消息失败失败: " + err.Error())
|
428
|
|
- return errors.New("发送消息失败失败")
|
429
|
|
- }
|
430
|
|
- if len(weekList) > 0 {
|
431
|
|
- for i := 0; i < len(weekList); i++ {
|
432
|
|
- userMap, err := s.dao.GetUserMappingById(weekList[i].CustomerId)
|
433
|
|
- if err != nil {
|
434
|
|
- utils.LogError("发送消息失败失败: " + err.Error())
|
435
|
|
- return errors.New("发送消息失败失败")
|
436
|
|
- }
|
437
|
|
- message := utils.Message{
|
438
|
|
- To: utils.ClientID{ID: userMap.Openid},
|
439
|
|
- Data: map[string]interface{}{
|
440
|
|
- "orgid": weekList[i].OrgId,
|
441
|
|
- "tplid": "6WoxRkdXrRyF0T7Kc4PU5CjkpzAPWKKsA6wBLAGSQQg",
|
442
|
|
- "data": map[string]string{
|
443
|
|
- "first": "您好,您借阅图书即将逾期,请及时归还。",
|
444
|
|
- "keyword1": weekList[i].BookName,
|
445
|
|
- "keyword2": weekList[i].BorrowDate.Format("2006-01-02"),
|
446
|
|
- "keyword3": weekList[i].EndDate.Format("2006-01-02"),
|
447
|
|
- "remark": fmt.Sprintf("避免影响您下次借阅,请及时归还至", weekList[i].CaseName),
|
448
|
|
- },
|
449
|
|
- },
|
450
|
|
- }
|
451
|
|
- go utils.SendWechat(message)
|
452
|
|
- }
|
453
|
|
- }
|
454
|
|
- if len(lateList) > 0 {
|
455
|
|
- for i := 0; i < len(lateList); i++ {
|
456
|
|
- userMap, err := s.dao.GetUserMappingById(lateList[i].CustomerId)
|
457
|
|
- if err != nil {
|
458
|
|
- utils.LogError("发送消息失败失败: " + err.Error())
|
459
|
|
- return errors.New("发送消息失败失败")
|
460
|
|
- }
|
461
|
|
- message := utils.Message{
|
462
|
|
- To: utils.ClientID{ID: userMap.Openid},
|
463
|
|
- Data: map[string]interface{}{
|
464
|
|
- "orgid": lateList[i].OrgId,
|
465
|
|
- "tplid": "ID:Be0a25NMb3fzLtNaaQn_YOuECQDnlCs1es5aVvfwRhs",
|
466
|
|
- "data": map[string]string{
|
467
|
|
- "first": "您好,您借阅图书的时间已经逾期2天",
|
468
|
|
- "keyword1": lateList[i].BookName,
|
469
|
|
- "keyword2": weekList[i].BorrowDate.Format("2006-01-02"),
|
470
|
|
- "keyword3": weekList[i].EndDate.Format("2006-01-02"),
|
471
|
|
- "remark": fmt.Sprintf("避免影响您下次借阅,请及时归还至", lateList[i].CaseName),
|
472
|
|
- },
|
473
|
|
- },
|
474
|
|
- }
|
475
|
|
- go utils.SendWechat(message)
|
476
|
|
- }
|
|
418
|
+// func (s *BookServ) SendMessageToCustomer() error {
|
|
419
|
+// weekList, err := s.dao.GetAllOneWeekRecord()
|
|
420
|
+// if err != nil {
|
|
421
|
+// utils.LogError("发送消息失败失败: " + err.Error())
|
|
422
|
+// return errors.New("发送消息失败失败")
|
|
423
|
+// }
|
|
424
|
+// lateList, err := s.dao.GetAllLateRecord()
|
|
425
|
+// if err != nil {
|
|
426
|
+// utils.LogError("发送消息失败失败: " + err.Error())
|
|
427
|
+// return errors.New("发送消息失败失败")
|
|
428
|
+// }
|
|
429
|
+// if len(weekList) > 0 {
|
|
430
|
+// for i := 0; i < len(weekList); i++ {
|
|
431
|
+// userMap, err := s.dao.GetUserMappingById(weekList[i].CustomerId)
|
|
432
|
+// if err != nil {
|
|
433
|
+// utils.LogError("发送消息失败失败: " + err.Error())
|
|
434
|
+// return errors.New("发送消息失败失败")
|
|
435
|
+// }
|
|
436
|
+// message := utils.Message{
|
|
437
|
+// To: utils.ClientID{ID: userMap.Openid},
|
|
438
|
+// Data: map[string]interface{}{
|
|
439
|
+// "orgid": weekList[i].OrgId,
|
|
440
|
+// "tplid": "6WoxRkdXrRyF0T7Kc4PU5CjkpzAPWKKsA6wBLAGSQQg",
|
|
441
|
+// "data": map[string]string{
|
|
442
|
+// "first": "您好,您借阅图书即将逾期,请及时归还。",
|
|
443
|
+// "keyword1": weekList[i].BookName,
|
|
444
|
+// "keyword2": weekList[i].BorrowDate.Format("2006-01-02"),
|
|
445
|
+// "keyword3": weekList[i].EndDate.Format("2006-01-02"),
|
|
446
|
+// "remark": fmt.Sprintf("避免影响您下次借阅,请及时归还至", weekList[i].CaseName),
|
|
447
|
+// },
|
|
448
|
+// },
|
|
449
|
+// }
|
|
450
|
+// go utils.SendWechat(message)
|
|
451
|
+// }
|
|
452
|
+// }
|
|
453
|
+// if len(lateList) > 0 {
|
|
454
|
+// for i := 0; i < len(lateList); i++ {
|
|
455
|
+// userMap, err := s.dao.GetUserMappingById(lateList[i].CustomerId)
|
|
456
|
+// if err != nil {
|
|
457
|
+// utils.LogError("发送消息失败失败: " + err.Error())
|
|
458
|
+// return errors.New("发送消息失败失败")
|
|
459
|
+// }
|
|
460
|
+// message := utils.Message{
|
|
461
|
+// To: utils.ClientID{ID: userMap.Openid},
|
|
462
|
+// Data: map[string]interface{}{
|
|
463
|
+// "orgid": lateList[i].OrgId,
|
|
464
|
+// "tplid": "ID:Be0a25NMb3fzLtNaaQn_YOuECQDnlCs1es5aVvfwRhs",
|
|
465
|
+// "data": map[string]string{
|
|
466
|
+// "first": "您好,您借阅图书的时间已经逾期2天",
|
|
467
|
+// "keyword1": lateList[i].BookName,
|
|
468
|
+// "keyword2": weekList[i].BorrowDate.Format("2006-01-02"),
|
|
469
|
+// "keyword3": weekList[i].EndDate.Format("2006-01-02"),
|
|
470
|
+// "remark": fmt.Sprintf("避免影响您下次借阅,请及时归还至", lateList[i].CaseName),
|
|
471
|
+// },
|
|
472
|
+// },
|
|
473
|
+// }
|
|
474
|
+// go utils.SendWechat(message)
|
|
475
|
+// }
|
|
476
|
+// }
|
|
477
|
+// return nil
|
|
478
|
+// }
|
|
479
|
+func (s *BookServ) GetCustomerBorrowInfo(customerInfo string) (*book.CustomerInfo, error) {
|
|
480
|
+ customer, err := s.dao.GetCustomerBorrowInfo(customerInfo)
|
|
481
|
+ if err != nil {
|
|
482
|
+ utils.LogError("获取用户信息失败: " + err.Error())
|
|
483
|
+ return nil, errors.New("获取用户信息失败")
|
477
|
484
|
}
|
478
|
|
- return nil
|
|
485
|
+ return customer, nil
|
479
|
486
|
}
|