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({
""
})
List select(Detail detail);
}