Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
		
						commit
						b9e35bba6c
					
				@ -2,7 +2,6 @@ package gmodel
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"regexp"
 | 
			
		||||
@ -27,24 +26,31 @@ type PreLogoSearchResult struct {
 | 
			
		||||
 | 
			
		||||
// 搜索
 | 
			
		||||
func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) {
 | 
			
		||||
	keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1)
 | 
			
		||||
	for i, v := range keywords {
 | 
			
		||||
		keywords[i] = "+" + v + "*"
 | 
			
		||||
	}
 | 
			
		||||
	sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) and zip_code = ? limit %d;", count)
 | 
			
		||||
 | 
			
		||||
	tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "), zipcode)
 | 
			
		||||
	err = tx.Scan(&resp).Error
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logx.Error(err)
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i := range resp {
 | 
			
		||||
		if resp[i].RestaurantType == nil {
 | 
			
		||||
			resp[i].RestaurantType = FsString("")
 | 
			
		||||
	keywordsList := SplitSearchKeywords(keywordsStr)
 | 
			
		||||
	var keywords []string
 | 
			
		||||
	for _, v := range keywordsList {
 | 
			
		||||
		if len(v) > 1 {
 | 
			
		||||
			keywords = append(keywords, "+"+v+"*")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(keywords) != 0 {
 | 
			
		||||
 | 
			
		||||
		sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) and zip_code = ? limit %d;", count)
 | 
			
		||||
 | 
			
		||||
		tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "), zipcode)
 | 
			
		||||
		err = tx.Scan(&resp).Error
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logx.Error(err)
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for i := range resp {
 | 
			
		||||
			if resp[i].RestaurantType == nil {
 | 
			
		||||
				resp[i].RestaurantType = FsString("")
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if resp == nil {
 | 
			
		||||
@ -54,26 +60,38 @@ func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode strin
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SplitSearchKeywords(keywordsStr string) []string {
 | 
			
		||||
	return regexp.MustCompile(`\s+|\++`).Split(keywordsStr, -1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 搜索建议
 | 
			
		||||
func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) {
 | 
			
		||||
	keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1)
 | 
			
		||||
	for i, v := range keywords {
 | 
			
		||||
		keywords[i] = "+" + v + "*"
 | 
			
		||||
	}
 | 
			
		||||
	sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) limit %d;", count)
 | 
			
		||||
 | 
			
		||||
	tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "))
 | 
			
		||||
	err = tx.Scan(&resp).Error
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logx.Error(err)
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i := range resp {
 | 
			
		||||
		if resp[i].RestaurantType == nil {
 | 
			
		||||
			resp[i].RestaurantType = FsString("")
 | 
			
		||||
	// keywordsList := regexp.MustCompile(`\s+|\++`).Split(keywordsStr, -1)
 | 
			
		||||
	keywordsList := SplitSearchKeywords(keywordsStr)
 | 
			
		||||
	var keywords []string
 | 
			
		||||
	for _, v := range keywordsList {
 | 
			
		||||
		if len(v) > 1 {
 | 
			
		||||
			keywords = append(keywords, "+"+v+"*")
 | 
			
		||||
		}
 | 
			
		||||
		resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(keywords) != 0 {
 | 
			
		||||
		sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) limit %d;", count)
 | 
			
		||||
 | 
			
		||||
		tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "))
 | 
			
		||||
		err = tx.Scan(&resp).Error
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logx.Error(err)
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for i := range resp {
 | 
			
		||||
			if resp[i].RestaurantType == nil {
 | 
			
		||||
				resp[i].RestaurantType = FsString("")
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if resp == nil {
 | 
			
		||||
@ -82,89 +100,3 @@ func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, ke
 | 
			
		||||
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var testData = []string{
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7496a14fb62571d07c485a0e9de25440ff178122a4842b73f2ca49833a4ce74d",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/74ca91d9f3beaa1674832565dfa925d801c1b752703307b1205d546dff32e68b",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/75cea2f3993c39f19fe48f1cebb55c83049155fada1397e98a18f5f9c8a647d5",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7657923837e118644fd76d68c8238384c8c29156d2d84f243fd638386c9a6d32",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/76a86fd26acfa828cec89300da307cd83cbf785fb6b6af92afeb18192532ea13",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/78315df91146c77242314d22014083c764f336ba7abd89115eb02001c779e926",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/78feef6e8429e5121ebb160e7229402a3ec121a958c75f9ede07f730f6f25711",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7909c8e6485f3a908105aeb499bd07c6ca18feaca0fd724aac7b4f2d127735ca",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7a5e04ba33105a3935e808e8dcde12a2d793409d7e8b7f7ef465801ae92b982d",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7ad3beb80d268fdda4f312d25e3bc1721c00ef0d1badc133df03f38217c8c207",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7c5f51a90444edc1edf673904d11771f1c43930a9f28de2c42a1bf1164a73ade",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7d072fa805ae0e260e0619cda11ace59233adc4cc8bc63e2017013817dce5011",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7d34b57d47f4faea05ad6ba8ef73d9815fbaf048e945e85e7e36d7c26b02151b",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7fa3df13072e3fb0e47904be65109526bfb21db795c53cabae8625758135aa6c",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/802f96696e5b8a4fb5ef90bc812cde7ff50e54125d7e8439159a66da9a512bf5",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/81e9384055c708098bf4dfca893d7b39ba94444d980b87ee74385c7e01b94c6f",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/83352df2db64d50efc36d972dd01035a79edca77e7360dd486366fecf5799336",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/83b496eae54768a82c3a828d33e544bfaf46544977371eb8cc7dfdb3d43e453d",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/84e130d75a4cf3e27f1f3851395c75341a171053a42e93ae1a7b69c3e7cf58ad",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8505e9775556ee4d9fd03478098f73cbb9ccfdb3567d5cadc2ada7c43d2150df",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/864c84568b4816fbc29814d38b3bf079aba5a35b5d07f5b57f3dd2a79409b204",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/870446c5543c74cb351696713d4ff85a20a17ea9186da9b4c0bf6db3d6217a7c",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/88e1b79804a776272007a64da435e4a7bfee5d2693da8479f31c79036d45eec8",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/88f7e10f711d726c52fad4e6d378b0ed814067477a3564ed6601c98b9d98fb4c",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8908471ae4ff7b0ac405952d6bc2bd049af0cbff7fd892762076f5ed19a34cee",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/899fb5321402c8f562f072993f81ad22edb3df2feb43c2436e92cb4b97036caa",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8c59b2714ff399f394cc2e728766c2f0b07fc6d39bf090e4fea3c4f344c40508",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8cfcd0cbb8d11707dceb45f0936b8c3c7b6c30f434313c252d22b7629ee72b98",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8d47deacf2960de77ddaf742a3ea8b8c7ea4b40afbf5b4e3652e78973800aeef",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8f61f8d08c2cbf8b7e45450321037b1c51ae2a16547f8662bbb5c27e82defe84",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/922915f7ab94113afbe287feb1ddcc8a77840ee4b455e818bcef48ac35069818",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/923745c708fc1507d89c42fe3a47424bc89297754c3ff88a261abab0a59e4b8d",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/92a2fd97d6fa5385ff6bf5d64e8467331e32286fe8b179d020baf7674612e2e1",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/92f93ee2fa364b98ea13f0fe3dcf57e55ae939784ccb5489143deb6d2181ea09",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/937615ffe810ec1210d6ac9bc9671b04be4254046ded12264189637282adaa11",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/93b00364dcfd3b9f6d927eccdc65e10e293876cc0b859c0e1af35cb97343d3e4",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/93b4d14bbcf86743699825adac5bbefb737403061fceea2f8ce23027101a9b08",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/957fc76c9c84d6cc177ba1e7d92913a3fdcade6c5501103d7a39b743affd6451",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/958454c580e5708e2ca704893bc31196a8cf68dccca6549ded063e708e59b9a0",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/95bf354437c8c36bcc34979b81006586c3abcc8cbbd13b277fb8539d817a0400",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/95f6d1152a481e19f641272c4f0ef046b383abc8286e3b2ac329cc1558cd2453",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/96813af51fbc66556a5b616e4964434bac5fbdd5faccbd8c147727f0838b266f",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/96e1911af7a506c30c8d1d5a0df6ea7a20a7030fe5f43e26097e1c241e5688bf",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/97589c622074193c4f85afb5041b7fdaa22cde42c878520f190ac657e71bb257",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/98ce764aaf1021f8caf54eb299decaa28839b55bb7ee769804cb7e5ea942a051",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/98f7a95879da3ebe551c8a4484faaa3a3801ef9beb2129b1f1c450149768f28a",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/99ebccb5fe9d7c985bc4ea1cd1f0b9681ee8e4225a422f14c2efc0432b7adc09",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9b559c125a353299331068eb3d7bd5f41c8b922644725dc3df60c3a1a53763b3",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9b8c409168efe89e7b78437d1622f726b7a75c517c4386c30cbff4811665ad86",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9c246614316fe1727a5b36dc428876ac6f1d6424e8ce4feb51d9b6f8b363d39d",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9caf9bd0676e696bc5c0735498a50f2281941bc59ec323d96cfe2536096bdf50",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9d0594ca037f3998681a3f2458a954f1ecb2b4bd7f3dabcc304adc4d9ba452aa",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9d5809781f3f3e284add2a6e2e79965f0e1930744f8264f8e73750c05d3d4b20",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9ef6ded5b910985f35dc6cba469cb5eb20626b07ed6bca449261cc1d8f8147cf",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9f0cc4bf9f3a5642b1510b5a6a911c53f8f2664071dfcbd9239d160a6fb02d32",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9f91ada7ebc9a2bf623881a2daed0643a81785d2d7624738c3b6bb17cffa58a7",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a26d27fbf27bdd4ab76cefe46a337326432435fc36cce5e5f5e2499e22642f13",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a36543d0d6ee8435bf0ba18ab96fc424c52649a737502f663efd4fc128aaed22",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a4cb2e6c0d93adfb6ebc6c03820dc3dd4b2e5a6bf737782fc910502e5f78d6b7",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a5861470cc5dc7f23a0a66022301fe46a7cf5bf78aa4cbb8aff96bfe1a792220",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a6dbc806559141970a2309c3e20fa019d112eb76c96badc2b99e43c0e19ab17f",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a72eb76e76a2627f8532bc96d8111f22b7132e32795effc628b1acab0a31e8fb",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a827d4012554ea3be1ce1cc86c56d10bb43fa80d6d5e36be5c7ce5ef232e5757",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a93b38fdaf20bddb560ee6a9eb7c2ddf34b3480a771533fe3343905b4e05e4a8",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a9f540186a6e9ecf5dae469e83cd952fd0d1539798edf5c7690af858efbb8cbf",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ab1326e69ff13289c9ac00deac7d61a581a10580e701ff61fe9065937c2c7f11",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/abda7e2720063f576fbf3ada356a721a183c0548e11b1878d414de733cf3754e",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/abecd9297af902c0ec32350f4710b4ed6c4c596d6b24228314a833c95993aa94",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ad4a15c1eaa714e6481812ac938ab09a5f47de116ae8880353be6e12ba8eb64a",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ad677b423fee3d9a1fe3aee24dc00255b5ff0e266fcd0bbca1c2098a2712d91b",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/af0a5621c098fe437a419215105d0485603a27dfdf697df85b966c00fc45b7c8",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/af4d0f94627384bc66fda949052bc1db8d945c1f8e6dcea71dd3d35a011323a0",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/afad479690db35e8371cce3dceae13bfff06fff1a9c0b3487ae6f830e984e416",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b33574c05de24f5963e14813345c601663d66e1db4fedc840b728248e15e1992",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b3723604352d76aa3d6aee1db3cdfd96c3141926f5565efd8d7f7881cfe11ece",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b390c9c5456a1f97e743b2166de1c0dce56e582e4f2b32a0b7aaf842438aafb3",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b420ec89935d2b243600537096046d45bd4ecf071133accd9bd727f92916d442",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b656b871d6663fe0c180c25a001c3e7f0195e4b3e665cee0d52593ccd65a7ec1",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b698198af640aaf742371a873abe537993b086282c153705b65b7244aeccf154",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b95d2daf610d90098669f10b315b89765b011aec63ebac14e2a4aef68ed5fadb",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b976f1c46cf74753948bec7eb623cc0eb9235c1160f9677a31884bd34521a759",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ba529a80062844e682f545f5ba50d75ba53ffd59a6ebb0531c962e5c45122846",
 | 
			
		||||
	"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/bb2652012232cf15c52ab370ae5608621850577369242d9dff0e0f3dbebdab14",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -89,8 +89,12 @@ func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (r
 | 
			
		||||
	return resp, err
 | 
			
		||||
}
 | 
			
		||||
func (p *FsProductModel) GetIgnoreRandomProductList(ctx context.Context, limit int, notInProductIds []int64) (resp []FsProduct, err error) {
 | 
			
		||||
	err = p.db.WithContext(ctx).Model(&FsProduct{}).
 | 
			
		||||
		Where("`is_del` =? and `is_shelf` = ? and `id` not in(?)", 0, 1, notInProductIds).Order("RAND()").Limit(limit).Find(&resp).Error
 | 
			
		||||
	db := p.db.WithContext(ctx).Model(&FsProduct{}).
 | 
			
		||||
		Where("`is_del` =? and `is_shelf` = ? ", 0, 1)
 | 
			
		||||
	if len(notInProductIds) > 0 {
 | 
			
		||||
		db = db.Where("`id` not in(?)", notInProductIds)
 | 
			
		||||
	}
 | 
			
		||||
	err = db.Order("RAND()").Limit(limit).Find(&resp).Error
 | 
			
		||||
	return resp, err
 | 
			
		||||
}
 | 
			
		||||
func (p *FsProductModel) FindAllOnlyByIds(ctx context.Context, ids []int64) (resp []FsProduct, err error) {
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query  from %s where user_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
 | 
			
		||||
	err := m.db.Raw(rawsql, userId).Take(&baseinfo).Error
 | 
			
		||||
	err := m.db.WithContext(ctx).Raw(rawsql, userId).Take(&baseinfo).Error
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -87,3 +87,32 @@ func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int
 | 
			
		||||
	}
 | 
			
		||||
	return resp, err
 | 
			
		||||
}
 | 
			
		||||
func (m *FsUserInfoModel) GetProfileByUserIdGuestId(ctx context.Context, pkey string, userId, guestId int64) (map[string]any, error) {
 | 
			
		||||
 | 
			
		||||
	var baseinfo map[string]any
 | 
			
		||||
	tname := fssql.GetGormTableName(m.db, FsUserInfo{})
 | 
			
		||||
 | 
			
		||||
	if pkey == "." {
 | 
			
		||||
		pkey = ""
 | 
			
		||||
	} else {
 | 
			
		||||
		pkey = "." + pkey
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query  from %s where user_id = ? and guest_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
 | 
			
		||||
	err := m.db.WithContext(ctx).Raw(rawsql, userId, guestId).Take(&baseinfo).Error
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v, ok := baseinfo["query"].(string)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var info map[string]any
 | 
			
		||||
	err = json.Unmarshal([]byte(v), &info)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return info, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -27,16 +27,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 | 
			
		||||
				Path:    "/api/collection/get_collect_product_list",
 | 
			
		||||
				Handler: GetCollectProductListHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				Method:  http.MethodGet,
 | 
			
		||||
				Path:    "/api/collection/test_ai",
 | 
			
		||||
				Handler: TestAiHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				Method:  http.MethodPost,
 | 
			
		||||
				Path:    "/api/collection/test_pdf",
 | 
			
		||||
				Handler: TestPdfHandler(serverCtx),
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,35 +0,0 @@
 | 
			
		||||
package handler
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"reflect"
 | 
			
		||||
 | 
			
		||||
	"fusenapi/utils/basic"
 | 
			
		||||
 | 
			
		||||
	"fusenapi/server/collection/internal/logic"
 | 
			
		||||
	"fusenapi/server/collection/internal/svc"
 | 
			
		||||
	"fusenapi/server/collection/internal/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestAiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
 | 
			
		||||
		var req types.TestAiReq
 | 
			
		||||
		userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 创建一个业务逻辑层实例
 | 
			
		||||
		l := logic.NewTestAiLogic(r.Context(), svcCtx)
 | 
			
		||||
 | 
			
		||||
		rl := reflect.ValueOf(l)
 | 
			
		||||
		basic.BeforeLogic(w, r, rl)
 | 
			
		||||
 | 
			
		||||
		resp := l.TestAi(&req, userinfo)
 | 
			
		||||
 | 
			
		||||
		if !basic.AfterLogic(w, r, rl, resp) {
 | 
			
		||||
			basic.NormalAfterLogic(w, r, resp)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,35 +0,0 @@
 | 
			
		||||
package handler
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"reflect"
 | 
			
		||||
 | 
			
		||||
	"fusenapi/utils/basic"
 | 
			
		||||
 | 
			
		||||
	"fusenapi/server/collection/internal/logic"
 | 
			
		||||
	"fusenapi/server/collection/internal/svc"
 | 
			
		||||
	"fusenapi/server/collection/internal/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestPdfHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
 | 
			
		||||
		var req types.TestPdfReq
 | 
			
		||||
		userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 创建一个业务逻辑层实例
 | 
			
		||||
		l := logic.NewTestPdfLogic(r.Context(), svcCtx)
 | 
			
		||||
 | 
			
		||||
		rl := reflect.ValueOf(l)
 | 
			
		||||
		basic.BeforeLogic(w, r, rl)
 | 
			
		||||
 | 
			
		||||
		resp := l.TestPdf(&req, userinfo)
 | 
			
		||||
 | 
			
		||||
		if !basic.AfterLogic(w, r, rl, resp) {
 | 
			
		||||
			basic.NormalAfterLogic(w, r, resp)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -1,50 +0,0 @@
 | 
			
		||||
package logic
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fusenapi/server/collection/internal/svc"
 | 
			
		||||
	"fusenapi/server/collection/internal/types"
 | 
			
		||||
	"fusenapi/utils/auth"
 | 
			
		||||
	"fusenapi/utils/basic"
 | 
			
		||||
	"fusenapi/utils/pdf"
 | 
			
		||||
 | 
			
		||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type TestPdfLogic struct {
 | 
			
		||||
	logx.Logger
 | 
			
		||||
	ctx    context.Context
 | 
			
		||||
	svcCtx *svc.ServiceContext
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewTestPdfLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestPdfLogic {
 | 
			
		||||
	return &TestPdfLogic{
 | 
			
		||||
		Logger: logx.WithContext(ctx),
 | 
			
		||||
		ctx:    ctx,
 | 
			
		||||
		svcCtx: svcCtx,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 处理进入前逻辑w,r
 | 
			
		||||
// func (l *TestPdfLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
func (l *TestPdfLogic) TestPdf(req *types.TestPdfReq, userinfo *auth.UserInfo) (resp *basic.Response) {
 | 
			
		||||
	return resp.SetStatusWithMessage(basic.CodeOK, "你干嘛,哎哟")
 | 
			
		||||
	switch req.Type {
 | 
			
		||||
	case "url":
 | 
			
		||||
	case "html":
 | 
			
		||||
	default:
 | 
			
		||||
		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid type")
 | 
			
		||||
	}
 | 
			
		||||
	res, err := pdf.HtmlToPdfBase64(req.Content, req.Type)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
 | 
			
		||||
	}
 | 
			
		||||
	return resp.SetStatus(basic.CodeOK, res)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
 | 
			
		||||
// func (l *TestPdfLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
 | 
			
		||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
 | 
			
		||||
// }
 | 
			
		||||
@ -40,15 +40,6 @@ type GetCollectProductListRspItem struct {
 | 
			
		||||
	IsDeleted        int64       `json:"is_deleted"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TestAiReq struct {
 | 
			
		||||
	Num int `form:"num"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TestPdfReq struct {
 | 
			
		||||
	Content string `json:"content"`
 | 
			
		||||
	Type    string `json:"type"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Request struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -12,6 +12,7 @@ import (
 | 
			
		||||
	"fusenapi/utils/s3url_to_s3id"
 | 
			
		||||
	"fusenapi/utils/template_switch_info"
 | 
			
		||||
	"gorm.io/gorm"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"context"
 | 
			
		||||
@ -244,6 +245,7 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductDetailRsp{
 | 
			
		||||
		Logo:                 req.Logo,
 | 
			
		||||
		TemplateTagColorInfo: templateTagColorInfo,
 | 
			
		||||
		ProductInfo: types.ProductInfo{
 | 
			
		||||
			Id:              productInfo.Id,
 | 
			
		||||
@ -343,6 +345,24 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR
 | 
			
		||||
	if req.SelectedColorIndex < 0 {
 | 
			
		||||
		return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid")
 | 
			
		||||
	}
 | 
			
		||||
	if req.Logo == "" {
 | 
			
		||||
		//颜色选择置0
 | 
			
		||||
		req.SelectedColorIndex = 0
 | 
			
		||||
		//获取默认profile从中获取logo
 | 
			
		||||
		profile, err := l.svcCtx.AllModels.FsUserInfo.GetProfileByUserIdGuestId(l.ctx, "logo_selected", 0, 0)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			if errors.Is(err, gorm.ErrRecordNotFound) {
 | 
			
		||||
				return types.TemplateTagColorInfo{}, errors.New("the default profile info is not exists")
 | 
			
		||||
			}
 | 
			
		||||
			logx.Error(err)
 | 
			
		||||
			return types.TemplateTagColorInfo{}, errors.New("failed to get default profile info for without logo")
 | 
			
		||||
		}
 | 
			
		||||
		if profile["logo_url"] != nil && reflect.TypeOf(profile["logo_url"]).String() == "string" {
 | 
			
		||||
			req.Logo = profile["logo_url"].(string)
 | 
			
		||||
		} else {
 | 
			
		||||
			return types.TemplateTagColorInfo{}, errors.New("default profile logo url is not set !!")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	//根据logo查询素材资源
 | 
			
		||||
	resourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
 | 
			
		||||
	if resourceId == "" {
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package logic
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"fusenapi/constants"
 | 
			
		||||
	"fusenapi/model/gmodel"
 | 
			
		||||
	"fusenapi/utils/auth"
 | 
			
		||||
@ -64,6 +65,7 @@ func (l *GetRecommendProductListLogic) GetRecommendProductList(req *types.GetRec
 | 
			
		||||
			recommendProductList = recommendProductList[:req.Num]
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Println(recommendProductList)
 | 
			
		||||
	//资源id集合
 | 
			
		||||
	resourceIds := make([]string, 0, 50)
 | 
			
		||||
	//需要填充时需要忽略的id
 | 
			
		||||
 | 
			
		||||
@ -129,10 +129,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
 | 
			
		||||
		return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
 | 
			
		||||
	}
 | 
			
		||||
	//组装等级从属关系
 | 
			
		||||
	rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
 | 
			
		||||
	rspTagList, mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
 | 
			
		||||
	return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
 | 
			
		||||
		TotalCategoryProduct: TotalCategoryProduct,
 | 
			
		||||
		TagList:              rspTagList,
 | 
			
		||||
		TagMap:               mapTagRsp,
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -309,8 +310,8 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
 | 
			
		||||
			})
 | 
			
		||||
			//tag中产品
 | 
			
		||||
			for _, tmpProduct := range productListRsp {
 | 
			
		||||
				tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct.ProductId)
 | 
			
		||||
				req.MapTagProduct[tmpProduct.ProductId] = tmpProduct
 | 
			
		||||
				tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct.Id)
 | 
			
		||||
				req.MapTagProduct[tmpProduct.Id] = tmpProduct
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		//加入分类
 | 
			
		||||
@ -320,8 +321,9 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 组织等级从属关系
 | 
			
		||||
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, productCount int) {
 | 
			
		||||
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagRsp map[int64]types.TagItem, productCount int) {
 | 
			
		||||
	mapTop := make(map[string]struct{})
 | 
			
		||||
	mapTagRsp = make(map[int64]types.TagItem)
 | 
			
		||||
	//设置归属关系
 | 
			
		||||
	for prefix, tagItem := range mapTagLevel {
 | 
			
		||||
		prefixSlice := strings.Split(prefix, "/")
 | 
			
		||||
@ -377,12 +379,13 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
 | 
			
		||||
		}
 | 
			
		||||
		productCount += len(mapTagLevel[prefix].TagProductList)
 | 
			
		||||
		rspList = append(rspList, *mapTagLevel[prefix])
 | 
			
		||||
		mapTagRsp[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix]
 | 
			
		||||
	}
 | 
			
		||||
	//排序
 | 
			
		||||
	sort.SliceStable(rspList, func(i, j int) bool {
 | 
			
		||||
		return rspList[i].Sort < rspList[j].Sort
 | 
			
		||||
	})
 | 
			
		||||
	return rspList, productCount
 | 
			
		||||
	return rspList, mapTagRsp, productCount
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获取某个tag的直属产品
 | 
			
		||||
@ -424,6 +427,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
 | 
			
		||||
			haveOptionalFitting = true
 | 
			
		||||
		}
 | 
			
		||||
		item := types.TagProduct{
 | 
			
		||||
			Id:                  productInfo.Id,
 | 
			
		||||
			ProductId:           productInfo.Id,
 | 
			
		||||
			Sn:                  *productInfo.Sn,
 | 
			
		||||
			Title:               *productInfo.Title,
 | 
			
		||||
 | 
			
		||||
@ -35,8 +35,9 @@ type GetTagProductListReq struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetTagProductListRsp struct {
 | 
			
		||||
	TotalCategoryProduct int       `json:"total_category_product"`
 | 
			
		||||
	TagList              []TagItem `json:"tag_list"`
 | 
			
		||||
	TotalCategoryProduct int         `json:"total_category_product"`
 | 
			
		||||
	TagList              []TagItem   `json:"tag_list"`
 | 
			
		||||
	TagMap               interface{} `json:"tag_map"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TagItem struct {
 | 
			
		||||
@ -50,7 +51,8 @@ type TagItem struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TagProduct struct {
 | 
			
		||||
	ProductId           int64              `json:"product_id"`
 | 
			
		||||
	Id                  int64              `json:"id"`
 | 
			
		||||
	ProductId           int64              `json:"product_id"` //后面删掉这个
 | 
			
		||||
	Sn                  string             `json:"sn"`
 | 
			
		||||
	Title               string             `json:"title"`
 | 
			
		||||
	Cover               string             `json:"cover"`
 | 
			
		||||
@ -171,10 +173,11 @@ type GetProductDetailReq struct {
 | 
			
		||||
	ProductId          int64  `form:"product_id"`           //产品id
 | 
			
		||||
	TemplateTag        string `form:"template_tag"`         //模板标签
 | 
			
		||||
	SelectedColorIndex int    `form:"selected_color_index"` //模板标签颜色索引
 | 
			
		||||
	Logo               string `form:"logo"`                 //logo地址
 | 
			
		||||
	Logo               string `form:"logo,optional"`        //logo地址
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailRsp struct {
 | 
			
		||||
	Logo                 string               `json:"logo"`                    //logo
 | 
			
		||||
	TemplateTagColorInfo TemplateTagColorInfo `json:"template_tag_color_info"` //标签颜色信息
 | 
			
		||||
	ProductInfo          ProductInfo          `json:"product_info"`            //产品基本信息
 | 
			
		||||
	BaseColors           interface{}          `json:"base_colors"`             //一些返回写死的颜色
 | 
			
		||||
 | 
			
		||||
@ -18,12 +18,6 @@ service collection {
 | 
			
		||||
	//获取收藏列表
 | 
			
		||||
	@handler GetCollectProductListHandler
 | 
			
		||||
	get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response);
 | 
			
		||||
	//测试算法合图并发
 | 
			
		||||
	@handler TestAiHandler
 | 
			
		||||
	get /api/collection/test_ai(TestAiReq) returns (response);
 | 
			
		||||
	//测试pdf
 | 
			
		||||
	@handler TestPdfHandler
 | 
			
		||||
	post /api/collection/test_pdf(TestPdfReq) returns (response);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//收藏产品
 | 
			
		||||
@ -58,13 +52,4 @@ type GetCollectProductListRspItem {
 | 
			
		||||
	MinPrice         string      `json:"min_price"`
 | 
			
		||||
	IsShelf          int64       `json:"is_shelf"`
 | 
			
		||||
	IsDeleted        int64       `json:"is_deleted"`
 | 
			
		||||
}
 | 
			
		||||
//测试算法
 | 
			
		||||
type TestAiReq {
 | 
			
		||||
	Num int `form:"num"`
 | 
			
		||||
}
 | 
			
		||||
//测试pdf
 | 
			
		||||
type TestPdfReq {
 | 
			
		||||
	Content string `json:"content"`
 | 
			
		||||
	Type    string `json:"type"`
 | 
			
		||||
}
 | 
			
		||||
@ -77,8 +77,9 @@ type GetTagProductListReq {
 | 
			
		||||
	WithProduct bool   `form:"with_product,optional"` //是否携带分类下的产品
 | 
			
		||||
}
 | 
			
		||||
type GetTagProductListRsp {
 | 
			
		||||
	TotalCategoryProduct int       `json:"total_category_product"`
 | 
			
		||||
	TagList              []TagItem `json:"tag_list"`
 | 
			
		||||
	TotalCategoryProduct int         `json:"total_category_product"`
 | 
			
		||||
	TagList              []TagItem   `json:"tag_list"`
 | 
			
		||||
	TagMap               interface{} `json:"tag_map"`
 | 
			
		||||
}
 | 
			
		||||
type TagItem {
 | 
			
		||||
	TypeName       string        `json:"type_name"`
 | 
			
		||||
@ -90,7 +91,8 @@ type TagItem {
 | 
			
		||||
	ChildTagList   []*TagItem    `json:"child_tag_list"`
 | 
			
		||||
}
 | 
			
		||||
type TagProduct {
 | 
			
		||||
	ProductId     int64       `json:"product_id"`
 | 
			
		||||
	Id            int64       `json:"id"`
 | 
			
		||||
	ProductId     int64       `json:"product_id"` //后面删掉这个
 | 
			
		||||
	Sn            string      `json:"sn"`
 | 
			
		||||
	Title         string      `json:"title"`
 | 
			
		||||
	Cover         string      `json:"cover"`
 | 
			
		||||
@ -207,9 +209,10 @@ type GetProductDetailReq {
 | 
			
		||||
	ProductId          int64  `form:"product_id"`           //产品id
 | 
			
		||||
	TemplateTag        string `form:"template_tag"`         //模板标签
 | 
			
		||||
	SelectedColorIndex int    `form:"selected_color_index"` //模板标签颜色索引
 | 
			
		||||
	Logo               string `form:"logo"`                 //logo地址
 | 
			
		||||
	Logo               string `form:"logo,optional"`        //logo地址
 | 
			
		||||
}
 | 
			
		||||
type GetProductDetailRsp {
 | 
			
		||||
	Logo                 string               `json:"logo"`                    //logo
 | 
			
		||||
	TemplateTagColorInfo TemplateTagColorInfo `json:"template_tag_color_info"` //标签颜色信息
 | 
			
		||||
	ProductInfo          ProductInfo          `json:"product_info"`            //产品基本信息
 | 
			
		||||
	BaseColors           interface{}          `json:"base_colors"`             //一些返回写死的颜色
 | 
			
		||||
 | 
			
		||||
@ -223,7 +223,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
 | 
			
		||||
	moduleDataMap["materialList"] = materialList
 | 
			
		||||
 | 
			
		||||
	var combineParam map[string]interface{}
 | 
			
		||||
	json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam)
 | 
			
		||||
	json.Unmarshal(*resLogoInfo.Metadata, &combineParam)
 | 
			
		||||
	combineParam["resolution"] = in.Resolution
 | 
			
		||||
	combineParam["template_tagid"] = in.TemplateTag
 | 
			
		||||
	combineParam["website"] = in.Website
 | 
			
		||||
 | 
			
		||||
@ -136,9 +136,9 @@ func (d *defaultShoppingCart) CaculateStepPrice(purchaseQuantity int64, stepPric
 | 
			
		||||
	//遍历查询合适的价格
 | 
			
		||||
	for k, v := range stepPrice.PriceRange {
 | 
			
		||||
		//购买数量>起点
 | 
			
		||||
		if purchaseQuantity > v.StartQuantity {
 | 
			
		||||
			//最后一个 || 小于等于终点
 | 
			
		||||
			if k == l-1 || purchaseQuantity <= v.EndQuantity {
 | 
			
		||||
		if purchaseQuantity >= v.StartQuantity {
 | 
			
		||||
			//最后一个 || 小于终点
 | 
			
		||||
			if k == l-1 || purchaseQuantity < v.EndQuantity {
 | 
			
		||||
				itemPrice = v.Price + fittingPrice
 | 
			
		||||
				return itemPrice * purchaseQuantity, itemPrice, nil
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user