<?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.VolunteerMerchantDao">
|
|
<resultMap type="com.panzhihua.service_community.entity.VolunteerMerchant" id="VolunteerMerchantMap">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="merchantType" column="merchant_type" />
|
<result property="logoUrl" column="logo_url" />
|
<result property="address" column="address" />
|
<result property="lat" column="lat" />
|
<result property="lon" column="lon" />
|
<result property="userId" column="user_id" />
|
<result property="serviceCall" column="service_call" />
|
<result property="merchantContent" column="merchant_content" />
|
<result property="merchantUrl" column="merchant_url" />
|
<result property="legalPersonName" column="legal_person_name" />
|
<result property="legalPersonPhone" column="legal_person_phone" />
|
<result property="legalPersonIdCard" column="legal_person_id_card" />
|
<result property="communityId" column="community_id" />
|
<result property="businessType" column="business_type" />
|
<result property="businessStartTime" column="business_start_time" />
|
<result property="businessEndTime" column="business_end_time" />
|
<result property="merchantState" column="merchant_state" />
|
<result property="merchantDiscount" column="merchant_discount" />
|
<result property="creationTime" column="creation_time" />
|
<result property="updateTime" column="update_time" />
|
<result property="merchantIntegral" column="merchant_integral" />
|
</resultMap>
|
|
<sql id="beas_sql">
|
id,
|
name,
|
merchant_type,
|
logo_url,
|
address,
|
lat,
|
lon,
|
user_id,
|
(select su.phone from sys_user as su where su.user_id=volunteer_merchant.user_id) as merchantPhone,
|
(select su.name from sys_user as su where su.user_id=volunteer_merchant.user_id) as merchantLinkman,
|
(select vt.name from volunteer_type as vt where vt.id=volunteer_merchant.merchant_type) as merchantTypeName,
|
(SELECT ROUND(AVG(vme.evaluate_grade), 1) FROM volunteer_merchant_evaluate as vme WHERE vme.merchant_id=volunteer_merchant.id) as merchantGrade,
|
(select count(vim.id) from volunteer_integral_merchant as vim
|
where vim.merchant_id=volunteer_merchant.id and vim.state='1') as goodNum,
|
service_call,
|
merchant_content,
|
merchant_url,
|
legal_person_name,
|
legal_person_phone,
|
legal_person_id_card,
|
community_id,
|
business_type,
|
business_start_time,
|
business_end_time,
|
merchant_state,
|
merchant_discount,
|
creation_time,
|
merchant_integral,
|
update_time
|
</sql>
|
|
<select id="getById" resultMap="VolunteerMerchantMap">
|
select <include refid="beas_sql"/>
|
from volunteer_merchant
|
where volunteer_merchant.id=#{id}
|
</select>
|
|
|
<!-- 分页查询 -->
|
<select id="getList" resultMap="VolunteerMerchantMap">
|
select <include refid="beas_sql"/>
|
from volunteer_merchant
|
<where>
|
1=1
|
<if test="communityId!=null and communityId !='' ">
|
and community_id=#{communityId}
|
</if>
|
<if test="merchantState !=null and merchantState !='' ">
|
and merchant_state=#{merchantState}
|
</if>
|
<if test="merchantType !=null and merchantType !='' ">
|
and merchant_type=#{merchantType}
|
</if>
|
<if test="name !=null and name !='' ">
|
and (volunteer_merchant.name like concat('%',#{name},'%'))
|
</if>
|
</where>
|
order by merchantGrade desc,creation_time desc
|
</select>
|
|
<insert id="insertData">
|
insert into volunteer_merchant
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="vtvo.id != null">
|
id,
|
</if>
|
<if test="vtvo.name != null">
|
name,
|
</if>
|
<if test="vtvo.merchantType != null">
|
merchant_type,
|
</if>
|
<if test="vtvo.logoUrl != null">
|
logo_url,
|
</if>
|
<if test="vtvo.address != null">
|
address,
|
</if>
|
<if test="vtvo.lat != null">
|
lat,
|
</if>
|
<if test="vtvo.lon != null">
|
lon,
|
</if>
|
<if test="vtvo.userId != null">
|
user_id,
|
</if>
|
<if test="vtvo.serviceCall != null">
|
service_call,
|
</if>
|
<if test="vtvo.merchantContent != null">
|
merchant_content,
|
</if>
|
<if test="vtvo.merchantUrl != null">
|
merchant_url,
|
</if>
|
<if test="vtvo.legalPersonName != null">
|
legal_person_name,
|
</if>
|
<if test="vtvo.legalPersonPhone != null">
|
legal_person_phone,
|
</if>
|
<if test="vtvo.legalPersonIdCard != null">
|
legal_person_id_card,
|
</if>
|
<if test="vtvo.communityId != null">
|
community_id,
|
</if>
|
<if test="vtvo.businessType != null">
|
business_type,
|
</if>
|
<if test="vtvo.businessStartTime != null">
|
business_start_time,
|
</if>
|
<if test="vtvo.businessEndTime != null">
|
business_end_time,
|
</if>
|
<if test="vtvo.merchantState != null">
|
merchant_state,
|
</if>
|
<if test="vtvo.merchantDiscount != null">
|
merchant_discount,
|
</if>
|
<if test="vtvo.merchantIntegral != null">
|
merchant_integral,
|
</if>
|
creation_time
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="vtvo.id != null">
|
#{vtvo.id},
|
</if>
|
<if test="vtvo.name != null">
|
#{vtvo.name},
|
</if>
|
<if test="vtvo.merchantType != null">
|
#{vtvo.merchantType},
|
</if>
|
<if test="vtvo.logoUrl != null">
|
#{vtvo.logoUrl},
|
</if>
|
<if test="vtvo.address != null">
|
#{vtvo.address},
|
</if>
|
<if test="vtvo.lat != null">
|
#{vtvo.lat},
|
</if>
|
<if test="vtvo.lon != null">
|
#{vtvo.lon},
|
</if>
|
<if test="vtvo.userId != null">
|
#{vtvo.userId},
|
</if>
|
<if test="vtvo.serviceCall != null">
|
#{vtvo.serviceCall},
|
</if>
|
<if test="vtvo.merchantContent != null">
|
#{vtvo.merchantContent},
|
</if>
|
<if test="vtvo.merchantUrl != null">
|
#{vtvo.merchantUrl},
|
</if>
|
<if test="vtvo.legalPersonName != null">
|
#{vtvo.legalPersonName},
|
</if>
|
<if test="vtvo.legalPersonPhone != null">
|
#{vtvo.legalPersonPhone},
|
</if>
|
<if test="vtvo.legalPersonIdCard != null">
|
#{vtvo.legalPersonIdCard},
|
</if>
|
<if test="vtvo.communityId != null">
|
#{vtvo.communityId},
|
</if>
|
<if test="vtvo.businessType != null">
|
#{vtvo.businessType},
|
</if>
|
<if test="vtvo.businessStartTime != null">
|
#{vtvo.businessStartTime},
|
</if>
|
<if test="vtvo.businessEndTime != null">
|
#{vtvo.businessEndTime},
|
</if>
|
<if test="vtvo.merchantState != null">
|
#{vtvo.merchantState},
|
</if>
|
<if test="vtvo.merchantDiscount != null">
|
#{vtvo.merchantDiscount},
|
</if>
|
<if test="vtvo.merchantIntegral != null">
|
#{vtvo.merchantIntegral},
|
</if>
|
sysdate()
|
</trim>
|
</insert>
|
|
<update id="Update">
|
update volunteer_merchant
|
<set>
|
<if test="vtvo.id != null">
|
id=#{vtvo.id},
|
</if>
|
<if test="vtvo.name != null">
|
name=#{vtvo.name},
|
</if>
|
<if test="vtvo.merchantType != null">
|
merchant_type=#{vtvo.merchantType},
|
</if>
|
<if test="vtvo.logoUrl != null">
|
logo_url=#{vtvo.logoUrl},
|
</if>
|
<if test="vtvo.address != null">
|
address=#{vtvo.address},
|
</if>
|
<if test="vtvo.lat != null">
|
lat=#{vtvo.lat},
|
</if>
|
<if test="vtvo.lon != null">
|
lon=#{vtvo.lon},
|
</if>
|
<if test="vtvo.userId != null">
|
user_id=#{vtvo.userId},
|
</if>
|
<if test="vtvo.serviceCall != null">
|
service_call=#{vtvo.serviceCall},
|
</if>
|
<if test="vtvo.merchantContent != null">
|
merchant_content=#{vtvo.merchantContent},
|
</if>
|
<if test="vtvo.merchantUrl != null">
|
merchant_url=#{vtvo.merchantUrl},
|
</if>
|
<if test="vtvo.legalPersonName != null">
|
legal_person_name=#{vtvo.legalPersonName},
|
</if>
|
<if test="vtvo.legalPersonPhone != null">
|
legal_person_phone=#{vtvo.legalPersonPhone},
|
</if>
|
<if test="vtvo.legalPersonIdCard != null">
|
legal_person_id_card=#{vtvo.legalPersonIdCard},
|
</if>
|
<if test="vtvo.communityId != null">
|
community_id=#{vtvo.communityId},
|
</if>
|
<if test="vtvo.businessType != null">
|
business_type=#{vtvo.businessType},
|
</if>
|
<if test="vtvo.businessStartTime != null">
|
business_start_time=#{vtvo.businessStartTime},
|
</if>
|
<if test="vtvo.businessEndTime != null">
|
business_end_time=#{vtvo.businessEndTime},
|
</if>
|
<if test="vtvo.merchantState != null">
|
merchant_state=#{vtvo.merchantState},
|
</if>
|
<if test="vtvo.merchantDiscount != null">
|
merchant_discount=#{vtvo.id},
|
</if>
|
<if test="vtvo.merchantIntegral != null">
|
merchant_integral=#{vtvo.merchantIntegral},
|
</if>
|
update_time=sysdate()
|
</set>
|
where id = #{vtvo.id}
|
</update>
|
|
<delete id="delete" parameterType="String">
|
delete from volunteer_merchant where id=#{id}
|
</delete>
|
|
<select id="getUser" resultType="com.panzhihua.service_community.entity.SysUser">
|
SELECT
|
user_id,
|
account,
|
password,
|
openid,
|
session_key,
|
unionid,
|
phone,
|
nick_name,
|
name,
|
community_id,
|
sex,
|
id_card,
|
birthday,
|
image_url,
|
type,
|
job,
|
is_volunteer,
|
is_partymember,
|
status,
|
create_at,
|
last_login_time,
|
tags,
|
family_id,
|
face_url,
|
face_state,
|
reject_reson,
|
area_id,
|
card_photo_front,
|
card_photo_back,
|
family_book,
|
continuous_landing_days,
|
is_tips,
|
work_status,
|
work_start_time,
|
work_end_time,
|
big_age_tips,
|
plaintext_password,
|
street_id,
|
relation_name,
|
app_id,
|
is_accept,
|
binding_check_unit_id,
|
love_integral
|
FROM sys_user
|
<where>
|
1=1
|
<if test="communityId!=null and communityId!='' ">
|
and community_id=#{communityId}
|
</if>
|
|
<if test="userName!=null">
|
and (sys_user.name like concat('%',#{userName},'%'))
|
</if>
|
|
<if test="userPhone!=null">
|
and (sys_user.phone like concat('%',#{userPhone},'%'))
|
</if>
|
and app_id='wx0cef797390444b75'
|
</where>
|
</select>
|
|
<select id="isMerchant" resultType="String">
|
select id from volunteer_merchant
|
where volunteer_merchant.user_id=#{userId}
|
</select>
|
|
|
|
</mapper>
|