You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

68 lines
3.2 KiB

package com.example.demo.mapper;
import com.example.demo.domain.entity.Detail;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface RefundMapper {
@Insert({
"insert into detail",
"(jwcode,refund_type,refund_goods,contact_id,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type)",
"values",
"(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),'退款')"
})
@Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId")
int insert(Detail detail);
@Insert({
"insert into audit",
"(jwcode,refund_id,admin_id,create_time,detail_id)",
"values",
"(#{jwcode},#{detailId},#{adminId},now(),#{detailId})"
})
int insertAudit(Detail detail);
// 检查 contactId 是否存在
@Select("SELECT EXISTS (SELECT 1 FROM detail WHERE contact_id = #{contactId})")
boolean existsByContactId(@Param("contactId") Integer contactId);
@Update("update detail set detail_flag = 0 where detail_id = #{detailId}")
int update(@Param("detailId") Integer detailId);
@Select("select * from detail where detail_id = #{detailId} and detail_flag = 1")
Detail selectByDetailId(Integer detailId);
@Select({
"<script>",
"SELECT d.*,",
" a.area AS adminArea, a.name AS adminName,",
" u.name AS userName,",
" au.status AS auditStatus, au.reson AS auditReson",
"FROM detail d",
"LEFT JOIN admin a ON d.admin_id = a.admin_id",
"LEFT JOIN user u ON d.jwcode = u.jwcode",
"LEFT JOIN audit au ON d.detail_id = au.refund_id",
"WHERE d.detail_flag = 1 and update_type ='退款'",
"<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>",
"<if test='refundType != null'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>",
"<if test='refundGoods != null'>AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')</if>",
"<if test='rechargeCoin != null'>AND d.recharge_coin = #{rechargeCoin}</if>",
"<if test='freeCoin != null'>AND d.free_coin = #{freeCoin}</if>",
"<if test='taskCoin != null'>AND d.task_coin = #{taskCoin}</if>",
"<if test='remark != null'>AND d.remark LIKE CONCAT('%', #{remark}, '%')</if>",
"<if test='adminId != null'>AND d.admin_id = #{adminId}</if>",
"<if test='adminArea != null'>AND a.area LIKE CONCAT('%', #{adminArea}, '%')</if>", // admin表字段过滤
"<if test='adminName != null'>AND a.name LIKE CONCAT('%', #{adminName}, '%')</if>", // admin表字段过滤
"<if test='userName != null'>AND u.name LIKE CONCAT('%', #{userName}, '%')</if>", // user表字段过滤
"<if test='auditStatus != null'>AND au.status = #{auditStatus}</if>", // audit 表字段过滤
"<if test='auditReson != null'>AND au.reson LIKE CONCAT('%', #{auditReson}, '%')</if>", // audit表字段过滤
"ORDER BY d.create_time DESC",
"</script>"
})
List<Detail> select(Detail detail);
}