package com.example.demo.mapper; import com.example.demo.domain.entity.Detail; 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,order_code)", "values", "(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),2,#{orderCode})" }) @Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId") int insert(Detail detail); @Insert({ "insert into detail_y", "(jwcode,refund_type,refund_goods,contact_id,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type,order_code,area,username,name,consume_platform)", "values", "(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),2,#{orderCode},#{area},#{username},#{name},'客服退款')" }) @Options(useGeneratedKeys = true, keyColumn = "detaily_id", keyProperty = "detailyId") int inserty(Detail detail); @Insert({ "insert into audit", "(jwcode,refund_id,admin_id,create_time,detail_id,status,reson,audit_flag)", "values", "(#{jwcode},#{detailId},#{adminId},now(),#{detailId},0,#{reson},1)" }) int insertAudit(Detail detail); // 检查 contactId 是否存在 @Select("SELECT EXISTS (SELECT 1 FROM detail WHERE contact_id = #{contactId})") boolean existsByContactId(@Param("contactId") Integer contactId); //根据订单号查询 // @Select("select d.* " + // " p.name AS productName" + // "FROM detaily where order_code = #{orderCode} and detail_flag = 1" + // "LEFT JOIN product p ON d.product_id = p.id" ) // Detail selectByOrderCode(@Param("orderCode") String orderCode); //根据精网号查询 @Select("SELECT d.*, p.name AS productName " + "FROM detail_y d " + "LEFT JOIN product p ON d.product_id = p.product_id " + "WHERE d.jwcode = #{jwcode} AND d.detail_flag = 1 AND d.refund_flag = 1") Detail selectByJWCODE(String jwcode); //根据订单号查询 @Select("SELECT d.*, p.name AS productName " + "FROM detail_y d " + "LEFT JOIN product p ON d.product_id = p.product_id " + "WHERE d.order_code = #{orderCode} AND d.detail_flag = 1 AND d.refund_flag = 1") Detail selectByOrderCode(String OrderCode); //软删除 @Update("update detail set detail_flag = 0 where detail_id = #{detailId}") int update(@Param("detailId") Integer detailId); //退款成功,将detail表中的的记录退款状态改为已退款 @Update("update detail set refund_flag = 0 where detail_id = #{contactId}") int updateOrderCode(Integer contactId); @Select("select * from detail where detail_id = #{detailId} and detail_flag = 1") Detail selectByDetailId(Integer detailId); @Select({ "" }) List select(Detail detail); }