Browse Source

添加获取全部同类商品业务模块

multiwx
dy-hu 1 month ago
parent
commit
a7b6110798
  1. 12
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/product/ProductController.java
  2. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/product/CereShopProductDAO.java
  3. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java
  4. 5
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java
  5. 24
      cereshop-app/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml

12
cereshop-app/src/main/java/com/shop/cereshop/app/controller/product/ProductController.java

@ -249,4 +249,16 @@ public class ProductController {
return new Result(cereShopProductService.getBroadCastList(param.getProductId(), param.getShopGroupWorkId(), buyerUserId), CoReturnFormat.SUCCESS);
}
/**
* 获取全部同类商品
* @param classifyId 商品分类id
* @return
*/
@GetMapping("getAllSimilarProducts/{classifyId}")
@ApiOperation(value = "获取全部同类商品")
public Result<List<Product>> getAllSimilarProducts(@PathVariable Long classifyId){
List<Product> products = cereShopProductService.findAllSimilarProducts(classifyId);
return new Result(products, CoReturnFormat.SUCCESS);
}
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/product/CereShopProductDAO.java

@ -63,6 +63,8 @@ public interface CereShopProductDAO extends BaseMapper<CereShopProduct> {
List<Product> findSimilarProducts(@Param("project") String project, @Param("classifyId") Long classifyId);
List<Product> findAllSimilarProducts(@Param("project") String project, @Param("classifyId") Long classifyId);
void deleteAllSearch(@Param("buyerUserId") Long buyerUserId);
List<CanvasProduct> getGroupWorkProducts(CanvasAppProductParam param);

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java

@ -74,4 +74,6 @@ public interface CereShopProductService {
List<BroadCastDTO> getBroadCastList(Long productId, Long shopGroupWorkId, Long buyerUserId);
ShareProduct getShareProductParam(ProductParam param, CereBuyerUser user) throws CoBusinessException;
List<Product> findAllSimilarProducts(Long classifyId);
}

5
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java

@ -1901,4 +1901,9 @@ public class CereShopProductServiceImpl implements CereShopProductService {
productDetail.initData(ContextUtil.getLanguage());
}
}
@Override
public List<Product> findAllSimilarProducts(Long classifyId) {
return cereShopProductDAO.findAllSimilarProducts(ContextUtil.getProject(), classifyId == 0 ? null : classifyId);
}
}

24
cereshop-app/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml

@ -843,6 +843,30 @@
ORDER BY (f.number + a.fictitious_number) DESC LIMIT 4
</select>
<select id="findAllSimilarProducts" parameterType="java.lang.Object" resultType="com.shop.cereshop.app.page.index.Product">
SELECT a.shop_id,d.shop_name,a.product_id,a.product_name,c.product_image image,
b.price,b.sku_id,b.original_price,a.product_brief,g.users from cere_shop_product a
LEFT JOIN (SELECT a.product_id,a.price,a.sku_id,a.original_price from cere_product_sku a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) b ON a.product_id=b.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id
LEFT JOIN cere_platform_shop d ON a.shop_id=d.shop_id
LEFT JOIN (SELECT IF(SUM(number) IS NULL,0,SUM(number)) number,sku_id,order_id from cere_order_product GROUP BY sku_id) f ON b.sku_id=f.sku_id
LEFT JOIN (SELECT COUNT(a.buyer_user_id) users,a.product_id FROM (SELECT b.buyer_user_id,a.product_id FROM cere_order_product a,cere_shop_order b
where a.order_id=b.order_id and b.state in (2,3,4) GROUP BY a.product_id,b.buyer_user_id) a GROUP BY a.product_id) g ON a.product_id=g.product_id
where d.state=1
<if test="project == 0">
and a.plat_shelve_state=1
</if>
<if test="project!=0 and project != ''">
and a.shelve_state=1
</if>
<if test="classifyId!=null">
and (a.classify_id=#{classifyId} OR a.classify_business_id=#{classifyId})
</if>
ORDER BY (f.number + a.fictitious_number) DESC
</select>
<select id="getRandomSortProduct" resultType="com.shop.cereshop.app.page.index.Product">
SELECT a.shop_id,
d.shop_name,

Loading…
Cancel
Save