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

97 lines
4.4 KiB

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