浏览代码

Merge branch 'fixbug/568-bowen-time-zone' into debug

* fixbug/568-bowen-time-zone:
  优化
  修正时区
boweniac 4 天之前
父节点
当前提交
b79f4870e5
共有 2 个文件被更改,包括 12 次插入9 次删除
  1. 9 8
      crontask/contact_form.go
  2. 3 1
      internal/utils/compapi/form.go

+ 9 - 8
crontask/contact_form.go

@@ -131,7 +131,9 @@ func (l *CronTask) analyze() {
 	predicates = append(predicates, usagedetail.AppIn(1, 3, 4, 5))
 	//yesterdayStart := time.Now().AddDate(0, 0, -1).Truncate(24 * time.Hour)
 	//yesterdayEnd := yesterdayStart.Add(24 * time.Hour)
-	yesterdayEnd := time.Now().Truncate(24 * time.Hour)
+	loc, _ := time.LoadLocation("Asia/Shanghai")
+	now := time.Now().In(loc)
+	yesterdayEnd := now.Truncate(24 * time.Hour)
 	yesterdayStart := yesterdayEnd.AddDate(0, 0, -1)
 	predicates = append(predicates, usagedetail.CreatedAtGTE(yesterdayStart))
 	predicates = append(predicates, usagedetail.CreatedAtLT(yesterdayEnd))
@@ -400,13 +402,12 @@ func (l *CronTask) UpdateContactFields(botID string, receiverID string, fields [
 			} else {
 				if field.Value != nil {
 					if len(field.Value) == 0 || field.Value[0] == "" {
-						continue
-					}
-					_, err := l.svcCtx.DB.ContactField.UpdateOneID(f.ID).
-						SetValue(field.Value).
-						Save(l.ctx)
-					if err != nil {
-						continue
+						_, err := l.svcCtx.DB.ContactField.UpdateOneID(f.ID).
+							SetValue(field.Value).
+							Save(l.ctx)
+						if err != nil {
+							continue
+						}
 					}
 				}
 			}

+ 3 - 1
internal/utils/compapi/form.go

@@ -37,6 +37,7 @@ type FormList struct {
 
 func (me *FormClient) BuildRequest(req *types.CompApiReq) error {
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
+	weekday := time.Now().Weekday().String()
 	//bytes, err := json.Marshal(req.Variables["form_data"])
 	//if err != nil {
 	//	return err
@@ -49,7 +50,8 @@ func (me *FormClient) BuildRequest(req *types.CompApiReq) error {
 请帮助user从通话记录中提取表单值,并返回一个JSON格式的表单值。
 
 # 背景信息
-` + nowTime + `
+当前时间是:` + nowTime + `
+当前星期是:` + weekday + `
 
 # 返回值示例
 * 如表单类型为 input、autoComplete、textarea,返回示例:["表单值"]