|
|
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({ "<script>", "SELECT d.jwcode,d.refund_type,d.refund_goods,d.recharge_coin,d.free_coin,d.task_coin,d.remark,d.create_time,d.detail_id,", " u.area, a.name AS adminName,", " u.name AS userName,", " au.status , au.reson AS auditReson,au.refund_id,au.audit_id", "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='status!=null'>and au.status=#{status}</if>", "<if test='area!=null and area.length>0'>AND u.area = #{area}</if>", "<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>", "<if test='refundType != null and refundType.length>0'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>", "<if test='refundGoods != null and refundGoods.length>0'>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); }
|