Browse Source

Merge branch 'dev_v1.5.22_wh' of jianyu/datatools into feature/v1.5.22

王浩 7 months ago
parent
commit
09ad9243bb
4 changed files with 36 additions and 23 deletions
  1. 16 14
      clueSync/config.go
  2. 3 1
      clueSync/db.json
  3. 16 7
      clueSync/kc.go
  4. 1 1
      clueSync/log.go

+ 16 - 14
clueSync/config.go

@@ -176,20 +176,22 @@ type (
 			UserName string `json:"user	Name"`
 			Password string `json:"password"`
 		} `json:"es"`
-		ProductArr      []string          `json:"productArr"`
-		RedisServer     string            `json:"redisServer"`
-		AllocationCap   int64             `json:"allocationCap"`
-		WarningValue    int64             `json:"warningValue"`
-		CornMail        string            `json:"corn_mail"`
-		RegTimes        int               `json:"regTimes"`
-		NameToMail      map[string]string `json:"nameToMail"`
-		ThawDay         int64             `json:"thawDay"`
-		LoopType        int64             `json:"loopType"`
-		Sourceid        string            `json:"sourceid"`
-		AbhEmail        string            `json:"abhEmail"`
-		AfEmail         string            `json:"afEmail"`
-		NewRegistration int64             `json:"newRegistration"`
-		OperationEmail  []string          `json:"operationEmail"`
+		ProductArr       []string          `json:"productArr"`
+		RedisServer      string            `json:"redisServer"`
+		AllocationCap    int64             `json:"allocationCap"`
+		WarningValue     int64             `json:"warningValue"`
+		CornMail         string            `json:"corn_mail"`
+		RegTimes         int               `json:"regTimes"`
+		NameToMail       map[string]string `json:"nameToMail"`
+		ThawDay          int64             `json:"thawDay"`
+		LoopType         int64             `json:"loopType"`
+		Sourceid         string            `json:"sourceid"`
+		AbhEmail         string            `json:"abhEmail"`
+		AfEmail          string            `json:"afEmail"`
+		NewRegistration  int64             `json:"newRegistration"`
+		OperationEmail   []string          `json:"operationEmail"`
+		ExpirationPeriod int               `json:"expirationPeriod"` //客成到期周期
+		HandoverCycle    int64             `json:"handoverCycle"`    //移交周期
 	}
 )
 

+ 3 - 1
clueSync/db.json

@@ -161,5 +161,7 @@
   "sourceid": "88",
   "afEmail": "wanghao@topnet.net.cn",
   "abhEmail": "wanghao@topnet.net.cn",
-  "newRegistration": 1
+  "newRegistration": 1,
+  "expirationPeriod": 30,
+  "handoverCycle": 60
 }

+ 16 - 7
clueSync/kc.go

@@ -575,6 +575,7 @@ func ordersClue() {
 
 func refundAuto() {
 	log.Println("自动移交销售定时任务开始")
+	findNowTime := time.Now().AddDate(0, 0, db.ExpirationPeriod).Format(date.Date_Full_Layout)
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
 		for _, v := range *l {
@@ -594,7 +595,7 @@ func refundAuto() {
 			}
 			isFull := FindUpperLimit(gconv.String(saleId), "", false)
 			isAllRefund := false
-			myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and vip_endtime < ?`, uid, nowTime)
+			myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and vip_endtime < ?`, uid, findNowTime)
 			if myOrders != nil {
 				refundCount := 0
 				for _, v := range *myOrders {
@@ -651,19 +652,27 @@ func refundAuto() {
 				})
 				TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
 			} else {
-				order1 := TiDb.SelectBySql(`select id from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > ? and order_status = 1 `, uid, nowTime)
+				order1 := TiDb.SelectBySql(`select id from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > ? and order_status = 1 `, uid, findNowTime)
 				if order1 == nil || len(*order1) == 0 {
 					isOk := false
-					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ? and order_status = 1 `, uid, nowTime)
+					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ? and order_status = 1 `, uid, findNowTime)
 					if order3 != nil && len(*order3) > 0 {
 						for _, vv := range *order3 {
 							if isRenewalProtection == 1 {
 								vip_endtime := common.ObjToString(vv["vip_endtime"])
 								vip_endtimes, _ := time.ParseInLocation(date.Date_Full_Layout, vip_endtime, time.Local)
-								//beforeTime := time.Now().AddDate(0, -1, 0)
-								if time.Now().Unix()-vip_endtimes.Unix() < 3*30*86400 {
-									//if beforeTime.Unix() <= vip_endtimes.Unix() {
-									isOk = true
+								//查看服务到期时间
+								historyTimes, _ := time.ParseInLocation(date.Date_Full_Layout, nowTime, time.Local)
+								if vip_endtimes.Unix() <= historyTimes.Unix() {
+									//三个月
+									if time.Now().Unix()-vip_endtimes.Unix() < 3*30*86400 {
+										isOk = true
+									}
+								} else {
+									//一个月
+									if time.Now().Unix()-vip_endtimes.Unix() < db.HandoverCycle*86400 {
+										isOk = true
+									}
 								}
 							}
 						}

+ 1 - 1
clueSync/log.go

@@ -37,7 +37,7 @@ func initLog(saveDay int) {
 	go logfile()
 	task := cron.New()
 	task.Start()
-	task.AddFunc("0 0 0/1 * * ?", func() {
+	task.AddFunc("0 0 0/2 * * ?", func() {
 		go logfile()
 		time.Sleep(50 * time.Second)
 		if saveDay > 0 {