mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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.ComActWarehouseApplyDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActWarehouseApply"
               id="ComActWarehouseApplyBaseResultMap">
        <result property="id" column="id"/>
        <result property="goodsId" column="goods_id"/>
        <result property="goodsNum" column="goods_num"/>
        <result property="reserveTime" column="reserve_time"/>
        <result property="actualTime" column="actual_time"/>
        <result property="reason" column="reason"/>
        <result property="receiveUrl" column="receive_url"/>
        <result property="createTime" column="create_time"/>
        <result property="status" column="status"/>
        <result property="applyUserId" column="apply_user_id"/>
        <result property="applyName" column="apply_name"/>
        <result property="applyPhone" column="apply_phone"/>
        <result property="solveUserId" column="solve_user_id"/>
        <result property="solveTime" column="solve_time"/>
        <result property="solveContent" column="solve_content"/>
        <result property="writeOffUserId" column="write_off_user_id"/>
        <result property="cancelTime" column="cancel_time"/>
        <result property="communityId" column="community_id"/>
    </resultMap>
 
 
    <select id="queryAll" resultType="com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyVO">
        select t.*,t1.name as donateName,t1.item,t1.image,t1.phone as donatePhone,t2.name as writeOffUserName from com_act_warehouse_apply t inner join com_act_warehouse_donates t1 on t.goods_id = t1.id left join sys_user t2 on t.write_off_user_id = t2.user_id
        <where>
            1=1
            <if test="commonPage.paramId !=null">
                and t.community_id = ${commonPage.paramId}
            </if>
            <if test="commonPage.status !=null">
                and t.status=#{commonPage.status}
            </if>
            <if test="commonPage.paramId2 != null">
                and  t.goods_id = #{commonPage.paramId2}
            </if>
            <if test="commonPage.keyword !=null and commonPage.keyword !=''">
                and (t.id like concat('%',#{commonPage.keyword},'%') or t1.item like concat('%',#{commonPage.keyword},'%') or t.apply_phone  like concat('%',#{commonPage.keyword},'%') or t.apply_name like concat('%',#{commonPage.keyword},'%') or t.id like concat('%',#{commonPage.keyword},'%'))
            </if>
            <if test="commonPage.userId !=null">
                and t.apply_user_id = #{commonPage.userId}
            </if>
            <if test="commonPage.beginTime !=null">
                and t.actual_time >=#{commonPage.beginTime}
            </if>
            <if test="commonPage.endTime !=null">
                and #{commonPage.endTime} >=t.actual_time
            </if>
        </where>
        order by t.create_time desc
    </select>
 
    <select id="selectStatics" resultType="com.panzhihua.common.model.vos.community.warehouse.ApplyStatistics">
        select
                (select count(*)  from com_act_warehouse_apply where status = 0 and community_id = ${communityId}) as pending,
                (select count(*)  from com_act_warehouse_apply where status = 1 and community_id = ${communityId}) as unclaimed,
                (select count(*)  from com_act_warehouse_apply where status = 2 and community_id = ${communityId}) as rejected,
                (select count(*)  from com_act_warehouse_apply where status = 3 and community_id = ${communityId}) as received,
                (select count(*)  from com_act_warehouse_apply where status = -1 and community_id = ${communityId}) as cancelled
    </select>
 
    <select id="selectById" resultType="com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyVO">
        select t.*,t1.name as donateName,t1.item,t1.image,t1.phone as donatePhone,t2.name as writeOffUserName,t3.name as solveName,t1.surplus_quantity as surplusQuantity from com_act_warehouse_apply t inner join com_act_warehouse_donates t1 on t.goods_id = t1.id left join sys_user t2 on t.write_off_user_id = t2.user_id left join sys_user t3 on t.solve_user_id = t3.user_id
            where t.id=#{id}
    </select>
</mapper>