|
@@ -20,6 +20,7 @@ import (
|
|
|
)
|
|
|
|
|
|
type ProductDTO struct {
|
|
|
+ Id int `json:"-"`
|
|
|
Title string `json:"title"`
|
|
|
SourceTile string `json:"sourceTile"`
|
|
|
Abstract string `json:"abstract"`
|
|
@@ -35,6 +36,7 @@ type ProductDTO struct {
|
|
|
BeginDate string `json:"beginDate"`
|
|
|
EndDate string `json:"endDate"`
|
|
|
SourceId int `json:"sourceId"`
|
|
|
+ IsSubscribe bool `json:"isSubscribe"`
|
|
|
ReportId int `json:"reportId"`
|
|
|
MediaId int `json:"mediaId"`
|
|
|
}
|
|
@@ -131,6 +133,7 @@ func convertToProductDTO(product merchantService.MerchantProductDTO) (productDTO
|
|
|
beginDate := time.Now()
|
|
|
endDate := beginDate.Add(time.Duration(product.ValidDays) * 24 * time.Hour)
|
|
|
productDTO = ProductDTO{
|
|
|
+ Id: product.Id,
|
|
|
Title: product.Title,
|
|
|
Description: product.Description,
|
|
|
Price: product.Price.String(),
|
|
@@ -230,11 +233,12 @@ func GetRelatePackage(info ProductDTO) (prodList []ProductDTO, err error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func GetProductListByProductType(productType string, permissionIds []int, templateUserId int) (dtoList []ProductDTO, err error) {
|
|
|
+func GetProductListByProductType(productType string, permissionIds []int, templateUserId int) (total, latestId int64, productIds []int) {
|
|
|
filterPermissionIds, riskLevel, err := reportService.CheckUserRisk(permissionIds, true, templateUserId)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+ var dtoList []*ProductDTO
|
|
|
productList, err := merchantService.GetProductListByProductType(productType)
|
|
|
var wg sync.WaitGroup
|
|
|
wg.Add(len(productList))
|
|
@@ -258,10 +262,19 @@ func GetProductListByProductType(productType string, permissionIds []int, templa
|
|
|
if !match {
|
|
|
return
|
|
|
}
|
|
|
- dtoList = append(dtoList, product)
|
|
|
+ dtoList = append(dtoList, &product)
|
|
|
}(productList[i])
|
|
|
}
|
|
|
wg.Wait()
|
|
|
+ total = int64(len(dtoList))
|
|
|
+ var maxId int
|
|
|
+ for i := 0; i < len(dtoList); i++ {
|
|
|
+ productIds = append(productIds, dtoList[i].Id)
|
|
|
+ if dtoList[i].Id > maxId {
|
|
|
+ maxId = dtoList[i].Id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ latestId = int64(maxId)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -274,19 +287,28 @@ func compare(riskLevel, MatchRiskLevel string) bool {
|
|
|
if riskErr != nil {
|
|
|
return false
|
|
|
}
|
|
|
- if pRiskNum > riskLevelNum {
|
|
|
+ if pRiskNum <= riskLevelNum {
|
|
|
return true
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
-func ProductList(productType string, info page.PageInfo) (dtoList []ProductDTO, err error) {
|
|
|
+func ProductList(productIds []int, templateUserId int, info page.PageInfo) (dtoList []ProductDTO, err error) {
|
|
|
var merchantProductList []merchantService.MerchantProductDTO
|
|
|
- merchantProductList, err = merchantService.GetProductPageByProductType(productType, info)
|
|
|
+ merchantProductList, err = merchantService.GetProductPageByProductType(productIds, info)
|
|
|
for _, product := range merchantProductList {
|
|
|
productDTO := convertToProductDTO(product)
|
|
|
productDTO.RiskLevel, productDTO.SourceTile, productDTO.Abstract, productDTO.CoverUrl, productDTO.Src, productDTO.PermissionNames, _, err = GetProductRiskLevel(product)
|
|
|
dtoList = append(dtoList, productDTO)
|
|
|
}
|
|
|
+ var wg sync.WaitGroup
|
|
|
+ wg.Add(len(dtoList))
|
|
|
+ for i := 0; i < len(dtoList); i++ {
|
|
|
+ go func(productDTO *ProductDTO) {
|
|
|
+ defer wg.Done()
|
|
|
+ //subscibe, err := user.GetUserSubscribe(productDTO.Id, templateUserId)
|
|
|
+ //if
|
|
|
+ }(&dtoList[i])
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
func RangeProductList(isSignal bool) (total, latestId int64, ids []int) {
|