浏览代码

产品列表

kobe6258 4 月之前
父节点
当前提交
107e2139c1

+ 1 - 7
controllers/product/product_controller.go

@@ -153,7 +153,7 @@ func (p *ProductController) ProductList(productType string, permissionIds string
 			Current:  p.PageInfo.Current,
 			PageSize: p.PageInfo.PageSize,
 		}
-		pageRes.Total, pageRes.LatestId = productService.GetTotalPageCountByProductType(productType, permissionIdList, userInfo.Id)
+		list, err := productService.GetProductListByProductType(productType, permissionIdList, userInfo.Id)
 		if p.PageInfo.LatestId == 0 {
 			p.PageInfo.LatestId = pageRes.LatestId
 			p.PageInfo.Total = pageRes.Total
@@ -162,12 +162,6 @@ func (p *ProductController) ProductList(productType string, permissionIds string
 			pageRes.Total = p.PageInfo.Total
 		}
 		pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize)
-		list, err := productService.ProductList(productType, p.PageInfo)
-		if err != nil {
-			p.FailedResult("分页查询产品列表失败", result)
-			err = exception.NewWithException(exception.GetProductListFailed, err.Error())
-			return
-		}
 		productList := new(page.PageResult)
 		productList.Data = list
 		productList.Page = pageRes

+ 1 - 1
domian/order/product_order.go

@@ -133,7 +133,7 @@ func convertProductOrderDetailDTO(order orderDao.ProductOrder) (orderDetailDTO P
 		orderDetailDTO.StatusCN = transRefundStatusMap[order.RefundStatus]
 	}
 	if order.Status == orderDao.OrderStatusPending {
-		duration := time.Now().Sub(order.CreatedTime)
+		duration := time.Now().Sub(order.ExpiredTime)
 		timeout := duration - 15*time.Minute
 		if timeout > 0 {
 			logger.Info("订单已超时:%v", order.OrderID)

+ 1 - 1
models/order/product_order.go

@@ -77,7 +77,7 @@ func CreateProductOrder(order ProductOrder) (orderNo string, err error) {
 
 func GetTotalPageCountByUserId(userId int, status OrderStatus) (total int64, latestId int64) {
 	db := models.Main()
-	query := db.Model(&ProductOrder{}).Select("count(*)").Where("user_id = ? and is_deleted=0 ", userId)
+	query := db.Model(&ProductOrder{}).Select("count(*)").Where("template_user_id = ? and is_deleted=0 ", userId)
 	if string(status) != "" {
 		query.Where("  status=?", status)
 	}

+ 3 - 5
service/product/product_service.go

@@ -230,13 +230,12 @@ func GetRelatePackage(info ProductDTO) (prodList []ProductDTO, err error) {
 	}
 }
 
-func GetTotalPageCountByProductType(productType string, permissionIds []int, templateUserId int) (total int64, latestId int64) {
+func GetProductListByProductType(productType string, permissionIds []int, templateUserId int) (dtoList []ProductDTO, err error) {
 	filterPermissionIds, riskLevel, err := reportService.CheckUserRisk(permissionIds, true, templateUserId)
 	if err != nil {
-		return 0, 0
+		return
 	}
 	productList, err := merchantService.GetProductListByProductType(productType)
-	var dtoList []*ProductDTO
 	var wg sync.WaitGroup
 	wg.Add(len(productList))
 	for i := 0; i < len(productList); i++ {
@@ -256,11 +255,10 @@ func GetTotalPageCountByProductType(productType string, permissionIds []int, tem
 					}
 				}
 			}
-
 			if !match {
 				return
 			}
-			dtoList = append(dtoList, &product)
+			dtoList = append(dtoList, product)
 		}(productList[i])
 	}
 	wg.Wait()