<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.inspection.mapper.AppInspectionGoodsMapper">
    <select id="homePartners" resultType="cn.iocoder.yudao.module.inspection.vo.PartnerListVo">
        SELECT
            partner.partner_id,partner.partner_name,partner.partner_logo,partner.sales_num,partner.average_score,partner.address, ROUND(ST_Distance_Sphere (POINT (#{longitude}, #{latitude}),POINT (partner.longitude, partner.latitude ))) AS distance
        FROM
            shop_mall_partners partner
                Inner JOIN shop_inspection_goods sig ON partner.partner_id = sig.partner_id  AND sig.is_listing='1'
        where partner.is_banned = '0' and partner.partner_logo is not null
        group by partner.partner_id
        order by distance
    </select>
    <select id="goodsList" resultType="cn.iocoder.yudao.module.inspection.vo.GoodsVo">
        SELECT
            category.category_name,goods.id as goodsId,category.image as goodsImage
        FROM
            shop_inspection_category category
                INNER JOIN shop_inspection_goods goods ON category.id = goods.goods_category_id and goods.is_listing='1'
                INNER JOIN inspection_goods_sku sku ON goods.id = sku.goods_id
        where goods.partner_id = #{partnerId}
        group by goods.id
        ORDER BY category.order_num
    </select>


</mapper>
