Răsfoiți Sursa

feat:退款判断

wangchuanjin 1 an în urmă
părinte
comite
182c5f04d9
1 a modificat fișierele cu 5 adăugiri și 11 ștergeri
  1. 5 11
      clueSync/kc.go

+ 5 - 11
clueSync/kc.go

@@ -4,12 +4,13 @@ import (
 	"database/sql"
 	"encoding/json"
 	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
 	"log"
 	"strconv"
 	"strings"
 	"time"
 
+	"github.com/gogf/gf/v2/util/gconv"
+
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/mongodb"
@@ -648,12 +649,7 @@ func refundAuto() {
 				phone = common.ObjToString((*clueData)["phone"])
 			}
 			isFull := FindUpperLimit(gconv.String(saleId), "", false)
-			query1 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
-			query2 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and pay_money > 0 and uid = "%s"`, uid)
-			log.Println("query1 ", query1)
-			log.Println("query2 ", query2)
-			order2 := TiDb.SelectBySql(query2)
-			if order2 == nil || len(*order2) == 0 {
+			if TiDb.CountBySql(`select count(1) as count from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and refund_status=1 and order_status = 1 and pay_money > 0`, uid) > 0 {
 				//全退款了
 				TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET is_assign=0,trailstatus="01",position_id=null,seatNumber=null,updatetime=?,comeintime_open=?,comeinsource_open=1,level_open=3,next_trail_time=null,is_task=null,tasktime=null,taskstatus=null,comeinsource_private=null,tasksource=null,is_transfer=0 WHERE id = ?`, nowTime, nowTime, clueId)
 				TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
@@ -698,12 +694,10 @@ func refundAuto() {
 				})
 				TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
 			} else {
-				order1 := TiDb.SelectBySql(query1)
+				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 and pay_money > 0`, uid, nowTime)
 				if order1 == nil || len(*order1) == 0 {
 					isOk := false
-					query3 := fmt.Sprintf(`select vip_endtime from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
-					log.Println("query3 ", query3)
-					order3 := TiDb.SelectBySql(query3)
+					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 and pay_money > 0`, uid, nowTime)
 					if order3 != nil && len(*order3) > 0 {
 						for _, vv := range *order3 {
 							if isRenewalProtection == 1 {