101captain
2021-09-22 1775bb71f952106c58657cf02891cbe2a286c8f8
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActMicroWishDAO.java
@@ -1,13 +1,5 @@
package com.panzhihua.service_community.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +8,13 @@
import com.panzhihua.common.model.vos.community.TodoEventsVO;
import com.panzhihua.common.model.vos.community.screen.work.MicroListVO;
import com.panzhihua.service_community.model.dos.ComActMicroWishDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Map;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -26,88 +25,205 @@
@Mapper
public interface ComActMicroWishDAO extends BaseMapper<ComActMicroWishDO> {
    @Select("<script> " + "SELECT " + "w.id, " + "u.name sponsor_name, " + "u.nick_name userNickName, "
        + "u.image_url , " + "w.sponsor_phone, " + "w.wish_name, " + "w.`status`, " + "w.`feedback_at`, "
        + "w.`examine_at`, " + "w.`distribution_at`, " + "w.`evaluate_at`, " + "w.`photo_path_list`, "
        + "count(wu.id)star_num, " + "w.`detail`, " + "w.form, " + "w.reject_reason, " + "su.`name` responsible_name, "
        + "w.score, " + "w.create_at  " + "FROM " + "com_act_micro_wish w "
        + "left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id "
        + "JOIN sys_user u ON w.sponsor_id = u.user_id  "
        + "<if test='comActMicroWishVO.sponsorName != null and comActMicroWishVO.sponsorName.trim() != &quot;&quot;'>"
        + "AND u.name like concat(#{comActMicroWishVO.sponsorName},'%')   " + " </if> "
        + "<if test='comActMicroWishVO.responsibleName == null or comActMicroWishVO.responsibleName.trim() == &quot;&quot;'>"
        + "LEFT JOIN com_pb_service_team su ON w.responsible_id = su.id  " + " </if> "
        + "<if test='comActMicroWishVO.responsibleName != null and comActMicroWishVO.responsibleName.trim() != &quot;&quot;'>"
        + " JOIN com_pb_service_team su ON w.responsible_id = su.id  "
        + "AND su.`name` like concat(#{comActMicroWishVO.responsibleName},'%')   " + " </if> " + " <where>"
        + "<if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>"
        + " and w.community_id=#{comActMicroWishVO.communityId}  " + " </if> "
        + "<if test='comActMicroWishVO.sponsorPhone != null and comActMicroWishVO.sponsorPhone.trim() != &quot;&quot;'>"
        + "AND w.sponsor_phone like concat(#{comActMicroWishVO.sponsorPhone},'%')   " + " </if> "
        + "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 and comActMicroWishVO.status!=3 and comActMicroWishVO.isPageMyWish==null'>"
        + "AND w.`status` = #{comActMicroWishVO.status}  " + " </if> "
        + "<if test='comActMicroWishVO.status == 3  and comActMicroWishVO.isPageMyWish==null'>" + "AND w.`status` = 3 "
        + " </if> "
        + "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 and comActMicroWishVO.isPageMyWish!=null and comActMicroWishVO.status==1'>"
        + "AND w.`status` =1  " + " </if> "
        + "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status==3  and comActMicroWishVO.isPageMyWish!=null '>"
        + "AND w.`status` in (2, 3)  " + " </if> " + "<if test='comActMicroWishVO.createBegin != null '>"
        + "AND w.create_at BETWEEN #{comActMicroWishVO.createBegin}  " + "AND #{comActMicroWishVO.createEnd}"
        + " </if> " + "<if test='comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>"
        + "AND w.status  in (3, 5, 6)  " + " </if> "
        + "<if test='comActMicroWishVO.userId != null and comActMicroWishVO.userId != 0'>"
        + "AND w.sponsor_id  =#{comActMicroWishVO.userId}  " + " </if> "
        + "<if test='comActMicroWishVO.backUserId != null and comActMicroWishVO.backUserId != 0 and  comActMicroWishVO.status==3 '>"
        + "AND w.responsible_id  =#{comActMicroWishVO.backUserId}  " + " </if> "
        + "<if test='comActMicroWishVO.backUserId != null and comActMicroWishVO.backUserId != 0 and  comActMicroWishVO.status==0 '>"
        + "and (w.status in(1,2,4,5,6) or (w.status=3 and w.responsible_id  =#{comActMicroWishVO.backUserId})) "
        + " </if> " + " </where>" + " group by w.id   " + "ORDER BY  w.create_at desc " + "</script>")
    @Select("<script> " +
            "SELECT " +
            "w.id, " +
            "u.name sponsor_name, " +
            "u.nick_name userNickName, " +
            "u.image_url , " +
            "w.sponsor_phone, " +
            "w.wish_name, " +
            "w.`status`, " +
            "w.`feedback_at`, " +
            "w.`examine_at`, " +
            "w.`distribution_at`, " +
            "w.`evaluate_at`, " +
            "w.`photo_path_list`, " +
            "count(wu.id)star_num, " +
            "w.`detail`, " +
            "w.form, " +
            "w.reject_reason, " +
            "su1.`name` responsible_name, " +
            "w.score, " +
            "w.img_width, " +
            "w.finish_at, " +
            "w.aim_num, " +
            "w.img_height, " +
            "w.create_at  " +
            "FROM " +
            "com_act_micro_wish w " +
            "left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id "+
            "left JOIN sys_user u ON w.sponsor_id = u.user_id  " +
            "<if test='comActMicroWishVO.sponsorName != null and comActMicroWishVO.sponsorName.trim() != &quot;&quot;'>" +
            "AND u.name like concat(#{comActMicroWishVO.sponsorName},'%')   " +
            " </if> " +
            "<if test='comActMicroWishVO.responsibleName == null or comActMicroWishVO.responsibleName.trim() == &quot;&quot;'>" +
            "LEFT JOIN sys_user su1 ON w.responsible_id = su1.user_id  " +
            " </if> " +
            "<if test='comActMicroWishVO.responsibleName != null and comActMicroWishVO.responsibleName.trim() != &quot;&quot;'>" +
            " JOIN sys_user su1 ON w.responsible_id = su1.user_id  " +
            "AND su1.`name` like concat(#{comActMicroWishVO.responsibleName},'%')   " +
            " </if> " +
            " <where>" +
            "<if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>" +
            " and w.community_id=#{comActMicroWishVO.communityId}  " +
            " </if> " +
            "<if test='comActMicroWishVO.sponsorPhone != null and comActMicroWishVO.sponsorPhone.trim() != &quot;&quot;'>" +
            "AND w.sponsor_phone like concat(#{comActMicroWishVO.sponsorPhone},'%')   " +
            " </if> " +
            "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 and comActMicroWishVO.status!=3 and comActMicroWishVO.isPageMyWish==null'>" +
            "AND w.`status` = #{comActMicroWishVO.status}  " +
            " </if> " +
            "<if test='comActMicroWishVO.status == 3  and comActMicroWishVO.isPageMyWish==null'>" +
            "AND w.`status` in (2,3) " +
            " </if> " +
            "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 and comActMicroWishVO.isPageMyWish!=null and comActMicroWishVO.status==1'>" +
            "AND w.`status` =1  " +
            " </if> " +
            "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status==3  and comActMicroWishVO.isPageMyWish!=null '>" +
            "AND w.`status` in (2, 3)  " +
            " </if> " +
            "<if test='comActMicroWishVO.createBegin != null '>" +
            "AND w.create_at BETWEEN #{comActMicroWishVO.createBegin}  " +
            "AND #{comActMicroWishVO.createEnd}" +
            " </if> " +
            "<if test='comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0 and comActMicroWishVO.status != null and comActMicroWishVO.status != 7'>" +
            "AND w.status  in (3, 5, 6)  " +
            " </if> " +
            "<if test='comActMicroWishVO.userId != null and comActMicroWishVO.userId != 0'>" +
            "AND w.sponsor_id  =#{comActMicroWishVO.userId}  " +
            " </if> " +
            "<if test='comActMicroWishVO.backUserId != null and comActMicroWishVO.backUserId != 0 and  comActMicroWishVO.status==3 '>" +
            "AND w.responsible_id  =#{comActMicroWishVO.backUserId}  " +
            " </if> " +
            "<if test='comActMicroWishVO.backUserId != null and comActMicroWishVO.backUserId != 0 and  comActMicroWishVO.status==0 '>" +
            "and (w.status in(1,2,4,5,6) or (w.status=3 and w.responsible_id  =#{comActMicroWishVO.backUserId})) " +
            " </if> " +
            " </where>" +
            " group by w.id   "+
            "ORDER BY  w.create_at desc "+
            "</script>")
    IPage<ComActMicroWishVO> pageMicroWish(Page page, @Param("comActMicroWishVO") ComActMicroWishVO comActMicroWishVO);
    @Select("SELECT " + "w.id, " + "u.name sponsor_name, " + "u.nick_name userNickName, " + "w.create_at, "
        + "u.image_url, " + "w.sponsor_phone, " + "w.`status`, " + "w.`sponsor_id`, " + "w.wish_name, "
        + "count(wu.id)starNum, " + "w.detail, " + "w.photo_path_list, " + "su.`name` responsible_name, " + "w.form, "
        + "w.reject_reason, " + "w.examine_at, " + "w.finish, " + "w.finish_photo_path_list, " + "w.finish_at, "
        + "w.score, " + "w.feedback, " + "w.feedback_at, " + "w.feedback_photo_path_list, " + "w.distribution_at, "
        + "w.evaluate_at, " + "w.evaluate  " + "FROM " + "com_act_micro_wish w "
        + "JOIN sys_user u ON w.sponsor_id = u.user_id "
        + "LEFT JOIN com_pb_service_team su ON w.responsible_id = su.id  "
        + "LEFT JOIN com_act_micro_wish_user wu ON w.id = wu.micro_wish_id  " + "WHERE " + "w.id =#{id}"
        + " group by w.id " + "order by w.create_at desc")
    IPage<ComActMicroWishVO> pageMicroWishApplets(Page page, @Param("comActMicroWishVO") ComActMicroWishVO comActMicroWishVO);
    @Select("SELECT " +
            "w.id, " +
            "u.name sponsor_name, " +
            "u.nick_name userNickName, " +
            "w.create_at, " +
            "w.aim_num, " +
            "u.image_url, " +
            "w.sponsor_phone, " +
            "w.`status`, " +
            "w.`sponsor_id`, " +
            "w.wish_name, " +
            "count(wu.id)starNum, " +
            "w.detail, " +
            "w.photo_path_list, " +
            "su.`name` responsible_name, " +
            "w.form, " +
            "w.reject_reason, " +
            "w.community_id, " +
            "w.examine_at, " +
            "w.finish, " +
            "w.finish_photo_path_list, " +
            "w.finish_at, " +
            "w.score, " +
            "w.feedback, " +
            "w.feedback_at, " +
            "w.feedback_photo_path_list, " +
            "w.distribution_at, " +
            "w.evaluate_at, " +
            "w.img_width, " +
            "w.img_height, " +
            "w.evaluate  " +
            "FROM " +
            "com_act_micro_wish w " +
            "LEFT JOIN sys_user u ON w.sponsor_id = u.user_id " +
            "LEFT JOIN com_pb_service_team su ON w.responsible_id = su.id  " +
            "LEFT JOIN com_act_micro_wish_user wu ON w.id = wu.micro_wish_id  " +
            "WHERE " +
            "w.id =#{id}"+
            " group by w.id " +
            "order by w.create_at desc"
    )
    ComActMicroWishVO detailMicroWish(Long id);
    @Select("SELECT " + "'2' type " + "FROM " + "com_act_micro_wish w  " + "WHERE "
        + "w.community_id = #{communityId}  " + "AND w.`status` = 1 " + " " + "union all  " + " " + "SELECT "
        + "'2' type " + "FROM " + " com_act_micro_wish w  " + "WHERE " + " w.community_id = #{communityId}  "
        + " AND w.`status` = 3  " + " AND w.form = 1  " + " AND w.responsible_id = #{userId}  " + "GROUP BY "
        + " w.community_id ")
    @Select("SELECT " +
            "'2' type " +
            "FROM " +
            "com_act_micro_wish w  " +
            "WHERE " +
            "w.community_id = #{communityId}  " +
            "AND w.`status` = 1 " +
            " " +
            "union all  " +
            " " +
            "SELECT " +
            "'2' type " +
            "FROM " +
            " com_act_micro_wish w  " +
            "WHERE " +
            " w.community_id = #{communityId}  " +
            " AND w.`status` = 3  " +
            " AND w.form = 1  " +
            " AND w.responsible_id = #{userId}  " +
            "GROUP BY " +
            " w.community_id ")
    List<TodoEventsVO> selectNeedToDo(@Param("communityId") Long communityId, @Param("userId") Long userId);
    @Update("update com_act_micro_wish set `status`=6, evaluate_at=now() where `status`=5 and TIMESTAMPDIFF(HOUR, feedback_at, SYSDATE())>=72")
    @Update("update com_act_micro_wish set `status`=6, evaluate_at=now() where `status`=5 and TIMESTAMPDIFF(HOUR, finish_at, SYSDATE())>=72")
    int updateStatusAutoConfirm();
    @Select("SELECT COUNT(id) AS completedNum,"
        + "(SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = #{communityId} AND (status =1 OR status =2 OR status = 3 OR status = 5)) AS willNum ,"
        + "(SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = #{communityId} AND (status =1 OR status =2 OR status = 3 OR status = 5 OR status = 6) AND create_at LIKE CONCAT(#{nowDate},'%')) AS currentNum "
        + "FROM com_act_micro_wish WHERE community_id = #{communityId} AND status = 6 ")
    Map<String, Long> countByCommunityId(@Param("communityId") Long communityId, @Param("nowDate") String nowDate);
    @Select("select id from com_act_micro_wish where `status`=5 and TIMESTAMPDIFF(HOUR, feedback_at, SYSDATE())>=72 ")
    List<Long> getWishAutoConfirmIds();
    @Select("SELECT COUNT(id) AS completedNum," +
            "(SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = #{communityId} AND (status =1 OR status =2 OR status = 3 OR status = 5)) AS willNum ," +
            "(SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = #{communityId} AND (status =1 OR status =2 OR status = 3 OR status = 5 OR status = 6) AND create_at LIKE CONCAT(#{nowDate},'%')) AS currentNum " +
            "FROM com_act_micro_wish WHERE community_id = #{communityId} AND status = 6 ")
    Map<String, Long> countByCommunityId(@Param("communityId") Long communityId,@Param("nowDate") String nowDate);
    @Select("SELECT photo_path_list FROM com_act_micro_wish WHERE community_id = #{communityId} AND (status =1 OR status =2 OR status = 3 OR status = 5 OR status = 6) ORDER BY create_at DESC limit #{pageSize}")
    List<String> getAllImgs(@Param("communityId") Long communityId, @Param("pageSize") Integer pageSize);
    List<String> getAllImgs(@Param("communityId") Long communityId,@Param("pageSize") Integer pageSize);
    @Select("<script> " + "SELECT " + " camw.id, " + " su.`name` AS userName, " + " camw.sponsor_id, "
        + " su.image_url, " + " su.phone, " + " camw.`status`, " + " camw.create_at, " + " camw.wish_name, "
        + " camw.finish, " + " camw.finish_photo_path_list, " + " camw.form, " + " camw.evaluate_at, "
        + " su1.name as responsibleName, " + " camw.score, " + " camw.distribution_at, " + " camw.detail, "
        + " camw.photo_path_list  " + "FROM " + " com_act_micro_wish AS camw "
        + " LEFT JOIN sys_user AS su ON su.user_id = camw.sponsor_id "
        + " LEFT JOIN com_pb_service_team AS su1 ON su1.id = camw.responsible_id " + " <where> "
        + "<if test='microListDTO.status != null'>" + "AND camw.`status` =#{microListDTO.status}  " + " </if> "
        + "<if test='microListDTO.communityId != null'>" + "AND camw.community_id =#{microListDTO.communityId}  "
        + " </if> " + "<if test='microListDTO.startTime!=null and microListDTO.startTime != &quot;&quot;'>"
        + " AND DATE_FORMAT(camw.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{microListDTO.startTime} " + " </if> "
        + "<if test='microListDTO.endTime!=null and microListDTO.endTime != &quot;&quot;'>"
        + " AND DATE_FORMAT(camw.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{microListDTO.endTime} " + " </if> "
        + " </where>" + "ORDER BY  camw.create_at desc " + " </script>")
    @Select("<script> " +
            "SELECT " +
            " camw.id, " +
            " su.`name` AS userName, " +
            " camw.sponsor_id, " +
            " su.image_url, " +
            " su.phone, " +
            " camw.`status`, " +
            " camw.create_at, " +
            " camw.wish_name, " +
            " camw.finish, " +
            " camw.finish_photo_path_list, " +
            " camw.form, " +
            " camw.evaluate_at, " +
            " su1.name as responsibleName, " +
            " camw.score, " +
            " camw.distribution_at, " +
            " camw.detail, " +
            " camw.photo_path_list  " +
            "FROM " +
            " com_act_micro_wish AS camw " +
            " LEFT JOIN sys_user AS su ON su.user_id = camw.sponsor_id " +
            " LEFT JOIN com_pb_service_team AS su1 ON su1.id = camw.responsible_id " +
            " <where> " +
            "<if test='microListDTO.status != null'>" +
            "AND camw.`status` =#{microListDTO.status}  " +
            " </if> " +
            "<if test='microListDTO.communityId != null'>" +
            "AND camw.community_id =#{microListDTO.communityId}  " +
            " </if> " +
            "<if test='microListDTO.startTime!=null and microListDTO.startTime != &quot;&quot;'>" +
            " AND DATE_FORMAT(camw.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{microListDTO.startTime} " +
            " </if> " +
            "<if test='microListDTO.endTime!=null and microListDTO.endTime != &quot;&quot;'>" +
            " AND DATE_FORMAT(camw.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{microListDTO.endTime} " +
            " </if> " +
            " </where>" +
            "ORDER BY  camw.create_at desc "+
            " </script>")
    IPage<MicroListVO> getScreenMicroList(Page page, @Param("microListDTO") ScreenMicroListDTO microListDTO);
}