<?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.panzhihua.service_community.dao.ComBatteryStoreMapper">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComBatteryStore" id="ComBatteryStoreMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="regPhone" column="reg_phone" jdbcType="VARCHAR"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="account" column="account" jdbcType="VARCHAR"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="isDel" column="is_del" jdbcType="INTEGER"/>
|
<result property="logo" column="logo" jdbcType="VARCHAR"/>
|
<result property="introduction" column="introduction" jdbcType="VARCHAR"/>
|
<result property="address" column="address" jdbcType="VARCHAR"/>
|
<result property="detailAddress" column="detail_address" jdbcType="VARCHAR"/>
|
<result property="longitude" column="longitude" jdbcType="VARCHAR"/>
|
<result property="latitude" column="latitude" jdbcType="VARCHAR"/>
|
<result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
|
<result property="createBy" column="create_by" jdbcType="INTEGER"/>
|
<result property="updateAt" column="update_at" jdbcType="TIMESTAMP"/>
|
<result property="updateBy" column="update_by" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComBatteryStoreVo">
|
select
|
id, name, reg_phone, phone, account, status, is_del, logo, introduction, address, detail_address, longitude, latitude, create_at, create_by, update_at, update_by
|
from com_battery_store
|
where id = #{id}
|
</select>
|
|
<!--查询指定行数据-->
|
<select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComBatteryStoreVo">
|
select
|
id, name, reg_phone, phone, account, status, is_del, logo, introduction, address, detail_address, longitude,
|
latitude, create_at, create_by, update_at, update_by,
|
(select count(id) from com_battery_commodity_order where store_id = cbs.id and `status` in (2,3,4)
|
and create_at between DATE_ADD(curdate(),interval -day(curdate())+1 day) and now()) as monthSale
|
from com_battery_store as cbs
|
<where>
|
and is_del = 2
|
<if test="dto.id != null">
|
and id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and `name` = #{dto.name}
|
</if>
|
<if test="dto.regPhone != null and dto.regPhone != ''">
|
and reg_phone = #{dto.regPhone}
|
</if>
|
<if test="dto.phone != null and dto.phone != ''">
|
and phone = #{dto.phone}
|
</if>
|
<if test="dto.account != null and dto.account != ''">
|
and account = #{dto.account}
|
</if>
|
<if test="dto.status != null">
|
and status = #{dto.status}
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (`name` like concat('%',#{dto.keyWord},'%') or
|
`reg_phone` like concat('%',#{dto.keyWord},'%') or
|
`account` like concat('%',#{dto.keyWord},'%')
|
)
|
</if>
|
</where>
|
order by create_at desc
|
</select>
|
|
<!--查询所有数据-->
|
<select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComBatteryStoreVo">
|
select
|
id, name, reg_phone, phone, account, status, is_del, logo, introduction, address, detail_address, longitude,
|
latitude, create_at, create_by, update_at, update_by,
|
(select count(id) from com_battery_commodity_order where store_id = cbs.id and `status` in (2,3,4)
|
and create_at between DATE_ADD(curdate(),interval -day(curdate())+1 day) and now()) as monthSale
|
from com_battery_store as cbs
|
<where>
|
and is_del = 2
|
<if test="dto.id != null">
|
and id = #{dto.id}
|
</if>
|
<if test="dto.name != null and dto.name != ''">
|
and `name` = #{dto.name}
|
</if>
|
<if test="dto.regPhone != null and dto.regPhone != ''">
|
and reg_phone = #{dto.regPhone}
|
</if>
|
<if test="dto.phone != null and dto.phone != ''">
|
and phone = #{dto.phone}
|
</if>
|
<if test="dto.account != null and dto.account != ''">
|
and account = #{dto.account}
|
</if>
|
<if test="dto.status != null">
|
and status = #{dto.status}
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (`name` like concat('%',#{dto.keyWord},'%') or
|
`reg_phone` like concat('%',#{dto.keyWord},'%') or
|
`account` like concat('%',#{dto.keyWord},'%')
|
)
|
</if>
|
</where>
|
order by create_at desc
|
</select>
|
|
<select id="getStoreUserCountByAccount" resultType="integer">
|
select count(user_id) from sys_user where `type` = 20 and account = #{account}
|
</select>
|
|
<select id="getStoreUserCountByPhone" resultType="integer">
|
select count(user_id) from sys_user where `type` = 20 and phone = #{regPhone}
|
</select>
|
|
<delete id="deleteStoreUserByStoreId">
|
delete from sys_user where `type` = 20 and community_id = #{storeId}
|
</delete>
|
|
</mapper>
|