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

87 lines
3.6 KiB

11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. package com.example.demo.mapper;
  2. import com.example.demo.domain.entity.Detail;
  3. import org.apache.ibatis.annotations.*;
  4. import java.util.List;
  5. @Mapper
  6. public interface RefundMapper {
  7. @Insert({
  8. "insert into detail",
  9. "(jwcode,refund_type,refund_goods,contact_id,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type,order_code)",
  10. "values",
  11. "(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),2,#{orderCode})"
  12. })
  13. @Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId")
  14. int insert(Detail detail);
  15. @Insert({
  16. "insert into audit",
  17. "(jwcode,refund_id,admin_id,create_time,detail_id)",
  18. "values",
  19. "(#{jwcode},#{detailId},#{adminId},now(),#{detailId})"
  20. })
  21. int insertAudit(Detail detail);
  22. // 检查 contactId 是否存在
  23. @Select("SELECT EXISTS (SELECT 1 FROM detail WHERE contact_id = #{contactId})")
  24. boolean existsByContactId(@Param("contactId") Integer contactId);
  25. //根据订单号查询
  26. // @Select("select d.* " +
  27. // " p.name AS productName" +
  28. // "FROM detail where order_code = #{orderCode} and detail_flag = 1" +
  29. // "LEFT JOIN product p ON d.product_id = p.id" )
  30. // Detail selectByOrderCode(@Param("orderCode") String orderCode);
  31. //根据精网号查询
  32. @Select("SELECT d.*, p.name AS productName " +
  33. "FROM detail d " +
  34. "LEFT JOIN product p ON d.product_id = p.product_id " +
  35. "WHERE d.jwcode = #{jwcode} AND d.detail_flag = 1 AND d.refund_flag = 1")
  36. Detail selectByJWCODE(String jwcode);
  37. //根据订单号查询
  38. @Select("SELECT d.*, p.name AS productName " +
  39. "FROM detail d " +
  40. "LEFT JOIN product p ON d.product_id = p.product_id " +
  41. "WHERE d.order_code = #{orderCode} AND d.detail_flag = 1 AND d.refund_flag = 1")
  42. Detail selectByOrderCode(String OrderCode);
  43. //软删除
  44. @Update("update detail set detail_flag = 0 where detail_id = #{detailId}")
  45. int update(@Param("detailId") Integer detailId);
  46. //是否退款
  47. @Update("update detail set refund_flag = 0 where detail_id = #{contactId}")
  48. int updateOrderCode(Integer contactId);
  49. @Select("select * from detail where detail_id = #{detailId} and detail_flag = 1")
  50. Detail selectByDetailId(Integer detailId);
  51. @Select({
  52. "<script>",
  53. "SELECT d.jwcode,d.refund_type,d.refund_goods,d.recharge_coin,d.free_coin,d.task_coin,d.remark,d.create_time ,",
  54. " a.area AS adminArea, a.name AS adminName,",
  55. " u.name AS userName,",
  56. " au.status AS auditStatus, au.reson AS auditReson",
  57. "FROM detail d",
  58. "LEFT JOIN admin a ON d.admin_id = a.admin_id",
  59. "LEFT JOIN user u ON d.jwcode = u.jwcode",
  60. "LEFT JOIN audit au ON d.detail_id = au.refund_id",
  61. "WHERE d.detail_flag = 1 and update_type = 2 ",
  62. "<if test='auditStatus!=null'>and auditStatus=#{auditStatus}</if>",
  63. "<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>",
  64. "<if test='refundType != null'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>",
  65. "<if test='refundGoods != null'>AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')</if>",
  66. "<if test='startDate != null and endDate != null'>AND d.create_time BETWEEN #{startDate} AND #{endDate}</if>",
  67. "ORDER BY d.create_time DESC",
  68. "</script>"
  69. })
  70. List<Detail> select(Detail detail);
  71. }