<?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="com.sinata.rest.modular.member.dao.MemMerchantMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.sinata.rest.modular.member.model.MemMerchant">
|
<id column="id" property="id" />
|
<result column="create_time" property="createTime" />
|
<result column="merchant_name" property="merchantName" />
|
<result column="linkman" property="linkman" />
|
<result column="link_phone" property="linkPhone" />
|
<result column="user_id" property="userId" />
|
<result column="business_license" property="businessLicense" />
|
<result column="other_details" property="otherDetails" />
|
<result column="apply_des" property="applyDes" />
|
<result column="state" property="state" />
|
<result column="audit_state" property="auditState" />
|
<result column="audit_time" property="auditTime" />
|
<result column="audit_mark" property="auditMark" />
|
<result column="is_delete" property="isDelete" />
|
<result column="logo" property="logo" />
|
</resultMap>
|
|
<select id="merchantInfoByGoodsId" parameterType="java.lang.Integer" resultType="com.sinata.rest.modular.member.controller.common.vo.VoGoodsMerchantInfo">
|
SELECT m.*
|
FROM mem_merchant m
|
WHERE m.id = #{id}
|
</select>
|
|
<select id="getMerchantUserScore" parameterType="java.lang.Integer" resultType="java.lang.Double">
|
SELECT IFNULL(SUM(ue.score)/count(ue.id), 0) userScore
|
FROM mall_goods g
|
RIGHT JOIN mall_user_evaluation ue ON g.id = ue.goods_id
|
WHERE g.merchant_id = #{id} AND g.is_delete = 0 AND ue.is_delete = 0
|
</select>
|
|
<select id="selectInfo" resultType="com.sinata.rest.modular.member.controller.common.vo.VoGoodsMerchantInfo">
|
SELECT * FROM mem_merchant WHERE user_id = #{userId}
|
</select>
|
|
<select id="getMerchantParentUser" resultType="com.sinata.rest.modular.member.model.MemUserRelation">
|
SELECT o.id, o.parent_id FROM mem_user_relation o
|
LEFT JOIN mem_merchant m ON o.id = m.user_id
|
WHERE m.id = #{merchantId}
|
</select>
|
|
<select id="queryMerchantList" resultType="com.sinata.rest.modular.member.model.MemMerchant">
|
SELECT
|
mt.id,
|
mt.merchant_name,mt.address,
|
mt.`work_end_time` ,
|
mt.`work_start_time` ,
|
mt.`work_end_date` ,
|
mt.`work_start_date` ,
|
mt.link_phone
|
FROM
|
mem_merchant mt
|
LEFT JOIN sys_area_city ac on ac.id = mt.city_id
|
where mt.is_delete = 0
|
<if test="level != null and level == 1 ">
|
and ac.province_code = #{cityCode}
|
</if>
|
<if test="level != null and level == 2 ">
|
and ac.city_code = #{cityCode}
|
</if>
|
<if test="level != null and level == 3 ">
|
and ac.county_code = #{cityCode}
|
</if>
|
order by mt.id desc
|
|
</select>
|
|
<select id="getMerchantCount" resultType="com.sinata.rest.modular.member.model.MemMerchant">
|
SELECT
|
ac.county_code,
|
ac.county_name,
|
count(1) merchantCount
|
FROM
|
mem_merchant mt
|
LEFT JOIN sys_area_city ac on ac.id = mt.city_id
|
where mt.is_delete = 0
|
<if test="level != null and level == 1 ">
|
and ac.province_code = #{cityCode}
|
</if>
|
<if test="level != null and level == 2 ">
|
and ac.city_code = #{cityCode}
|
</if>
|
<if test="level != null and level == 3 ">
|
and ac.county_code = #{cityCode}
|
</if>
|
group by ac.county_code
|
order by mt.id desc
|
|
</select>
|
|
<select id="getMerchantMallGoods" resultType="com.sinata.rest.modular.mall.model.MallGoodsSku">
|
SELECT
|
md.goods_name,
|
md.buy_count,
|
md.goods_image,
|
mk.*
|
FROM
|
`mall_goods_sku` mk
|
LEFT JOIN mall_goods md ON md.id = mk.goods_id
|
WHERE
|
mk.merchant_id = #{merchantId}
|
AND mk.state = 1
|
GROUP BY
|
mk.goods_id
|
ORDER BY
|
md.buy_count DESC
|
</select>
|
|
<select id="getMerchantListByGoodsId" resultType="com.sinata.rest.modular.member.model.MemMerchant">
|
SELECT * FROM mem_merchant o
|
WHERE id IN (
|
SELECT merchant_id FROM mall_goods_sku
|
WHERE state = 1
|
and is_delete = 0
|
<if test="goodsId != null">
|
AND goods_id = #{goodsId}
|
</if>
|
<if test="cityCode != null and cityCode != ''">
|
AND county_code = #{cityCode}
|
</if>
|
)
|
</select>
|
|
<select id="getMerchantOrderList" resultType="com.sinata.rest.modular.mall.controller.vo.VoMallOrder">
|
SELECT
|
mo.*,
|
md.goods_image goodsImage, md.use_time,
|
ms.goods_name
|
FROM
|
mall_order mo
|
Left JOIN `mall_order_detail` md ON md.order_no = mo.order_no
|
Left JOIN mall_goods ms ON ms.id = md.goods_id
|
WHERE mo.is_delete = 0 and mo.state in (1,2,3)
|
<if test="merchantId != null">
|
and (mo.merchant_id = #{merchantId})
|
</if>
|
<if test="condition != null and condition != ''">
|
and (mo.order_no =#{condition} or mo.phone =#{condition} or ms.goods_name like CONCAT('%', #{condition},'%') )
|
</if>
|
<if test="isUse !=null and isUse">
|
and mo.state = 3
|
group by mo.order_no
|
order by md.use_time desc
|
</if>
|
<if test="isUse !=null and !isUse">
|
and mo.state <> 3
|
group by mo.order_no
|
order by mo.order_no desc
|
</if>
|
</select>
|
|
<select id="getMemMerchant" resultType="com.sinata.rest.modular.member.model.MemMerchant">
|
select *,(select GROUP_CONCAT(name) from my_store_service where FIND_IN_SET(id,service_ids)) serviceName from mem_merchant where id =#{merchantId}
|
</select>
|
|
<select id="getMerchantService" resultType="java.lang.String">
|
SELECT `name` FROM `my_store_service` where is_delete = 0
|
and id in
|
<foreach collection="list" item="id" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
</select>
|
|
</mapper>
|