金币系统后端
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.

109 lines
4.9 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. package com.example.demo.mapper;
  2. import com.example.demo.domain.entity.Detail;
  3. import com.example.demo.domain.vo.RefundA;
  4. import org.apache.ibatis.annotations.*;
  5. import java.util.List;
  6. @Mapper
  7. public interface RefundMapper {
  8. List<RefundA> getRefundA(@Param("flags") List<Integer> flags);
  9. @Insert({
  10. "insert into detail",
  11. "(jwcode,refund_type,refund_goods,contact_id,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type,order_code)",
  12. "values",
  13. "(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),2,#{orderCode})"
  14. })
  15. @Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId")
  16. int insert(Detail detail);
  17. @Insert({
  18. "insert into detail_y",
  19. "(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,refund_flag)",
  20. "values",
  21. "(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),2,#{orderCode},#{area},#{username},#{name},'金币系统',0)"
  22. })
  23. @Options(useGeneratedKeys = true, keyColumn = "detaily_id", keyProperty = "detailyId")
  24. int inserty(Detail detail);
  25. @Insert({
  26. "insert into audit",
  27. "(jwcode,refund_id,admin_id,create_time,detail_id,status,reson,audit_flag)",
  28. "values",
  29. "(#{jwcode},#{detailId},#{adminId},now(),#{detailId},0,#{reson},1)"
  30. })
  31. int insertAudit(Detail detail);
  32. // 检查 contactId 是否存在
  33. @Select("SELECT EXISTS (SELECT 1 FROM detail WHERE contact_id = #{contactId})")
  34. boolean existsByContactId(@Param("contactId") Integer contactId);
  35. //根据订单号查询
  36. // @Select("select d.* " +
  37. // " p.name AS productName" +
  38. // "FROM detaily where order_code = #{orderCode} and detail_flag = 1" +
  39. // "LEFT JOIN product p ON d.product_id = p.id" )
  40. // Detail selectByOrderCode(@Param("orderCode") String orderCode);
  41. //根据精网号查询
  42. @Select("SELECT d.*, p.name AS productName " +
  43. "FROM detail_y d " +
  44. "LEFT JOIN product p ON d.product_id = p.product_id " +
  45. "WHERE d.jwcode = #{jwcode} AND d.detail_flag = 1 AND d.refund_flag = 1")
  46. Detail selectByJWCODE(String jwcode);
  47. //根据订单号查询
  48. @Select("SELECT d.*, p.name AS productName " +
  49. "FROM detail_y d " +
  50. "LEFT JOIN product p ON d.product_id = p.product_id " +
  51. "WHERE d.order_code = #{orderCode} AND d.detail_flag = 1 AND d.refund_flag = 1")
  52. Detail selectByOrderCode(String OrderCode);
  53. //软删除
  54. @Update("update detail set detail_flag = 0 where detail_id = #{detailId}")
  55. int update(@Param("detailId") Integer detailId);
  56. //退款成功,将detail表中的的记录退款状态改为已退款
  57. @Update("update detail_y set refund_flag = 0 where detaily_id = #{contactId}")
  58. int updateOrderCode(Integer contactId);
  59. @Select("select * from detail where detail_id = #{detailId} and detail_flag = 1")
  60. Detail selectByDetailId(Integer detailId);
  61. @Select({
  62. "<script>",
  63. "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,",
  64. " u.area, a.name AS adminName,",
  65. " u.name AS userName,",
  66. " au.status , au.reson AS auditReson,au.refund_id,au.audit_id",
  67. "FROM detail d",
  68. "LEFT JOIN `admin` a ON d.admin_id = a.admin_id",
  69. "LEFT JOIN `user` u ON d.jwcode = u.jwcode",
  70. "LEFT JOIN audit au ON d.detail_id = au.refund_id",
  71. "WHERE d.detail_flag = 1 and update_type = 2 ",
  72. "<if test='status!=null'>and au.status=#{status}</if>",
  73. "<if test='area!=null and area.length>0'>AND u.area = #{area}</if>",
  74. "<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>",
  75. "<if test='refundType != null and refundType.length>0'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>",
  76. "<if test='refundGoods != null and refundGoods.length>0'>AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')</if>",
  77. "<if test='startDate != null and endDate != null'>AND d.create_time BETWEEN #{startDate} AND #{endDate}</if>",
  78. "<choose>",
  79. " <!-- 优先使用前端传入的排序参数 -->",
  80. " <when test='sortField != null or sortOrder != null'>",
  81. " ORDER BY ${sortField} ${sortOrder}",
  82. " </when>",
  83. " <!-- 默认排序 -->",
  84. " <otherwise>",
  85. "ORDER BY d.create_time DESC",
  86. " </otherwise>",
  87. "</choose>",
  88. "</script>"
  89. })
  90. List<Detail> select(Detail detail);
  91. }