xuzhiheng 4 lat temu
rodzic
commit
d77f6366ec

+ 2 - 2
service/projects.go

@@ -16,7 +16,7 @@ var (
 	pjt_count    = 100
 	pjt_field    = `"_id","jgtime","zbtime","projectname","buyer","buyerclass"`
 	pjt_fields   = `"_id","area","city","bidamount","budget","zbtime","jgtime","projectname","projectcode","s_winner","buyer","buyerclass","buyerperson","buyertel","sourceinfourl"`
-	pjt_sort     = `{"firsttime":-1}`
+	pjt_sort     = `{"jgtime":-1}`
 	query        = `{"query": {"bool": {"must":[%s],"should":[%s],"minimum_should_match": 1}}}`
 	query_string = `{"constant_score": {"boost": 2,"query": {"match_phrase": {"projectname.pname": {"analyzer": "my_ngram","query": "%s","slop": 6}}}}},{"multi_match": {"query": "%s","fields": ["projectname.pname"],"analyzer": "ik","minimum_should_match": "100%%"}}`
 	query_winner = `{"term": {"s_winner": "%s"}}`
@@ -50,7 +50,7 @@ func ProjectListData(projectName, winner, times string, isDetail bool) (data []m
 		// } else if start != "" && end == "" {
 		// 	timestr = `{"range": {"firsttime": {"gte": ` + start + `}}}`
 		// } else if start != "" && end != "" {
-		timestr = `{"range": {"firsttime": {"gte": ` + startTimes + `,"lte": ` + endTimes + `}}}`
+		timestr = `{"range": {"jgtime": {"gte": ` + startTimes + `,"lte": ` + endTimes + `}}}`
 		// }
 	}
 	if pjt_len >= 4 && winner == "" {

+ 13 - 4
sword_base/utils/stringutil.go

@@ -5,11 +5,12 @@ import (
 	cryptoRand "crypto/rand"
 	"encoding/hex"
 	"fmt"
-	"github.com/dchest/captcha"
 	"io"
 	"math/rand"
 	"strings"
 	"time"
+
+	"github.com/dchest/captcha"
 )
 
 func FilterXSS(str string) string {
@@ -58,9 +59,8 @@ func GenerateSimpleToken() string {
 	h.Write([]byte(str))
 	return hex.EncodeToString(h.Sum(nil))
 }
-//var pool = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@#$"
-
 
+//var pool = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@#$"
 
 //获取复杂的随机数
 func GetLetterRandom(length int, flag ...bool) string {
@@ -129,4 +129,13 @@ func GetComplexRandom(c, n, l int) string {
 		array[r2] = o
 	}
 	return strings.Join(array, "")
-}
+}
+
+func GetRandom(n int) string {
+	var idChars = []byte("0123456789")
+	b := captcha.RandomDigits(n)
+	for i, c := range b {
+		b[i] = idChars[c]
+	}
+	return string(b)
+}

+ 3 - 2
utils/cost_by_account_balance.go

@@ -7,6 +7,7 @@ import (
 	"sfbase/utils"
 	"sfis/db"
 	"sfis/model"
+	"time"
 
 	"fmt"
 
@@ -84,15 +85,15 @@ func afterCheck(dataLen, payMoney int, userProduct *model.UserProduct, statusCod
 			tx.Rollback()
 			return err
 		}
+		orderCode := fmt.Sprint(time.Now().Year()) + fmt.Sprint(utils.GetRandom(8))
 		//生调用记录
-		err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param) values (?,?,?,?,?)", appID, userProductID, statusCode, ip, param).Error
+		err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param,order_code) values (?,?,?,?,?,?)", appID, userProductID, statusCode, ip, param, orderCode).Error
 		if err != nil {
 			log.Printf("appID:[%s],productID:[%d] execute insert into user_call_record error:[%v]", appID, productID, err)
 			tx.Rollback()
 			return err
 		}
 		//生订单
-		orderCode := utils.GenerateSimpleToken()
 		err = tx.Exec("insert into interface_order (order_code,app_id,user_product_id,`before`,`after`,cost_model,trade_num) values (?,?,?,?,?,?,?)", orderCode, appID, userProductID, orderBefore, orderAfter, 1, payMoney).Error
 		if err != nil {
 			log.Printf("appID:[%s],productID:[%d] execute insert into interface_order error:[%v]", appID, productID, err)

+ 6 - 4
utils/cost_by_left_num.go

@@ -2,11 +2,13 @@ package utils
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sfbase/global"
 	"sfbase/utils"
 	"sfis/db"
 	"sfis/model"
+	"time"
 
 	"gorm.io/gorm"
 )
@@ -34,7 +36,7 @@ func costByLeftNum(getData func() ([]map[string]interface{}, int, error), appID
 	} else {
 		err = errors.New("剩余量不足")
 	}
-	log.Println("1111111",err)
+	log.Println("1111111", err)
 	return datas, err
 }
 
@@ -78,6 +80,7 @@ func after(productType int, dataLen int, userProduct *model.UserProduct, statusC
 	productID := userProduct.ProductID
 	userProductID := userProduct.ID
 	var errs error
+	orderCode := fmt.Sprint(time.Now().Year()) + fmt.Sprint(utils.GetRandom(8))
 	switch productType {
 	case 0:
 		//按次扣费-(每调一次剩余量-1)
@@ -92,7 +95,7 @@ func after(productType int, dataLen int, userProduct *model.UserProduct, statusC
 				return err
 			}
 			//生调用记录
-			err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param) values (?,?,?,?,?)", appID, userProductID, statusCode, ip, param).Error
+			err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param,order_code) values (?,?,?,?,?,?)", appID, userProductID, statusCode, ip, param, orderCode).Error
 			if err != nil {
 				log.Printf("appID:[%s],productID:[%d] execute insert into user_call_record error:[%v]", appID, productID, err)
 				tx.Rollback()
@@ -122,14 +125,13 @@ func after(productType int, dataLen int, userProduct *model.UserProduct, statusC
 				return err
 			}
 			//生调用记录
-			err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param) values (?,?,?,?,?)", appID, userProductID, statusCode, ip, param).Error
+			err = tx.Exec("insert into user_call_record (app_id,user_product_id,status,ip,param,order_code) values (?,?,?,?,?,?)", appID, userProductID, statusCode, ip, param, orderCode).Error
 			if err != nil {
 				log.Printf("appID:[%s],productID:[%d] execute insert into user_call_record error:[%v]", appID, productID, err)
 				tx.Rollback()
 				return err
 			}
 			//生订单
-			orderCode := utils.GenerateSimpleToken()
 			err = tx.Exec("insert into interface_order (order_code,app_id,user_product_id,`before`,`after`,cost_model,trade_num) values (?,?,?,?,?,?,?)", orderCode, appID, userProductID, orderBefore, orderAfter, 0, dataLen).Error
 			if err != nil {
 				log.Printf("appID:[%s],productID:[%d] execute insert into interface_order error:[%v]", appID, productID, err)