|
|
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,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 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);
//根据订单号查询
// @Select("select d.* " +
// " p.name AS productName" +
// "FROM detail 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 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 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);
//是否退款
@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({ "<script>", "SELECT d.jwcode,d.refund_type,d.refund_goods,d.recharge_coin,d.free_coin,d.task_coin,d.remark,d.create_time ,", " 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 = 2 ", "<if test='auditStatus!=null'>and auditStatus=#{auditStatus}</if>", "<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='startDate != null and endDate != null'>AND d.create_time BETWEEN #{startDate} AND #{endDate}</if>", "ORDER BY d.create_time DESC", "</script>" }) List<Detail> select(Detail detail); }
|