Browse Source

即将到期发邮件修改

WH01243 6 months ago
parent
commit
9fa97a1b38
1 changed files with 16 additions and 13 deletions
  1. 16 13
      clueSync/kc.go

+ 16 - 13
clueSync/kc.go

@@ -632,20 +632,23 @@ func refundAuto() {
 			}
 			//查询即将到期数据
 			if isRenewalProtection == 0 {
-				aaa := TiDb.CountBySql(`select count(1) from dwd_f_userbase_order_info where uid=?   and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and  refund_status!=1 and vip_endtime < ? and  vip_endtime > ? `, uid, time.Now().AddDate(0, 0, -db.ExpirationPeriod+1).Format(date.Date_Short_Layout), time.Now().AddDate(0, 0, -db.ExpirationPeriod).Format(date.Date_Short_Layout))
-				log.Println(aaa)
-				if aaa > 0 {
-					//即将到期
-					mailData[name] = append(mailData[name], map[string]interface{}{
-						"company_name": company_name,
-						"phone":        phone,
-						"userName":     userName,
-						"remrk":        "1天后即将移交",
-						"reason":       "成交客户续费失败",
-					})
-					continue
+				orderData := TiDb.SelectBySql(`select * from dwd_f_userbase_order_info where uid=?   and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and  refund_status!=1  `, uid)
+				if orderData != nil && len(*orderData) > 0 {
+					endDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod+1).Unix()
+					startDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod).Unix()
+					vipEndDate, _ := time.Parse(time.DateTime, gconv.String((*orderData)[0]["vip_endtime"]))
+					if vipEndDate.Unix() > startDate && vipEndDate.Unix() < endDate {
+						//即将到期
+						mailData[name] = append(mailData[name], map[string]interface{}{
+							"company_name": company_name,
+							"phone":        phone,
+							"userName":     userName,
+							"remrk":        "1天后即将移交",
+							"reason":       "成交客户续费失败",
+						})
+						continue
+					}
 				}
-
 			}
 			isFull := FindUpperLimit(gconv.String(saleId), "", false)
 			isAllRefund := false