<?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.ComActWarehouseDonatesDao">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComActWarehouseDonates"
|
id="ComActWarehouseDonatesBaseResultMap">
|
<result property="id" column="id"/>
|
<result property="userId" column="user_id"/>
|
<result property="name" column="name"/>
|
<result property="phone" column="phone"/>
|
<result property="item" column="item"/>
|
<result property="image" column="image"/>
|
<result property="quantity" column="quantity"/>
|
<result property="surplusQuantity" column="surplus_quantity"/>
|
<result property="isAnonymous" column="is_anonymous"/>
|
<result property="message" column="message"/>
|
<result property="registerAt" column="register_at"/>
|
<result property="signingAt" column="signing_at"/>
|
<result property="status" column="status"/>
|
<result property="communityId" column="community_id"/>
|
<result property="registerBy" column="register_by"/>
|
<result property="signingBy" column="signing_by"/>
|
</resultMap>
|
<insert id="batchInsertDonates" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO `com_act_warehouse_donates`(`name`,phone,item,quantity,surplus_quantity,
|
is_anonymous,message,register_at,signing_at,status,community_id,register_by,signing_by)
|
VALUES
|
<foreach collection="donateList" item="item" index="index" separator="," >
|
(#{item.name}, #{item.phone}, #{item.item}, #{item.quantity}, #{item.surplusQuantity},#{item.isAnonymous},
|
#{item.message}, #{item.registerAt}, #{item.signingAt}, #{item.status}, #{item.communityId}, #{item.registerBy}, #{item.signingBy})
|
</foreach>
|
</insert>
|
<select id="exportDonatesByIds"
|
resultType="com.panzhihua.common.model.vos.community.warehouse.ExportDonatesVO">
|
SELECT * FROM com_act_warehouse_donates
|
WHERE id IN
|
<foreach collection="needExportIds" open="(" separator="," close=")" index="index" item="item">
|
#{item}
|
</foreach>
|
</select>
|
<select id="exportDonatesBySearch"
|
resultType="com.panzhihua.common.model.vos.community.warehouse.ExportDonatesVO">
|
SELECT * FROM com_act_warehouse_donates
|
WHERE community_id = ${exportDonatesDTO.communityId}
|
<if test="exportDonatesDTO.status != null">
|
AND status = #{exportDonatesDTO.status}
|
</if>
|
<if test="exportDonatesDTO.isAnonymous != null">
|
AND is_anonymous = #{exportDonatesDTO.isAnonymous}
|
</if>
|
<if test="exportDonatesDTO.signingAtBegin != null">
|
AND signing_at >= #{exportDonatesDTO.signingAtBegin}
|
</if>
|
<if test="exportDonatesDTO.signingAtEnd != null">
|
AND signing_at <= #{exportDonatesDTO.signingAtEnd}
|
</if>
|
<if test="exportDonatesDTO.keyword != null and exportDonatesDTO.keyword != """>
|
AND (
|
`name` LIKE CONCAT('%', #{exportDonatesDTO.keyword}, '%')
|
OR phone LIKE CONCAT('%', #{exportDonatesDTO.keyword}, '%')
|
OR item LIKE CONCAT('%', #{exportDonatesDTO.keyword}, '%')
|
)
|
</if>
|
ORDER BY id DESC
|
</select>
|
<select id="pageDonates"
|
resultType="com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseDonatesVO">
|
SELECT * FROM com_act_warehouse_donates
|
WHERE community_id = ${pageDonatesDTO.communityId}
|
<if test="pageDonatesDTO.isWhich != null and pageDonatesDTO.isWhich == 1">
|
AND user_id = #{pageDonatesDTO.userId}
|
</if>
|
<if test="pageDonatesDTO.status != null">
|
AND status = #{pageDonatesDTO.status}
|
</if>
|
<if test="pageDonatesDTO.isAnonymous != null">
|
AND is_anonymous = #{pageDonatesDTO.isAnonymous}
|
</if>
|
<if test="pageDonatesDTO.signingAtBegin != null">
|
AND signing_at >= #{pageDonatesDTO.signingAtBegin}
|
</if>
|
<if test="pageDonatesDTO.signingAtEnd != null">
|
AND signing_at <= #{pageDonatesDTO.signingAtEnd}
|
</if>
|
<if test="pageDonatesDTO.keyword != null and pageDonatesDTO.keyword != """>
|
<if test="pageDonatesDTO.isWhich != null">
|
AND status = 2
|
AND item LIKE CONCAT('%', #{pageDonatesDTO.keyword}, '%')
|
</if>
|
<if test="pageDonatesDTO.isWhich == null">
|
AND (
|
`name` LIKE CONCAT('%', #{pageDonatesDTO.keyword}, '%')
|
OR phone LIKE CONCAT('%', #{pageDonatesDTO.keyword}, '%')
|
OR item LIKE CONCAT('%', #{pageDonatesDTO.keyword}, '%')
|
)
|
</if>
|
</if>
|
ORDER BY id DESC
|
</select>
|
<select id="selectDetailById"
|
resultType="com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseDonatesVO">
|
SELECT temp.*,IF(su.name IS NULL, su.nick_name, su.name) AS signingBy FROM (
|
SELECT * FROM com_act_warehouse_donates WHERE id = #{donatesId}
|
) temp LEFT JOIN sys_user su ON temp.signing_by = su.user_id
|
</select>
|
<select id="selectDonatesStatistics"
|
resultType="com.panzhihua.common.model.vos.community.warehouse.DonatesStatisticsVO">
|
SELECT
|
(SELECT IF(SUM(quantity) IS NULL,0,SUM(quantity)) FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2) as totalInc ,
|
(SELECT IF(SUM(surplus_quantity) IS NULL,0,SUM(surplus_quantity)) FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2) as surplus,
|
(SELECT IF(SUM(quantity) IS NULL,0,SUM(quantity)) FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2 AND signing_at LIKE #{currentYear}) as yearInc,
|
(SELECT IF(SUM(quantity) IS NULL,0,SUM(quantity)) FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2 AND signing_at LIKE #{currentMonth}) as mothInc,
|
(SELECT IF(SUM(quantity) IS NULL,0,SUM(quantity)) FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2 AND signing_at LIKE #{today}) as dayInc,
|
(SELECT IF(SUM(goods_num) IS NULL,0,SUM(goods_num)) FROM com_act_warehouse_apply WHERE community_id = ${communityId} AND `status` = 3 AND actual_time LIKE #{currentYear}) as yearDec,
|
(SELECT IF(SUM(goods_num) IS NULL,0,SUM(goods_num)) FROM com_act_warehouse_apply WHERE community_id = ${communityId} AND `status` = 3 AND actual_time LIKE #{currentMonth}) as mothDec,
|
(SELECT IF(SUM(goods_num) IS NULL,0,SUM(goods_num)) FROM com_act_warehouse_apply WHERE community_id = ${communityId} AND `status` = 3 AND actual_time LIKE #{today}) as dayDec
|
</select>
|
<select id="getWarehouseDonateRecords" resultType="java.lang.String">
|
SELECT CONCAT('收到爱心人士捐赠的',item,'x', quantity)
|
FROM com_act_warehouse_donates WHERE community_id = ${communityId} AND `status` = 2 ORDER BY signing_at DESC limit #{pageSize}
|
</select>
|
<select id="getWarehouseLoveTransfer" resultType="java.lang.String">
|
SELECT t1.content FROM com_act_warehouse_operation t1
|
LEFT JOIN com_act_warehouse_donates t2 ON t1.goods_id = t2.id
|
WHERE t2.community_id = ${communityId} AND t1.`type` = 2 ORDER BY create_time DESC limit #{pageSize}
|
</select>
|
<select id="getWarehouseImages" resultType="java.lang.String">
|
SELECT image FROM com_act_warehouse_donates
|
WHERE community_id = ${communityId} AND `status` = 2 AND image IS NOT NULL AND image != '' ORDER BY signing_at DESC limit #{pageSize}
|
</select>
|
|
</mapper>
|